Skip to content

Commit c23f39e

Browse files
committed
Add sample Storybook stories for few simple components
Also add short doc string for the components, to see how Storybook displays these on its Docs tab.
1 parent 86d5c54 commit c23f39e

File tree

8 files changed

+174
-48
lines changed

8 files changed

+174
-48
lines changed

apps/storybook/.storybook/main.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,11 @@
11
module.exports = {
22
"stories": [
33
"../stories/**/*.stories.mdx",
4-
"../stories/**/*.stories.@(js|jsx|ts|tsx)"
4+
{
5+
"directory": "../stories/components",
6+
"files": "*.stories.*",
7+
"titlePrefix": "@thunderstore/components"
8+
},
59
],
610
"addons": [
711
"@storybook/addon-links",

apps/storybook/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@
3939
"@emotion/react": "^11.7.0",
4040
"@emotion/styled": "^11.6.0",
4141
"@snek-at/storybook-addon-chakra-ui": "^1.0.0-beta.1",
42+
"@thunderstore/components": "^0.1.0",
4243
"react": "^17.0.2",
4344
"react-dom": "^17.0.2",
4445
"webpack": "^4.46.0"
Lines changed: 83 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,83 @@
1+
import { ComponentStory, ComponentMeta } from "@storybook/react";
2+
import { Markdown } from "@thunderstore/components";
3+
import React from "react";
4+
5+
const basicContent = `
6+
# Main header
7+
8+
This is a markdown renderer.
9+
10+
## Subheader
11+
12+
This is first paragraph.
13+
14+
This is second paragraph.
15+
`;
16+
17+
const codeContent = `
18+
${"```"}js
19+
console.log("Hello, World!");
20+
${"```"}
21+
22+
23+
24+
${"```"}python
25+
print('Hello, World!')
26+
${"```"}
27+
`;
28+
29+
const listContent = `
30+
* Some item
31+
* Another item
32+
* Subitem
33+
* Subitem
34+
* Yet another item
35+
36+
37+
38+
1. First item
39+
2. Second item
40+
1. Subitem
41+
2. Subitem
42+
3. Last item
43+
44+
45+
46+
- [x] Read ticket thoroughly
47+
- [ ] Design implementation
48+
- [ ] Write code and tests
49+
`;
50+
51+
const textContent = `
52+
*This text is italicized*
53+
54+
**This is bold text**
55+
56+
**The bold and _the italicized_**
57+
58+
***All bold and italicized***
59+
60+
~~Nevermind~~
61+
62+
> Quoth the Raven "Nevermore."
63+
`;
64+
65+
const meta = { component: Markdown } as ComponentMeta<typeof Markdown>;
66+
67+
const Template: ComponentStory<typeof Markdown> = (args) => (
68+
<Markdown>{args.children}</Markdown>
69+
);
70+
71+
const BasicContent = Template.bind({});
72+
BasicContent.args = { children: basicContent };
73+
74+
const CodeContent = Template.bind({});
75+
CodeContent.args = { children: codeContent };
76+
77+
const ListContent = Template.bind({});
78+
ListContent.args = { children: listContent };
79+
80+
const TextContent = Template.bind({});
81+
TextContent.args = { children: textContent };
82+
83+
export { meta as default, BasicContent, CodeContent, ListContent, TextContent };
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
import { MultiSelect } from "@thunderstore/components";
2+
import { ComponentStory, ComponentMeta } from "@storybook/react";
3+
import React from "react";
4+
5+
import * as SelectStories from "./Select.stories";
6+
7+
const meta = { component: MultiSelect } as ComponentMeta<typeof MultiSelect>;
8+
9+
const Template: ComponentStory<typeof MultiSelect> = (args) => (
10+
<MultiSelect {...args} />
11+
);
12+
13+
const Multi = Template.bind({});
14+
Multi.args = { ...SelectStories.Select.args };
15+
16+
export { meta as default, Multi as MultiSelect };
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
import { Select } from "@thunderstore/components";
2+
import { ComponentStory, ComponentMeta } from "@storybook/react";
3+
import React from "react";
4+
5+
const args = {
6+
options: [
7+
{ label: "Option 1", value: "option-1" },
8+
{ label: "Option 2", value: "option-2" },
9+
{ label: "Option 3", value: "option-3" },
10+
],
11+
onChange: () => null,
12+
};
13+
14+
const meta = { component: Select } as ComponentMeta<typeof Select>;
15+
16+
const Template: ComponentStory<typeof Select> = (args) => <Select {...args} />;
17+
18+
const Select_ = Template.bind({});
19+
Select_.args = { ...args };
20+
21+
export { meta as default, Select_ as Select };

packages/components/src/components/Markdown.tsx

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,9 @@ interface MarkdownProps {
55
children: string;
66
}
77

8+
/**
9+
* Wrapper for rendering markdown strings as proper markup.
10+
*/
811
export const Markdown: React.FC<MarkdownProps> = ({ children }) => {
912
const [markup, setMarkup] = React.useState<JSX.Element>();
1013

packages/components/src/components/Select.tsx

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,9 @@ export interface SelectProps<T extends SelectOption = SelectOption> {
2424
onChange(option: T | null): void;
2525
}
2626

27+
/**
28+
* Select element that supports filtering options by text search.
29+
*/
2730
export const Select = <T extends SelectOption = SelectOption>({
2831
options,
2932
disabled = false,
@@ -113,6 +116,11 @@ export interface MultiSelectProps<T extends SelectOption = SelectOption> {
113116
onChange(options: T[]): void;
114117
}
115118

119+
/**
120+
* Multiselect element that supports filtering options by text search.
121+
*
122+
* Selected options are shown as tags above the select component.
123+
*/
116124
export const MultiSelect = <T extends SelectOption = SelectOption>({
117125
options,
118126
disabled = false,

yarn.lock

Lines changed: 37 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -2198,16 +2198,11 @@
21982198
schema-utils "^3.0.0"
21992199
source-map "^0.7.3"
22002200

2201-
"@popperjs/core@^2.5.4", "@popperjs/core@^2.6.0":
2201+
"@popperjs/core@^2.5.4", "@popperjs/core@^2.6.0", "@popperjs/core@^2.9.3":
22022202
version "2.11.0"
22032203
resolved "https://registry.yarnpkg.com/@popperjs/core/-/core-2.11.0.tgz#6734f8ebc106a0860dff7f92bf90df193f0935d7"
22042204
integrity sha512-zrsUxjLOKAzdewIDRWy9nsV1GQsKBCWaGwsZQlCgr6/q+vjyZhFgqedLfFBuI9anTPEUT4APq9Mu0SZBTzIcGQ==
22052205

2206-
"@popperjs/core@^2.9.3":
2207-
version "2.10.2"
2208-
resolved "https://registry.yarnpkg.com/@popperjs/core/-/core-2.10.2.tgz#0798c03351f0dea1a5a4cabddf26a55a7cbee590"
2209-
integrity sha512-IXf3XA7+XyN7CP9gGh/XB0UxVMlvARGEgGXLubFICsUMGz6Q+DU+i4gGlpOxTjKvXjkJDJC8YdqdKkDj9qZHEQ==
2210-
22112206
"@preconstruct/cli@^2.1.5":
22122207
version "2.1.5"
22132208
resolved "https://registry.yarnpkg.com/@preconstruct/cli/-/cli-2.1.5.tgz#f7f6d06809f382521589af15f67b87009b240c58"
@@ -3370,9 +3365,9 @@
33703365
form-data "^3.0.0"
33713366

33723367
"@types/node@*", "@types/node@^16.6.2":
3373-
version "16.11.10"
3374-
resolved "https://registry.yarnpkg.com/@types/node/-/node-16.11.10.tgz#2e3ad0a680d96367103d3e670d41c2fed3da61ae"
3375-
integrity sha512-3aRnHa1KlOEEhJ6+CvyHKK5vE9BcLGjtUpwvqYLRvYNQKMfabu3BwfJaA/SLW8dxe28LsNDjtHwePTuzn3gmOA==
3368+
version "16.11.11"
3369+
resolved "https://registry.yarnpkg.com/@types/node/-/node-16.11.11.tgz#6ea7342dfb379ea1210835bada87b3c512120234"
3370+
integrity sha512-KB0sixD67CeecHC33MYn+eYARkqTheIRNuu97y2XMjR7Wu3XibO1vaY6VBV6O/a89SPI81cEUIYT87UqUWlZNw==
33763371

33773372
"@types/node@^14.0.10":
33783373
version "14.17.34"
@@ -4557,7 +4552,7 @@ browserslist@4.16.6:
45574552
escalade "^3.1.1"
45584553
node-releases "^1.1.71"
45594554

4560-
browserslist@^4.12.0, browserslist@^4.17.5, browserslist@^4.17.6:
4555+
browserslist@^4.12.0, browserslist@^4.17.5, browserslist@^4.18.1:
45614556
version "4.18.1"
45624557
resolved "https://registry.yarnpkg.com/browserslist/-/browserslist-4.18.1.tgz#60d3920f25b6860eb917c6c7b185576f4d8b017f"
45634558
integrity sha512-8ScCzdpPwR2wQh8IT82CA2VgDwjHyqMovPBZSNH54+tm4Jk2pCuv90gmAdH6J84OCRWi0b4gMe6O6XPXuJnjgQ==
@@ -5213,22 +5208,22 @@ copy-to-clipboard@3.3.1, copy-to-clipboard@^3.3.1:
52135208
toggle-selection "^1.0.6"
52145209

52155210
core-js-compat@^3.18.0, core-js-compat@^3.19.1, core-js-compat@^3.8.1:
5216-
version "3.19.1"
5217-
resolved "https://registry.yarnpkg.com/core-js-compat/-/core-js-compat-3.19.1.tgz#fe598f1a9bf37310d77c3813968e9f7c7bb99476"
5218-
integrity sha512-Q/VJ7jAF/y68+aUsQJ/afPOewdsGkDtcMb40J8MbuWKlK3Y+wtHq8bTHKPj2WKWLIqmS5JhHs4CzHtz6pT2W6g==
5211+
version "3.19.2"
5212+
resolved "https://registry.yarnpkg.com/core-js-compat/-/core-js-compat-3.19.2.tgz#18066a3404a302433cb0aa8be82dd3d75c76e5c4"
5213+
integrity sha512-ObBY1W5vx/LFFMaL1P5Udo4Npib6fu+cMokeziWkA8Tns4FcDemKF5j9JvaI5JhdkW8EQJQGJN1EcrzmEwuAqQ==
52195214
dependencies:
5220-
browserslist "^4.17.6"
5215+
browserslist "^4.18.1"
52215216
semver "7.0.0"
52225217

52235218
core-js-pure@^3.19.0, core-js-pure@^3.8.1, core-js-pure@^3.8.2:
5224-
version "3.19.1"
5225-
resolved "https://registry.yarnpkg.com/core-js-pure/-/core-js-pure-3.19.1.tgz#edffc1fc7634000a55ba05e95b3f0fe9587a5aa4"
5226-
integrity sha512-Q0Knr8Es84vtv62ei6/6jXH/7izKmOrtrxH9WJTHLCMAVeU+8TF8z8Nr08CsH4Ot0oJKzBzJJL9SJBYIv7WlfQ==
5219+
version "3.19.2"
5220+
resolved "https://registry.yarnpkg.com/core-js-pure/-/core-js-pure-3.19.2.tgz#26b5bfb503178cff6e3e115bc2ba6c6419383680"
5221+
integrity sha512-5LkcgQEy8pFeVnd/zomkUBSwnmIxuF1C8E9KrMAbOc8f34IBT9RGvTYeNDdp1PnvMJrrVhvk1hg/yVV5h/znlg==
52275222

52285223
core-js@^3.0.4, core-js@^3.19.1, core-js@^3.6.5, core-js@^3.8.2:
5229-
version "3.19.1"
5230-
resolved "https://registry.yarnpkg.com/core-js/-/core-js-3.19.1.tgz#f6f173cae23e73a7d88fa23b6e9da329276c6641"
5231-
integrity sha512-Tnc7E9iKd/b/ff7GFbhwPVzJzPztGrChB8X8GLqoYGdEOG8IpLnK1xPyo3ZoO3HsK6TodJS58VGPOxA+hLHQMg==
5224+
version "3.19.2"
5225+
resolved "https://registry.yarnpkg.com/core-js/-/core-js-3.19.2.tgz#ae216d7f4f7e924d9a2e3ff1e4b1940220f9157b"
5226+
integrity sha512-ciYCResnLIATSsXuXnIOH4CbdfgV+H1Ltg16hJFN7/v6OxqnFr/IFGeLacaZ+fHLAm0TBbXwNK9/DNBzBUrO/g==
52325227

52335228
core-util-is@~1.0.0:
52345229
version "1.0.3"
@@ -5468,9 +5463,9 @@ debug@^3.0.0, debug@^3.2.7:
54685463
ms "^2.1.1"
54695464

54705465
debug@^4.0.0, debug@^4.0.1, debug@^4.1.0, debug@^4.1.1, debug@^4.3.1:
5471-
version "4.3.2"
5472-
resolved "https://registry.yarnpkg.com/debug/-/debug-4.3.2.tgz#f0a49c18ac8779e31d4a0c6029dfb76873c7428b"
5473-
integrity sha512-mOp8wKcvj7XxC78zLgw/ZA+6TSgkoE2C/ienthhRD298T7UNwAg9diBpLRxC0mOezLl4B0xV7M0cCO6P/O0Xhw==
5466+
version "4.3.3"
5467+
resolved "https://registry.yarnpkg.com/debug/-/debug-4.3.3.tgz#04266e0b70a98d4462e6e288e38259213332b664"
5468+
integrity sha512-/zxw5+vh1Tfv+4Qn7a5nsbcJKPaSvCDhojn6FEl9vupwK2VCSDtEiEtqr8DFtzYFOdz63LBkxec7DYuc2jon6Q==
54745469
dependencies:
54755470
ms "2.1.2"
54765471

@@ -5774,15 +5769,10 @@ ee-first@1.1.1:
57745769
resolved "https://registry.yarnpkg.com/ee-first/-/ee-first-1.1.1.tgz#590c61156b0ae2f4f0255732a158b266bc56b21d"
57755770
integrity sha1-WQxhFWsK4vTwJVcyoViyZrxWsh0=
57765771

5777-
electron-to-chromium@^1.3.564:
5778-
version "1.4.4"
5779-
resolved "https://registry.yarnpkg.com/electron-to-chromium/-/electron-to-chromium-1.4.4.tgz#57311918524c1a26878c330537f967804d43788a"
5780-
integrity sha512-teHtgwcmVcL46jlFvAaqjyiTLWuMrUQO1JqV303JKB4ysXG6m8fXSFhbjal9st0r9mNskI22AraJZorb1VcLVg==
5781-
5782-
electron-to-chromium@^1.3.723, electron-to-chromium@^1.3.896:
5783-
version "1.4.3"
5784-
resolved "https://registry.yarnpkg.com/electron-to-chromium/-/electron-to-chromium-1.4.3.tgz#82480df3ef607f04bb38cc3f30a628d8b895339f"
5785-
integrity sha512-hfpppjYhqIZB8jrNb0rNceQRkSnBN7QJl3W26O1jUv3F3BkQknqy1YTqVXkFnIcFtBc3Qnv5M7r5Lez2iOLgZA==
5772+
electron-to-chromium@^1.3.564, electron-to-chromium@^1.3.723, electron-to-chromium@^1.3.896:
5773+
version "1.4.5"
5774+
resolved "https://registry.yarnpkg.com/electron-to-chromium/-/electron-to-chromium-1.4.5.tgz#912e8fd1645edee2f0f212558f40916eb538b1f9"
5775+
integrity sha512-YKaB+t8ul5crdh6OeqT2qXdxJGI0fAYb6/X8pDIyye+c3a7ndOCk5gVeKX+ABwivCGNS56vOAif3TN0qJMpEHw==
57865776

57875777
element-resize-detector@^1.2.2:
57885778
version "1.2.3"
@@ -6670,9 +6660,9 @@ fork-ts-checker-webpack-plugin@4.1.6, fork-ts-checker-webpack-plugin@^4.1.6:
66706660
worker-rpc "^0.1.0"
66716661

66726662
fork-ts-checker-webpack-plugin@^6.0.4:
6673-
version "6.4.2"
6674-
resolved "https://registry.yarnpkg.com/fork-ts-checker-webpack-plugin/-/fork-ts-checker-webpack-plugin-6.4.2.tgz#6d307fb4072ce4abe4d56a89c8ef060066f33d81"
6675-
integrity sha512-EqtzzRdx2mldr0KEydSN9jaNrf419gMpwkloumG6K/S7jtJc9Fl7wMJ+y+o7DLLGMMU/kouYr06agTD/YkxzIQ==
6663+
version "6.5.0"
6664+
resolved "https://registry.yarnpkg.com/fork-ts-checker-webpack-plugin/-/fork-ts-checker-webpack-plugin-6.5.0.tgz#0282b335fa495a97e167f69018f566ea7d2a2b5e"
6665+
integrity sha512-cS178Y+xxtIjEUorcHddKS7yCMlrDPV31mt47blKKRfMd70Kxu5xruAFE2o9sDY6wVC5deuob/u/alD04YYHnw==
66766666
dependencies:
66776667
"@babel/code-frame" "^7.8.3"
66786668
"@types/json-schema" "^7.0.5"
@@ -10683,9 +10673,9 @@ react-helmet-async@^1.0.7:
1068310673
shallowequal "^1.1.0"
1068410674

1068510675
react-hook-form@^7.15.4:
10686-
version "7.20.4"
10687-
resolved "https://registry.yarnpkg.com/react-hook-form/-/react-hook-form-7.20.4.tgz#7c23dcaed54812fba9ac63be0313b7c5d11d2b93"
10688-
integrity sha512-Nvy6TnNMlBoR+qS8FpA8lrqtGJ4uoi/MRYEgMEdBMY0HwHVuC7wB1sk6wTjg7FjOUt7QqMAP2W/vOhTWbKrtkQ==
10676+
version "7.20.5"
10677+
resolved "https://registry.yarnpkg.com/react-hook-form/-/react-hook-form-7.20.5.tgz#69d563c9cceafb2d4449bd3c28d17342b57b5830"
10678+
integrity sha512-xYeBmQW6oqxDYAYVWIoZYC7tRD6lJBJt9b8Rr1Mv/VhZ+ZUCy2IuXlm2YA9i0/zl0TKKxqBWQOxGEb3qyVIhMg==
1068910679

1069010680
react-inspector@^5.1.0:
1069110681
version "5.1.1"
@@ -10707,9 +10697,9 @@ react-is@^16.7.0, react-is@^16.8.1:
1070710697
integrity sha512-24e6ynE2H+OKt4kqsOvNd8kBpV65zoxbA4BVsEOB3ARVWQki/DHzaUoC5KuON/BiccDaCCTZBuOcfZs70kR8bQ==
1070810698

1070910699
react-markdown@^7.1.0:
10710-
version "7.1.0"
10711-
resolved "https://registry.yarnpkg.com/react-markdown/-/react-markdown-7.1.0.tgz#0ba62a4459daab6600ede83495a9228dae9d8f8e"
10712-
integrity sha512-hL8cLLkTydyoKlZWZOjlU6TvMYIw9qKLh1CCzVfnhKt/R/SnKVAqiyugetXY61CkjhBqJl2C5FdU3OwHYo7SrQ==
10700+
version "7.1.1"
10701+
resolved "https://registry.yarnpkg.com/react-markdown/-/react-markdown-7.1.1.tgz#cb4d2c2fa3bc1292c889b068a5bf064ae4be1c60"
10702+
integrity sha512-bXS7indkcPlCLB6wRFFzX8Xdghr62TBxUF2587o+CUkaZlNaoILb2qNt+5pYmTZuCOC+OeEcdJ+06mu5whtCVQ==
1071310703
dependencies:
1071410704
"@types/hast" "^2.0.0"
1071510705
"@types/unist" "^2.0.0"
@@ -10744,9 +10734,9 @@ react-popper@^2.2.4:
1074410734
warning "^4.0.2"
1074510735

1074610736
react-query@^3.21.1:
10747-
version "3.33.5"
10748-
resolved "https://registry.yarnpkg.com/react-query/-/react-query-3.33.5.tgz#5d8a42bd3237e25a00173a8f8aa59c04b6af5729"
10749-
integrity sha512-gNpTzbY9Xw/s0ALeLsXdUGXtzXbXQcRAMa4Ina2JOJHbDr2mdA79O2SMNUwctKJ1/c0vKTdALIdn4taptv+MTQ==
10737+
version "3.33.7"
10738+
resolved "https://registry.yarnpkg.com/react-query/-/react-query-3.33.7.tgz#6ab1b2cb39e2e925a4fc44e8a269c7691e7eb2f3"
10739+
integrity sha512-uL/1ZatxcRyvfhbNPeuOlLVbcdMQKzQ2t+SQLJMrMM0plfa/Al3buaPbGsbsmIwvyWeI4CVkkSBKzQIkU4p9MQ==
1075010740
dependencies:
1075110741
"@babel/runtime" "^7.5.5"
1075210742
broadcast-channel "^3.4.1"
@@ -11207,9 +11197,9 @@ ripemd160@^2.0.0, ripemd160@^2.0.1:
1120711197
inherits "^2.0.1"
1120811198

1120911199
rollup@^2.32.0:
11210-
version "2.60.1"
11211-
resolved "https://registry.yarnpkg.com/rollup/-/rollup-2.60.1.tgz#4b34cd247f09b421f10a3c9286eda2ecf9972079"
11212-
integrity sha512-akwfnpjY0rXEDSn1UTVfKXJhPsEBu+imi1gqBA1ZkHGydUnkV/fWCC90P7rDaLEW8KTwBcS1G3N4893Ndz+jwg==
11200+
version "2.60.2"
11201+
resolved "https://registry.yarnpkg.com/rollup/-/rollup-2.60.2.tgz#3f45ace36a9b10b4297181831ea0719922513463"
11202+
integrity sha512-1Bgjpq61sPjgoZzuiDSGvbI1tD91giZABgjCQBKM5aYLnzjq52GoDuWVwT/cm/MCxCMPU8gqQvkj8doQ5C8Oqw==
1121311203
optionalDependencies:
1121411204
fsevents "~2.3.2"
1121511205

0 commit comments

Comments
 (0)