Skip to content

Commit

Permalink
Add storybook (metabase#19083)
Browse files Browse the repository at this point in the history
  • Loading branch information
ranquild authored Nov 29, 2021
1 parent 85db2cd commit eb0d21a
Show file tree
Hide file tree
Showing 9 changed files with 5,388 additions and 184 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@
/screenshots
/sqlite.db
/stats.json
/storybook-static
/target
/test-report-*
\#*\#
Expand Down
19 changes: 19 additions & 0 deletions .storybook/main.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
const appConfig = require("../webpack.config");

module.exports = {
core: {
builder: "webpack5",
},
stories: [
"../frontend/**/*.stories.mdx",
"../frontend/**/*.stories.@(js|jsx|ts|tsx)",
],
addons: ["@storybook/addon-links", "@storybook/addon-essentials"],
webpackFinal: storybookConfig => ({
...storybookConfig,
resolve: {
...storybookConfig.resolve,
alias: appConfig.resolve.alias,
},
}),
};
9 changes: 9 additions & 0 deletions .storybook/preview.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
export const parameters = {
actions: { argTypesRegex: "^on[A-Z].*" },
controls: {
matchers: {
color: /(background|color)$/i,
date: /Date$/,
},
},
};
14 changes: 14 additions & 0 deletions frontend/src/metabase/components/TextInput/TextInput.stories.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import React, { useState } from "react";
import TextInput from "./TextInput";

export default {
title: "Components/TextInput",
component: TextInput,
};

export const Default = args => {
const [value, setValue] = useState("");
return <TextInput {...args} value={value} onChange={setValue} />;
};

Default.args = { hasClearButton: false };
1 change: 1 addition & 0 deletions frontend/src/metabase/components/TextInput/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export { default } from "./TextInput";
10 changes: 9 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,12 @@
"@cypress/webpack-preprocessor": "^5.9.1",
"@percy/cli": "^1.0.0-beta.48",
"@percy/cypress": "^3.0.0",
"@storybook/addon-actions": "^6.3.12",
"@storybook/addon-essentials": "^6.3.12",
"@storybook/addon-links": "^6.3.12",
"@storybook/builder-webpack5": "^6.3.12",
"@storybook/manager-webpack5": "^6.3.12",
"@storybook/react": "^6.3.12",
"@testing-library/cypress": "^5.0.2",
"@testing-library/dom": "^7.29.0",
"@testing-library/jest-dom": "^4.0.0",
Expand Down Expand Up @@ -283,7 +289,9 @@
"test-visual": "ELECTRON_EXTRA_LAUNCH_ARGS=\"--force-prefers-reduced-motion\" yarn build && ./bin/build-for-test && yarn test-visual-no-build",
"test-visual-no-build": "percy exec -- yarn test-cypress-no-build --spec \"./frontend/test/metabase-visual/**/*.cy.spec.js\"",
"test-visual-open": "percy exec -- yarn test-cypress-open --spec \"./frontend/test/metabase-visual/**/*.cy.spec.js\"",
"prepare": "husky install"
"prepare": "husky install",
"storybook": "start-storybook -p 6006",
"build-storybook": "build-storybook"
},
"lint-staged": {
"frontend/**/*.{js,jsx,ts,tsx,css}": [
Expand Down
Loading

0 comments on commit eb0d21a

Please sign in to comment.