-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #302 from ably/add-storybook
[WEB-3364] Storybook migration: Add Storybook
- Loading branch information
Showing
55 changed files
with
10,677 additions
and
1,325 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
@import url("https://fonts.googleapis.com/css2?family=Manrope:wght@200;300;400;500;600;700;800&display=swap"); | ||
|
||
.pi-checkered-bg { | ||
--size: 0.25rem; | ||
--double: calc(var(--size) * 2); | ||
--bg: #eee; | ||
--fg: #ddd; | ||
background: linear-gradient( | ||
45deg, | ||
var(--fg) 25%, | ||
transparent 25.1%, | ||
transparent 74.9%, | ||
var(--fg) 75% | ||
), | ||
linear-gradient( | ||
45deg, | ||
var(--fg) 25%, | ||
transparent 25.1%, | ||
transparent 74.9%, | ||
var(--fg) 75% | ||
), | ||
var(--bg); | ||
background-repeat: repeat, repeat; | ||
background-position: 0 0, var(--size) var(--size); | ||
background-size: var(--double) var(--double), var(--double) var(--double); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
const path = require("path"); | ||
|
||
/** @type { import('@storybook/react-webpack5').StorybookConfig } */ | ||
const config = { | ||
stories: ["../src/**/*.mdx", "../src/**/*.stories.@(js|jsx|mjs|ts|tsx)"], | ||
staticDirs: ["../public"], | ||
framework: { | ||
name: "@storybook/react-webpack5", | ||
options: { | ||
builder: { | ||
useSWC: true, | ||
}, | ||
}, | ||
}, | ||
core: { | ||
disableTelemetry: true, | ||
}, | ||
addons: [ | ||
"@storybook/addon-links", | ||
"@storybook/addon-essentials", | ||
"@storybook/addon-interactions", | ||
"@storybook/addon-styling-webpack", | ||
{ | ||
name: "@storybook/addon-styling-webpack", | ||
|
||
options: { | ||
rules: [ | ||
{ | ||
test: /\.css$/, | ||
sideEffects: true, | ||
use: [ | ||
require.resolve("style-loader"), | ||
{ | ||
loader: require.resolve("css-loader"), | ||
options: { | ||
importLoaders: 1, | ||
}, | ||
}, | ||
{ | ||
loader: require.resolve("postcss-loader"), | ||
options: { | ||
postcssOptions: { | ||
config: path.resolve( | ||
__dirname, | ||
"postcss.storybook.config.js" | ||
), | ||
}, | ||
}, | ||
}, | ||
], | ||
}, | ||
], | ||
}, | ||
}, | ||
], | ||
docs: { | ||
autodocs: "tag", | ||
}, | ||
}; | ||
export default config; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
import { addons } from "@storybook/manager-api"; | ||
import theme from "./theme"; | ||
import "./application.css"; | ||
|
||
addons.setConfig({ | ||
theme, | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
module.exports = { | ||
plugins: [ | ||
"postcss-import", | ||
"postcss-custom-properties", | ||
"postcss-calc", | ||
"autoprefixer", | ||
"tailwindcss", | ||
], | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
import React from "react"; | ||
import { DocsContainer } from "@storybook/blocks"; | ||
import { initialize, mswDecorator } from "msw-storybook-addon"; | ||
|
||
import "./styles.css"; | ||
import theme from "./theme"; | ||
import loadIcons from "../src/core/icons"; | ||
|
||
const docsContainer = ({ children, context, ...props }) => { | ||
loadIcons(); | ||
|
||
return ( | ||
<DocsContainer context={context} {...props}> | ||
{children} | ||
</DocsContainer> | ||
); | ||
}; | ||
|
||
initialize({ | ||
onUnhandledRequest: "bypass", | ||
}); | ||
|
||
const preview = { | ||
parameters: { | ||
actions: { argTypesRegex: "^on[A-Z].*" }, | ||
controls: { | ||
matchers: { | ||
color: /(background|color)$/i, | ||
date: /Date$/i, | ||
}, | ||
}, | ||
docs: { | ||
theme, | ||
container: docsContainer, | ||
}, | ||
}, | ||
decorators: [ | ||
mswDecorator, | ||
(Story) => { | ||
loadIcons(); | ||
return Story(); | ||
}, | ||
], | ||
}; | ||
|
||
export default preview; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
@import "tailwindcss/base"; | ||
@import "tailwindcss/components"; | ||
@import "tailwindcss/utilities"; | ||
|
||
@import "../src/core/fonts/jetBrains-mono.css"; | ||
@import "../src/core/fonts/manrope.css"; | ||
@import "../src/core/styles.css"; | ||
@import "../src/reset/styles.css"; | ||
|
||
@import "./application.css"; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
import { create } from "@storybook/theming/create"; | ||
|
||
const brandImage = | ||
"data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iMTA4IiBoZWlnaHQ9IjMyIiB2aWV3Qm94PSIwIDAgMTA4IDMyIiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciPgoJPGcgY2xhc3M9InRleH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vcj0iI0ZGMDkwMiIgLz4KCQkJPHN0b3Agb2Zmc2V0PSIxIiBzdG9wLWNvbG9yPSIjRkY1MjE1IiAvPgoJCTwvbGluZWFyR3JhZGllbnQ+Cgk8L2RlZnM+Cjwvc3ZnPgo="; | ||
|
||
export default create({ | ||
base: "light", | ||
brandTitle: "Ably UI", | ||
brandImage, | ||
brandTarget: "_self", | ||
fontBase: '"Manrope", "Open Sans", sans-serif', | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
{ | ||
"css.lint.unknownAtRules": "ignore" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
declare module "*.png"; | ||
declare module "*.svg" { | ||
const content: string; | ||
export default content; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -21,6 +21,16 @@ | |
"@babel/preset-env": "^7.12.1", | ||
"@babel/preset-react": "^7.12.5", | ||
"@prettier/plugin-ruby": "^1.5.2", | ||
"@storybook/addon-essentials": "^7.6.4", | ||
"@storybook/addon-interactions": "^7.6.4", | ||
"@storybook/addon-links": "^7.6.4", | ||
"@storybook/addon-styling-webpack": "^0.0.5", | ||
"@storybook/blocks": "^7.6.4", | ||
"@storybook/react": "^7.6.4", | ||
"@storybook/react-webpack5": "^7.6.4", | ||
"@storybook/test": "^7.6.4", | ||
"@typescript-eslint/eslint-plugin": "^6.21.0", | ||
"@typescript-eslint/parser": "^6.21.0", | ||
"autoprefixer": "^10.0.2", | ||
"babel-loader": "^8.2.0", | ||
"blink-diff": "^1.0.13", | ||
|
@@ -31,17 +41,24 @@ | |
"eslint-config-prettier": "^6.15.0", | ||
"eslint-plugin-cypress": "^2.11.2", | ||
"eslint-plugin-react": "^7.21.5", | ||
"eslint-plugin-storybook": "^0.6.15", | ||
"extra-watch-webpack-plugin": "^1.0.3", | ||
"find-imports": "^1.1.0", | ||
"mini-css-extract-plugin": "^1.2.1", | ||
"msw": "1.3.2", | ||
"msw-storybook-addon": "^1.10.0", | ||
"null-loader": "^4.0.1", | ||
"postcss": "^8.1.10", | ||
"postcss-calc": "^7.0.5", | ||
"postcss-custom-properties": "^10.0.0", | ||
"postcss-import": "^13.0.0", | ||
"postcss-loader": "^4.0.4", | ||
"prettier": "^2.3.0", | ||
"storybook": "^7.6.4", | ||
"style-loader": "^3.3.3", | ||
"svg-spritemap-webpack-plugin": "^3.7.1", | ||
"tailwindcss": "^3.3.6", | ||
"typescript": "5.3.3", | ||
"webpack": "^5.3.2", | ||
"webpack-cli": "^4.2.0", | ||
"yargs": "^16.2.0" | ||
|
@@ -51,14 +68,16 @@ | |
"build:verbose": "node scripts/build.js -v", | ||
"watch": "node scripts/build.js -w", | ||
"dev": "./scripts/cleanstart.sh", | ||
"format:check": "yarn prettier -c *.js src src/**/*.jsx cypress", | ||
"format:write": "yarn prettier -w *.js src src/**/*.jsx cypress", | ||
"lint": "eslint *.js src src/**/*.jsx cypress", | ||
"format:check": "yarn prettier -c *.{js,ts} src/**/*.{js,jsx,ts,tsx} cypress", | ||
"format:write": "yarn prettier -w *.{js,ts} src/**/*.{js,jsx,ts,tsx} cypress", | ||
"lint": "eslint *.{js,ts} src/**/*.{js,jsx,ts,tsx} cypress", | ||
"cy:open": "cypress open", | ||
"cy:headless": "cypress run --quiet", | ||
"update:all": "./scripts/update-dependents.sh", | ||
"pre-release": "./scripts/pre-release.sh", | ||
"release": "./scripts/release.sh" | ||
"release": "./scripts/release.sh", | ||
"storybook": "storybook dev -p 6006 --no-version-updates", | ||
"build-storybook": "storybook build" | ||
}, | ||
"dependencies": { | ||
"@mrtkrcm/cypress-plugin-snapshots": "https://github.com/mrtkrcm/cypress-plugin-snapshots#v1.13.0", | ||
|
@@ -87,5 +106,8 @@ | |
"react", | ||
"view-components" | ||
], | ||
"author": "Ably Real-time Ltd <[email protected]>" | ||
} | ||
"author": "Ably Real-time Ltd <[email protected]>", | ||
"msw": { | ||
"workerDirectory": "public" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,7 @@ | ||
module.exports = { | ||
plugins: [ | ||
"postcss-import", | ||
"postcss-custom-properties", | ||
"postcss-calc", | ||
"autoprefixer", | ||
], | ||
export default { | ||
plugins: { | ||
"postcss-import": {}, | ||
tailwindcss: {}, | ||
autoprefixer: {}, | ||
}, | ||
}; |
Oops, something went wrong.