Skip to content

Commit

Permalink
feat(sharing): Add storybook
Browse files Browse the repository at this point in the history
  • Loading branch information
cballevre committed Mar 11, 2024
1 parent 0436fda commit fa7a028
Show file tree
Hide file tree
Showing 8 changed files with 154 additions and 7 deletions.
18 changes: 18 additions & 0 deletions packages/cozy-sharing/.storybook/main.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
const config = {
stories: ["../src/**/*.mdx", "../src/**/*.stories.@(js|jsx|ts|tsx)"],
addons: [
"@storybook/addon-links",
"@storybook/addon-essentials",
"@storybook/addon-interactions",
],
framework: {
name: "@storybook/react-webpack5",
options: {},
},
docs: {
autodocs: true
},
staticDirs: ['./public'],
};

export default config;
6 changes: 6 additions & 0 deletions packages/cozy-sharing/.storybook/manager.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import { addons } from '@storybook/manager-api';
import { themes } from '@storybook/theming';

addons.setConfig({
theme: themes.light,
});
21 changes: 21 additions & 0 deletions packages/cozy-sharing/.storybook/preview-head.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
<!-- This is the `head` of the preview iframe -->
<!-- Pull in static files served from your Static directory or the internet -->

<meta name="color-scheme" content="only light" />
<style>
@font-face {
font-family: Lato;
font-style: normal;
font-weight: normal;
src: url("/Lato-Regular.immutable.woff2") format("woff2");
font-display: fallback;
}

@font-face {
font-family: Lato;
font-style: normal;
font-weight: bold;
src: url("/Lato-Bold.immutable.woff2") format("woff2");
font-display: fallback;
}
</style>
64 changes: 64 additions & 0 deletions packages/cozy-sharing/.storybook/preview.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
import React from "react";

import 'cozy-ui/dist/cozy-ui.min.css'
import 'cozy-ui/dist/cozy-ui.utils.min.css'
import 'cozy-ui/transpiled/react/stylesheet.css'

import I18n from 'cozy-ui/transpiled/react/providers/I18n'
import { BreakpointsProvider } from 'cozy-ui/transpiled/react/providers/Breakpoints'
import CozyTheme from 'cozy-ui/transpiled/react/providers/CozyTheme'
import { CozyProvider, createFakeClient } from 'cozy-client'

import enLocale from '../locales/en.json'

const preview = {
decorators: [
(Story) => {
const fakeClient = createFakeClient({
queries: {
'io.cozy.settings/instance': {
doctype: 'io.cozy.settings',
definition: {
doctype: 'io.cozy.settings',
id: 'io.cozy.settings/io.cozy.settings.instance'
},
data: [
{
id: 'io.cozy.settings/io.cozy.settings.instance',
attributes: {
public_name: 'Alice'
}
}
]
}
},
clientOptions: {
uri: 'http://alice.cozy.localhost:8080'
}
})
return (
<CozyProvider client={fakeClient}>
<CozyTheme>
<BreakpointsProvider>
<I18n lang="en" dictRequire={() => enLocale}>
<div style={{position: "relative"}}>
<Story />
</div>
</I18n>
</BreakpointsProvider>
</CozyTheme>
</CozyProvider>
)},
],
parameters: {
actions: { argTypesRegex: "^on[A-Z].*" },
controls: {
matchers: {
color: /(background|color)$/i,
date: /Date$/,
},
},
},
};

