react-achievements 1.1.0 → 1.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.idea/jsLibraryMappings.xml +6 -0
- package/.idea/modules.xml +8 -0
- package/.idea/react-achievements.iml +12 -0
- package/.idea/vcs.xml +6 -0
- package/README.md +15 -7
- package/coverage/clover.xml +131 -0
- package/coverage/coverage-final.json +9 -0
- package/coverage/lcov-report/base.css +224 -0
- package/coverage/lcov-report/block-navigation.js +87 -0
- package/coverage/lcov-report/favicon.png +0 -0
- package/coverage/lcov-report/index.html +146 -0
- package/coverage/lcov-report/prettify.css +1 -0
- package/coverage/lcov-report/prettify.js +2 -0
- package/coverage/lcov-report/sort-arrow-sprite.png +0 -0
- package/coverage/lcov-report/sorter.js +196 -0
- package/coverage/lcov-report/src/components/AchievementModal.tsx.html +229 -0
- package/coverage/lcov-report/src/components/BadgesButton.tsx.html +169 -0
- package/coverage/lcov-report/src/components/BadgesModal.tsx.html +253 -0
- package/coverage/lcov-report/src/components/ConfettiWrapper.tsx.html +157 -0
- package/coverage/lcov-report/src/components/index.html +161 -0
- package/coverage/lcov-report/src/context/AchievementContext.tsx.html +505 -0
- package/coverage/lcov-report/src/context/index.html +116 -0
- package/coverage/lcov-report/src/index.html +146 -0
- package/coverage/lcov-report/src/index.ts.html +121 -0
- package/coverage/lcov-report/src/react-confetti.d.ts.html +139 -0
- package/coverage/lcov-report/src/react-use.d.ts.html +94 -0
- package/coverage/lcov.info +240 -0
- package/demo/README.md +8 -0
- package/demo/eslint.config.js +38 -0
- package/demo/index.html +13 -0
- package/demo/package-lock.json +11062 -0
- package/demo/package.json +47 -0
- package/demo/public/vite.svg +1 -0
- package/demo/src/App.css +42 -0
- package/demo/src/App.jsx +35 -0
- package/demo/src/assets/react.svg +1 -0
- package/demo/src/index.css +68 -0
- package/demo/src/main.jsx +10 -0
- package/demo/src/stories/Button.jsx +50 -0
- package/demo/src/stories/Button.stories.js +48 -0
- package/demo/src/stories/Configure.mdx +364 -0
- package/demo/src/stories/Header.jsx +59 -0
- package/demo/src/stories/Header.stories.js +28 -0
- package/demo/src/stories/Page.jsx +69 -0
- package/demo/src/stories/Page.stories.js +28 -0
- package/demo/src/stories/assets/accessibility.png +0 -0
- package/demo/src/stories/assets/accessibility.svg +1 -0
- package/demo/src/stories/assets/addon-library.png +0 -0
- package/demo/src/stories/assets/assets.png +0 -0
- package/demo/src/stories/assets/avif-test-image.avif +0 -0
- package/demo/src/stories/assets/context.png +0 -0
- package/demo/src/stories/assets/discord.svg +1 -0
- package/demo/src/stories/assets/docs.png +0 -0
- package/demo/src/stories/assets/figma-plugin.png +0 -0
- package/demo/src/stories/assets/github.svg +1 -0
- package/demo/src/stories/assets/share.png +0 -0
- package/demo/src/stories/assets/styling.png +0 -0
- package/demo/src/stories/assets/testing.png +0 -0
- package/demo/src/stories/assets/theming.png +0 -0
- package/demo/src/stories/assets/tutorials.svg +1 -0
- package/demo/src/stories/assets/youtube.svg +1 -0
- package/demo/src/stories/button.css +30 -0
- package/demo/src/stories/header.css +32 -0
- package/demo/src/stories/page.css +69 -0
- package/demo/vite.config.js +7 -0
- package/dist/index.cjs.js +22 -19
- package/dist/index.esm.js +22 -19
- package/dist/stories/Button.d.ts +28 -0
- package/dist/stories/Button.stories.d.ts +23 -0
- package/dist/stories/Header.d.ts +13 -0
- package/dist/stories/Header.stories.d.ts +18 -0
- package/dist/stories/Page.d.ts +3 -0
- package/dist/stories/Page.stories.d.ts +12 -0
- package/package.json +15 -2
- package/src/context/AchievementContext.tsx +27 -24
- package/src/stories/Button.stories.ts +52 -0
- package/src/stories/Button.tsx +48 -0
- package/src/stories/Configure.mdx +364 -0
- package/src/stories/Header.stories.ts +33 -0
- package/src/stories/Header.tsx +56 -0
- package/src/stories/Page.stories.ts +32 -0
- package/src/stories/Page.tsx +73 -0
- package/src/stories/assets/accessibility.png +0 -0
- package/src/stories/assets/accessibility.svg +1 -0
- package/src/stories/assets/addon-library.png +0 -0
- package/src/stories/assets/assets.png +0 -0
- package/src/stories/assets/avif-test-image.avif +0 -0
- package/src/stories/assets/context.png +0 -0
- package/src/stories/assets/discord.svg +1 -0
- package/src/stories/assets/docs.png +0 -0
- package/src/stories/assets/figma-plugin.png +0 -0
- package/src/stories/assets/github.svg +1 -0
- package/src/stories/assets/share.png +0 -0
- package/src/stories/assets/styling.png +0 -0
- package/src/stories/assets/testing.png +0 -0
- package/src/stories/assets/theming.png +0 -0
- package/src/stories/assets/tutorials.svg +1 -0
- package/src/stories/assets/youtube.svg +1 -0
- package/src/stories/button.css +30 -0
- package/src/stories/header.css +32 -0
- package/src/stories/page.css +69 -0
- package/tsconfig.json +2 -2
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "demo",
|
|
3
|
+
"private": true,
|
|
4
|
+
"version": "0.0.0",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"scripts": {
|
|
7
|
+
"dev": "vite",
|
|
8
|
+
"build": "vite build",
|
|
9
|
+
"lint": "eslint .",
|
|
10
|
+
"preview": "vite preview",
|
|
11
|
+
"storybook": "storybook dev -p 6006",
|
|
12
|
+
"build-storybook": "storybook build"
|
|
13
|
+
},
|
|
14
|
+
"dependencies": {
|
|
15
|
+
"react": "^18.3.1",
|
|
16
|
+
"react-dom": "^18.3.1"
|
|
17
|
+
},
|
|
18
|
+
"devDependencies": {
|
|
19
|
+
"@chromatic-com/storybook": "^1.6.1",
|
|
20
|
+
"@eslint/js": "^9.8.0",
|
|
21
|
+
"@storybook/addon-essentials": "^8.2.8",
|
|
22
|
+
"@storybook/addon-interactions": "^8.2.8",
|
|
23
|
+
"@storybook/addon-links": "^8.2.8",
|
|
24
|
+
"@storybook/addon-onboarding": "^8.2.8",
|
|
25
|
+
"@storybook/blocks": "^8.2.8",
|
|
26
|
+
"@storybook/react": "^8.2.8",
|
|
27
|
+
"@storybook/react-vite": "^8.2.8",
|
|
28
|
+
"@storybook/test": "^8.2.8",
|
|
29
|
+
"@types/react": "^18.3.3",
|
|
30
|
+
"@types/react-dom": "^18.3.0",
|
|
31
|
+
"@vitejs/plugin-react": "^4.3.1",
|
|
32
|
+
"eslint": "^9.8.0",
|
|
33
|
+
"eslint-plugin-react": "^7.35.0",
|
|
34
|
+
"eslint-plugin-react-hooks": "^5.1.0-rc.0",
|
|
35
|
+
"eslint-plugin-react-refresh": "^0.4.9",
|
|
36
|
+
"eslint-plugin-storybook": "^0.8.0",
|
|
37
|
+
"globals": "^15.9.0",
|
|
38
|
+
"prop-types": "^15.8.1",
|
|
39
|
+
"storybook": "^8.2.8",
|
|
40
|
+
"vite": "^5.4.0"
|
|
41
|
+
},
|
|
42
|
+
"eslintConfig": {
|
|
43
|
+
"extends": [
|
|
44
|
+
"plugin:storybook/recommended"
|
|
45
|
+
]
|
|
46
|
+
}
|
|
47
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" aria-hidden="true" role="img" class="iconify iconify--logos" width="31.88" height="32" preserveAspectRatio="xMidYMid meet" viewBox="0 0 256 257"><defs><linearGradient id="IconifyId1813088fe1fbc01fb466" x1="-.828%" x2="57.636%" y1="7.652%" y2="78.411%"><stop offset="0%" stop-color="#41D1FF"></stop><stop offset="100%" stop-color="#BD34FE"></stop></linearGradient><linearGradient id="IconifyId1813088fe1fbc01fb467" x1="43.376%" x2="50.316%" y1="2.242%" y2="89.03%"><stop offset="0%" stop-color="#FFEA83"></stop><stop offset="8.333%" stop-color="#FFDD35"></stop><stop offset="100%" stop-color="#FFA800"></stop></linearGradient></defs><path fill="url(#IconifyId1813088fe1fbc01fb466)" d="M255.153 37.938L134.897 252.976c-2.483 4.44-8.862 4.466-11.382.048L.875 37.958c-2.746-4.814 1.371-10.646 6.827-9.67l120.385 21.517a6.537 6.537 0 0 0 2.322-.004l117.867-21.483c5.438-.991 9.574 4.796 6.877 9.62Z"></path><path fill="url(#IconifyId1813088fe1fbc01fb467)" d="M185.432.063L96.44 17.501a3.268 3.268 0 0 0-2.634 3.014l-5.474 92.456a3.268 3.268 0 0 0 3.997 3.378l24.777-5.718c2.318-.535 4.413 1.507 3.936 3.838l-7.361 36.047c-.495 2.426 1.782 4.5 4.151 3.78l15.304-4.649c2.372-.72 4.652 1.36 4.15 3.788l-11.698 56.621c-.732 3.542 3.979 5.473 5.943 2.437l1.313-2.028l72.516-144.72c1.215-2.423-.88-5.186-3.54-4.672l-25.505 4.922c-2.396.462-4.435-1.77-3.759-4.114l16.646-57.705c.677-2.35-1.37-4.583-3.769-4.113Z"></path></svg>
|
package/demo/src/App.css
ADDED
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
#root {
|
|
2
|
+
max-width: 1280px;
|
|
3
|
+
margin: 0 auto;
|
|
4
|
+
padding: 2rem;
|
|
5
|
+
text-align: center;
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
.logo {
|
|
9
|
+
height: 6em;
|
|
10
|
+
padding: 1.5em;
|
|
11
|
+
will-change: filter;
|
|
12
|
+
transition: filter 300ms;
|
|
13
|
+
}
|
|
14
|
+
.logo:hover {
|
|
15
|
+
filter: drop-shadow(0 0 2em #646cffaa);
|
|
16
|
+
}
|
|
17
|
+
.logo.react:hover {
|
|
18
|
+
filter: drop-shadow(0 0 2em #61dafbaa);
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
@keyframes logo-spin {
|
|
22
|
+
from {
|
|
23
|
+
transform: rotate(0deg);
|
|
24
|
+
}
|
|
25
|
+
to {
|
|
26
|
+
transform: rotate(360deg);
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
@media (prefers-reduced-motion: no-preference) {
|
|
31
|
+
a:nth-of-type(2) .logo {
|
|
32
|
+
animation: logo-spin infinite 20s linear;
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
.card {
|
|
37
|
+
padding: 2em;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
.read-the-docs {
|
|
41
|
+
color: #888;
|
|
42
|
+
}
|
package/demo/src/App.jsx
ADDED
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { useState } from 'react'
|
|
2
|
+
import reactLogo from './assets/react.svg'
|
|
3
|
+
import viteLogo from '/vite.svg'
|
|
4
|
+
import './App.css'
|
|
5
|
+
|
|
6
|
+
function App() {
|
|
7
|
+
const [count, setCount] = useState(0)
|
|
8
|
+
|
|
9
|
+
return (
|
|
10
|
+
<>
|
|
11
|
+
<div>
|
|
12
|
+
<a href="https://vitejs.dev" target="_blank">
|
|
13
|
+
<img src={viteLogo} className="logo" alt="Vite logo" />
|
|
14
|
+
</a>
|
|
15
|
+
<a href="https://react.dev" target="_blank">
|
|
16
|
+
<img src={reactLogo} className="logo react" alt="React logo" />
|
|
17
|
+
</a>
|
|
18
|
+
</div>
|
|
19
|
+
<h1>Vite + React</h1>
|
|
20
|
+
<div className="card">
|
|
21
|
+
<button onClick={() => setCount((count) => count + 1)}>
|
|
22
|
+
count is {count}
|
|
23
|
+
</button>
|
|
24
|
+
<p>
|
|
25
|
+
Edit <code>src/App.jsx</code> and save to test HMR
|
|
26
|
+
</p>
|
|
27
|
+
</div>
|
|
28
|
+
<p className="read-the-docs">
|
|
29
|
+
Click on the Vite and React logos to learn more
|
|
30
|
+
</p>
|
|
31
|
+
</>
|
|
32
|
+
)
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
export default App
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" aria-hidden="true" role="img" class="iconify iconify--logos" width="35.93" height="32" preserveAspectRatio="xMidYMid meet" viewBox="0 0 256 228"><path fill="#00D8FF" d="M210.483 73.824a171.49 171.49 0 0 0-8.24-2.597c.465-1.9.893-3.777 1.273-5.621c6.238-30.281 2.16-54.676-11.769-62.708c-13.355-7.7-35.196.329-57.254 19.526a171.23 171.23 0 0 0-6.375 5.848a155.866 155.866 0 0 0-4.241-3.917C100.759 3.829 77.587-4.822 63.673 3.233C50.33 10.957 46.379 33.89 51.995 62.588a170.974 170.974 0 0 0 1.892 8.48c-3.28.932-6.445 1.924-9.474 2.98C17.309 83.498 0 98.307 0 113.668c0 15.865 18.582 31.778 46.812 41.427a145.52 145.52 0 0 0 6.921 2.165a167.467 167.467 0 0 0-2.01 9.138c-5.354 28.2-1.173 50.591 12.134 58.266c13.744 7.926 36.812-.22 59.273-19.855a145.567 145.567 0 0 0 5.342-4.923a168.064 168.064 0 0 0 6.92 6.314c21.758 18.722 43.246 26.282 56.54 18.586c13.731-7.949 18.194-32.003 12.4-61.268a145.016 145.016 0 0 0-1.535-6.842c1.62-.48 3.21-.974 4.76-1.488c29.348-9.723 48.443-25.443 48.443-41.52c0-15.417-17.868-30.326-45.517-39.844Zm-6.365 70.984c-1.4.463-2.836.91-4.3 1.345c-3.24-10.257-7.612-21.163-12.963-32.432c5.106-11 9.31-21.767 12.459-31.957c2.619.758 5.16 1.557 7.61 2.4c23.69 8.156 38.14 20.213 38.14 29.504c0 9.896-15.606 22.743-40.946 31.14Zm-10.514 20.834c2.562 12.94 2.927 24.64 1.23 33.787c-1.524 8.219-4.59 13.698-8.382 15.893c-8.067 4.67-25.32-1.4-43.927-17.412a156.726 156.726 0 0 1-6.437-5.87c7.214-7.889 14.423-17.06 21.459-27.246c12.376-1.098 24.068-2.894 34.671-5.345a134.17 134.17 0 0 1 1.386 6.193ZM87.276 214.515c-7.882 2.783-14.16 2.863-17.955.675c-8.075-4.657-11.432-22.636-6.853-46.752a156.923 156.923 0 0 1 1.869-8.499c10.486 2.32 22.093 3.988 34.498 4.994c7.084 9.967 14.501 19.128 21.976 27.15a134.668 134.668 0 0 1-4.877 4.492c-9.933 8.682-19.886 14.842-28.658 17.94ZM50.35 144.747c-12.483-4.267-22.792-9.812-29.858-15.863c-6.35-5.437-9.555-10.836-9.555-15.216c0-9.322 13.897-21.212 37.076-29.293c2.813-.98 5.757-1.905 8.812-2.773c3.204 10.42 7.406 21.315 12.477 32.332c-5.137 11.18-9.399 22.249-12.634 32.792a134.718 134.718 0 0 1-6.318-1.979Zm12.378-84.26c-4.811-24.587-1.616-43.134 6.425-47.789c8.564-4.958 27.502 2.111 47.463 19.835a144.318 144.318 0 0 1 3.841 3.545c-7.438 7.987-14.787 17.08-21.808 26.988c-12.04 1.116-23.565 2.908-34.161 5.309a160.342 160.342 0 0 1-1.76-7.887Zm110.427 27.268a347.8 347.8 0 0 0-7.785-12.803c8.168 1.033 15.994 2.404 23.343 4.08c-2.206 7.072-4.956 14.465-8.193 22.045a381.151 381.151 0 0 0-7.365-13.322Zm-45.032-43.861c5.044 5.465 10.096 11.566 15.065 18.186a322.04 322.04 0 0 0-30.257-.006c4.974-6.559 10.069-12.652 15.192-18.18ZM82.802 87.83a323.167 323.167 0 0 0-7.227 13.238c-3.184-7.553-5.909-14.98-8.134-22.152c7.304-1.634 15.093-2.97 23.209-3.984a321.524 321.524 0 0 0-7.848 12.897Zm8.081 65.352c-8.385-.936-16.291-2.203-23.593-3.793c2.26-7.3 5.045-14.885 8.298-22.6a321.187 321.187 0 0 0 7.257 13.246c2.594 4.48 5.28 8.868 8.038 13.147Zm37.542 31.03c-5.184-5.592-10.354-11.779-15.403-18.433c4.902.192 9.899.29 14.978.29c5.218 0 10.376-.117 15.453-.343c-4.985 6.774-10.018 12.97-15.028 18.486Zm52.198-57.817c3.422 7.8 6.306 15.345 8.596 22.52c-7.422 1.694-15.436 3.058-23.88 4.071a382.417 382.417 0 0 0 7.859-13.026a347.403 347.403 0 0 0 7.425-13.565Zm-16.898 8.101a358.557 358.557 0 0 1-12.281 19.815a329.4 329.4 0 0 1-23.444.823c-7.967 0-15.716-.248-23.178-.732a310.202 310.202 0 0 1-12.513-19.846h.001a307.41 307.41 0 0 1-10.923-20.627a310.278 310.278 0 0 1 10.89-20.637l-.001.001a307.318 307.318 0 0 1 12.413-19.761c7.613-.576 15.42-.876 23.31-.876H128c7.926 0 15.743.303 23.354.883a329.357 329.357 0 0 1 12.335 19.695a358.489 358.489 0 0 1 11.036 20.54a329.472 329.472 0 0 1-11 20.722Zm22.56-122.124c8.572 4.944 11.906 24.881 6.52 51.026c-.344 1.668-.73 3.367-1.15 5.09c-10.622-2.452-22.155-4.275-34.23-5.408c-7.034-10.017-14.323-19.124-21.64-27.008a160.789 160.789 0 0 1 5.888-5.4c18.9-16.447 36.564-22.941 44.612-18.3ZM128 90.808c12.625 0 22.86 10.235 22.86 22.86s-10.235 22.86-22.86 22.86s-22.86-10.235-22.86-22.86s10.235-22.86 22.86-22.86Z"></path></svg>
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
:root {
|
|
2
|
+
font-family: Inter, system-ui, Avenir, Helvetica, Arial, sans-serif;
|
|
3
|
+
line-height: 1.5;
|
|
4
|
+
font-weight: 400;
|
|
5
|
+
|
|
6
|
+
color-scheme: light dark;
|
|
7
|
+
color: rgba(255, 255, 255, 0.87);
|
|
8
|
+
background-color: #242424;
|
|
9
|
+
|
|
10
|
+
font-synthesis: none;
|
|
11
|
+
text-rendering: optimizeLegibility;
|
|
12
|
+
-webkit-font-smoothing: antialiased;
|
|
13
|
+
-moz-osx-font-smoothing: grayscale;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
a {
|
|
17
|
+
font-weight: 500;
|
|
18
|
+
color: #646cff;
|
|
19
|
+
text-decoration: inherit;
|
|
20
|
+
}
|
|
21
|
+
a:hover {
|
|
22
|
+
color: #535bf2;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
body {
|
|
26
|
+
margin: 0;
|
|
27
|
+
display: flex;
|
|
28
|
+
place-items: center;
|
|
29
|
+
min-width: 320px;
|
|
30
|
+
min-height: 100vh;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
h1 {
|
|
34
|
+
font-size: 3.2em;
|
|
35
|
+
line-height: 1.1;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
button {
|
|
39
|
+
border-radius: 8px;
|
|
40
|
+
border: 1px solid transparent;
|
|
41
|
+
padding: 0.6em 1.2em;
|
|
42
|
+
font-size: 1em;
|
|
43
|
+
font-weight: 500;
|
|
44
|
+
font-family: inherit;
|
|
45
|
+
background-color: #1a1a1a;
|
|
46
|
+
cursor: pointer;
|
|
47
|
+
transition: border-color 0.25s;
|
|
48
|
+
}
|
|
49
|
+
button:hover {
|
|
50
|
+
border-color: #646cff;
|
|
51
|
+
}
|
|
52
|
+
button:focus,
|
|
53
|
+
button:focus-visible {
|
|
54
|
+
outline: 4px auto -webkit-focus-ring-color;
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
@media (prefers-color-scheme: light) {
|
|
58
|
+
:root {
|
|
59
|
+
color: #213547;
|
|
60
|
+
background-color: #ffffff;
|
|
61
|
+
}
|
|
62
|
+
a:hover {
|
|
63
|
+
color: #747bff;
|
|
64
|
+
}
|
|
65
|
+
button {
|
|
66
|
+
background-color: #f9f9f9;
|
|
67
|
+
}
|
|
68
|
+
}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import PropTypes from 'prop-types';
|
|
3
|
+
import './button.css';
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Primary UI component for user interaction
|
|
7
|
+
*/
|
|
8
|
+
export const Button = ({ primary, backgroundColor, size, label, ...props }) => {
|
|
9
|
+
const mode = primary ? 'storybook-button--primary' : 'storybook-button--secondary';
|
|
10
|
+
return (
|
|
11
|
+
<button
|
|
12
|
+
type="button"
|
|
13
|
+
className={['storybook-button', `storybook-button--${size}`, mode].join(' ')}
|
|
14
|
+
style={backgroundColor && { backgroundColor }}
|
|
15
|
+
{...props}
|
|
16
|
+
>
|
|
17
|
+
{label}
|
|
18
|
+
</button>
|
|
19
|
+
);
|
|
20
|
+
};
|
|
21
|
+
|
|
22
|
+
Button.propTypes = {
|
|
23
|
+
/**
|
|
24
|
+
* Is this the principal call to action on the page?
|
|
25
|
+
*/
|
|
26
|
+
primary: PropTypes.bool,
|
|
27
|
+
/**
|
|
28
|
+
* What background color to use
|
|
29
|
+
*/
|
|
30
|
+
backgroundColor: PropTypes.string,
|
|
31
|
+
/**
|
|
32
|
+
* How large should the button be?
|
|
33
|
+
*/
|
|
34
|
+
size: PropTypes.oneOf(['small', 'medium', 'large']),
|
|
35
|
+
/**
|
|
36
|
+
* Button contents
|
|
37
|
+
*/
|
|
38
|
+
label: PropTypes.string.isRequired,
|
|
39
|
+
/**
|
|
40
|
+
* Optional click handler
|
|
41
|
+
*/
|
|
42
|
+
onClick: PropTypes.func,
|
|
43
|
+
};
|
|
44
|
+
|
|
45
|
+
Button.defaultProps = {
|
|
46
|
+
backgroundColor: null,
|
|
47
|
+
primary: false,
|
|
48
|
+
size: 'medium',
|
|
49
|
+
onClick: undefined,
|
|
50
|
+
};
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import { fn } from '@storybook/test';
|
|
2
|
+
import { Button } from './Button';
|
|
3
|
+
|
|
4
|
+
// More on how to set up stories at: https://storybook.js.org/docs/writing-stories#default-export
|
|
5
|
+
export default {
|
|
6
|
+
title: 'Example/Button',
|
|
7
|
+
component: Button,
|
|
8
|
+
parameters: {
|
|
9
|
+
// Optional parameter to center the component in the Canvas. More info: https://storybook.js.org/docs/configure/story-layout
|
|
10
|
+
layout: 'centered',
|
|
11
|
+
},
|
|
12
|
+
// This component will have an automatically generated Autodocs entry: https://storybook.js.org/docs/writing-docs/autodocs
|
|
13
|
+
tags: ['autodocs'],
|
|
14
|
+
// More on argTypes: https://storybook.js.org/docs/api/argtypes
|
|
15
|
+
argTypes: {
|
|
16
|
+
backgroundColor: { control: 'color' },
|
|
17
|
+
},
|
|
18
|
+
// Use `fn` to spy on the onClick arg, which will appear in the actions panel once invoked: https://storybook.js.org/docs/essentials/actions#action-args
|
|
19
|
+
args: { onClick: fn() },
|
|
20
|
+
};
|
|
21
|
+
|
|
22
|
+
// More on writing stories with args: https://storybook.js.org/docs/writing-stories/args
|
|
23
|
+
export const Primary = {
|
|
24
|
+
args: {
|
|
25
|
+
primary: true,
|
|
26
|
+
label: 'Button',
|
|
27
|
+
},
|
|
28
|
+
};
|
|
29
|
+
|
|
30
|
+
export const Secondary = {
|
|
31
|
+
args: {
|
|
32
|
+
label: 'Button',
|
|
33
|
+
},
|
|
34
|
+
};
|
|
35
|
+
|
|
36
|
+
export const Large = {
|
|
37
|
+
args: {
|
|
38
|
+
size: 'large',
|
|
39
|
+
label: 'Button',
|
|
40
|
+
},
|
|
41
|
+
};
|
|
42
|
+
|
|
43
|
+
export const Small = {
|
|
44
|
+
args: {
|
|
45
|
+
size: 'small',
|
|
46
|
+
label: 'Button',
|
|
47
|
+
},
|
|
48
|
+
};
|
|
@@ -0,0 +1,364 @@
|
|
|
1
|
+
import { Meta } from "@storybook/blocks";
|
|
2
|
+
|
|
3
|
+
import Github from "./assets/github.svg";
|
|
4
|
+
import Discord from "./assets/discord.svg";
|
|
5
|
+
import Youtube from "./assets/youtube.svg";
|
|
6
|
+
import Tutorials from "./assets/tutorials.svg";
|
|
7
|
+
import Styling from "./assets/styling.png";
|
|
8
|
+
import Context from "./assets/context.png";
|
|
9
|
+
import Assets from "./assets/assets.png";
|
|
10
|
+
import Docs from "./assets/docs.png";
|
|
11
|
+
import Share from "./assets/share.png";
|
|
12
|
+
import FigmaPlugin from "./assets/figma-plugin.png";
|
|
13
|
+
import Testing from "./assets/testing.png";
|
|
14
|
+
import Accessibility from "./assets/accessibility.png";
|
|
15
|
+
import Theming from "./assets/theming.png";
|
|
16
|
+
import AddonLibrary from "./assets/addon-library.png";
|
|
17
|
+
|
|
18
|
+
export const RightArrow = () => <svg
|
|
19
|
+
viewBox="0 0 14 14"
|
|
20
|
+
width="8px"
|
|
21
|
+
height="14px"
|
|
22
|
+
style={{
|
|
23
|
+
marginLeft: '4px',
|
|
24
|
+
display: 'inline-block',
|
|
25
|
+
shapeRendering: 'inherit',
|
|
26
|
+
verticalAlign: 'middle',
|
|
27
|
+
fill: 'currentColor',
|
|
28
|
+
'path fill': 'currentColor'
|
|
29
|
+
}}
|
|
30
|
+
>
|
|
31
|
+
<path d="m11.1 7.35-5.5 5.5a.5.5 0 0 1-.7-.7L10.04 7 4.9 1.85a.5.5 0 1 1 .7-.7l5.5 5.5c.2.2.2.5 0 .7Z" />
|
|
32
|
+
</svg>
|
|
33
|
+
|
|
34
|
+
<Meta title="Configure your project" />
|
|
35
|
+
|
|
36
|
+
<div className="sb-container">
|
|
37
|
+
<div className='sb-section-title'>
|
|
38
|
+
# Configure your project
|
|
39
|
+
|
|
40
|
+
Because Storybook works separately from your app, you'll need to configure it for your specific stack and setup. Below, explore guides for configuring Storybook with popular frameworks and tools. If you get stuck, learn how you can ask for help from our community.
|
|
41
|
+
</div>
|
|
42
|
+
<div className="sb-section">
|
|
43
|
+
<div className="sb-section-item">
|
|
44
|
+
<img
|
|
45
|
+
src={Styling}
|
|
46
|
+
alt="A wall of logos representing different styling technologies"
|
|
47
|
+
/>
|
|
48
|
+
<h4 className="sb-section-item-heading">Add styling and CSS</h4>
|
|
49
|
+
<p className="sb-section-item-paragraph">Like with web applications, there are many ways to include CSS within Storybook. Learn more about setting up styling within Storybook.</p>
|
|
50
|
+
<a
|
|
51
|
+
href="https://storybook.js.org/docs/configure/styling-and-css/?renderer=react"
|
|
52
|
+
target="_blank"
|
|
53
|
+
>Learn more<RightArrow /></a>
|
|
54
|
+
</div>
|
|
55
|
+
<div className="sb-section-item">
|
|
56
|
+
<img
|
|
57
|
+
src={Context}
|
|
58
|
+
alt="An abstraction representing the composition of data for a component"
|
|
59
|
+
/>
|
|
60
|
+
<h4 className="sb-section-item-heading">Provide context and mocking</h4>
|
|
61
|
+
<p className="sb-section-item-paragraph">Often when a story doesn't render, it's because your component is expecting a specific environment or context (like a theme provider) to be available.</p>
|
|
62
|
+
<a
|
|
63
|
+
href="https://storybook.js.org/docs/writing-stories/decorators/?renderer=react#context-for-mocking"
|
|
64
|
+
target="_blank"
|
|
65
|
+
>Learn more<RightArrow /></a>
|
|
66
|
+
</div>
|
|
67
|
+
<div className="sb-section-item">
|
|
68
|
+
<img src={Assets} alt="A representation of typography and image assets" />
|
|
69
|
+
<div>
|
|
70
|
+
<h4 className="sb-section-item-heading">Load assets and resources</h4>
|
|
71
|
+
<p className="sb-section-item-paragraph">To link static files (like fonts) to your projects and stories, use the
|
|
72
|
+
`staticDirs` configuration option to specify folders to load when
|
|
73
|
+
starting Storybook.</p>
|
|
74
|
+
<a
|
|
75
|
+
href="https://storybook.js.org/docs/configure/images-and-assets/?renderer=react"
|
|
76
|
+
target="_blank"
|
|
77
|
+
>Learn more<RightArrow /></a>
|
|
78
|
+
</div>
|
|
79
|
+
</div>
|
|
80
|
+
</div>
|
|
81
|
+
</div>
|
|
82
|
+
<div className="sb-container">
|
|
83
|
+
<div className='sb-section-title'>
|
|
84
|
+
# Do more with Storybook
|
|
85
|
+
|
|
86
|
+
Now that you know the basics, let's explore other parts of Storybook that will improve your experience. This list is just to get you started. You can customise Storybook in many ways to fit your needs.
|
|
87
|
+
</div>
|
|
88
|
+
|
|
89
|
+
<div className="sb-section">
|
|
90
|
+
<div className="sb-features-grid">
|
|
91
|
+
<div className="sb-grid-item">
|
|
92
|
+
<img src={Docs} alt="A screenshot showing the autodocs tag being set, pointing a docs page being generated" />
|
|
93
|
+
<h4 className="sb-section-item-heading">Autodocs</h4>
|
|
94
|
+
<p className="sb-section-item-paragraph">Auto-generate living,
|
|
95
|
+
interactive reference documentation from your components and stories.</p>
|
|
96
|
+
<a
|
|
97
|
+
href="https://storybook.js.org/docs/writing-docs/autodocs/?renderer=react"
|
|
98
|
+
target="_blank"
|
|
99
|
+
>Learn more<RightArrow /></a>
|
|
100
|
+
</div>
|
|
101
|
+
<div className="sb-grid-item">
|
|
102
|
+
<img src={Share} alt="A browser window showing a Storybook being published to a chromatic.com URL" />
|
|
103
|
+
<h4 className="sb-section-item-heading">Publish to Chromatic</h4>
|
|
104
|
+
<p className="sb-section-item-paragraph">Publish your Storybook to review and collaborate with your entire team.</p>
|
|
105
|
+
<a
|
|
106
|
+
href="https://storybook.js.org/docs/sharing/publish-storybook/?renderer=react#publish-storybook-with-chromatic"
|
|
107
|
+
target="_blank"
|
|
108
|
+
>Learn more<RightArrow /></a>
|
|
109
|
+
</div>
|
|
110
|
+
<div className="sb-grid-item">
|
|
111
|
+
<img src={FigmaPlugin} alt="Windows showing the Storybook plugin in Figma" />
|
|
112
|
+
<h4 className="sb-section-item-heading">Figma Plugin</h4>
|
|
113
|
+
<p className="sb-section-item-paragraph">Embed your stories into Figma to cross-reference the design and live
|
|
114
|
+
implementation in one place.</p>
|
|
115
|
+
<a
|
|
116
|
+
href="https://storybook.js.org/docs/sharing/design-integrations/?renderer=react#embed-storybook-in-figma-with-the-plugin"
|
|
117
|
+
target="_blank"
|
|
118
|
+
>Learn more<RightArrow /></a>
|
|
119
|
+
</div>
|
|
120
|
+
<div className="sb-grid-item">
|
|
121
|
+
<img src={Testing} alt="Screenshot of tests passing and failing" />
|
|
122
|
+
<h4 className="sb-section-item-heading">Testing</h4>
|
|
123
|
+
<p className="sb-section-item-paragraph">Use stories to test a component in all its variations, no matter how
|
|
124
|
+
complex.</p>
|
|
125
|
+
<a
|
|
126
|
+
href="https://storybook.js.org/docs/writing-tests/?renderer=react"
|
|
127
|
+
target="_blank"
|
|
128
|
+
>Learn more<RightArrow /></a>
|
|
129
|
+
</div>
|
|
130
|
+
<div className="sb-grid-item">
|
|
131
|
+
<img src={Accessibility} alt="Screenshot of accessibility tests passing and failing" />
|
|
132
|
+
<h4 className="sb-section-item-heading">Accessibility</h4>
|
|
133
|
+
<p className="sb-section-item-paragraph">Automatically test your components for a11y issues as you develop.</p>
|
|
134
|
+
<a
|
|
135
|
+
href="https://storybook.js.org/docs/writing-tests/accessibility-testing/?renderer=react"
|
|
136
|
+
target="_blank"
|
|
137
|
+
>Learn more<RightArrow /></a>
|
|
138
|
+
</div>
|
|
139
|
+
<div className="sb-grid-item">
|
|
140
|
+
<img src={Theming} alt="Screenshot of Storybook in light and dark mode" />
|
|
141
|
+
<h4 className="sb-section-item-heading">Theming</h4>
|
|
142
|
+
<p className="sb-section-item-paragraph">Theme Storybook's UI to personalize it to your project.</p>
|
|
143
|
+
<a
|
|
144
|
+
href="https://storybook.js.org/docs/configure/theming/?renderer=react"
|
|
145
|
+
target="_blank"
|
|
146
|
+
>Learn more<RightArrow /></a>
|
|
147
|
+
</div>
|
|
148
|
+
</div>
|
|
149
|
+
</div>
|
|
150
|
+
</div>
|
|
151
|
+
<div className='sb-addon'>
|
|
152
|
+
<div className='sb-addon-text'>
|
|
153
|
+
<h4>Addons</h4>
|
|
154
|
+
<p className="sb-section-item-paragraph">Integrate your tools with Storybook to connect workflows.</p>
|
|
155
|
+
<a
|
|
156
|
+
href="https://storybook.js.org/addons/"
|
|
157
|
+
target="_blank"
|
|
158
|
+
>Discover all addons<RightArrow /></a>
|
|
159
|
+
</div>
|
|
160
|
+
<div className='sb-addon-img'>
|
|
161
|
+
<img src={AddonLibrary} alt="Integrate your tools with Storybook to connect workflows." />
|
|
162
|
+
</div>
|
|
163
|
+
</div>
|
|
164
|
+
|
|
165
|
+
<div className="sb-section sb-socials">
|
|
166
|
+
<div className="sb-section-item">
|
|
167
|
+
<img src={Github} alt="Github logo" className="sb-explore-image"/>
|
|
168
|
+
Join our contributors building the future of UI development.
|
|
169
|
+
|
|
170
|
+
<a
|
|
171
|
+
href="https://github.com/storybookjs/storybook"
|
|
172
|
+
target="_blank"
|
|
173
|
+
>Star on GitHub<RightArrow /></a>
|
|
174
|
+
</div>
|
|
175
|
+
<div className="sb-section-item">
|
|
176
|
+
<img src={Discord} alt="Discord logo" className="sb-explore-image"/>
|
|
177
|
+
<div>
|
|
178
|
+
Get support and chat with frontend developers.
|
|
179
|
+
|
|
180
|
+
<a
|
|
181
|
+
href="https://discord.gg/storybook"
|
|
182
|
+
target="_blank"
|
|
183
|
+
>Join Discord server<RightArrow /></a>
|
|
184
|
+
</div>
|
|
185
|
+
</div>
|
|
186
|
+
<div className="sb-section-item">
|
|
187
|
+
<img src={Youtube} alt="Youtube logo" className="sb-explore-image"/>
|
|
188
|
+
<div>
|
|
189
|
+
Watch tutorials, feature previews and interviews.
|
|
190
|
+
|
|
191
|
+
<a
|
|
192
|
+
href="https://www.youtube.com/@chromaticui"
|
|
193
|
+
target="_blank"
|
|
194
|
+
>Watch on YouTube<RightArrow /></a>
|
|
195
|
+
</div>
|
|
196
|
+
</div>
|
|
197
|
+
<div className="sb-section-item">
|
|
198
|
+
<img src={Tutorials} alt="A book" className="sb-explore-image"/>
|
|
199
|
+
<p>Follow guided walkthroughs on for key workflows.</p>
|
|
200
|
+
|
|
201
|
+
<a
|
|
202
|
+
href="https://storybook.js.org/tutorials/"
|
|
203
|
+
target="_blank"
|
|
204
|
+
>Discover tutorials<RightArrow /></a>
|
|
205
|
+
</div>
|
|
206
|
+
</div>
|
|
207
|
+
|
|
208
|
+
<style>
|
|
209
|
+
{`
|
|
210
|
+
.sb-container {
|
|
211
|
+
margin-bottom: 48px;
|
|
212
|
+
}
|
|
213
|
+
|
|
214
|
+
.sb-section {
|
|
215
|
+
width: 100%;
|
|
216
|
+
display: flex;
|
|
217
|
+
flex-direction: row;
|
|
218
|
+
gap: 20px;
|
|
219
|
+
}
|
|
220
|
+
|
|
221
|
+
img {
|
|
222
|
+
object-fit: cover;
|
|
223
|
+
}
|
|
224
|
+
|
|
225
|
+
.sb-section-title {
|
|
226
|
+
margin-bottom: 32px;
|
|
227
|
+
}
|
|
228
|
+
|
|
229
|
+
.sb-section a:not(h1 a, h2 a, h3 a) {
|
|
230
|
+
font-size: 14px;
|
|
231
|
+
}
|
|
232
|
+
|
|
233
|
+
.sb-section-item, .sb-grid-item {
|
|
234
|
+
flex: 1;
|
|
235
|
+
display: flex;
|
|
236
|
+
flex-direction: column;
|
|
237
|
+
}
|
|
238
|
+
|
|
239
|
+
.sb-section-item-heading {
|
|
240
|
+
padding-top: 20px !important;
|
|
241
|
+
padding-bottom: 5px !important;
|
|
242
|
+
margin: 0 !important;
|
|
243
|
+
}
|
|
244
|
+
.sb-section-item-paragraph {
|
|
245
|
+
margin: 0;
|
|
246
|
+
padding-bottom: 10px;
|
|
247
|
+
}
|
|
248
|
+
|
|
249
|
+
.sb-chevron {
|
|
250
|
+
margin-left: 5px;
|
|
251
|
+
}
|
|
252
|
+
|
|
253
|
+
.sb-features-grid {
|
|
254
|
+
display: grid;
|
|
255
|
+
grid-template-columns: repeat(2, 1fr);
|
|
256
|
+
grid-gap: 32px 20px;
|
|
257
|
+
}
|
|
258
|
+
|
|
259
|
+
.sb-socials {
|
|
260
|
+
display: grid;
|
|
261
|
+
grid-template-columns: repeat(4, 1fr);
|
|
262
|
+
}
|
|
263
|
+
|
|
264
|
+
.sb-socials p {
|
|
265
|
+
margin-bottom: 10px;
|
|
266
|
+
}
|
|
267
|
+
|
|
268
|
+
.sb-explore-image {
|
|
269
|
+
max-height: 32px;
|
|
270
|
+
align-self: flex-start;
|
|
271
|
+
}
|
|
272
|
+
|
|
273
|
+
.sb-addon {
|
|
274
|
+
width: 100%;
|
|
275
|
+
display: flex;
|
|
276
|
+
align-items: center;
|
|
277
|
+
position: relative;
|
|
278
|
+
background-color: #EEF3F8;
|
|
279
|
+
border-radius: 5px;
|
|
280
|
+
border: 1px solid rgba(0, 0, 0, 0.05);
|
|
281
|
+
background: #EEF3F8;
|
|
282
|
+
height: 180px;
|
|
283
|
+
margin-bottom: 48px;
|
|
284
|
+
overflow: hidden;
|
|
285
|
+
}
|
|
286
|
+
|
|
287
|
+
.sb-addon-text {
|
|
288
|
+
padding-left: 48px;
|
|
289
|
+
max-width: 240px;
|
|
290
|
+
}
|
|
291
|
+
|
|
292
|
+
.sb-addon-text h4 {
|
|
293
|
+
padding-top: 0px;
|
|
294
|
+
}
|
|
295
|
+
|
|
296
|
+
.sb-addon-img {
|
|
297
|
+
position: absolute;
|
|
298
|
+
left: 345px;
|
|
299
|
+
top: 0;
|
|
300
|
+
height: 100%;
|
|
301
|
+
width: 200%;
|
|
302
|
+
overflow: hidden;
|
|
303
|
+
}
|
|
304
|
+
|
|
305
|
+
.sb-addon-img img {
|
|
306
|
+
width: 650px;
|
|
307
|
+
transform: rotate(-15deg);
|
|
308
|
+
margin-left: 40px;
|
|
309
|
+
margin-top: -72px;
|
|
310
|
+
box-shadow: 0 0 1px rgba(255, 255, 255, 0);
|
|
311
|
+
backface-visibility: hidden;
|
|
312
|
+
}
|
|
313
|
+
|
|
314
|
+
@media screen and (max-width: 800px) {
|
|
315
|
+
.sb-addon-img {
|
|
316
|
+
left: 300px;
|
|
317
|
+
}
|
|
318
|
+
}
|
|
319
|
+
|
|
320
|
+
@media screen and (max-width: 600px) {
|
|
321
|
+
.sb-section {
|
|
322
|
+
flex-direction: column;
|
|
323
|
+
}
|
|
324
|
+
|
|
325
|
+
.sb-features-grid {
|
|
326
|
+
grid-template-columns: repeat(1, 1fr);
|
|
327
|
+
}
|
|
328
|
+
|
|
329
|
+
.sb-socials {
|
|
330
|
+
grid-template-columns: repeat(2, 1fr);
|
|
331
|
+
}
|
|
332
|
+
|
|
333
|
+
.sb-addon {
|
|
334
|
+
height: 280px;
|
|
335
|
+
align-items: flex-start;
|
|
336
|
+
padding-top: 32px;
|
|
337
|
+
overflow: hidden;
|
|
338
|
+
}
|
|
339
|
+
|
|
340
|
+
.sb-addon-text {
|
|
341
|
+
padding-left: 24px;
|
|
342
|
+
}
|
|
343
|
+
|
|
344
|
+
.sb-addon-img {
|
|
345
|
+
right: 0;
|
|
346
|
+
left: 0;
|
|
347
|
+
top: 130px;
|
|
348
|
+
bottom: 0;
|
|
349
|
+
overflow: hidden;
|
|
350
|
+
height: auto;
|
|
351
|
+
width: 124%;
|
|
352
|
+
}
|
|
353
|
+
|
|
354
|
+
.sb-addon-img img {
|
|
355
|
+
width: 1200px;
|
|
356
|
+
transform: rotate(-12deg);
|
|
357
|
+
margin-left: 0;
|
|
358
|
+
margin-top: 48px;
|
|
359
|
+
margin-bottom: -40px;
|
|
360
|
+
margin-left: -24px;
|
|
361
|
+
}
|
|
362
|
+
}
|
|
363
|
+
`}
|
|
364
|
+
</style>
|