mirror of
https://github.com/storybookjs/storybook.git
synced 2025-03-28 05:10:17 +08:00
Merge branch 'next' into tech/tsup-core-client
# Conflicts: # code/lib/core-client/src/globals.ts # code/lib/core-server/src/presets/common-preset.ts
This commit is contained in:
commit
67f0aafe74
@ -151,7 +151,7 @@ jobs:
|
||||
executor:
|
||||
class: medium+
|
||||
name: sb_node_14_browsers
|
||||
parallelism: 13
|
||||
parallelism: 12
|
||||
steps:
|
||||
- git-shallow-clone/checkout_advanced:
|
||||
clone_options: '--depth 1 --verbose'
|
||||
@ -477,7 +477,7 @@ jobs:
|
||||
executor:
|
||||
class: medium+
|
||||
name: sb_node_14_browsers
|
||||
parallelism: 8
|
||||
parallelism: 10
|
||||
steps:
|
||||
- git-shallow-clone/checkout_advanced:
|
||||
clone_options: '--depth 1 --verbose'
|
||||
@ -497,7 +497,7 @@ jobs:
|
||||
executor:
|
||||
class: medium+
|
||||
name: sb_node_14_browsers
|
||||
parallelism: 8
|
||||
parallelism: 10
|
||||
steps:
|
||||
- git-shallow-clone/checkout_advanced:
|
||||
clone_options: '--depth 1 --verbose'
|
||||
@ -513,7 +513,7 @@ jobs:
|
||||
executor:
|
||||
class: medium+
|
||||
name: sb_node_14_browsers
|
||||
parallelism: 8
|
||||
parallelism: 10
|
||||
steps:
|
||||
- git-shallow-clone/checkout_advanced:
|
||||
clone_options: '--depth 1 --verbose'
|
||||
@ -533,7 +533,7 @@ jobs:
|
||||
executor:
|
||||
class: medium+
|
||||
name: sb_node_14_browsers
|
||||
parallelism: 8
|
||||
parallelism: 10
|
||||
steps:
|
||||
- git-shallow-clone/checkout_advanced:
|
||||
clone_options: '--depth 1 --verbose'
|
||||
@ -549,7 +549,7 @@ jobs:
|
||||
executor:
|
||||
class: medium+
|
||||
name: sb_node_14_browsers
|
||||
parallelism: 8
|
||||
parallelism: 10
|
||||
steps:
|
||||
- git-shallow-clone/checkout_advanced:
|
||||
clone_options: '--depth 1 --verbose'
|
||||
@ -565,7 +565,7 @@ jobs:
|
||||
executor:
|
||||
class: medium+
|
||||
name: sb_playwright
|
||||
parallelism: 8
|
||||
parallelism: 10
|
||||
steps:
|
||||
- git-shallow-clone/checkout_advanced:
|
||||
clone_options: '--depth 1 --verbose'
|
||||
|
13
MIGRATION.md
13
MIGRATION.md
@ -20,8 +20,9 @@
|
||||
- [7.0 feature flags removed](#70-feature-flags-removed)
|
||||
- [Vite builder uses vite config automatically](#vite-builder-uses-vite-config-automatically)
|
||||
- [Removed docs.getContainer and getPage parameters](#removed-docsgetcontainer-and-getpage-parameters)
|
||||
- [Removed STORYBOOK_REACT_CLASSES global](#removed-storybook_react_classes-global)
|
||||
- [Icons API changed](#icons-api-changed)
|
||||
- ['config' preset entry replaced with 'previewAnnotations'](#config-preset-entry-replaced-with-preview-annotations)
|
||||
- ['config' preset entry replaced with 'previewAnnotations'](#config-preset-entry-replaced-with-previewannotations)
|
||||
- [Docs Changes](#docs-changes)
|
||||
- [Standalone docs files](#standalone-docs-files)
|
||||
- [Referencing stories in docs files](#referencing-stories-in-docs-files)
|
||||
@ -529,6 +530,10 @@ If you were using `viteFinal` in 6.5 to simply merge in your project's standard
|
||||
|
||||
It is no longer possible to set `parameters.docs.getContainer()` and `getPage()`. Instead use `parameters.docs.container` or `parameters.docs.page` directly.
|
||||
|
||||
#### Removed STORYBOOK_REACT_CLASSES global
|
||||
|
||||
This was a legacy global variable from the early days of react docgen. If you were using this variable, you can instead use docgen information which is added directly to components using `.__docgenInfo`.
|
||||
|
||||
#### Icons API changed
|
||||
|
||||
For addon authors who use the `Icons` component, its API has been updated in Storybook 7.
|
||||
@ -550,6 +555,12 @@ The preset field `'config'` has been replaced with `'previewAnnotations'`. `'con
|
||||
|
||||
Additionally, the internal field `'previewEntries'` has been removed. If you need a preview entry, just use a `'previewAnnotations'` file and don't export anything.
|
||||
|
||||
#### Vue2 DOM structure changed
|
||||
|
||||
In 6.x, `@storybook/vue` would replace the "root" element (formerly `#root`, now `#storybook-root`) with a new node that contains the rendered children. This was problematic because it broke the `play` function, which often starts with `within(canvasElement)` and the old `canvasElement` would get replaced out from under the play function.
|
||||
|
||||
In 7.0, `@storybook/vue` now leaves `#storybook-root` alone, and creates a new "dummy node" called `#storybook-vue-root` beneath it. This will break DOM snapshots moving from 6.5 to 7.0, but shouldn't have any other negative effects.
|
||||
|
||||
### Docs Changes
|
||||
|
||||
The information hierarchy of docs in Storybook has changed in 7.0. The main difference is that each docs is listed in the sidebar as a separate entry, rather than attached to individual stories.
|
||||
|
@ -15,8 +15,6 @@ scripts/repros-generator
|
||||
*.d.ts
|
||||
examples/ember-cli/.storybook/preview-head.html
|
||||
examples/official-storybook/tests/addon-jest.test.js
|
||||
examples/cra-ts-kitchen-sink/*.json
|
||||
examples/cra-ts-kitchen-sink/public/*
|
||||
ember-output
|
||||
.yarn
|
||||
!.remarkrc.js
|
||||
|
@ -1 +1 @@
|
||||
import './dist/esm/manager';
|
||||
import './dist/manager';
|
||||
|
@ -21,9 +21,32 @@
|
||||
"url": "https://opencollective.com/storybook"
|
||||
},
|
||||
"license": "MIT",
|
||||
"main": "dist/cjs/index.js",
|
||||
"module": "dist/esm/index.js",
|
||||
"types": "dist/types/index.d.ts",
|
||||
"exports": {
|
||||
".": {
|
||||
"require": "./dist/index.js",
|
||||
"import": "./dist/index.mjs",
|
||||
"types": "./dist/index.d.ts"
|
||||
},
|
||||
"./manager": {
|
||||
"require": "./dist/manager.js",
|
||||
"import": "./dist/manager.mjs",
|
||||
"types": "./dist/manager.d.ts"
|
||||
},
|
||||
"./preview": {
|
||||
"require": "./dist/preview.js",
|
||||
"import": "./dist/preview.mjs",
|
||||
"types": "./dist/preview.d.ts"
|
||||
},
|
||||
"./register.js": {
|
||||
"require": "./dist/manager.js",
|
||||
"import": "./dist/manager.mjs",
|
||||
"types": "./dist/manager.d.ts"
|
||||
},
|
||||
"./package.json": "./package.json"
|
||||
},
|
||||
"main": "dist/index.js",
|
||||
"module": "dist/index.mjs",
|
||||
"types": "dist/index.d.ts",
|
||||
"files": [
|
||||
"dist/**/*",
|
||||
"README.md",
|
||||
@ -32,7 +55,7 @@
|
||||
],
|
||||
"scripts": {
|
||||
"check": "../../../scripts/node_modules/.bin/tsc --noEmit",
|
||||
"prep": "node ../../../scripts/prepare.js"
|
||||
"prep": "../../../scripts/prepare/bundle.ts"
|
||||
},
|
||||
"dependencies": {
|
||||
"@storybook/addons": "7.0.0-alpha.34",
|
||||
@ -72,6 +95,13 @@
|
||||
"publishConfig": {
|
||||
"access": "public"
|
||||
},
|
||||
"bundler": {
|
||||
"entries": [
|
||||
"./src/index.ts",
|
||||
"./src/manager.tsx",
|
||||
"./src/preview.ts"
|
||||
]
|
||||
},
|
||||
"gitHead": "fc90fc875462421c1faa35862ac4bc436de8e75f",
|
||||
"storybook": {
|
||||
"displayName": "Actions",
|
||||
|
@ -1 +1 @@
|
||||
export * from './dist/esm/preset/preview';
|
||||
export * from './dist/preview';
|
||||
|
@ -1,5 +1,5 @@
|
||||
import type { Args, AnyFramework, ArgsEnhancer } from '@storybook/csf';
|
||||
import { action } from '../index';
|
||||
import { action } from './runtime/action';
|
||||
|
||||
// interface ActionsParameter {
|
||||
// disable?: boolean;
|
3
code/addons/actions/src/addDecorator.ts
Normal file
3
code/addons/actions/src/addDecorator.ts
Normal file
@ -0,0 +1,3 @@
|
||||
import { withActions } from './runtime/withActions';
|
||||
|
||||
export const decorators = [withActions];
|
@ -2,7 +2,7 @@
|
||||
|
||||
export * from './constants';
|
||||
export * from './models';
|
||||
export * from './preview';
|
||||
export * from './runtime';
|
||||
|
||||
if (module && module.hot && module.hot.decline) {
|
||||
module.hot.decline();
|
||||
|
@ -1,3 +0,0 @@
|
||||
import { withActions } from '../index';
|
||||
|
||||
export const decorators = [withActions];
|
@ -7,7 +7,6 @@ import loadFramework from '../frameworks/frameworkLoader';
|
||||
import { StoryshotsOptions } from './StoryshotsOptions';
|
||||
|
||||
const { describe, window: globalWindow } = global;
|
||||
global.STORYBOOK_REACT_CLASSES = global.STORYBOOK_REACT_CLASSES || {};
|
||||
|
||||
type TestMethod = 'beforeAll' | 'beforeEach' | 'afterEach' | 'afterAll';
|
||||
const methods: TestMethod[] = ['beforeAll', 'beforeEach', 'afterEach', 'afterAll'];
|
||||
|
@ -1,3 +0,0 @@
|
||||
DISABLE_ESLINT_PLUGIN=true
|
||||
SKIP_PREFLIGHT_CHECK=true
|
||||
NODE_PATH=src
|
@ -1,15 +0,0 @@
|
||||
import React from 'react';
|
||||
import { addons, types } from '@storybook/addons';
|
||||
|
||||
const ID = 'local-addon';
|
||||
|
||||
const LocalAddonPanel = () => <>Local addon</>;
|
||||
|
||||
addons.register(ID, (api) =>
|
||||
addons.add(ID, {
|
||||
title: ID,
|
||||
type: types.PANEL,
|
||||
match: () => true,
|
||||
render: ({ active, key }) => (active ? <LocalAddonPanel key={key} /> : null),
|
||||
})
|
||||
);
|
@ -1,3 +0,0 @@
|
||||
module.exports = {
|
||||
managerEntries: [],
|
||||
};
|
@ -1,44 +0,0 @@
|
||||
import type { StorybookConfig } from '@storybook/react-webpack5';
|
||||
|
||||
const path = require('path');
|
||||
|
||||
const mainConfig: StorybookConfig = {
|
||||
stories: ['../src/components', '../src/stories'],
|
||||
logLevel: 'debug',
|
||||
addons: [
|
||||
'@storybook/preset-create-react-app',
|
||||
'@storybook/addon-docs',
|
||||
'@storybook/addon-actions',
|
||||
'@storybook/addon-links',
|
||||
'@storybook/addon-a11y',
|
||||
'@storybook/addon-highlight',
|
||||
'./localAddon/manager.tsx',
|
||||
'./localAddon/preset.ts',
|
||||
],
|
||||
// add monorepo root as a valid directory to import modules from
|
||||
webpackFinal: (config) => {
|
||||
const resolvePlugins = config.resolve?.plugins;
|
||||
if (Array.isArray(resolvePlugins)) {
|
||||
resolvePlugins.forEach((p) => {
|
||||
// @ts-expect-error (Converted from ts-ignore)
|
||||
const appSrcs = p.appSrcs as unknown as string[];
|
||||
if (Array.isArray(appSrcs)) {
|
||||
appSrcs.push(path.join(__dirname, '..', '..', '..'));
|
||||
}
|
||||
});
|
||||
}
|
||||
return config;
|
||||
},
|
||||
core: {
|
||||
channelOptions: { allowFunction: false, maxDepth: 10 },
|
||||
disableTelemetry: true,
|
||||
},
|
||||
staticDirs: ['../public'],
|
||||
features: {
|
||||
buildStoriesJson: true,
|
||||
breakingChangesV7: true,
|
||||
},
|
||||
framework: '@storybook/react-webpack5',
|
||||
};
|
||||
|
||||
module.exports = mainConfig;
|
@ -1,6 +0,0 @@
|
||||
export const parameters = {
|
||||
options: {
|
||||
brandTitle: 'CRA TypeScript Kitchen Sink',
|
||||
brandUrl: 'https://github.com/storybookjs/storybook/tree/master/examples/cra-ts-kitchen-sink',
|
||||
},
|
||||
};
|
@ -1,44 +0,0 @@
|
||||
This project was bootstrapped with [Create React App](https://github.com/facebook/create-react-app).
|
||||
|
||||
## Available Scripts
|
||||
|
||||
In the project directory, you can run:
|
||||
|
||||
### `yarn start`
|
||||
|
||||
Runs the app in the development mode.<br />
|
||||
Open [http://localhost:3000](http://localhost:3000) to view it in the browser.
|
||||
|
||||
The page will reload if you make edits.<br />
|
||||
You will also see any lint errors in the console.
|
||||
|
||||
### `yarn test`
|
||||
|
||||
Launches the test runner in the interactive watch mode.<br />
|
||||
See the section about [running tests](https://facebook.github.io/create-react-app/docs/running-tests) for more information.
|
||||
|
||||
### `yarn build`
|
||||
|
||||
Builds the app for production to the `build` folder.<br />
|
||||
It correctly bundles React in production mode and optimizes the build for the best performance.
|
||||
|
||||
The build is minified and the filenames include the hashes.<br />
|
||||
Your app is ready to be deployed!
|
||||
|
||||
See the section about [deployment](https://facebook.github.io/create-react-app/docs/deployment) for more information.
|
||||
|
||||
### `yarn eject`
|
||||
|
||||
**Note: this is a one-way operation. Once you `eject`, you can’t go back!**
|
||||
|
||||
If you aren’t satisfied with the build tool and configuration choices, you can `eject` at any time. This command will remove the single build dependency from your project.
|
||||
|
||||
Instead, it will copy all the configuration files and the transitive dependencies (Webpack, Babel, ESLint, etc) right into your project so you have full control over them. All of the commands except `eject` will still work, but they will point to the copied scripts so you can tweak them. At this point you’re on your own.
|
||||
|
||||
You don’t have to ever use `eject`. The curated feature set is suitable for small and middle deployments, and you shouldn’t feel obligated to use this feature. However we understand that this tool wouldn’t be useful if you couldn’t customize it when you are ready for it.
|
||||
|
||||
## Learn More
|
||||
|
||||
You can learn more in the [Create React App documentation](https://facebook.github.io/create-react-app/docs/getting-started).
|
||||
|
||||
To learn React, check out the [React documentation](https://reactjs.org/).
|
@ -1,62 +0,0 @@
|
||||
{
|
||||
"name": "cra-ts-kitchen-sink",
|
||||
"version": "7.0.0-alpha.34",
|
||||
"private": true,
|
||||
"scripts": {
|
||||
"build": "react-scripts build",
|
||||
"build-storybook": "storybook build",
|
||||
"eject": "react-scripts eject",
|
||||
"start": "react-scripts start",
|
||||
"storybook": "storybook dev -p 9009 --no-manager-cache",
|
||||
"test": "react-scripts test"
|
||||
},
|
||||
"browserslist": {
|
||||
"production": [
|
||||
">0.2%",
|
||||
"not dead",
|
||||
"not op_mini all"
|
||||
],
|
||||
"development": [
|
||||
"last 1 chrome version",
|
||||
"last 1 firefox version",
|
||||
"last 1 safari version"
|
||||
]
|
||||
},
|
||||
"dependencies": {
|
||||
"@types/jest": "25.2.3",
|
||||
"@types/node": "^14.14.20 || ^16.0.0",
|
||||
"@types/react": "^16.14.23",
|
||||
"@types/react-dom": "^16.9.14",
|
||||
"prop-types": "^15.7.2",
|
||||
"react": "16.14.0",
|
||||
"react-dom": "16.14.0",
|
||||
"react-scripts": "^5.0.1",
|
||||
"typescript": "~4.6.3"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@storybook/addon-a11y": "7.0.0-alpha.34",
|
||||
"@storybook/addon-actions": "7.0.0-alpha.34",
|
||||
"@storybook/addon-docs": "7.0.0-alpha.34",
|
||||
"@storybook/addon-highlight": "7.0.0-alpha.34",
|
||||
"@storybook/addon-links": "7.0.0-alpha.34",
|
||||
"@storybook/addons": "7.0.0-alpha.34",
|
||||
"@storybook/builder-webpack5": "7.0.0-alpha.34",
|
||||
"@storybook/preset-create-react-app": "^4.1.0",
|
||||
"@storybook/react": "7.0.0-alpha.34",
|
||||
"@storybook/react-webpack5": "7.0.0-alpha.34",
|
||||
"@types/enzyme": "^3.10.8",
|
||||
"enzyme": "^3.11.0",
|
||||
"enzyme-adapter-react-16": "^1.9.1",
|
||||
"enzyme-to-json": "^3.6.1",
|
||||
"fork-ts-checker-webpack-plugin": "^7.2.6",
|
||||
"react-moment-proptypes": "^1.7.0",
|
||||
"storybook": "7.0.0-alpha.34",
|
||||
"ts-node": "^10.4.0",
|
||||
"webpack": "5"
|
||||
},
|
||||
"storybook": {
|
||||
"chromatic": {
|
||||
"projectToken": "19whyj1tlac"
|
||||
}
|
||||
}
|
||||
}
|
Binary file not shown.
Before Width: | Height: | Size: 22 KiB |
@ -1,41 +0,0 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="utf-8" />
|
||||
<link rel="icon" href="%PUBLIC_URL%/favicon.ico" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1" />
|
||||
<meta name="theme-color" content="#000000" />
|
||||
<meta name="description" content="Web site created using create-react-app" />
|
||||
<link rel="apple-touch-icon" href="logo192.png" />
|
||||
<!--
|
||||
manifest.json provides metadata used when your web app is installed on a
|
||||
user's mobile device or desktop. See https://developers.google.com/web/fundamentals/web-app-manifest/
|
||||
-->
|
||||
<link rel="manifest" href="%PUBLIC_URL%/manifest.json" />
|
||||
<!--
|
||||
Notice the use of %PUBLIC_URL% in the tags above.
|
||||
It will be replaced with the URL of the `public` folder during the build.
|
||||
Only files inside the `public` folder can be referenced from the HTML.
|
||||
|
||||
Unlike "/favicon.ico" or "favicon.ico", "%PUBLIC_URL%/favicon.ico" will
|
||||
work correctly both with client-side routing and a non-root public URL.
|
||||
Learn how to configure a non-root public URL by running `npm run build`.
|
||||
-->
|
||||
<title>React App</title>
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<noscript>You need to enable JavaScript to run this app.</noscript>
|
||||
<div id="root"></div>
|
||||
<!--
|
||||
This HTML file is a template.
|
||||
If you open it directly in the browser, you will see an empty page.
|
||||
|
||||
You can add webfonts, meta tags, or analytics to this file.
|
||||
The build step will place the bundled scripts into the <body> tag.
|
||||
|
||||
To begin the development, run `npm start` or `yarn start`.
|
||||
To create a production bundle, use `npm run build` or `yarn build`.
|
||||
-->
|
||||
</body>
|
||||
</html>
|
Binary file not shown.
Before Width: | Height: | Size: 5.1 KiB |
Binary file not shown.
Before Width: | Height: | Size: 14 KiB |
@ -1,25 +0,0 @@
|
||||
{
|
||||
"short_name": "React App",
|
||||
"name": "Create React App Sample",
|
||||
"icons": [
|
||||
{
|
||||
"src": "favicon.ico",
|
||||
"sizes": "64x64 32x32 24x24 16x16",
|
||||
"type": "image/x-icon"
|
||||
},
|
||||
{
|
||||
"src": "logo192.png",
|
||||
"type": "image/png",
|
||||
"sizes": "192x192"
|
||||
},
|
||||
{
|
||||
"src": "logo512.png",
|
||||
"type": "image/png",
|
||||
"sizes": "512x512"
|
||||
}
|
||||
],
|
||||
"start_url": ".",
|
||||
"display": "standalone",
|
||||
"theme_color": "#000000",
|
||||
"background_color": "#ffffff"
|
||||
}
|
@ -1,2 +0,0 @@
|
||||
# https://www.robotstxt.org/robotstxt.html
|
||||
User-agent: *
|
@ -1,22 +0,0 @@
|
||||
.App {
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
.App-logo {
|
||||
height: 40vmin;
|
||||
}
|
||||
|
||||
.App-header {
|
||||
background-color: #282c34;
|
||||
min-height: 100vh;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
font-size: calc(10px + 2vmin);
|
||||
color: white;
|
||||
}
|
||||
|
||||
.App-link {
|
||||
color: #09d3ac;
|
||||
}
|
@ -1,26 +0,0 @@
|
||||
import React, { FC } from 'react';
|
||||
import logo from './logo.svg';
|
||||
import './App.css';
|
||||
|
||||
const App: FC = () => {
|
||||
return (
|
||||
<div className="App">
|
||||
<header className="App-header">
|
||||
<img src={logo} className="App-logo" alt="logo" />
|
||||
<p>
|
||||
Edit <code>src/App.tsx</code> and save to reload.
|
||||
</p>
|
||||
<a
|
||||
className="App-link"
|
||||
href="https://reactjs.org"
|
||||
target="_blank"
|
||||
rel="noopener noreferrer"
|
||||
>
|
||||
Learn React
|
||||
</a>
|
||||
</header>
|
||||
</div>
|
||||
);
|
||||
};
|
||||
|
||||
export default App;
|
@ -1,19 +0,0 @@
|
||||
import React from 'react';
|
||||
import Button, { Type } from './Button';
|
||||
|
||||
export default {
|
||||
title: 'Docgen/Button',
|
||||
component: Button,
|
||||
};
|
||||
|
||||
export const SimpleButton = () => {
|
||||
const x = 0;
|
||||
return <Button>OK {x}</Button>;
|
||||
};
|
||||
|
||||
const typeOptions = {
|
||||
Default: 'default',
|
||||
Action: 'action',
|
||||
};
|
||||
|
||||
export const WithType = () => <Button type={typeOptions.Default as Type}>Label</Button>;
|
@ -1,35 +0,0 @@
|
||||
import React, { FC } from 'react';
|
||||
|
||||
export type Type = 'default' | 'action';
|
||||
|
||||
interface Props {
|
||||
/**
|
||||
* Click event `handler`
|
||||
*
|
||||
* Example function:
|
||||
*
|
||||
* ```
|
||||
* () => {
|
||||
* doThis();
|
||||
* }
|
||||
* ```
|
||||
*
|
||||
* @default null
|
||||
*/
|
||||
onClick?: () => void;
|
||||
|
||||
/**
|
||||
* Button type yo
|
||||
*/
|
||||
type?: Type;
|
||||
}
|
||||
|
||||
const Button: FC<Props> = ({ children, type = 'default', onClick }) => {
|
||||
return (
|
||||
<button type="button" onClick={onClick}>
|
||||
{type}: {children}
|
||||
</button>
|
||||
);
|
||||
};
|
||||
|
||||
export default Button;
|
@ -1,37 +0,0 @@
|
||||
import React, { FC, HTMLAttributes } from 'react';
|
||||
|
||||
const styles = {
|
||||
border: '1px solid #eee',
|
||||
borderRadius: 3,
|
||||
backgroundColor: '#FFFFFF',
|
||||
cursor: 'pointer',
|
||||
fontSize: 15,
|
||||
padding: '3px 10px',
|
||||
margin: 10,
|
||||
};
|
||||
|
||||
type ButtonProps = Pick<HTMLAttributes<HTMLButtonElement>, 'onClick'>;
|
||||
export const Button: FC<ButtonProps> = ({ children, onClick }) => (
|
||||
<button onClick={onClick} style={styles} type="button">
|
||||
{children}
|
||||
</button>
|
||||
);
|
||||
|
||||
Button.displayName = 'Button';
|
||||
Button.defaultProps = {
|
||||
onClick: () => {},
|
||||
};
|
||||
|
||||
interface WelcomeProps {
|
||||
showApp: () => void;
|
||||
}
|
||||
|
||||
export const Welcome: FC<WelcomeProps> = ({ showApp }) => (
|
||||
<button type="button" onClick={showApp}>
|
||||
Welcome
|
||||
</button>
|
||||
);
|
||||
Welcome.displayName = 'Welcome';
|
||||
Welcome.defaultProps = {
|
||||
showApp: () => {},
|
||||
};
|
@ -1,11 +0,0 @@
|
||||
body {
|
||||
margin: 0;
|
||||
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Oxygen', 'Ubuntu',
|
||||
'Cantarell', 'Fira Sans', 'Droid Sans', 'Helvetica Neue', sans-serif;
|
||||
-webkit-font-smoothing: antialiased;
|
||||
-moz-osx-font-smoothing: grayscale;
|
||||
}
|
||||
|
||||
code {
|
||||
font-family: source-code-pro, Menlo, Monaco, Consolas, 'Courier New', monospace;
|
||||
}
|
@ -1,6 +0,0 @@
|
||||
import React from 'react';
|
||||
import ReactDOM from 'react-dom';
|
||||
import './index.css';
|
||||
import App from './App';
|
||||
|
||||
ReactDOM.render(<App />, document.getElementById('root'));
|
File diff suppressed because one or more lines are too long
Before Width: | Height: | Size: 8.0 KiB |
@ -1 +0,0 @@
|
||||
/// <reference types="react-scripts" />
|
@ -1,11 +0,0 @@
|
||||
import React from 'react';
|
||||
import { Welcome } from '../components/react-demo';
|
||||
|
||||
export default {
|
||||
title: 'Welcome',
|
||||
component: Welcome,
|
||||
};
|
||||
|
||||
export const ToStorybook = () => <Welcome showApp={() => {}} />;
|
||||
|
||||
ToStorybook.storyName = 'to Storybook';
|
@ -1,17 +0,0 @@
|
||||
import React from 'react';
|
||||
import { Button } from './Button';
|
||||
|
||||
export default {
|
||||
title: '1-Button',
|
||||
component: Button,
|
||||
};
|
||||
|
||||
export const Text = () => <Button>Hello Button</Button>;
|
||||
|
||||
export const Emoji = () => (
|
||||
<Button>
|
||||
<span role="img" aria-label="so cool">
|
||||
😀 😎 👍 💯
|
||||
</span>
|
||||
</Button>
|
||||
);
|
@ -1,32 +0,0 @@
|
||||
import React, { FC } from 'react';
|
||||
|
||||
interface ButtonProps {
|
||||
/**
|
||||
* Simple click handler
|
||||
*/
|
||||
onClick?: () => void;
|
||||
|
||||
/**
|
||||
* Is primary?
|
||||
*/
|
||||
primary?: boolean;
|
||||
|
||||
/**
|
||||
* default is false
|
||||
*/
|
||||
secondary?: boolean;
|
||||
}
|
||||
|
||||
/**
|
||||
* The world's most _basic_ button
|
||||
*/
|
||||
export const Button: FC<ButtonProps> = ({ children, onClick }) => (
|
||||
<button onClick={onClick} type="button">
|
||||
{children}
|
||||
</button>
|
||||
);
|
||||
|
||||
Button.defaultProps = {
|
||||
primary: true,
|
||||
secondary: false,
|
||||
};
|
@ -1,20 +0,0 @@
|
||||
import { Meta } from '@storybook/addon-docs';
|
||||
|
||||
<Meta title="Classes Stripped" />
|
||||
|
||||
# Preview
|
||||
|
||||
<style>
|
||||
{`
|
||||
.a-custom-class {
|
||||
border: 10px solid hotpink;
|
||||
}
|
||||
.a-custom-classname {
|
||||
border: 10px solid blue;
|
||||
}
|
||||
`}
|
||||
</style>
|
||||
|
||||
<div class="a-custom-class">
|
||||
<div className="a-custom-classname">This box should have BOTH a pink and blue border</div>
|
||||
</div>
|
@ -1,16 +0,0 @@
|
||||
/* eslint-disable react/no-unused-prop-types */
|
||||
/* eslint-disable react/require-default-props */
|
||||
import React from 'react';
|
||||
import PropTypes from 'prop-types';
|
||||
|
||||
export const PropsSort = () => <div>PropsSort!</div>;
|
||||
PropsSort.propTypes = {
|
||||
foo: PropTypes.string.isRequired,
|
||||
middleWithDefaultValue: PropTypes.string,
|
||||
bar: PropTypes.string,
|
||||
endWithDefaultValue: PropTypes.string,
|
||||
};
|
||||
PropsSort.defaultProps = {
|
||||
middleWithDefaultValue: 'Middle!',
|
||||
endWithDefaultValue: 'End!',
|
||||
};
|
@ -1,18 +0,0 @@
|
||||
import { Meta, Story, Canvas, ArgsTable } from '@storybook/addon-docs';
|
||||
import { Button } from './Button';
|
||||
|
||||
<Meta title="Test" />
|
||||
|
||||
Here's some _markdown_!
|
||||
|
||||
# Canvas
|
||||
|
||||
<Canvas>
|
||||
<Story name="button">
|
||||
<Button>hello</Button>
|
||||
</Story>
|
||||
</Canvas>
|
||||
|
||||
# ArgsTable
|
||||
|
||||
<ArgsTable of={Button} />
|
@ -1,265 +0,0 @@
|
||||
import { Meta } from '@storybook/addon-docs';
|
||||
|
||||
<Meta title="Anchors" />
|
||||
|
||||
<a href="#bottom">go to bottom</a>
|
||||
|
||||
## Hey
|
||||
|
||||
<code>Some code!!!</code>
|
||||
<p>
|
||||
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Quisque leo dolor, pharetra non arcu vel,
|
||||
accumsan commodo ligula. Vestibulum ut nulla mauris. Mauris vehicula pharetra sem, ac semper quam
|
||||
euismod eget. Fusce sit amet laoreet leo. Maecenas vitae mollis nibh. Morbi ullamcorper justo at
|
||||
enim malesuada, non porta augue ullamcorper. Etiam varius ultrices nisi, eu pharetra lacus
|
||||
sollicitudin eu. Suspendisse sit amet tincidunt dolor, a lobortis lectus.
|
||||
</p>
|
||||
<p>
|
||||
Quisque venenatis placerat est, sed pulvinar dui cursus ut. Curabitur rutrum odio sit amet est
|
||||
bibendum maximus. Nulla euismod finibus condimentum. Vestibulum finibus, felis nec malesuada
|
||||
accumsan, urna velit convallis ligula, ut pharetra lacus lorem elementum nunc. Donec ac massa eget
|
||||
massa auctor rhoncus at et nulla. Nam sollicitudin, mauris eget egestas pellentesque, leo eros
|
||||
tincidunt felis, in luctus metus tortor sit amet tortor. Mauris ut velit vitae ipsum pharetra
|
||||
consequat. Vivamus id magna quis orci congue fringilla. Vestibulum vitae mollis risus.
|
||||
</p>
|
||||
<p>
|
||||
Phasellus eu mauris lacus. Fusce nec ante non ante condimentum ullamcorper. Phasellus condimentum
|
||||
massa vitae diam dignissim volutpat. Aenean ut dignissim felis. Suspendisse vitae sollicitudin
|
||||
est, vel dapibus elit. Nullam auctor dui et erat sagittis, quis imperdiet tellus consequat. Donec
|
||||
eu auctor nulla. Pellentesque sed leo lectus. Quisque molestie, urna non gravida vestibulum, nulla
|
||||
augue pellentesque neque, sed ultrices quam diam id metus.
|
||||
</p>
|
||||
<p>
|
||||
Etiam nec suscipit nunc. Vestibulum in euismod neque, eu vehicula tellus. Praesent id suscipit
|
||||
nunc. Pellentesque non orci egestas, bibendum magna et, commodo lorem. Phasellus et convallis
|
||||
arcu, ac dapibus velit. Integer ac pellentesque nibh. Aenean erat magna, hendrerit bibendum
|
||||
fringilla a, maximus eu mi. Curabitur pulvinar pulvinar pellentesque. Duis in dapibus enim.
|
||||
</p>
|
||||
<p>
|
||||
Integer vitae convallis velit. Integer ut turpis risus. Nunc non dui vitae est aliquam tempus nec
|
||||
ac nibh. Integer condimentum libero lorem, vitae ultrices neque commodo sit amet. Sed et lacinia
|
||||
sapien. Sed mattis magna eu nunc varius vehicula. Ut id velit vitae nunc aliquet iaculis. Proin
|
||||
enim turpis, ultricies vel vulputate in, pharetra at mauris. Duis non tincidunt augue.
|
||||
</p>
|
||||
|
||||
## Ho
|
||||
|
||||
<p>
|
||||
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Quisque leo dolor, pharetra non arcu vel,
|
||||
accumsan commodo ligula. Vestibulum ut nulla mauris. Mauris vehicula pharetra sem, ac semper quam
|
||||
euismod eget. Fusce sit amet laoreet leo. Maecenas vitae mollis nibh. Morbi ullamcorper justo at
|
||||
enim malesuada, non porta augue ullamcorper. Etiam varius ultrices nisi, eu pharetra lacus
|
||||
sollicitudin eu. Suspendisse sit amet tincidunt dolor, a lobortis lectus.
|
||||
</p>
|
||||
<p>
|
||||
Quisque venenatis placerat est, sed pulvinar dui cursus ut. Curabitur rutrum odio sit amet est
|
||||
bibendum maximus. Nulla euismod finibus condimentum. Vestibulum finibus, felis nec malesuada
|
||||
accumsan, urna velit convallis ligula, ut pharetra lacus lorem elementum nunc. Donec ac massa eget
|
||||
massa auctor rhoncus at et nulla. Nam sollicitudin, mauris eget egestas pellentesque, leo eros
|
||||
tincidunt felis, in luctus metus tortor sit amet tortor. Mauris ut velit vitae ipsum pharetra
|
||||
consequat. Vivamus id magna quis orci congue fringilla. Vestibulum vitae mollis risus.
|
||||
</p>
|
||||
<p>
|
||||
Phasellus eu mauris lacus. Fusce nec ante non ante condimentum ullamcorper. Phasellus condimentum
|
||||
massa vitae diam dignissim volutpat. Aenean ut dignissim felis. Suspendisse vitae sollicitudin
|
||||
est, vel dapibus elit. Nullam auctor dui et erat sagittis, quis imperdiet tellus consequat. Donec
|
||||
eu auctor nulla. Pellentesque sed leo lectus. Quisque molestie, urna non gravida vestibulum, nulla
|
||||
augue pellentesque neque, sed ultrices quam diam id metus.
|
||||
</p>
|
||||
<p>
|
||||
Etiam nec suscipit nunc. Vestibulum in euismod neque, eu vehicula tellus. Praesent id suscipit
|
||||
nunc. Pellentesque non orci egestas, bibendum magna et, commodo lorem. Phasellus et convallis
|
||||
arcu, ac dapibus velit. Integer ac pellentesque nibh. Aenean erat magna, hendrerit bibendum
|
||||
fringilla a, maximus eu mi. Curabitur pulvinar pulvinar pellentesque. Duis in dapibus enim.
|
||||
</p>
|
||||
<p>
|
||||
Integer vitae convallis velit. Integer ut turpis risus. Nunc non dui vitae est aliquam tempus nec
|
||||
ac nibh. Integer condimentum libero lorem, vitae ultrices neque commodo sit amet. Sed et lacinia
|
||||
sapien. Sed mattis magna eu nunc varius vehicula. Ut id velit vitae nunc aliquet iaculis. Proin
|
||||
enim turpis, ultricies vel vulputate in, pharetra at mauris. Duis non tincidunt augue.
|
||||
</p>
|
||||
|
||||
## Hey
|
||||
|
||||
<p>
|
||||
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Quisque leo dolor, pharetra non arcu vel,
|
||||
accumsan commodo ligula. Vestibulum ut nulla mauris. Mauris vehicula pharetra sem, ac semper quam
|
||||
euismod eget. Fusce sit amet laoreet leo. Maecenas vitae mollis nibh. Morbi ullamcorper justo at
|
||||
enim malesuada, non porta augue ullamcorper. Etiam varius ultrices nisi, eu pharetra lacus
|
||||
sollicitudin eu. Suspendisse sit amet tincidunt dolor, a lobortis lectus.
|
||||
</p>
|
||||
<p>
|
||||
Quisque venenatis placerat est, sed pulvinar dui cursus ut. Curabitur rutrum odio sit amet est
|
||||
bibendum maximus. Nulla euismod finibus condimentum. Vestibulum finibus, felis nec malesuada
|
||||
accumsan, urna velit convallis ligula, ut pharetra lacus lorem elementum nunc. Donec ac massa eget
|
||||
massa auctor rhoncus at et nulla. Nam sollicitudin, mauris eget egestas pellentesque, leo eros
|
||||
tincidunt felis, in luctus metus tortor sit amet tortor. Mauris ut velit vitae ipsum pharetra
|
||||
consequat. Vivamus id magna quis orci congue fringilla. Vestibulum vitae mollis risus.
|
||||
</p>
|
||||
<p>
|
||||
Phasellus eu mauris lacus. Fusce nec ante non ante condimentum ullamcorper. Phasellus condimentum
|
||||
massa vitae diam dignissim volutpat. Aenean ut dignissim felis. Suspendisse vitae sollicitudin
|
||||
est, vel dapibus elit. Nullam auctor dui et erat sagittis, quis imperdiet tellus consequat. Donec
|
||||
eu auctor nulla. Pellentesque sed leo lectus. Quisque molestie, urna non gravida vestibulum, nulla
|
||||
augue pellentesque neque, sed ultrices quam diam id metus.
|
||||
</p>
|
||||
<p>
|
||||
Etiam nec suscipit nunc. Vestibulum in euismod neque, eu vehicula tellus. Praesent id suscipit
|
||||
nunc. Pellentesque non orci egestas, bibendum magna et, commodo lorem. Phasellus et convallis
|
||||
arcu, ac dapibus velit. Integer ac pellentesque nibh. Aenean erat magna, hendrerit bibendum
|
||||
fringilla a, maximus eu mi. Curabitur pulvinar pulvinar pellentesque. Duis in dapibus enim.
|
||||
</p>
|
||||
<p>
|
||||
Integer vitae convallis velit. Integer ut turpis risus. Nunc non dui vitae est aliquam tempus nec
|
||||
ac nibh. Integer condimentum libero lorem, vitae ultrices neque commodo sit amet. Sed et lacinia
|
||||
sapien. Sed mattis magna eu nunc varius vehicula. Ut id velit vitae nunc aliquet iaculis. Proin
|
||||
enim turpis, ultricies vel vulputate in, pharetra at mauris. Duis non tincidunt augue.
|
||||
</p>
|
||||
|
||||
## Ho
|
||||
|
||||
<p>
|
||||
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Quisque leo dolor, pharetra non arcu vel,
|
||||
accumsan commodo ligula. Vestibulum ut nulla mauris. Mauris vehicula pharetra sem, ac semper quam
|
||||
euismod eget. Fusce sit amet laoreet leo. Maecenas vitae mollis nibh. Morbi ullamcorper justo at
|
||||
enim malesuada, non porta augue ullamcorper. Etiam varius ultrices nisi, eu pharetra lacus
|
||||
sollicitudin eu. Suspendisse sit amet tincidunt dolor, a lobortis lectus.
|
||||
</p>
|
||||
<p>
|
||||
Quisque venenatis placerat est, sed pulvinar dui cursus ut. Curabitur rutrum odio sit amet est
|
||||
bibendum maximus. Nulla euismod finibus condimentum. Vestibulum finibus, felis nec malesuada
|
||||
accumsan, urna velit convallis ligula, ut pharetra lacus lorem elementum nunc. Donec ac massa eget
|
||||
massa auctor rhoncus at et nulla. Nam sollicitudin, mauris eget egestas pellentesque, leo eros
|
||||
tincidunt felis, in luctus metus tortor sit amet tortor. Mauris ut velit vitae ipsum pharetra
|
||||
consequat. Vivamus id magna quis orci congue fringilla. Vestibulum vitae mollis risus.
|
||||
</p>
|
||||
<p>
|
||||
Phasellus eu mauris lacus. Fusce nec ante non ante condimentum ullamcorper. Phasellus condimentum
|
||||
massa vitae diam dignissim volutpat. Aenean ut dignissim felis. Suspendisse vitae sollicitudin
|
||||
est, vel dapibus elit. Nullam auctor dui et erat sagittis, quis imperdiet tellus consequat. Donec
|
||||
eu auctor nulla. Pellentesque sed leo lectus. Quisque molestie, urna non gravida vestibulum, nulla
|
||||
augue pellentesque neque, sed ultrices quam diam id metus.
|
||||
</p>
|
||||
<p>
|
||||
Etiam nec suscipit nunc. Vestibulum in euismod neque, eu vehicula tellus. Praesent id suscipit
|
||||
nunc. Pellentesque non orci egestas, bibendum magna et, commodo lorem. Phasellus et convallis
|
||||
arcu, ac dapibus velit. Integer ac pellentesque nibh. Aenean erat magna, hendrerit bibendum
|
||||
fringilla a, maximus eu mi. Curabitur pulvinar pulvinar pellentesque. Duis in dapibus enim.
|
||||
</p>
|
||||
<p>
|
||||
Integer vitae convallis velit. Integer ut turpis risus. Nunc non dui vitae est aliquam tempus nec
|
||||
ac nibh. Integer condimentum libero lorem, vitae ultrices neque commodo sit amet. Sed et lacinia
|
||||
sapien. Sed mattis magna eu nunc varius vehicula. Ut id velit vitae nunc aliquet iaculis. Proin
|
||||
enim turpis, ultricies vel vulputate in, pharetra at mauris. Duis non tincidunt augue.
|
||||
</p>
|
||||
|
||||
## Hey
|
||||
|
||||
<p>
|
||||
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Quisque leo dolor, pharetra non arcu vel,
|
||||
accumsan commodo ligula. Vestibulum ut nulla mauris. Mauris vehicula pharetra sem, ac semper quam
|
||||
euismod eget. Fusce sit amet laoreet leo. Maecenas vitae mollis nibh. Morbi ullamcorper justo at
|
||||
enim malesuada, non porta augue ullamcorper. Etiam varius ultrices nisi, eu pharetra lacus
|
||||
sollicitudin eu. Suspendisse sit amet tincidunt dolor, a lobortis lectus.
|
||||
</p>
|
||||
<p>
|
||||
Quisque venenatis placerat est, sed pulvinar dui cursus ut. Curabitur rutrum odio sit amet est
|
||||
bibendum maximus. Nulla euismod finibus condimentum. Vestibulum finibus, felis nec malesuada
|
||||
accumsan, urna velit convallis ligula, ut pharetra lacus lorem elementum nunc. Donec ac massa eget
|
||||
massa auctor rhoncus at et nulla. Nam sollicitudin, mauris eget egestas pellentesque, leo eros
|
||||
tincidunt felis, in luctus metus tortor sit amet tortor. Mauris ut velit vitae ipsum pharetra
|
||||
consequat. Vivamus id magna quis orci congue fringilla. Vestibulum vitae mollis risus.
|
||||
</p>
|
||||
<p>
|
||||
Phasellus eu mauris lacus. Fusce nec ante non ante condimentum ullamcorper. Phasellus condimentum
|
||||
massa vitae diam dignissim volutpat. Aenean ut dignissim felis. Suspendisse vitae sollicitudin
|
||||
est, vel dapibus elit. Nullam auctor dui et erat sagittis, quis imperdiet tellus consequat. Donec
|
||||
eu auctor nulla. Pellentesque sed leo lectus. Quisque molestie, urna non gravida vestibulum, nulla
|
||||
augue pellentesque neque, sed ultrices quam diam id metus.
|
||||
</p>
|
||||
<p>
|
||||
Etiam nec suscipit nunc. Vestibulum in euismod neque, eu vehicula tellus. Praesent id suscipit
|
||||
nunc. Pellentesque non orci egestas, bibendum magna et, commodo lorem. Phasellus et convallis
|
||||
arcu, ac dapibus velit. Integer ac pellentesque nibh. Aenean erat magna, hendrerit bibendum
|
||||
fringilla a, maximus eu mi. Curabitur pulvinar pulvinar pellentesque. Duis in dapibus enim.
|
||||
</p>
|
||||
<p>
|
||||
Integer vitae convallis velit. Integer ut turpis risus. Nunc non dui vitae est aliquam tempus nec
|
||||
ac nibh. Integer condimentum libero lorem, vitae ultrices neque commodo sit amet. Sed et lacinia
|
||||
sapien. Sed mattis magna eu nunc varius vehicula. Ut id velit vitae nunc aliquet iaculis. Proin
|
||||
enim turpis, ultricies vel vulputate in, pharetra at mauris. Duis non tincidunt augue.
|
||||
</p>
|
||||
|
||||
## Ho
|
||||
|
||||
<p>
|
||||
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Quisque leo dolor, pharetra non arcu vel,
|
||||
accumsan commodo ligula. Vestibulum ut nulla mauris. Mauris vehicula pharetra sem, ac semper quam
|
||||
euismod eget. Fusce sit amet laoreet leo. Maecenas vitae mollis nibh. Morbi ullamcorper justo at
|
||||
enim malesuada, non porta augue ullamcorper. Etiam varius ultrices nisi, eu pharetra lacus
|
||||
sollicitudin eu. Suspendisse sit amet tincidunt dolor, a lobortis lectus.
|
||||
</p>
|
||||
<p>
|
||||
Quisque venenatis placerat est, sed pulvinar dui cursus ut. Curabitur rutrum odio sit amet est
|
||||
bibendum maximus. Nulla euismod finibus condimentum. Vestibulum finibus, felis nec malesuada
|
||||
accumsan, urna velit convallis ligula, ut pharetra lacus lorem elementum nunc. Donec ac massa eget
|
||||
massa auctor rhoncus at et nulla. Nam sollicitudin, mauris eget egestas pellentesque, leo eros
|
||||
tincidunt felis, in luctus metus tortor sit amet tortor. Mauris ut velit vitae ipsum pharetra
|
||||
consequat. Vivamus id magna quis orci congue fringilla. Vestibulum vitae mollis risus.
|
||||
</p>
|
||||
<p>
|
||||
Phasellus eu mauris lacus. Fusce nec ante non ante condimentum ullamcorper. Phasellus condimentum
|
||||
massa vitae diam dignissim volutpat. Aenean ut dignissim felis. Suspendisse vitae sollicitudin
|
||||
est, vel dapibus elit. Nullam auctor dui et erat sagittis, quis imperdiet tellus consequat. Donec
|
||||
eu auctor nulla. Pellentesque sed leo lectus. Quisque molestie, urna non gravida vestibulum, nulla
|
||||
augue pellentesque neque, sed ultrices quam diam id metus.
|
||||
</p>
|
||||
<p>
|
||||
Etiam nec suscipit nunc. Vestibulum in euismod neque, eu vehicula tellus. Praesent id suscipit
|
||||
nunc. Pellentesque non orci egestas, bibendum magna et, commodo lorem. Phasellus et convallis
|
||||
arcu, ac dapibus velit. Integer ac pellentesque nibh. Aenean erat magna, hendrerit bibendum
|
||||
fringilla a, maximus eu mi. Curabitur pulvinar pulvinar pellentesque. Duis in dapibus enim.
|
||||
</p>
|
||||
<p>
|
||||
Integer vitae convallis velit. Integer ut turpis risus. Nunc non dui vitae est aliquam tempus nec
|
||||
ac nibh. Integer condimentum libero lorem, vitae ultrices neque commodo sit amet. Sed et lacinia
|
||||
sapien. Sed mattis magna eu nunc varius vehicula. Ut id velit vitae nunc aliquet iaculis. Proin
|
||||
enim turpis, ultricies vel vulputate in, pharetra at mauris. Duis non tincidunt augue.
|
||||
</p>
|
||||
|
||||
## Bottom
|
||||
|
||||
<p>
|
||||
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Quisque leo dolor, pharetra non arcu vel,
|
||||
accumsan commodo ligula. Vestibulum ut nulla mauris. Mauris vehicula pharetra sem, ac semper quam
|
||||
euismod eget. Fusce sit amet laoreet leo. Maecenas vitae mollis nibh. Morbi ullamcorper justo at
|
||||
enim malesuada, non porta augue ullamcorper. Etiam varius ultrices nisi, eu pharetra lacus
|
||||
sollicitudin eu. Suspendisse sit amet tincidunt dolor, a lobortis lectus.
|
||||
</p>
|
||||
<p>
|
||||
Quisque venenatis placerat est, sed pulvinar dui cursus ut. Curabitur rutrum odio sit amet est
|
||||
bibendum maximus. Nulla euismod finibus condimentum. Vestibulum finibus, felis nec malesuada
|
||||
accumsan, urna velit convallis ligula, ut pharetra lacus lorem elementum nunc. Donec ac massa eget
|
||||
massa auctor rhoncus at et nulla. Nam sollicitudin, mauris eget egestas pellentesque, leo eros
|
||||
tincidunt felis, in luctus metus tortor sit amet tortor. Mauris ut velit vitae ipsum pharetra
|
||||
consequat. Vivamus id magna quis orci congue fringilla. Vestibulum vitae mollis risus.
|
||||
</p>
|
||||
<p>
|
||||
Phasellus eu mauris lacus. Fusce nec ante non ante condimentum ullamcorper. Phasellus condimentum
|
||||
massa vitae diam dignissim volutpat. Aenean ut dignissim felis. Suspendisse vitae sollicitudin
|
||||
est, vel dapibus elit. Nullam auctor dui et erat sagittis, quis imperdiet tellus consequat. Donec
|
||||
eu auctor nulla. Pellentesque sed leo lectus. Quisque molestie, urna non gravida vestibulum, nulla
|
||||
augue pellentesque neque, sed ultrices quam diam id metus.
|
||||
</p>
|
||||
<p>
|
||||
Etiam nec suscipit nunc. Vestibulum in euismod neque, eu vehicula tellus. Praesent id suscipit
|
||||
nunc. Pellentesque non orci egestas, bibendum magna et, commodo lorem. Phasellus et convallis
|
||||
arcu, ac dapibus velit. Integer ac pellentesque nibh. Aenean erat magna, hendrerit bibendum
|
||||
fringilla a, maximus eu mi. Curabitur pulvinar pulvinar pellentesque. Duis in dapibus enim.
|
||||
</p>
|
||||
<p>
|
||||
Integer vitae convallis velit. Integer ut turpis risus. Nunc non dui vitae est aliquam tempus nec
|
||||
ac nibh. Integer condimentum libero lorem, vitae ultrices neque commodo sit amet. Sed et lacinia
|
||||
sapien. Sed mattis magna eu nunc varius vehicula. Ut id velit vitae nunc aliquet iaculis. Proin
|
||||
enim turpis, ultricies vel vulputate in, pharetra at mauris. Duis non tincidunt augue.
|
||||
</p>
|
@ -1,78 +0,0 @@
|
||||
/* eslint-disable react/button-has-type */
|
||||
/* eslint-disable react/prefer-stateless-function */
|
||||
/* eslint-disable react/prop-types */
|
||||
import React, { Component } from 'react';
|
||||
import PropTypes from 'prop-types';
|
||||
|
||||
/**
|
||||
* Button functional component
|
||||
*/
|
||||
export const ButtonFn = ({ onClick, children }) => <button onClick={onClick}>{children}</button>;
|
||||
ButtonFn.propTypes = {
|
||||
/**
|
||||
* onClick description
|
||||
*/
|
||||
onClick: PropTypes.func,
|
||||
};
|
||||
ButtonFn.defaultProps = {
|
||||
onClick: null,
|
||||
};
|
||||
|
||||
/**
|
||||
* Button class React.Component
|
||||
*/
|
||||
export class ButtonReactComponent extends React.Component {
|
||||
render() {
|
||||
const { onClick, children } = this.props;
|
||||
return <button onClick={onClick}>{children}</button>;
|
||||
}
|
||||
}
|
||||
ButtonReactComponent.propTypes = {
|
||||
/**
|
||||
* onClick description
|
||||
*/
|
||||
onClick: PropTypes.func,
|
||||
};
|
||||
ButtonReactComponent.defaultProps = {
|
||||
onClick: null,
|
||||
};
|
||||
|
||||
/**
|
||||
* Button class Component
|
||||
*/
|
||||
export class ButtonComponent extends Component {
|
||||
render() {
|
||||
const { onClick, children } = this.props;
|
||||
return <button onClick={onClick}>{children}</button>;
|
||||
}
|
||||
}
|
||||
ButtonComponent.propTypes = {
|
||||
/**
|
||||
* onClick description
|
||||
*/
|
||||
onClick: PropTypes.func,
|
||||
};
|
||||
ButtonComponent.defaultProps = {
|
||||
onClick: null,
|
||||
};
|
||||
|
||||
/**
|
||||
* Button class static props
|
||||
*/
|
||||
export class ButtonStaticProps extends Component {
|
||||
static propTypes = {
|
||||
/**
|
||||
* onClick description
|
||||
*/
|
||||
onClick: PropTypes.func,
|
||||
};
|
||||
|
||||
static defaultProps = {
|
||||
onClick: null,
|
||||
};
|
||||
|
||||
render() {
|
||||
const { onClick, children } = this.props;
|
||||
return <button onClick={onClick}>{children}</button>;
|
||||
}
|
||||
}
|
@ -1,39 +0,0 @@
|
||||
/* eslint-disable react/button-has-type */
|
||||
import React, { FC, SyntheticEvent } from 'react';
|
||||
|
||||
interface ButtonProps {
|
||||
/**
|
||||
* onClick description
|
||||
*/
|
||||
onClick?: (e: SyntheticEvent) => void;
|
||||
}
|
||||
|
||||
/**
|
||||
* Button functional component (React.FC)
|
||||
*/
|
||||
export const ButtonReactFC: React.FC<ButtonProps> = ({ onClick, children }) => (
|
||||
<button onClick={onClick}>{children}</button>
|
||||
);
|
||||
ButtonReactFC.defaultProps = {
|
||||
onClick: null,
|
||||
};
|
||||
|
||||
/**
|
||||
* Button functional component (FC)
|
||||
*/
|
||||
export const ButtonFC: FC<ButtonProps> = ({ onClick, children }) => (
|
||||
<button onClick={onClick}>{children}</button>
|
||||
);
|
||||
ButtonFC.defaultProps = {
|
||||
onClick: null,
|
||||
};
|
||||
|
||||
/**
|
||||
* Button functional component (FunctionComponent)
|
||||
*/
|
||||
export const ButtonFunctionComponent: FC<ButtonProps> = ({ onClick, children }) => (
|
||||
<button onClick={onClick}>{children}</button>
|
||||
);
|
||||
ButtonFunctionComponent.defaultProps = {
|
||||
onClick: null,
|
||||
};
|
@ -1,29 +0,0 @@
|
||||
import { Meta, ArgsTable, Description } from '@storybook/addon-docs';
|
||||
import * as DocgenJS from './DocgenJS';
|
||||
import * as DocgenTS from './DocgenTS';
|
||||
|
||||
<Meta title="Docgen/Props" />
|
||||
|
||||
export const DescriptionProps = ({ of }) => (
|
||||
<>
|
||||
<h2>{of.displayName}</h2>
|
||||
<Description of={of} />
|
||||
<ArgsTable of={of} />
|
||||
</>
|
||||
);
|
||||
|
||||
# React Docgen Test Cases
|
||||
|
||||
<div>
|
||||
{Object.entries(DocgenJS).map(([key, val]) => (
|
||||
<DescriptionProps key={key} of={val} />
|
||||
))}
|
||||
</div>
|
||||
|
||||
# React Typescript Docgen Test Cases
|
||||
|
||||
<div>
|
||||
{Object.entries(DocgenTS).map(([key, val]) => (
|
||||
<DescriptionProps key={key} of={val} />
|
||||
))}
|
||||
</div>
|
@ -1,472 +0,0 @@
|
||||
/* eslint-disable react/no-unused-prop-types */
|
||||
/* eslint-disable react/require-default-props */
|
||||
/* eslint-disable react/prop-types */
|
||||
import React from 'react';
|
||||
import PropTypes from 'prop-types';
|
||||
|
||||
export const ButtonTooManyProps = ({ onClick, children }) => (
|
||||
<button type="button" onClick={onClick}>
|
||||
{children}
|
||||
</button>
|
||||
);
|
||||
ButtonTooManyProps.propTypes = {
|
||||
/**
|
||||
* onClick description
|
||||
* @param {SyntheticEvent} event - React's original SyntheticEvent.
|
||||
* @param {SyntheticEvent} event1 - React's original SyntheticEvent.
|
||||
* @param {SyntheticEvent} event2 - React's original SyntheticEvent.
|
||||
* @param {SyntheticEvent} event3 - React's original SyntheticEvent.
|
||||
* @returns {void}
|
||||
*/
|
||||
onClick: PropTypes.func,
|
||||
/**
|
||||
* onClick description
|
||||
* @param {SyntheticEvent} event - React's original SyntheticEvent.
|
||||
* @param {SyntheticEvent} event1 - React's original SyntheticEvent.
|
||||
* @param {SyntheticEvent} event2 - React's original SyntheticEvent.
|
||||
* @param {SyntheticEvent} event3 - React's original SyntheticEvent.
|
||||
* @returns {void}
|
||||
*/
|
||||
onClick1: PropTypes.func,
|
||||
/**
|
||||
* onClick description
|
||||
* @param {SyntheticEvent} event - React's original SyntheticEvent.
|
||||
* @param {SyntheticEvent} event1 - React's original SyntheticEvent.
|
||||
* @param {SyntheticEvent} event2 - React's original SyntheticEvent.
|
||||
* @param {SyntheticEvent} event3 - React's original SyntheticEvent.
|
||||
* @returns {void}
|
||||
*/
|
||||
onClick2: PropTypes.func,
|
||||
/**
|
||||
* onClick description
|
||||
* @param {SyntheticEvent} event - React's original SyntheticEvent.
|
||||
* @param {SyntheticEvent} event1 - React's original SyntheticEvent.
|
||||
* @param {SyntheticEvent} event2 - React's original SyntheticEvent.
|
||||
* @param {SyntheticEvent} event3 - React's original SyntheticEvent.
|
||||
* @returns {void}
|
||||
*/
|
||||
onClick3: PropTypes.func,
|
||||
/**
|
||||
* onClick description
|
||||
* @param {SyntheticEvent} event - React's original SyntheticEvent.
|
||||
* @param {SyntheticEvent} event1 - React's original SyntheticEvent.
|
||||
* @param {SyntheticEvent} event2 - React's original SyntheticEvent.
|
||||
* @param {SyntheticEvent} event3 - React's original SyntheticEvent.
|
||||
* @returns {void}
|
||||
*/
|
||||
onClick4: PropTypes.func,
|
||||
/**
|
||||
* onClick description
|
||||
* @param {SyntheticEvent} event - React's original SyntheticEvent.
|
||||
* @param {SyntheticEvent} event1 - React's original SyntheticEvent.
|
||||
* @param {SyntheticEvent} event2 - React's original SyntheticEvent.
|
||||
* @param {SyntheticEvent} event3 - React's original SyntheticEvent.
|
||||
* @returns {void}
|
||||
*/
|
||||
onClick5: PropTypes.func,
|
||||
/**
|
||||
* onClick description
|
||||
* @param {SyntheticEvent} event - React's original SyntheticEvent.
|
||||
* @param {SyntheticEvent} event1 - React's original SyntheticEvent.
|
||||
* @param {SyntheticEvent} event2 - React's original SyntheticEvent.
|
||||
* @param {SyntheticEvent} event3 - React's original SyntheticEvent.
|
||||
* @returns {void}
|
||||
*/
|
||||
onClick6: PropTypes.func,
|
||||
/**
|
||||
* onClick description
|
||||
* @param {SyntheticEvent} event - React's original SyntheticEvent.
|
||||
* @param {SyntheticEvent} event1 - React's original SyntheticEvent.
|
||||
* @param {SyntheticEvent} event2 - React's original SyntheticEvent.
|
||||
* @param {SyntheticEvent} event3 - React's original SyntheticEvent.
|
||||
* @returns {void}
|
||||
*/
|
||||
onClick7: PropTypes.func,
|
||||
/**
|
||||
* onClick description
|
||||
* @param {SyntheticEvent} event - React's original SyntheticEvent.
|
||||
* @param {SyntheticEvent} event1 - React's original SyntheticEvent.
|
||||
* @param {SyntheticEvent} event2 - React's original SyntheticEvent.
|
||||
* @param {SyntheticEvent} event3 - React's original SyntheticEvent.
|
||||
* @returns {void}
|
||||
*/
|
||||
onClick8: PropTypes.func,
|
||||
/**
|
||||
* onClick description
|
||||
* @param {SyntheticEvent} event - React's original SyntheticEvent.
|
||||
* @param {SyntheticEvent} event1 - React's original SyntheticEvent.
|
||||
* @param {SyntheticEvent} event2 - React's original SyntheticEvent.
|
||||
* @param {SyntheticEvent} event3 - React's original SyntheticEvent.
|
||||
* @returns {void}
|
||||
*/
|
||||
onClick9: PropTypes.func,
|
||||
/**
|
||||
* onClick description
|
||||
* @param {SyntheticEvent} event - React's original SyntheticEvent.
|
||||
* @param {SyntheticEvent} event1 - React's original SyntheticEvent.
|
||||
* @param {SyntheticEvent} event2 - React's original SyntheticEvent.
|
||||
* @param {SyntheticEvent} event3 - React's original SyntheticEvent.
|
||||
* @returns {void}
|
||||
*/
|
||||
onClick10: PropTypes.func,
|
||||
/**
|
||||
* onClick description
|
||||
* @param {SyntheticEvent} event - React's original SyntheticEvent.
|
||||
* @param {SyntheticEvent} event1 - React's original SyntheticEvent.
|
||||
* @param {SyntheticEvent} event2 - React's original SyntheticEvent.
|
||||
* @param {SyntheticEvent} event3 - React's original SyntheticEvent.
|
||||
* @returns {void}
|
||||
*/
|
||||
onClick11: PropTypes.func,
|
||||
/**
|
||||
* onClick description
|
||||
* @param {SyntheticEvent} event - React's original SyntheticEvent.
|
||||
* @param {SyntheticEvent} event1 - React's original SyntheticEvent.
|
||||
* @param {SyntheticEvent} event2 - React's original SyntheticEvent.
|
||||
* @param {SyntheticEvent} event3 - React's original SyntheticEvent.
|
||||
* @returns {void}
|
||||
*/
|
||||
onClick12: PropTypes.func,
|
||||
/**
|
||||
* onClick description
|
||||
* @param {SyntheticEvent} event - React's original SyntheticEvent.
|
||||
* @param {SyntheticEvent} event1 - React's original SyntheticEvent.
|
||||
* @param {SyntheticEvent} event2 - React's original SyntheticEvent.
|
||||
* @param {SyntheticEvent} event3 - React's original SyntheticEvent.
|
||||
* @returns {void}
|
||||
*/
|
||||
onClick13: PropTypes.func,
|
||||
/**
|
||||
* onClick description
|
||||
* @param {SyntheticEvent} event - React's original SyntheticEvent.
|
||||
* @param {SyntheticEvent} event1 - React's original SyntheticEvent.
|
||||
* @param {SyntheticEvent} event2 - React's original SyntheticEvent.
|
||||
* @param {SyntheticEvent} event3 - React's original SyntheticEvent.
|
||||
* @returns {void}
|
||||
*/
|
||||
onClick14: PropTypes.func,
|
||||
/**
|
||||
* onClick description
|
||||
* @param {SyntheticEvent} event - React's original SyntheticEvent.
|
||||
* @param {SyntheticEvent} event1 - React's original SyntheticEvent.
|
||||
* @param {SyntheticEvent} event2 - React's original SyntheticEvent.
|
||||
* @param {SyntheticEvent} event3 - React's original SyntheticEvent.
|
||||
* @returns {void}
|
||||
*/
|
||||
onClick15: PropTypes.func,
|
||||
/**
|
||||
* onClick description
|
||||
* @param {SyntheticEvent} event - React's original SyntheticEvent.
|
||||
* @param {SyntheticEvent} event1 - React's original SyntheticEvent.
|
||||
* @param {SyntheticEvent} event2 - React's original SyntheticEvent.
|
||||
* @param {SyntheticEvent} event3 - React's original SyntheticEvent.
|
||||
* @returns {void}
|
||||
*/
|
||||
onClick16: PropTypes.func,
|
||||
/**
|
||||
* onClick description
|
||||
* @param {SyntheticEvent} event - React's original SyntheticEvent.
|
||||
* @param {SyntheticEvent} event1 - React's original SyntheticEvent.
|
||||
* @param {SyntheticEvent} event2 - React's original SyntheticEvent.
|
||||
* @param {SyntheticEvent} event3 - React's original SyntheticEvent.
|
||||
* @returns {void}
|
||||
*/
|
||||
onClick17: PropTypes.func,
|
||||
/**
|
||||
* onClick description
|
||||
* @param {SyntheticEvent} event - React's original SyntheticEvent.
|
||||
* @param {SyntheticEvent} event1 - React's original SyntheticEvent.
|
||||
* @param {SyntheticEvent} event2 - React's original SyntheticEvent.
|
||||
* @param {SyntheticEvent} event3 - React's original SyntheticEvent.
|
||||
* @returns {void}
|
||||
*/
|
||||
onClick18: PropTypes.func,
|
||||
/**
|
||||
* onClick description
|
||||
* @param {SyntheticEvent} event - React's original SyntheticEvent.
|
||||
* @param {SyntheticEvent} event1 - React's original SyntheticEvent.
|
||||
* @param {SyntheticEvent} event2 - React's original SyntheticEvent.
|
||||
* @param {SyntheticEvent} event3 - React's original SyntheticEvent.
|
||||
* @returns {void}
|
||||
*/
|
||||
onClick19: PropTypes.func,
|
||||
/**
|
||||
* onClick description
|
||||
* @param {SyntheticEvent} event - React's original SyntheticEvent.
|
||||
* @param {SyntheticEvent} event1 - React's original SyntheticEvent.
|
||||
* @param {SyntheticEvent} event2 - React's original SyntheticEvent.
|
||||
* @param {SyntheticEvent} event3 - React's original SyntheticEvent.
|
||||
* @returns {void}
|
||||
*/
|
||||
onClick20: PropTypes.func,
|
||||
/**
|
||||
* onClick description
|
||||
* @param {SyntheticEvent} event - React's original SyntheticEvent.
|
||||
* @param {SyntheticEvent} event1 - React's original SyntheticEvent.
|
||||
* @param {SyntheticEvent} event2 - React's original SyntheticEvent.
|
||||
* @param {SyntheticEvent} event3 - React's original SyntheticEvent.
|
||||
* @returns {void}
|
||||
*/
|
||||
onClick21: PropTypes.func,
|
||||
/**
|
||||
* onClick description
|
||||
* @param {SyntheticEvent} event - React's original SyntheticEvent.
|
||||
* @param {SyntheticEvent} event1 - React's original SyntheticEvent.
|
||||
* @param {SyntheticEvent} event2 - React's original SyntheticEvent.
|
||||
* @param {SyntheticEvent} event3 - React's original SyntheticEvent.
|
||||
* @returns {void}
|
||||
*/
|
||||
onClick22: PropTypes.func,
|
||||
/**
|
||||
* onClick description
|
||||
* @param {SyntheticEvent} event - React's original SyntheticEvent.
|
||||
* @param {SyntheticEvent} event1 - React's original SyntheticEvent.
|
||||
* @param {SyntheticEvent} event2 - React's original SyntheticEvent.
|
||||
* @param {SyntheticEvent} event3 - React's original SyntheticEvent.
|
||||
* @returns {void}
|
||||
*/
|
||||
onClick23: PropTypes.func,
|
||||
/**
|
||||
* onClick description
|
||||
* @param {SyntheticEvent} event - React's original SyntheticEvent.
|
||||
* @param {SyntheticEvent} event1 - React's original SyntheticEvent.
|
||||
* @param {SyntheticEvent} event2 - React's original SyntheticEvent.
|
||||
* @param {SyntheticEvent} event3 - React's original SyntheticEvent.
|
||||
* @returns {void}
|
||||
*/
|
||||
onClick24: PropTypes.func,
|
||||
/**
|
||||
* onClick description
|
||||
* @param {SyntheticEvent} event - React's original SyntheticEvent.
|
||||
* @param {SyntheticEvent} event1 - React's original SyntheticEvent.
|
||||
* @param {SyntheticEvent} event2 - React's original SyntheticEvent.
|
||||
* @param {SyntheticEvent} event3 - React's original SyntheticEvent.
|
||||
* @returns {void}
|
||||
*/
|
||||
onClick25: PropTypes.func,
|
||||
/**
|
||||
* onClick description
|
||||
* @param {SyntheticEvent} event - React's original SyntheticEvent.
|
||||
* @param {SyntheticEvent} event1 - React's original SyntheticEvent.
|
||||
* @param {SyntheticEvent} event2 - React's original SyntheticEvent.
|
||||
* @param {SyntheticEvent} event3 - React's original SyntheticEvent.
|
||||
* @returns {void}
|
||||
*/
|
||||
onClick26: PropTypes.func,
|
||||
/**
|
||||
* onClick description
|
||||
* @param {SyntheticEvent} event - React's original SyntheticEvent.
|
||||
* @param {SyntheticEvent} event1 - React's original SyntheticEvent.
|
||||
* @param {SyntheticEvent} event2 - React's original SyntheticEvent.
|
||||
* @param {SyntheticEvent} event3 - React's original SyntheticEvent.
|
||||
* @returns {void}
|
||||
*/
|
||||
onClick27: PropTypes.func,
|
||||
/**
|
||||
* onClick description
|
||||
* @param {SyntheticEvent} event - React's original SyntheticEvent.
|
||||
* @param {SyntheticEvent} event1 - React's original SyntheticEvent.
|
||||
* @param {SyntheticEvent} event2 - React's original SyntheticEvent.
|
||||
* @param {SyntheticEvent} event3 - React's original SyntheticEvent.
|
||||
* @returns {void}
|
||||
*/
|
||||
onClick28: PropTypes.func,
|
||||
/**
|
||||
* onClick description
|
||||
* @param {SyntheticEvent} event - React's original SyntheticEvent.
|
||||
* @param {SyntheticEvent} event1 - React's original SyntheticEvent.
|
||||
* @param {SyntheticEvent} event2 - React's original SyntheticEvent.
|
||||
* @param {SyntheticEvent} event3 - React's original SyntheticEvent.
|
||||
* @returns {void}
|
||||
*/
|
||||
onClick29: PropTypes.func,
|
||||
/**
|
||||
* onClick description
|
||||
* @param {SyntheticEvent} event - React's original SyntheticEvent.
|
||||
* @param {SyntheticEvent} event1 - React's original SyntheticEvent.
|
||||
* @param {SyntheticEvent} event2 - React's original SyntheticEvent.
|
||||
* @param {SyntheticEvent} event3 - React's original SyntheticEvent.
|
||||
* @returns {void}
|
||||
*/
|
||||
onClick30: PropTypes.func,
|
||||
/**
|
||||
* onClick description
|
||||
* @param {SyntheticEvent} event - React's original SyntheticEvent.
|
||||
* @param {SyntheticEvent} event1 - React's original SyntheticEvent.
|
||||
* @param {SyntheticEvent} event2 - React's original SyntheticEvent.
|
||||
* @param {SyntheticEvent} event3 - React's original SyntheticEvent.
|
||||
* @returns {void}
|
||||
*/
|
||||
onClick31: PropTypes.func,
|
||||
/**
|
||||
* onClick description
|
||||
* @param {SyntheticEvent} event - React's original SyntheticEvent.
|
||||
* @param {SyntheticEvent} event1 - React's original SyntheticEvent.
|
||||
* @param {SyntheticEvent} event2 - React's original SyntheticEvent.
|
||||
* @param {SyntheticEvent} event3 - React's original SyntheticEvent.
|
||||
* @returns {void}
|
||||
*/
|
||||
onClick32: PropTypes.func,
|
||||
/**
|
||||
* onClick description
|
||||
* @param {SyntheticEvent} event - React's original SyntheticEvent.
|
||||
* @param {SyntheticEvent} event1 - React's original SyntheticEvent.
|
||||
* @param {SyntheticEvent} event2 - React's original SyntheticEvent.
|
||||
* @param {SyntheticEvent} event3 - React's original SyntheticEvent.
|
||||
* @returns {void}
|
||||
*/
|
||||
onClick33: PropTypes.func,
|
||||
/**
|
||||
* onClick description
|
||||
* @param {SyntheticEvent} event - React's original SyntheticEvent.
|
||||
* @param {SyntheticEvent} event1 - React's original SyntheticEvent.
|
||||
* @param {SyntheticEvent} event2 - React's original SyntheticEvent.
|
||||
* @param {SyntheticEvent} event3 - React's original SyntheticEvent.
|
||||
* @returns {void}
|
||||
*/
|
||||
onClick34: PropTypes.func,
|
||||
/**
|
||||
* onClick description
|
||||
* @param {SyntheticEvent} event - React's original SyntheticEvent.
|
||||
* @param {SyntheticEvent} event1 - React's original SyntheticEvent.
|
||||
* @param {SyntheticEvent} event2 - React's original SyntheticEvent.
|
||||
* @param {SyntheticEvent} event3 - React's original SyntheticEvent.
|
||||
* @returns {void}
|
||||
*/
|
||||
onClick35: PropTypes.func,
|
||||
/**
|
||||
* onClick description
|
||||
* @param {SyntheticEvent} event - React's original SyntheticEvent.
|
||||
* @param {SyntheticEvent} event1 - React's original SyntheticEvent.
|
||||
* @param {SyntheticEvent} event2 - React's original SyntheticEvent.
|
||||
* @param {SyntheticEvent} event3 - React's original SyntheticEvent.
|
||||
* @returns {void}
|
||||
*/
|
||||
onClick36: PropTypes.func,
|
||||
/**
|
||||
* onClick description
|
||||
* @param {SyntheticEvent} event - React's original SyntheticEvent.
|
||||
* @param {SyntheticEvent} event1 - React's original SyntheticEvent.
|
||||
* @param {SyntheticEvent} event2 - React's original SyntheticEvent.
|
||||
* @param {SyntheticEvent} event3 - React's original SyntheticEvent.
|
||||
* @returns {void}
|
||||
*/
|
||||
onClick37: PropTypes.func,
|
||||
/**
|
||||
* onClick description
|
||||
* @param {SyntheticEvent} event - React's original SyntheticEvent.
|
||||
* @param {SyntheticEvent} event1 - React's original SyntheticEvent.
|
||||
* @param {SyntheticEvent} event2 - React's original SyntheticEvent.
|
||||
* @param {SyntheticEvent} event3 - React's original SyntheticEvent.
|
||||
* @returns {void}
|
||||
*/
|
||||
onClick38: PropTypes.func,
|
||||
/**
|
||||
* onClick description
|
||||
* @param {SyntheticEvent} event - React's original SyntheticEvent.
|
||||
* @param {SyntheticEvent} event1 - React's original SyntheticEvent.
|
||||
* @param {SyntheticEvent} event2 - React's original SyntheticEvent.
|
||||
* @param {SyntheticEvent} event3 - React's original SyntheticEvent.
|
||||
* @returns {void}
|
||||
*/
|
||||
onClick39: PropTypes.func,
|
||||
/**
|
||||
* onClick description
|
||||
* @param {SyntheticEvent} event - React's original SyntheticEvent.
|
||||
* @param {SyntheticEvent} event1 - React's original SyntheticEvent.
|
||||
* @param {SyntheticEvent} event2 - React's original SyntheticEvent.
|
||||
* @param {SyntheticEvent} event3 - React's original SyntheticEvent.
|
||||
* @returns {void}
|
||||
*/
|
||||
onClick40: PropTypes.func,
|
||||
/**
|
||||
* onClick description
|
||||
* @param {SyntheticEvent} event - React's original SyntheticEvent.
|
||||
* @param {SyntheticEvent} event1 - React's original SyntheticEvent.
|
||||
* @param {SyntheticEvent} event2 - React's original SyntheticEvent.
|
||||
* @param {SyntheticEvent} event3 - React's original SyntheticEvent.
|
||||
* @returns {void}
|
||||
*/
|
||||
onClick41: PropTypes.func,
|
||||
/**
|
||||
* onClick description
|
||||
* @param {SyntheticEvent} event - React's original SyntheticEvent.
|
||||
* @param {SyntheticEvent} event1 - React's original SyntheticEvent.
|
||||
* @param {SyntheticEvent} event2 - React's original SyntheticEvent.
|
||||
* @param {SyntheticEvent} event3 - React's original SyntheticEvent.
|
||||
* @returns {void}
|
||||
*/
|
||||
onClick42: PropTypes.func,
|
||||
/**
|
||||
* onClick description
|
||||
* @param {SyntheticEvent} event - React's original SyntheticEvent.
|
||||
* @param {SyntheticEvent} event1 - React's original SyntheticEvent.
|
||||
* @param {SyntheticEvent} event2 - React's original SyntheticEvent.
|
||||
* @param {SyntheticEvent} event3 - React's original SyntheticEvent.
|
||||
* @returns {void}
|
||||
*/
|
||||
onClick43: PropTypes.func,
|
||||
/**
|
||||
* onClick description
|
||||
* @param {SyntheticEvent} event - React's original SyntheticEvent.
|
||||
* @param {SyntheticEvent} event1 - React's original SyntheticEvent.
|
||||
* @param {SyntheticEvent} event2 - React's original SyntheticEvent.
|
||||
* @param {SyntheticEvent} event3 - React's original SyntheticEvent.
|
||||
* @returns {void}
|
||||
*/
|
||||
onClick44: PropTypes.func,
|
||||
/**
|
||||
* onClick description
|
||||
* @param {SyntheticEvent} event - React's original SyntheticEvent.
|
||||
* @param {SyntheticEvent} event1 - React's original SyntheticEvent.
|
||||
* @param {SyntheticEvent} event2 - React's original SyntheticEvent.
|
||||
* @param {SyntheticEvent} event3 - React's original SyntheticEvent.
|
||||
* @returns {void}
|
||||
*/
|
||||
onClick45: PropTypes.func,
|
||||
/**
|
||||
* onClick description
|
||||
* @param {SyntheticEvent} event - React's original SyntheticEvent.
|
||||
* @param {SyntheticEvent} event1 - React's original SyntheticEvent.
|
||||
* @param {SyntheticEvent} event2 - React's original SyntheticEvent.
|
||||
* @param {SyntheticEvent} event3 - React's original SyntheticEvent.
|
||||
* @returns {void}
|
||||
*/
|
||||
onClick46: PropTypes.func,
|
||||
/**
|
||||
* onClick description
|
||||
* @param {SyntheticEvent} event - React's original SyntheticEvent.
|
||||
* @param {SyntheticEvent} event1 - React's original SyntheticEvent.
|
||||
* @param {SyntheticEvent} event2 - React's original SyntheticEvent.
|
||||
* @param {SyntheticEvent} event3 - React's original SyntheticEvent.
|
||||
* @returns {void}
|
||||
*/
|
||||
onClick47: PropTypes.func,
|
||||
/**
|
||||
* onClick description
|
||||
* @param {SyntheticEvent} event - React's original SyntheticEvent.
|
||||
* @param {SyntheticEvent} event1 - React's original SyntheticEvent.
|
||||
* @param {SyntheticEvent} event2 - React's original SyntheticEvent.
|
||||
* @param {SyntheticEvent} event3 - React's original SyntheticEvent.
|
||||
* @returns {void}
|
||||
*/
|
||||
onClick48: PropTypes.func,
|
||||
/**
|
||||
* onClick description
|
||||
* @param {SyntheticEvent} event - React's original SyntheticEvent.
|
||||
* @param {SyntheticEvent} event1 - React's original SyntheticEvent.
|
||||
* @param {SyntheticEvent} event2 - React's original SyntheticEvent.
|
||||
* @param {SyntheticEvent} event3 - React's original SyntheticEvent.
|
||||
* @returns {void}
|
||||
*/
|
||||
onClick49: PropTypes.func,
|
||||
/**
|
||||
* onClick description
|
||||
* @param {SyntheticEvent} event - React's original SyntheticEvent.
|
||||
* @param {SyntheticEvent} event1 - React's original SyntheticEvent.
|
||||
* @param {SyntheticEvent} event2 - React's original SyntheticEvent.
|
||||
* @param {SyntheticEvent} event3 - React's original SyntheticEvent.
|
||||
* @returns {void}
|
||||
*/
|
||||
onClick50: PropTypes.func,
|
||||
};
|
@ -1,10 +0,0 @@
|
||||
import { Meta, ArgsTable } from '@storybook/addon-docs';
|
||||
import { ButtonTooManyProps } from './jsdoc-perfo';
|
||||
|
||||
<Meta title="Docgen/jsdoc-perfo" />
|
||||
|
||||
## Render 150 props with JSDoc tags
|
||||
|
||||
<ArgsTable of={ButtonTooManyProps} />
|
||||
<ArgsTable of={ButtonTooManyProps} />
|
||||
<ArgsTable of={ButtonTooManyProps} />
|
@ -1,9 +0,0 @@
|
||||
import { Meta, ArgsTable } from '@storybook/addon-docs';
|
||||
import { JsDocProps, FailingJsDocProps } from './jsdoc';
|
||||
import { TypeScriptProps } from './jsdoc-ts';
|
||||
|
||||
<Meta title="Docgen/jsdoc" />
|
||||
|
||||
<ArgsTable of={JsDocProps} />
|
||||
<ArgsTable of={TypeScriptProps} />
|
||||
<ArgsTable of={FailingJsDocProps} />
|
@ -1,15 +0,0 @@
|
||||
import { Meta, ArgsTable } from '@storybook/addon-docs';
|
||||
import { PropTypesProps } from './prop-types';
|
||||
import { TypeScriptProps, TypeScriptHtmlComponent } from './ts-types';
|
||||
|
||||
<Meta title="Docgen/types" />
|
||||
|
||||
## Prop Types
|
||||
|
||||
<ArgsTable of={PropTypesProps} />
|
||||
|
||||
## TypeScript
|
||||
|
||||
<ArgsTable of={TypeScriptProps} />
|
||||
|
||||
<ArgsTable of={TypeScriptHtmlComponent} />
|
@ -1,10 +0,0 @@
|
||||
import { PropsSort } from './PropsSort';
|
||||
import { ArgsTable, Meta } from '@storybook/addon-docs';
|
||||
import { SortType } from '@storybook/components';
|
||||
|
||||
<Meta title="PropsSort" />
|
||||
|
||||
<ArgsTable of={PropsSort} />
|
||||
<ArgsTable of={PropsSort} exclude={['foo']} />
|
||||
<ArgsTable of={PropsSort} sort="alpha" />
|
||||
<ArgsTable of={PropsSort} sort="requiredFirst" />
|
@ -1,18 +0,0 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"baseUrl": ".",
|
||||
"incremental": false,
|
||||
"noImplicitAny": true,
|
||||
"experimentalDecorators": true,
|
||||
"emitDecoratorMetadata": true,
|
||||
"jsx": "react",
|
||||
"target": "ES2020",
|
||||
"module": "CommonJS",
|
||||
"skipLibCheck": true,
|
||||
"allowSyntheticDefaultImports": true,
|
||||
"esModuleInterop": true,
|
||||
"types": ["jest", "node"],
|
||||
"lib": ["es2017", "dom"]
|
||||
},
|
||||
"include": ["src"]
|
||||
}
|
@ -1,3 +1,4 @@
|
||||
import { within, userEvent } from '@storybook/testing-library';
|
||||
import MyButton from '../Button.vue';
|
||||
|
||||
export default {
|
||||
@ -11,7 +12,8 @@ export default {
|
||||
const Template = (args, { argTypes }) => ({
|
||||
props: Object.keys(argTypes),
|
||||
components: { MyButton },
|
||||
template: '<my-button :color="color" :rounded="rounded">{{label}}</my-button>',
|
||||
template: `
|
||||
<my-button :color="color" :rounded="rounded">{{label}}</my-button>`,
|
||||
});
|
||||
|
||||
export const Rounded = Template.bind({});
|
||||
@ -20,6 +22,18 @@ Rounded.args = {
|
||||
color: '#f00',
|
||||
label: 'A Button with rounded edges',
|
||||
};
|
||||
// Rounded.decorators = [
|
||||
// (storyFn, context) => {
|
||||
// return storyFn({ ...context, args: { ...context.args, label: 'Overridden args' } });
|
||||
// },
|
||||
// () => ({
|
||||
// template: '<div style="background: #eee;"><story/></div>',
|
||||
// }),
|
||||
// ];
|
||||
Rounded.play = async ({ canvasElement }) => {
|
||||
const canvas = within(canvasElement);
|
||||
await userEvent.click(canvas.getByRole('button'));
|
||||
};
|
||||
|
||||
export const Square = Template.bind({});
|
||||
Square.args = {
|
||||
|
@ -786,7 +786,6 @@ const newWebpackConfiguration = (
|
||||
devtool: 'cheap-module-source-map',
|
||||
entry: [
|
||||
'/Users/joe/storybook/lib/core-server/dist/esm/globals/polyfills.js',
|
||||
'/Users/joe/storybook/lib/core-server/dist/esm/globals/globals.js',
|
||||
'/Users/joe/storybook/examples/angular-cli/.storybook/storybook-init-framework-entry.js',
|
||||
'/Users/joe/storybook/addons/docs/dist/esm/frameworks/common/config.js-generated-other-entry.js',
|
||||
'/Users/joe/storybook/addons/docs/dist/esm/frameworks/angular/config.js-generated-other-entry.js',
|
||||
|
@ -64,12 +64,12 @@
|
||||
"ast-types": "^0.14.2",
|
||||
"magic-string": "^0.26.1",
|
||||
"react-docgen": "^6.0.0-alpha.3",
|
||||
"vite": "3"
|
||||
"vite": "^3.1.3"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@types/node": "^14.14.20 || ^16.0.0",
|
||||
"typescript": "~4.6.3",
|
||||
"vite": "^3.1.0"
|
||||
"vite": "^3.1.3"
|
||||
},
|
||||
"peerDependencies": {
|
||||
"react": "^16.8.0 || ^17.0.0 || ^18.0.0",
|
||||
|
@ -9,7 +9,7 @@ export const core: StorybookConfig['core'] = {
|
||||
builder: '@storybook/builder-vite',
|
||||
};
|
||||
|
||||
export function readPackageJson(): Record<string, any> | false {
|
||||
function readPackageJson(): Record<string, any> | false {
|
||||
const packageJsonPath = path.resolve('package.json');
|
||||
if (!fs.existsSync(packageJsonPath)) {
|
||||
return false;
|
||||
|
@ -64,12 +64,12 @@
|
||||
"magic-string": "^0.26.1",
|
||||
"svelte": "^3.0.0",
|
||||
"sveltedoc-parser": "^4.2.1",
|
||||
"vite": "3"
|
||||
"vite": "^3.1.3"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@types/node": "^14.14.20 || ^16.0.0",
|
||||
"typescript": "~4.6.3",
|
||||
"vite": "^3.1.0"
|
||||
"vite": "^3.1.3"
|
||||
},
|
||||
"engines": {
|
||||
"node": "^14.18 || >=16"
|
||||
|
@ -1,5 +1,3 @@
|
||||
import path from 'path';
|
||||
import fs from 'fs';
|
||||
import type { StorybookConfig } from '@storybook/builder-vite';
|
||||
import { svelteDocgen } from './plugins/svelte-docgen';
|
||||
|
||||
@ -9,16 +7,6 @@ export const core: StorybookConfig['core'] = {
|
||||
builder: '@storybook/builder-vite',
|
||||
};
|
||||
|
||||
export function readPackageJson(): Record<string, any> | false {
|
||||
const packageJsonPath = path.resolve('package.json');
|
||||
if (!fs.existsSync(packageJsonPath)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
const jsonContent = fs.readFileSync(packageJsonPath, 'utf8');
|
||||
return JSON.parse(jsonContent);
|
||||
}
|
||||
|
||||
export const viteFinal: StorybookConfig['viteFinal'] = async (config, { presets }) => {
|
||||
const { plugins = [] } = config;
|
||||
|
||||
|
48
code/frameworks/vue-vite/README.md
Normal file
48
code/frameworks/vue-vite/README.md
Normal file
@ -0,0 +1,48 @@
|
||||
# Storybook for Vue and Vite
|
||||
|
||||
Storybook for Vue is a UI development environment for your Vue components.
|
||||
With it, you can visualize different states of your UI components and develop them interactively.
|
||||
|
||||

|
||||
|
||||
Storybook runs outside of your app.
|
||||
So you can develop UI components in isolation without worrying about app specific dependencies and requirements.
|
||||
|
||||
## Getting Started
|
||||
|
||||
```sh
|
||||
cd my-vue-app
|
||||
npx storybook init
|
||||
```
|
||||
|
||||
For more information visit: [storybook.js.org](https://storybook.js.org)
|
||||
|
||||
## Starter Storybook-for-Vue Boilerplate project with [Vuetify](https://github.com/vuetifyjs/vuetify) Material Component Framework
|
||||
|
||||
<https://github.com/white-rabbit-japan/vue-vuetify-storybook>
|
||||
|
||||
---
|
||||
|
||||
Storybook also comes with a lot of [addons](https://storybook.js.org/addons) and a great API to customize as you wish.
|
||||
You can also build a [static version](https://storybook.js.org/docs/vue/sharing/publish-storybook) of your Storybook and deploy it anywhere you want.
|
||||
|
||||
## Vue Notes
|
||||
|
||||
- When using global custom components or extensions (e.g., `Vue.use`). You will need to declare those in the `./storybook/preview.js`.
|
||||
|
||||
## Known Limitations
|
||||
|
||||
In Storybook story and decorator components, you can not access the Vue instance
|
||||
in factory functions for default prop values:
|
||||
|
||||
```js
|
||||
{
|
||||
props: {
|
||||
foo: {
|
||||
default() {
|
||||
return this.bar; // does not work!
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
```
|
87
code/frameworks/vue-vite/package.json
Normal file
87
code/frameworks/vue-vite/package.json
Normal file
@ -0,0 +1,87 @@
|
||||
{
|
||||
"name": "@storybook/vue-vite",
|
||||
"version": "7.0.0-alpha.34",
|
||||
"description": "Storybook for Vue2 and Vite: Develop Vue2 Components in isolation with Hot Reloading.",
|
||||
"keywords": [
|
||||
"storybook"
|
||||
],
|
||||
"homepage": "https://github.com/storybookjs/storybook/tree/main/frameworks/vue-vite",
|
||||
"bugs": {
|
||||
"url": "https://github.com/storybookjs/storybook/issues"
|
||||
},
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/storybookjs/storybook.git",
|
||||
"directory": "frameworks/vue-vite"
|
||||
},
|
||||
"funding": {
|
||||
"type": "opencollective",
|
||||
"url": "https://opencollective.com/storybook"
|
||||
},
|
||||
"license": "MIT",
|
||||
"exports": {
|
||||
".": {
|
||||
"require": "./dist/index.js",
|
||||
"import": "./dist/index.mjs",
|
||||
"types": "./dist/index.d.ts"
|
||||
},
|
||||
"./preset": {
|
||||
"require": "./dist/preset.js",
|
||||
"import": "./dist/preset.mjs",
|
||||
"types": "./dist/preset.d.ts"
|
||||
},
|
||||
"./package.json": {
|
||||
"require": "./package.json",
|
||||
"import": "./package.json",
|
||||
"types": "./package.json"
|
||||
}
|
||||
},
|
||||
"main": "dist/index.js",
|
||||
"module": "dist/index.mjs",
|
||||
"types": "dist/index.d.ts",
|
||||
"files": [
|
||||
"dist/**/*",
|
||||
"README.md",
|
||||
"*.js",
|
||||
"*.d.ts"
|
||||
],
|
||||
"scripts": {
|
||||
"check": "../../../scripts/node_modules/.bin/tsc --noEmit",
|
||||
"prep": "../../../scripts/prepare/bundle.ts"
|
||||
},
|
||||
"dependencies": {
|
||||
"@storybook/addons": "7.0.0-alpha.34",
|
||||
"@storybook/builder-vite": "7.0.0-alpha.34",
|
||||
"@storybook/channel-postmessage": "7.0.0-alpha.34",
|
||||
"@storybook/channel-websocket": "7.0.0-alpha.34",
|
||||
"@storybook/client-api": "7.0.0-alpha.34",
|
||||
"@storybook/core-common": "7.0.0-alpha.34",
|
||||
"@storybook/core-server": "7.0.0-alpha.34",
|
||||
"@storybook/preview-web": "7.0.0-alpha.34",
|
||||
"@storybook/vue": "7.0.0-alpha.34",
|
||||
"magic-string": "^0.26.1",
|
||||
"vite": "^3.1.3",
|
||||
"vue-docgen-api": "^4.40.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"typescript": "~4.6.3",
|
||||
"vue": "^2.7.10"
|
||||
},
|
||||
"peerDependencies": {
|
||||
"vue": "^2.7.0"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=10.13.0"
|
||||
},
|
||||
"publishConfig": {
|
||||
"access": "public"
|
||||
},
|
||||
"bundler": {
|
||||
"entries": [
|
||||
"./src/index.ts",
|
||||
"./src/preset.ts"
|
||||
],
|
||||
"platform": "node"
|
||||
},
|
||||
"gitHead": "5da5b0fabd04cc5cd5771e8242a960f05d03234a"
|
||||
}
|
1
code/frameworks/vue-vite/preset.js
Normal file
1
code/frameworks/vue-vite/preset.js
Normal file
@ -0,0 +1 @@
|
||||
module.exports = require('./dist/preset');
|
9
code/frameworks/vue-vite/src/index.ts
Normal file
9
code/frameworks/vue-vite/src/index.ts
Normal file
@ -0,0 +1,9 @@
|
||||
// exports for builder-vite
|
||||
export { createChannel as createPostMessageChannel } from '@storybook/channel-postmessage';
|
||||
export { createChannel as createWebSocketChannel } from '@storybook/channel-websocket';
|
||||
export { addons } from '@storybook/addons';
|
||||
export { composeConfigs, PreviewWeb } from '@storybook/preview-web';
|
||||
export { ClientApi } from '@storybook/client-api';
|
||||
|
||||
export * from '@storybook/vue';
|
||||
export type { StorybookConfig } from '@storybook/builder-vite';
|
27
code/frameworks/vue-vite/src/plugins/vue-docgen.ts
Normal file
27
code/frameworks/vue-vite/src/plugins/vue-docgen.ts
Normal file
@ -0,0 +1,27 @@
|
||||
import { parse } from 'vue-docgen-api';
|
||||
import type { PluginOption } from 'vite';
|
||||
import { createFilter } from 'vite';
|
||||
import MagicString from 'magic-string';
|
||||
|
||||
export function vueDocgen(): PluginOption {
|
||||
const include = /\.(vue)$/;
|
||||
const filter = createFilter(include);
|
||||
|
||||
return {
|
||||
name: 'storybook:vue2-docgen-plugin',
|
||||
|
||||
async transform(src: string, id: string) {
|
||||
if (!filter(id)) return undefined;
|
||||
|
||||
const metaData = await parse(id);
|
||||
const metaSource = JSON.stringify(metaData);
|
||||
const s = new MagicString(src);
|
||||
s.append(`;__component__.exports.__docgenInfo = ${metaSource}`);
|
||||
|
||||
return {
|
||||
code: s.toString(),
|
||||
map: s.generateMap({ hires: true, source: id }),
|
||||
};
|
||||
},
|
||||
};
|
||||
}
|
44
code/frameworks/vue-vite/src/preset.ts
Normal file
44
code/frameworks/vue-vite/src/preset.ts
Normal file
@ -0,0 +1,44 @@
|
||||
import path from 'path';
|
||||
import type { PresetProperty } from '@storybook/core-common';
|
||||
import type { StorybookConfig } from '@storybook/builder-vite';
|
||||
import { vueDocgen } from './plugins/vue-docgen';
|
||||
|
||||
export const core: PresetProperty<'core', StorybookConfig> = async (config, options) => {
|
||||
const framework = await options.presets.apply<StorybookConfig['framework']>('framework');
|
||||
|
||||
return {
|
||||
...config,
|
||||
builder: {
|
||||
name: path.dirname(
|
||||
require.resolve(path.join('@storybook/builder-vite', 'package.json'))
|
||||
) as '@storybook/builder-webpack5',
|
||||
options: typeof framework === 'string' ? {} : framework?.options.builder || {},
|
||||
},
|
||||
};
|
||||
};
|
||||
|
||||
export const addons: StorybookConfig['addons'] = ['@storybook/vue'];
|
||||
|
||||
export const typescript: PresetProperty<'typescript', StorybookConfig> = async (config) => ({
|
||||
...config,
|
||||
skipBabel: true,
|
||||
});
|
||||
|
||||
export const viteFinal: StorybookConfig['viteFinal'] = async (config, { presets }) => {
|
||||
const { plugins = [] } = config;
|
||||
|
||||
plugins.push(vueDocgen());
|
||||
|
||||
const updated = {
|
||||
...config,
|
||||
plugins,
|
||||
resolve: {
|
||||
...config.resolve,
|
||||
alias: {
|
||||
...config.resolve?.alias,
|
||||
vue: 'vue/dist/vue.esm.js',
|
||||
},
|
||||
},
|
||||
};
|
||||
return updated;
|
||||
};
|
9
code/frameworks/vue-vite/tsconfig.json
Normal file
9
code/frameworks/vue-vite/tsconfig.json
Normal file
@ -0,0 +1,9 @@
|
||||
{
|
||||
"extends": "../../tsconfig.json",
|
||||
"compilerOptions": {
|
||||
"strict": true,
|
||||
"resolveJsonModule": true
|
||||
},
|
||||
"include": ["src/**/*"],
|
||||
"exclude": ["src/**/*.test.*"]
|
||||
}
|
@ -61,13 +61,13 @@
|
||||
"@storybook/vue3": "7.0.0-alpha.34",
|
||||
"@vitejs/plugin-vue": "^3.0.3",
|
||||
"magic-string": "^0.26.1",
|
||||
"vite": "3",
|
||||
"vite": "^3.1.3",
|
||||
"vue-docgen-api": "^4.40.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@types/node": "^14.14.20 || ^16.0.0",
|
||||
"typescript": "~4.6.3",
|
||||
"vite": "^3.1.0"
|
||||
"vite": "^3.1.3"
|
||||
},
|
||||
"engines": {
|
||||
"node": "^14.18 || >=16"
|
||||
|
@ -1,2 +1 @@
|
||||
console.log('vue3-vite preset!');
|
||||
module.exports = require('./dist/preset');
|
||||
|
1
code/frameworks/web-components-vite/README.md
Normal file
1
code/frameworks/web-components-vite/README.md
Normal file
@ -0,0 +1 @@
|
||||
# Storybook for Web components
|
86
code/frameworks/web-components-vite/package.json
Normal file
86
code/frameworks/web-components-vite/package.json
Normal file
@ -0,0 +1,86 @@
|
||||
{
|
||||
"name": "@storybook/web-components-vite",
|
||||
"version": "7.0.0-alpha.34",
|
||||
"description": "Storybook for web-components and Vite: Develop Web Components in isolation with Hot Reloading.",
|
||||
"keywords": [
|
||||
"storybook"
|
||||
],
|
||||
"homepage": "https://github.com/storybookjs/storybook/tree/main/frameworks/web-components-vite",
|
||||
"bugs": {
|
||||
"url": "https://github.com/storybookjs/storybook/issues"
|
||||
},
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/storybookjs/storybook.git",
|
||||
"directory": "frameworks/web-components-vite"
|
||||
},
|
||||
"funding": {
|
||||
"type": "opencollective",
|
||||
"url": "https://opencollective.com/storybook"
|
||||
},
|
||||
"license": "MIT",
|
||||
"exports": {
|
||||
".": {
|
||||
"require": "./dist/index.js",
|
||||
"import": "./dist/index.mjs",
|
||||
"types": "./dist/index.d.ts"
|
||||
},
|
||||
"./preset": {
|
||||
"require": "./dist/preset.js",
|
||||
"import": "./dist/preset.mjs",
|
||||
"types": "./dist/preset.d.ts"
|
||||
},
|
||||
"./package.json": {
|
||||
"require": "./package.json",
|
||||
"import": "./package.json",
|
||||
"types": "./package.json"
|
||||
}
|
||||
},
|
||||
"main": "dist/index.js",
|
||||
"module": "dist/index.mjs",
|
||||
"types": "dist/index.d.ts",
|
||||
"files": [
|
||||
"dist/**/*",
|
||||
"types/**/*",
|
||||
"README.md",
|
||||
"*.js",
|
||||
"*.d.ts"
|
||||
],
|
||||
"scripts": {
|
||||
"check": "tsc --noEmit",
|
||||
"prep": "../../../scripts/prepare/bundle.ts"
|
||||
},
|
||||
"dependencies": {
|
||||
"@storybook/addons": "7.0.0-alpha.34",
|
||||
"@storybook/builder-vite": "7.0.0-alpha.34",
|
||||
"@storybook/channel-postmessage": "7.0.0-alpha.34",
|
||||
"@storybook/channel-websocket": "7.0.0-alpha.34",
|
||||
"@storybook/client-api": "7.0.0-alpha.34",
|
||||
"@storybook/core-server": "7.0.0-alpha.34",
|
||||
"@storybook/node-logger": "7.0.0-alpha.34",
|
||||
"@storybook/preview-web": "7.0.0-alpha.34",
|
||||
"@storybook/web-components": "7.0.0-alpha.34",
|
||||
"@vitejs/plugin-vue": "^3.0.3",
|
||||
"magic-string": "^0.26.1",
|
||||
"vite": "3"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@types/node": "^14.14.20 || ^16.0.0",
|
||||
"typescript": "~4.6.3",
|
||||
"vite": "^3.1.0"
|
||||
},
|
||||
"engines": {
|
||||
"node": "^14.18 || >=16"
|
||||
},
|
||||
"publishConfig": {
|
||||
"access": "public"
|
||||
},
|
||||
"bundler": {
|
||||
"entries": [
|
||||
"./src/index.ts",
|
||||
"./src/preset.ts"
|
||||
],
|
||||
"platform": "node"
|
||||
},
|
||||
"gitHead": "02c013c33186479017098d532a18ff8654b91f1f"
|
||||
}
|
1
code/frameworks/web-components-vite/preset.js
Normal file
1
code/frameworks/web-components-vite/preset.js
Normal file
@ -0,0 +1 @@
|
||||
module.exports = require('./dist/preset');
|
9
code/frameworks/web-components-vite/src/index.ts
Normal file
9
code/frameworks/web-components-vite/src/index.ts
Normal file
@ -0,0 +1,9 @@
|
||||
// exports for builder-vite
|
||||
export { createChannel as createPostMessageChannel } from '@storybook/channel-postmessage';
|
||||
export { createChannel as createWebSocketChannel } from '@storybook/channel-websocket';
|
||||
export { addons } from '@storybook/addons';
|
||||
export { composeConfigs, PreviewWeb } from '@storybook/preview-web';
|
||||
export { ClientApi } from '@storybook/client-api';
|
||||
|
||||
export * from '@storybook/web-components';
|
||||
export type { StorybookConfig } from '@storybook/builder-vite';
|
7
code/frameworks/web-components-vite/src/preset.ts
Normal file
7
code/frameworks/web-components-vite/src/preset.ts
Normal file
@ -0,0 +1,7 @@
|
||||
import type { StorybookConfig } from '@storybook/builder-vite';
|
||||
|
||||
export const addons: StorybookConfig['addons'] = ['@storybook/web-components'];
|
||||
|
||||
export const core: StorybookConfig['core'] = {
|
||||
builder: '@storybook/builder-vite',
|
||||
};
|
10
code/frameworks/web-components-vite/tsconfig.json
Normal file
10
code/frameworks/web-components-vite/tsconfig.json
Normal file
@ -0,0 +1,10 @@
|
||||
{
|
||||
"extends": "../../tsconfig.json",
|
||||
"compilerOptions": {
|
||||
"rootDir": "./src",
|
||||
"types": ["node"],
|
||||
"resolveJsonModule": true
|
||||
},
|
||||
"include": ["src/**/*"],
|
||||
"exclude": ["src/**/*.test.*", "src/**/__testfixtures__/**"]
|
||||
}
|
@ -27,7 +27,6 @@ module.exports = {
|
||||
projects: [
|
||||
'<rootDir>',
|
||||
// '<rootDir>/app/angular',
|
||||
// '<rootDir>/examples/cra-ts-kitchen-sink',
|
||||
// '<rootDir>/examples/html-kitchen-sink',
|
||||
// '<rootDir>/examples/svelte-kitchen-sink',
|
||||
// '<rootDir>/examples/vue-kitchen-sink',
|
||||
|
@ -51,9 +51,6 @@
|
||||
"@storybook/theming": "7.0.0-alpha.34",
|
||||
"global": "^4.4.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@types/webpack-env": "^1.16.0"
|
||||
},
|
||||
"peerDependencies": {
|
||||
"react": "^16.8.0 || ^17.0.0 || ^18.0.0",
|
||||
"react-dom": "^16.8.0 || ^17.0.0 || ^18.0.0"
|
||||
|
@ -27,19 +27,20 @@
|
||||
"@storybook/preview-web": "7.0.0-alpha.34",
|
||||
"@storybook/source-loader": "7.0.0-alpha.34",
|
||||
"@vitejs/plugin-react": "^2.0.0",
|
||||
"browser-assert": "^1.2.1",
|
||||
"es-module-lexer": "^0.9.3",
|
||||
"glob": "^7.2.0",
|
||||
"glob-promise": "^4.2.0",
|
||||
"magic-string": "^0.26.1",
|
||||
"slash": "^3.0.0",
|
||||
"vite": "3"
|
||||
"vite": "^3.1.3"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@storybook/mdx2-csf": "^0.0.3",
|
||||
"@types/express": "^4.17.13",
|
||||
"@types/node": "^17.0.23",
|
||||
"typescript": "~4.6.3",
|
||||
"vite": "^3.1.0"
|
||||
"vite": "^3.1.3"
|
||||
},
|
||||
"peerDependencies": {
|
||||
"@storybook/mdx2-csf": "^0.0.3"
|
||||
|
@ -1,5 +1,4 @@
|
||||
import * as path from 'path';
|
||||
import fs from 'fs';
|
||||
import { loadConfigFromFile, mergeConfig } from 'vite';
|
||||
import type {
|
||||
ConfigEnv,
|
||||
@ -20,16 +19,6 @@ import type { ExtendedOptions, EnvsRaw } from './types';
|
||||
|
||||
export type PluginConfigType = 'build' | 'development';
|
||||
|
||||
export function readPackageJson(): Record<string, any> | false {
|
||||
const packageJsonPath = path.resolve('package.json');
|
||||
if (!fs.existsSync(packageJsonPath)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
const jsonContent = fs.readFileSync(packageJsonPath, 'utf8');
|
||||
return JSON.parse(jsonContent);
|
||||
}
|
||||
|
||||
const configEnvServe: ConfigEnv = {
|
||||
mode: 'development',
|
||||
command: 'serve',
|
||||
@ -57,7 +46,12 @@ export async function commonConfig(
|
||||
cacheDir: 'node_modules/.vite-storybook',
|
||||
root: path.resolve(options.configDir, '..'),
|
||||
plugins: await pluginConfig(options),
|
||||
resolve: { preserveSymlinks: isPreservingSymlinks() },
|
||||
resolve: {
|
||||
preserveSymlinks: isPreservingSymlinks(),
|
||||
alias: {
|
||||
assert: require.resolve('browser-assert'),
|
||||
},
|
||||
},
|
||||
// If an envPrefix is specified in the vite config, add STORYBOOK_ to it,
|
||||
// otherwise, add VITE_ and STORYBOOK_ so that vite doesn't lose its default.
|
||||
envPrefix: userConfig.envPrefix ? 'STORYBOOK_' : ['VITE_', 'STORYBOOK_'],
|
||||
|
@ -98,11 +98,6 @@ export class PostmsgTransport {
|
||||
...eventOptions,
|
||||
};
|
||||
|
||||
// backwards compat: convert depth to maxDepth
|
||||
if (options && Number.isInteger(options.depth)) {
|
||||
stringifyOptions.maxDepth = options.depth;
|
||||
}
|
||||
|
||||
const frames = this.getFrames(target);
|
||||
|
||||
const query = qs.parse(location.search, { ignoreQueryPrefix: true });
|
||||
|
@ -1,4 +1,4 @@
|
||||
import MyHeader from './Header';
|
||||
import MyHeader from './Header.vue';
|
||||
|
||||
export default {
|
||||
title: 'Example/Header',
|
||||
|
@ -1,6 +1,6 @@
|
||||
import { within, userEvent } from '@storybook/testing-library';
|
||||
|
||||
import MyPage from './Page';
|
||||
import MyPage from './Page.vue';
|
||||
|
||||
export default {
|
||||
title: 'Example/Page',
|
||||
|
@ -1,209 +0,0 @@
|
||||
import {
|
||||
addStorybookAddonToFile,
|
||||
storybookAddonScope,
|
||||
getPackageName,
|
||||
getInstalledStorybookVersion,
|
||||
getPackageArg,
|
||||
} from './add';
|
||||
|
||||
describe('addStorybookAddonToFile should correctly register an Storybook addon', () => {
|
||||
test('to an empty array', () => {
|
||||
expect(addStorybookAddonToFile('addon-name', [], true)).toEqual([
|
||||
`import '${storybookAddonScope}addon-name/manager';`,
|
||||
]);
|
||||
});
|
||||
|
||||
test('to an empty file', () => {
|
||||
expect(addStorybookAddonToFile('addon-name', [''], true)).toEqual([
|
||||
`import '${storybookAddonScope}addon-name/manager';`,
|
||||
'',
|
||||
]);
|
||||
});
|
||||
|
||||
test('to an addons file with existing addons registered', () => {
|
||||
expect(
|
||||
addStorybookAddonToFile(
|
||||
'addon-name',
|
||||
[
|
||||
"import '@storybook/addon-actions/manager';",
|
||||
"import '@storybook/addon-links/manager';",
|
||||
'',
|
||||
],
|
||||
true
|
||||
)
|
||||
).toEqual([
|
||||
`import '${storybookAddonScope}addon-name/manager';`,
|
||||
"import '@storybook/addon-actions/manager';",
|
||||
"import '@storybook/addon-links/manager';",
|
||||
'',
|
||||
]);
|
||||
});
|
||||
|
||||
test('to an addons file with more than only imports', () => {
|
||||
expect(
|
||||
addStorybookAddonToFile(
|
||||
'addon-name',
|
||||
[
|
||||
"import '@storybook/addon-links/manager';",
|
||||
"import '@storybook/addon-actions/manager';",
|
||||
'',
|
||||
'//some other stuff',
|
||||
'',
|
||||
'and more stuff',
|
||||
'',
|
||||
],
|
||||
true
|
||||
)
|
||||
).toEqual([
|
||||
`import '${storybookAddonScope}addon-name/manager';`,
|
||||
"import '@storybook/addon-links/manager';",
|
||||
"import '@storybook/addon-actions/manager';",
|
||||
'',
|
||||
'//some other stuff',
|
||||
'',
|
||||
'and more stuff',
|
||||
'',
|
||||
]);
|
||||
});
|
||||
|
||||
test('to an addon file with it already being installed by not duplicating it', () => {
|
||||
expect(
|
||||
addStorybookAddonToFile(
|
||||
'addon-name',
|
||||
[
|
||||
"import '@storybook/addon-actions/manager';",
|
||||
"import '@storybook/addon-links/manager';",
|
||||
`import '${storybookAddonScope}addon-name/manager';`,
|
||||
'',
|
||||
],
|
||||
true
|
||||
)
|
||||
).toEqual([
|
||||
"import '@storybook/addon-actions/manager';",
|
||||
"import '@storybook/addon-links/manager';",
|
||||
`import '${storybookAddonScope}addon-name/manager';`,
|
||||
'',
|
||||
]);
|
||||
});
|
||||
|
||||
test('to an addons file if it is not an official addon', () => {
|
||||
expect(
|
||||
addStorybookAddonToFile(
|
||||
'addon-name',
|
||||
[
|
||||
"import '@storybook/addon-actions/manager';",
|
||||
"import '@storybook/addon-links/manager';",
|
||||
'',
|
||||
],
|
||||
false
|
||||
)
|
||||
).toEqual([
|
||||
`import 'addon-name/manager';`,
|
||||
"import '@storybook/addon-actions/manager';",
|
||||
"import '@storybook/addon-links/manager';",
|
||||
'',
|
||||
]);
|
||||
});
|
||||
});
|
||||
|
||||
describe('getPackageName should correctly return the full package name', () => {
|
||||
test('on a normal addon', () => {
|
||||
const name = 'normal-addon';
|
||||
expect(getPackageName(name, false)).toBe(name);
|
||||
});
|
||||
test('on an official addon', () => {
|
||||
const name = 'official-addon';
|
||||
expect(getPackageName(name, true)).toBe(storybookAddonScope + name);
|
||||
});
|
||||
});
|
||||
|
||||
describe('getInstalledStorybookVersion should return the correct Storybook version', () => {
|
||||
test('when single official Storybook package is installed', () => {
|
||||
expect(
|
||||
getInstalledStorybookVersion({
|
||||
devDependencies: {
|
||||
'@storybook/react': '^4.0.0-alpha.22',
|
||||
},
|
||||
})
|
||||
).toBe('^4.0.0-alpha.22');
|
||||
});
|
||||
|
||||
test('when no official Storybook package is installed', () => {
|
||||
expect(
|
||||
getInstalledStorybookVersion({
|
||||
devDependencies: {
|
||||
'random package': '^4.0.0-alpha.22',
|
||||
},
|
||||
})
|
||||
).toBeFalsy();
|
||||
});
|
||||
|
||||
test('when an unofficial package with "storybook" in its name is installed', () => {
|
||||
expect(
|
||||
getInstalledStorybookVersion({
|
||||
devDependencies: {
|
||||
'not-storybook': '^4.0.0-alpha.22',
|
||||
},
|
||||
})
|
||||
).toBeFalsy();
|
||||
});
|
||||
});
|
||||
|
||||
describe('getPackageArg returns the correct package argument to install', () => {
|
||||
const officialAddonName = 'knob';
|
||||
const randomAddonName = 'random';
|
||||
const officialAddonNameWithTag = `${officialAddonName}@alpha`;
|
||||
const randomAddonNameWithTag = `${randomAddonName}@latest`;
|
||||
|
||||
test('when it is an official Storybook addon without any Storybook package installed', () => {
|
||||
expect(
|
||||
getPackageArg(officialAddonName, true, {
|
||||
devDependencies: {},
|
||||
})
|
||||
).toBe(officialAddonName);
|
||||
});
|
||||
|
||||
test('when it is a random addon without any Storybook package installed', () => {
|
||||
expect(
|
||||
getPackageArg(randomAddonName, true, {
|
||||
devDependencies: {},
|
||||
})
|
||||
).toBe(randomAddonName);
|
||||
});
|
||||
|
||||
test('when it is a random addon with tag without any Storybook package installed', () => {
|
||||
expect(
|
||||
getPackageArg(randomAddonNameWithTag, true, {
|
||||
devDependencies: {},
|
||||
})
|
||||
).toBe(randomAddonNameWithTag);
|
||||
});
|
||||
|
||||
test('when it is an official addon with tag without any Storybook package installed', () => {
|
||||
expect(
|
||||
getPackageArg(officialAddonNameWithTag, true, {
|
||||
devDependencies: {},
|
||||
})
|
||||
).toBe(officialAddonNameWithTag);
|
||||
});
|
||||
|
||||
test('when it is an official addon with tag with a Storybook package installed', () => {
|
||||
expect(
|
||||
getPackageArg(officialAddonNameWithTag, true, {
|
||||
devDependencies: {
|
||||
'@storybook/html': '^4.0.0-alpha.21',
|
||||
},
|
||||
})
|
||||
).toBe(`${officialAddonName}@^4.0.0-alpha.21`);
|
||||
});
|
||||
|
||||
test('when it is an official addon with a Storybook package installed', () => {
|
||||
expect(
|
||||
getPackageArg(officialAddonName, true, {
|
||||
devDependencies: {
|
||||
'@storybook/html': '^4.0.0-alpha.21',
|
||||
},
|
||||
})
|
||||
).toBe(`${officialAddonName}@^4.0.0-alpha.21`);
|
||||
});
|
||||
});
|
@ -1,102 +1,14 @@
|
||||
import path from 'path';
|
||||
import fs from 'fs';
|
||||
import { sync as spawnSync } from 'cross-spawn';
|
||||
|
||||
import { getStorybookInfo } from '@storybook/core-common';
|
||||
import { readConfig, writeConfig } from '@storybook/csf-tools';
|
||||
|
||||
import { commandLog } from './helpers';
|
||||
import { JsPackageManager, JsPackageManagerFactory, PackageJson } from './js-package-manager';
|
||||
import { JsPackageManagerFactory } from './js-package-manager';
|
||||
|
||||
const logger = console;
|
||||
export const storybookAddonScope = '@storybook/addon-';
|
||||
|
||||
const isAddon = async (packageManager: JsPackageManager, name: string) => {
|
||||
try {
|
||||
await packageManager.latestVersion(name);
|
||||
return true;
|
||||
} catch (e) {
|
||||
return false;
|
||||
}
|
||||
};
|
||||
|
||||
const isStorybookAddon = async (packageManager: JsPackageManager, name: string) =>
|
||||
isAddon(packageManager, `${storybookAddonScope}${name}`);
|
||||
|
||||
export const getPackageName = (addonName: string, isOfficialAddon: boolean) =>
|
||||
isOfficialAddon ? storybookAddonScope + addonName : addonName;
|
||||
|
||||
export const getInstalledStorybookVersion = (packageJson: PackageJson) =>
|
||||
packageJson.devDependencies[
|
||||
// This only considers the first occurrence.
|
||||
Object.keys(packageJson.devDependencies).find((devDep) => /@storybook/.test(devDep))
|
||||
] || false;
|
||||
|
||||
export const getPackageArg = (
|
||||
addonName: string,
|
||||
isOfficialAddon: boolean,
|
||||
packageJson: PackageJson
|
||||
) => {
|
||||
if (isOfficialAddon) {
|
||||
const addonNameNoTag = addonName.split('@')[0];
|
||||
const installedStorybookVersion = getInstalledStorybookVersion(packageJson);
|
||||
return installedStorybookVersion
|
||||
? `${addonNameNoTag}@${getInstalledStorybookVersion(packageJson)}`
|
||||
: addonName;
|
||||
}
|
||||
return addonName;
|
||||
};
|
||||
|
||||
const installAddon = (
|
||||
packageManager: JsPackageManager,
|
||||
addonName: string,
|
||||
isOfficialAddon: boolean
|
||||
) => {
|
||||
const prepareDone = commandLog(`Preparing to install the ${addonName} Storybook addon`);
|
||||
prepareDone();
|
||||
logger.log();
|
||||
|
||||
const packageArg = getPackageArg(
|
||||
addonName,
|
||||
isOfficialAddon,
|
||||
packageManager.retrievePackageJson()
|
||||
);
|
||||
|
||||
logger.log();
|
||||
const installDone = commandLog(`Installing the ${addonName} Storybook addon`);
|
||||
|
||||
try {
|
||||
packageManager.addDependencies({}, [packageArg]);
|
||||
} catch (e) {
|
||||
installDone(
|
||||
`Something went wrong installing the addon: "${getPackageName(addonName, isOfficialAddon)}"`
|
||||
);
|
||||
logger.log();
|
||||
process.exit(1);
|
||||
}
|
||||
installDone();
|
||||
};
|
||||
|
||||
export const addStorybookAddonToFile = (
|
||||
addonName: string,
|
||||
addonsFile: string[],
|
||||
isOfficialAddon: boolean
|
||||
) => {
|
||||
const addonNameNoTag = addonName.split('@')[0];
|
||||
const alreadyRegistered = addonsFile.find((line) => line.includes(`${addonNameNoTag}/manager`));
|
||||
|
||||
if (alreadyRegistered) {
|
||||
return addonsFile;
|
||||
}
|
||||
|
||||
const latestImportIndex = addonsFile.reduce(
|
||||
(prev, curr, currIndex) =>
|
||||
curr.startsWith('import') && curr.includes('register') ? currIndex : prev,
|
||||
-1
|
||||
);
|
||||
|
||||
return [
|
||||
...addonsFile.slice(0, latestImportIndex + 1),
|
||||
`import '${getPackageName(addonNameNoTag, isOfficialAddon)}/manager';`,
|
||||
...addonsFile.slice(latestImportIndex + 1),
|
||||
];
|
||||
};
|
||||
|
||||
const LEGACY_CONFIGS = ['addons', 'config', 'presets'];
|
||||
|
||||
@ -137,23 +49,58 @@ const postinstallAddon = async (addonName: string, isOfficialAddon: boolean) =>
|
||||
}
|
||||
};
|
||||
|
||||
export async function add(
|
||||
addonName: string,
|
||||
options: { useNpm: boolean; skipPostinstall: boolean }
|
||||
) {
|
||||
const packageManager = JsPackageManagerFactory.getPackageManager(options.useNpm);
|
||||
const getVersionSpecifier = (addon: string) => {
|
||||
const groups = /^(...*)@(.*)$/.exec(addon);
|
||||
return groups ? [groups[1], groups[2]] : [addon, undefined];
|
||||
};
|
||||
|
||||
const addonCheckDone = commandLog(`Verifying that ${addonName} is an addon`);
|
||||
const isOfficialAddon = await isStorybookAddon(packageManager, addonName);
|
||||
if (!isOfficialAddon) {
|
||||
if (!(await isAddon(packageManager, addonName))) {
|
||||
addonCheckDone(`The provided package was not a Storybook addon: ${addonName}.`);
|
||||
return;
|
||||
}
|
||||
/**
|
||||
* Install the given addon package and add it to main.js
|
||||
*
|
||||
* Usage:
|
||||
* - sb add @storybook/addon-docs
|
||||
* - sb add @storybook/addon-interactions@7.0.1
|
||||
*
|
||||
* If there is no version specifier and it's a storybook addon,
|
||||
* it will try to use the version specifier matching your current
|
||||
* Storybook install version.
|
||||
*/
|
||||
export async function add(addon: string, options: { useNpm: boolean; skipPostinstall: boolean }) {
|
||||
const packageManager = JsPackageManagerFactory.getPackageManager(options.useNpm);
|
||||
const packageJson = packageManager.retrievePackageJson();
|
||||
const [addonName, versionSpecifier] = getVersionSpecifier(addon);
|
||||
|
||||
const { mainConfig, version: storybookVersion } = getStorybookInfo(packageJson);
|
||||
if (!mainConfig) {
|
||||
logger.error('Unable to find storybook main.js config');
|
||||
return;
|
||||
}
|
||||
addonCheckDone();
|
||||
installAddon(packageManager, addonName, isOfficialAddon);
|
||||
const main = await readConfig(mainConfig);
|
||||
const addons = main.getFieldValue(['addons']);
|
||||
if (addons && !Array.isArray(addons)) {
|
||||
logger.error('Expected addons array in main.js config');
|
||||
}
|
||||
|
||||
logger.log(`Verifying ${addonName}`);
|
||||
const latestVersion = packageManager.latestVersion(addonName);
|
||||
if (!latestVersion) {
|
||||
logger.error(`Unknown addon ${addonName}`);
|
||||
}
|
||||
|
||||
// add to package.json
|
||||
const isStorybookAddon = addonName.startsWith('@storybook/');
|
||||
const version = versionSpecifier || (isStorybookAddon ? storybookVersion : latestVersion);
|
||||
const addonWithVersion = `${addonName}@${version}`;
|
||||
logger.log(`Installing ${addonWithVersion}`);
|
||||
packageManager.addDependencies({ installAsDevDependencies: true }, [addonWithVersion]);
|
||||
|
||||
// add to main.js
|
||||
logger.log(`Adding '${addon}' to main.js addons field.`);
|
||||
const updatedAddons = [...(addons || []), addonName];
|
||||
main.setFieldValue(['addons'], updatedAddons);
|
||||
await writeConfig(main);
|
||||
|
||||
if (!options.skipPostinstall) {
|
||||
await postinstallAddon(addonName, isOfficialAddon);
|
||||
await postinstallAddon(addon, isStorybookAddon);
|
||||
}
|
||||
}
|
||||
|
@ -35,11 +35,11 @@ const packagesMap: Record<string, { webpack5?: string; vite?: string }> = {
|
||||
},
|
||||
'@storybook/svelte': {
|
||||
webpack5: '@storybook/svelte-webpack5',
|
||||
// TODO: bring this back once we have the svelte-vite package
|
||||
vite: '@storybook/svelte-vite',
|
||||
},
|
||||
'@storybook/web-components': {
|
||||
webpack5: '@storybook/web-components-webpack5',
|
||||
vite: '@storybook/web-components-vite',
|
||||
},
|
||||
'@storybook/html': {
|
||||
webpack5: '@storybook/html-webpack5',
|
||||
|
@ -67,6 +67,23 @@ const vue3ViteTemplates = {
|
||||
},
|
||||
};
|
||||
|
||||
const vue2ViteTemplates = {
|
||||
'vue2-vite/2.7-js': {
|
||||
name: 'Vue2 Vite (vue 2.7 JS)',
|
||||
// TODO: convert this to an `npm create` script, use that instead.
|
||||
// We don't really want to maintain weird custom scripts like this,
|
||||
// preferring community bootstrap scripts / generators instead.
|
||||
script:
|
||||
'yarn create vite . --template vanilla && yarn add --dev @vitejs/plugin-vue2 vue-template-compiler vue@2 && echo "import vue2 from \'@vitejs/plugin-vue2\';\n\nexport default {\n\tplugins: [vue2()]\n};" > vite.config.js',
|
||||
cadence: ['ci', 'daily', 'weekly'],
|
||||
expected: {
|
||||
framework: '@storybook/vue2-vite',
|
||||
renderer: '@storybook/vue',
|
||||
builder: '@storybook/builder-vite',
|
||||
},
|
||||
},
|
||||
};
|
||||
|
||||
const svelteViteTemplates = {
|
||||
'svelte-vite/default-js': {
|
||||
name: 'Svelte Vite (JS)',
|
||||
@ -94,6 +111,29 @@ const svelteViteTemplates = {
|
||||
// }
|
||||
};
|
||||
|
||||
const litViteTemplates = {
|
||||
'lit-vite/default-js': {
|
||||
name: 'Lit Vite (JS)',
|
||||
script: 'yarn create vite . --template lit',
|
||||
cadence: [] as any,
|
||||
expected: {
|
||||
framework: '@storybook/web-components-vite',
|
||||
renderer: '@storybook/web-components',
|
||||
builder: '@storybook/builder-vite',
|
||||
},
|
||||
},
|
||||
'lit-vite/default-ts': {
|
||||
name: 'Lit Vite (TS)',
|
||||
script: 'yarn create vite . --template lit-ts',
|
||||
cadence: [] as any,
|
||||
expected: {
|
||||
framework: '@storybook/web-components-vite',
|
||||
renderer: '@storybook/web-components',
|
||||
builder: '@storybook/builder-vite',
|
||||
},
|
||||
},
|
||||
};
|
||||
|
||||
const vueCliTemplates = {
|
||||
'vue-cli/default-js': {
|
||||
name: 'Vue-CLI (Default JS)',
|
||||
@ -105,27 +145,26 @@ const vueCliTemplates = {
|
||||
builder: '@storybook/builder-webpack5',
|
||||
},
|
||||
},
|
||||
//
|
||||
// FIXME: https://github.com/storybookjs/storybook/issues/19204
|
||||
//
|
||||
// 'vue-cli/vue2-default-js': {
|
||||
// name: 'Vue-CLI (Vue2 JS)',
|
||||
// script:
|
||||
// 'npx -p @vue/cli vue create . --default --packageManager=yarn --force --merge --preset=Default\\ (Vue\\ 2)',
|
||||
// cadence: ['ci', 'daily', 'weekly'],
|
||||
// expected: {
|
||||
// framework: '@storybook/vue-webpack5',
|
||||
// renderer: '@storybook/vue',
|
||||
// builder: '@storybook/builder-webpack5',
|
||||
// },
|
||||
// },
|
||||
'vue-cli/vue2-default-js': {
|
||||
name: 'Vue-CLI (Vue2 JS)',
|
||||
script:
|
||||
'npx -p @vue/cli vue create . --default --packageManager=yarn --force --merge --preset=Default\\ (Vue\\ 2)',
|
||||
cadence: ['ci', 'daily', 'weekly'],
|
||||
expected: {
|
||||
framework: '@storybook/vue-webpack5',
|
||||
renderer: '@storybook/vue',
|
||||
builder: '@storybook/builder-webpack5',
|
||||
},
|
||||
},
|
||||
};
|
||||
|
||||
export default {
|
||||
...craTemplates,
|
||||
...reactViteTemplates,
|
||||
...vue2ViteTemplates,
|
||||
...vue3ViteTemplates,
|
||||
...svelteViteTemplates,
|
||||
...litViteTemplates,
|
||||
...vueCliTemplates,
|
||||
// FIXME: missing documentation.json
|
||||
// 'angular/latest': {
|
||||
|
@ -71,12 +71,14 @@ export default {
|
||||
'@storybook/theming': '7.0.0-alpha.34',
|
||||
'@storybook/ui': '7.0.0-alpha.34',
|
||||
'@storybook/vue': '7.0.0-alpha.34',
|
||||
'@storybook/vue-vite': '7.0.0-alpha.34',
|
||||
'@storybook/vue-webpack5': '7.0.0-alpha.34',
|
||||
'@storybook/vue3': '7.0.0-alpha.34',
|
||||
'@storybook/vue3-vite': '7.0.0-alpha.34',
|
||||
'@storybook/vue3-webpack5': '7.0.0-alpha.34',
|
||||
'@storybook/web-components': '7.0.0-alpha.34',
|
||||
'@storybook/web-components-webpack5': '7.0.0-alpha.34',
|
||||
'@storybook/web-components-vite': '7.0.0-alpha.34',
|
||||
sb: '7.0.0-alpha.34',
|
||||
storybook: '7.0.0-alpha.34',
|
||||
};
|
||||
|
@ -1,5 +0,0 @@
|
||||
import global from 'global';
|
||||
|
||||
const { window: globalWindow } = global;
|
||||
|
||||
globalWindow.STORYBOOK_REACT_CLASSES = {};
|
@ -93,7 +93,7 @@ export const previewAnnotations = async (base: any, options: Options) => {
|
||||
|
||||
if (config.length > 0) warnConfigField();
|
||||
|
||||
return [...config, require.resolve('@storybook/core-client/dist/globals'), ...base];
|
||||
return [...config, ...base];
|
||||
};
|
||||
|
||||
export const features = async (
|
||||
|
@ -20,9 +20,17 @@
|
||||
},
|
||||
"license": "MIT",
|
||||
"sideEffects": false,
|
||||
"main": "dist/cjs/index.js",
|
||||
"module": "dist/esm/index.js",
|
||||
"types": "dist/types/index.d.ts",
|
||||
"exports": {
|
||||
".": {
|
||||
"require": "./dist/index.js",
|
||||
"import": "./dist/index.mjs",
|
||||
"types": "./dist/index.d.ts"
|
||||
},
|
||||
"./package.json": "./package.json"
|
||||
},
|
||||
"main": "dist/index.js",
|
||||
"module": "dist/index.mjs",
|
||||
"types": "dist/index.d.ts",
|
||||
"files": [
|
||||
"dist/**/*",
|
||||
"README.md",
|
||||
@ -31,7 +39,7 @@
|
||||
],
|
||||
"scripts": {
|
||||
"check": "../../../scripts/node_modules/.bin/tsc --noEmit",
|
||||
"prep": "node ../../../scripts/prepare.js"
|
||||
"prep": "../../../scripts/prepare/bundle.ts"
|
||||
},
|
||||
"dependencies": {
|
||||
"@storybook/addons": "7.0.0-alpha.34",
|
||||
@ -57,5 +65,11 @@
|
||||
"publishConfig": {
|
||||
"access": "public"
|
||||
},
|
||||
"bundler": {
|
||||
"entries": [
|
||||
"./src/index.ts"
|
||||
],
|
||||
"platform": "node"
|
||||
},
|
||||
"gitHead": "fc90fc875462421c1faa35862ac4bc436de8e75f"
|
||||
}
|
||||
|
@ -24,6 +24,9 @@ export const UseState = {
|
||||
],
|
||||
play: async ({ canvasElement }: PlayFunctionContext) => {
|
||||
const button = await within(canvasElement).findByText('Clicked 0 times');
|
||||
// FIXME: onClick does not properly register in vue2
|
||||
// https://github.com/storybookjs/storybook/issues/19318
|
||||
if (globalThis.storybookRenderer === 'vue') return;
|
||||
|
||||
await userEvent.click(button);
|
||||
await within(canvasElement).findByText('Clicked 1 times');
|
||||
|
@ -20,9 +20,17 @@
|
||||
},
|
||||
"license": "MIT",
|
||||
"sideEffects": false,
|
||||
"main": "dist/cjs/index.js",
|
||||
"module": "dist/esm/index.js",
|
||||
"types": "dist/types/index.d.ts",
|
||||
"exports": {
|
||||
".": {
|
||||
"require": "./dist/index.js",
|
||||
"import": "./dist/index.mjs",
|
||||
"types": "./dist/index.d.ts"
|
||||
},
|
||||
"./package.json": "./package.json"
|
||||
},
|
||||
"main": "dist/index.js",
|
||||
"module": "dist/index.mjs",
|
||||
"types": "dist/index.d.ts",
|
||||
"files": [
|
||||
"dist/**/*",
|
||||
"README.md",
|
||||
@ -31,7 +39,7 @@
|
||||
],
|
||||
"scripts": {
|
||||
"check": "../../../scripts/node_modules/.bin/tsc --noEmit",
|
||||
"prep": "node ../../../scripts/prepare.js"
|
||||
"prep": "../../../scripts/prepare/bundle.ts"
|
||||
},
|
||||
"dependencies": {
|
||||
"@storybook/client-logger": "7.0.0-alpha.34",
|
||||
@ -50,5 +58,11 @@
|
||||
"publishConfig": {
|
||||
"access": "public"
|
||||
},
|
||||
"bundler": {
|
||||
"entries": [
|
||||
"./src/index.ts"
|
||||
],
|
||||
"platform": "node"
|
||||
},
|
||||
"gitHead": "fc90fc875462421c1faa35862ac4bc436de8e75f"
|
||||
}
|
||||
|
@ -66,8 +66,6 @@
|
||||
"@storybook/semver": "^7.3.2",
|
||||
"@storybook/theming": "7.0.0-alpha.34",
|
||||
"@testing-library/react": "^11.2.2",
|
||||
"@types/node": "^14.0.10 || ^16.0.0",
|
||||
"@types/webpack-env": "^1.16.0",
|
||||
"copy-to-clipboard": "^3.3.1",
|
||||
"downshift": "^6.0.15",
|
||||
"enzyme": "^3.11.0",
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
x
Reference in New Issue
Block a user