export default preview;
Binary file not shown.
Binary file not shown.
14 changes: 12 additions & 2 deletions packages/cozy-sharing/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,9 @@
"lint": "cd .. && yarn eslint --ext js,jsx packages/cozy-sharing",
"start": "yarn build --watch",
"watch": "yarn run start",
"watch:doc:react": "(cd ../.. && TARGET=cozy-sharing yarn watch:doc:react)"
"watch:doc:react": "(cd ../.. && TARGET=cozy-sharing yarn watch:doc:react)",
"storybook": "storybook dev -p 6006",
"build-storybook": "storybook build"
},
"dependencies": {
"@cozy/minilog": "^1.0.0",
Expand All @@ -37,6 +39,13 @@
},
"devDependencies": {
"@babel/core": "7.16.12",
"@storybook/addon-essentials": "7.6.0",
"@storybook/addon-interactions": "7.6.0",
"@storybook/addon-links": "7.6.0",
"@storybook/blocks": "7.6.0",
"@storybook/react": "7.6.0",
"@storybook/react-webpack5": "7.6.0",
"@storybook/testing-library": "0.2.2",
"babel-jest": "26.6.3",
"babel-plugin-css-modules-transform": "1.6.2",
"babel-plugin-inline-react-svg": "1.1.2",
Expand All @@ -48,7 +57,8 @@
"jest": "26.6.3",
"react": "16.12.0",
"react-dom": "16.13.0",
"react-router": "^5.0.1"
"react-router": "^5.0.1",
"storybook": "7.6.0"
},
"peerDependencies": {
"cozy-client": ">=45.14.0",
Expand Down
38 changes: 33 additions & 5 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -5557,7 +5557,7 @@
remark-slug "^6.0.0"
ts-dedent "^2.0.0"

"@storybook/addon-essentials@^7.0.23":
"@storybook/addon-essentials@7.6.0", "@storybook/addon-essentials@^7.0.23":
version "7.6.0"
resolved "https://registry.yarnpkg.com/@storybook/addon-essentials/-/addon-essentials-7.6.0.tgz#715f338bcbf84f4ed43c8fb70e2a063ac0897c64"
integrity sha512-cLmLradZqGxh3xavAhPTmJYUdV66NZsEyAZKdc2Fjo9sVWbWstODe/IC1xhD1dRgxEMCTlBpmUENqeCbbnkpqA==
Expand All @@ -5584,7 +5584,7 @@
dependencies:
"@storybook/global" "^5.0.0"

"@storybook/addon-interactions@^7.0.23":
"@storybook/addon-interactions@7.6.0", "@storybook/addon-interactions@^7.0.23":
version "7.6.0"
resolved "https://registry.yarnpkg.com/@storybook/addon-interactions/-/addon-interactions-7.6.0.tgz#6c294529ece6a54af425e9af06a2a8dadc2741fc"
integrity sha512-+u1+FFn8asqJ96qe8AHWhpazYGu60vsl6QFkS1AWcvcNHaevjcSyBkPoVJEywnnixd5H3rpKo6EkXLsUvdr3JQ==
Expand All @@ -5595,7 +5595,7 @@
polished "^4.2.2"
ts-dedent "^2.2.0"

"@storybook/addon-links@^7.0.23":
"@storybook/addon-links@7.6.0", "@storybook/addon-links@^7.0.23":
version "7.6.0"
resolved "https://registry.yarnpkg.com/@storybook/addon-links/-/addon-links-7.6.0.tgz#adefec37dfdff08630838be51d05c0d7f02e958e"
integrity sha512-Qfq6U7EuxlXUFSbWVH8XRzQWva+CNtNgqjwO2hGsbhCisX5cb8vjl1mQF9DH00Lc021UcUjDPXiCCEEhj6Mpvg==
Expand Down Expand Up @@ -6158,7 +6158,7 @@
resolved "https://registry.yarnpkg.com/@storybook/react-dom-shim/-/react-dom-shim-7.6.0.tgz#645e62469a0824d5997e32ff2312fe2fbe5fe33d"
integrity sha512-DBsQ9OBwSjUEI2bvHcGqs+ucVy3UE8CjoWpD93kRcJZY913DCoNDrMSBWozhBHlcO65LhuBjrNm7oKdmwAKJsg==

"@storybook/react-webpack5@^7.0.23":
"@storybook/react-webpack5@7.6.0", "@storybook/react-webpack5@^7.0.23":
version "7.6.0"
resolved "https://registry.yarnpkg.com/@storybook/react-webpack5/-/react-webpack5-7.6.0.tgz#f9dc543a9b6db522f1687271c29cae9bfa86e585"
integrity sha512-htDtBZ4S4kWWqG1DP4DqxLPh6CryGAvaT/rcYAqJsuFCW6kiV+IGSFUp31vTAz+IET8gU+IjGOckjg9tH+Zw6g==
Expand Down Expand Up @@ -6218,6 +6218,15 @@
fs-extra "^11.1.0"
read-pkg-up "^7.0.1"

"@storybook/testing-library@0.2.2":
version "0.2.2"
resolved "https://registry.yarnpkg.com/@storybook/testing-library/-/testing-library-0.2.2.tgz#c8e089cc8d7354f6066fdb580fae3eedf568aa7c"
integrity sha512-L8sXFJUHmrlyU2BsWWZGuAjv39Jl1uAqUHdxmN42JY15M4+XCMjGlArdCCjDe1wpTSW6USYISA9axjZojgtvnw==
dependencies:
"@testing-library/dom" "^9.0.0"
"@testing-library/user-event" "^14.4.0"
ts-dedent "^2.2.0"

"@storybook/testing-library@^0.0.14-next.2":
version "0.0.14-next.2"
resolved "https://registry.yarnpkg.com/@storybook/testing-library/-/testing-library-0.0.14-next.2.tgz#458e6c7623118e24826ba73b80db0a887f3f57e8"
Expand Down Expand Up @@ -6371,6 +6380,20 @@
lz-string "^1.5.0"
pretty-format "^27.0.2"

"@testing-library/dom@^9.0.0":
version "9.3.4"
resolved "https://registry.yarnpkg.com/@testing-library/dom/-/dom-9.3.4.tgz#50696ec28376926fec0a1bf87d9dbac5e27f60ce"
integrity sha512-FlS4ZWlp97iiNWig0Muq8p+3rVDjRiYE+YKGbAqXOu9nwJFFOdL00kFpz42M+4huzYi86vAK1sOOfyOG45muIQ==
dependencies:
"@babel/code-frame" "^7.10.4"
"@babel/runtime" "^7.12.5"
"@types/aria-query" "^5.0.1"
aria-query "5.1.3"
chalk "^4.1.0"
dom-accessibility-api "^0.5.9"
lz-string "^1.5.0"
pretty-format "^27.0.2"

"@testing-library/jest-dom@5.16.4":
version "5.16.4"
resolved "https://registry.yarnpkg.com/@testing-library/jest-dom/-/jest-dom-5.16.4.tgz#938302d7b8b483963a3ae821f1c0808f872245cd"
Expand Down Expand Up @@ -6451,6 +6474,11 @@
dependencies:
"@babel/runtime" "^7.12.5"

"@testing-library/user-event@^14.4.0":
version "14.5.2"
resolved "https://registry.yarnpkg.com/@testing-library/user-event/-/user-event-14.5.2.tgz#db7257d727c891905947bd1c1a99da20e03c2ebd"
integrity sha512-YAh82Wh4TIrxYLmfGcixwD18oIjyC1pFQC2Y01F2lzV2HTMiYrI0nze0FD0ocB//CKS/7jIUgae+adPqxK5yCQ==

"@tootallnate/once@1":
version "1.1.2"
resolved "https://registry.yarnpkg.com/@tootallnate/once/-/once-1.1.2.tgz#ccb91445360179a04e7fe6aff78c00ffc1eeaf82"
Expand Down Expand Up @@ -25277,7 +25305,7 @@ store2@^2.14.2:
resolved "https://registry.yarnpkg.com/store2/-/store2-2.14.2.tgz#56138d200f9fe5f582ad63bc2704dbc0e4a45068"
integrity sha512-siT1RiqlfQnGqgT/YzXVUNsom9S0H1OX+dpdGN1xkyYATo4I6sep5NmsRD/40s3IIOvlCq6akxkqG82urIZW1w==

storybook@^7.0.23:
storybook@7.6.0, storybook@^7.0.23:
version "7.6.0"
resolved "https://registry.yarnpkg.com/storybook/-/storybook-7.6.0.tgz#7f83316ff9d2ba614d129b64298790f60d99fe37"
integrity sha512-t844tajV8dcWiGmGV0zXUdmLzLnftTqQOfzX678AjJXh7ijhMkNi2dgSFLaAOLQqeljdGfyrgFrivveZxkaj2w==
Expand Down

0 comments on commit fa7a028

Please sign in to comment.