mirror of
https://github.com/storybookjs/storybook.git
synced 2025-04-01 05:05:25 +08:00
Fix missing react-demo
This commit is contained in:
parent
dd15eebc2c
commit
32e73c89bf
34
addons/storyshots/storyshots-core/stories/react-demo.js
vendored
Normal file
34
addons/storyshots/storyshots-core/stories/react-demo.js
vendored
Normal file
@ -0,0 +1,34 @@
|
||||
import React from 'react';
|
||||
|
||||
const styles = {
|
||||
border: '1px solid #eee',
|
||||
borderRadius: 3,
|
||||
backgroundColor: '#FFFFFF',
|
||||
cursor: 'pointer',
|
||||
fontSize: 15,
|
||||
padding: '3px 10px',
|
||||
margin: 10,
|
||||
};
|
||||
|
||||
// eslint-disable-next-line react/prop-types
|
||||
export const Button = ({ children, onClick }) => (
|
||||
<button onClick={onClick} style={styles} type="button">
|
||||
{children}
|
||||
</button>
|
||||
);
|
||||
|
||||
Button.displayName = 'Button';
|
||||
Button.defaultProps = {
|
||||
onClick: () => {},
|
||||
};
|
||||
|
||||
// eslint-disable-next-line react/prop-types
|
||||
export const Welcome = ({ showApp }) => (
|
||||
<button type="button" onClick={showApp}>
|
||||
Welcome
|
||||
</button>
|
||||
);
|
||||
Welcome.displayName = 'Welcome';
|
||||
Welcome.defaultProps = {
|
||||
showApp: () => {},
|
||||
};
|
@ -1,7 +1,7 @@
|
||||
import React from 'react';
|
||||
|
||||
import { action } from '@storybook/addon-actions';
|
||||
import { Button } from '@storybook/react/demo';
|
||||
import { Button } from '../react-demo';
|
||||
|
||||
export default {
|
||||
title: 'Button',
|
||||
|
@ -1,7 +1,7 @@
|
||||
import React from 'react';
|
||||
|
||||
import { linkTo } from '@storybook/addon-links';
|
||||
import { Welcome } from '@storybook/react/demo';
|
||||
import { Welcome } from '../react-demo';
|
||||
|
||||
export default {
|
||||
title: 'Welcome',
|
||||
|
@ -1,5 +1,5 @@
|
||||
import { linkTo } from '@storybook/addon-links';
|
||||
import { Welcome } from '@storybook/react/demo';
|
||||
import { Welcome } from '../react-demo';
|
||||
import { Meta, Story } from '@storybook/addon-docs';
|
||||
|
||||
<Meta
|
||||
|
34
examples/cra-kitchen-sink/src/components/react-demo.js
vendored
Normal file
34
examples/cra-kitchen-sink/src/components/react-demo.js
vendored
Normal file
@ -0,0 +1,34 @@
|
||||
import React from 'react';
|
||||
|
||||
const styles = {
|
||||
border: '1px solid #eee',
|
||||
borderRadius: 3,
|
||||
backgroundColor: '#FFFFFF',
|
||||
cursor: 'pointer',
|
||||
fontSize: 15,
|
||||
padding: '3px 10px',
|
||||
margin: 10,
|
||||
};
|
||||
|
||||
// eslint-disable-next-line react/prop-types
|
||||
export const Button = ({ children, onClick }) => (
|
||||
<button onClick={onClick} style={styles} type="button">
|
||||
{children}
|
||||
</button>
|
||||
);
|
||||
|
||||
Button.displayName = 'Button';
|
||||
Button.defaultProps = {
|
||||
onClick: () => {},
|
||||
};
|
||||
|
||||
// eslint-disable-next-line react/prop-types
|
||||
export const Welcome = ({ showApp }) => (
|
||||
<button type="button" onClick={showApp}>
|
||||
Welcome
|
||||
</button>
|
||||
);
|
||||
Welcome.displayName = 'Welcome';
|
||||
Welcome.defaultProps = {
|
||||
showApp: () => {},
|
||||
};
|
@ -1,6 +1,6 @@
|
||||
import React from 'react';
|
||||
import { action } from '@storybook/addon-actions';
|
||||
import { Button } from '@storybook/react/demo';
|
||||
import { Button } from '../components/react-demo';
|
||||
|
||||
export default {
|
||||
title: 'Button',
|
||||
|
@ -9,7 +9,7 @@ export default {
|
||||
|
||||
export const Story1 = () => {
|
||||
if (!Component) {
|
||||
import('@storybook/react/demo').then(({ Button }) => {
|
||||
import('../components/react-demo').then(({ Button }) => {
|
||||
Component = Button;
|
||||
forceReRender();
|
||||
});
|
||||
|
@ -1,7 +1,7 @@
|
||||
import React from 'react';
|
||||
import { action } from '@storybook/addon-actions';
|
||||
import { Button } from '@storybook/react/demo';
|
||||
import PropTypes from 'prop-types';
|
||||
import { Button } from '../components/react-demo';
|
||||
|
||||
const Bold = ({ children }) => {
|
||||
return <b>{children}</b>;
|
||||
|
@ -1,6 +1,6 @@
|
||||
import React from 'react';
|
||||
import { forceReRender } from '@storybook/react';
|
||||
import { Button } from '@storybook/react/demo';
|
||||
import { Button } from '../components/react-demo';
|
||||
|
||||
let count = 0;
|
||||
const increment = () => {
|
||||
|
@ -1,6 +1,6 @@
|
||||
import React from 'react';
|
||||
import { action } from '@storybook/addon-actions';
|
||||
import { Button } from '@storybook/react/demo';
|
||||
import { Button } from '../components/react-demo';
|
||||
|
||||
export default {
|
||||
title: 'Some really long story kind description',
|
||||
|
@ -1,6 +1,6 @@
|
||||
import React from 'react';
|
||||
import { Welcome } from '@storybook/react/demo';
|
||||
import { linkTo } from '@storybook/addon-links';
|
||||
import { Welcome } from '../components/react-demo';
|
||||
|
||||
export default {
|
||||
title: 'Welcome',
|
||||
|
@ -1,6 +1,6 @@
|
||||
import React from 'react';
|
||||
import { action } from '@storybook/addon-actions';
|
||||
import { Button } from '@storybook/react/demo';
|
||||
import { Button } from './react-demo';
|
||||
|
||||
export default {
|
||||
title: 'Button',
|
||||
|
34
examples/cra-react15/src/stories/react-demo.js
vendored
Normal file
34
examples/cra-react15/src/stories/react-demo.js
vendored
Normal file
@ -0,0 +1,34 @@
|
||||
import React from 'react';
|
||||
|
||||
const styles = {
|
||||
border: '1px solid #eee',
|
||||
borderRadius: 3,
|
||||
backgroundColor: '#FFFFFF',
|
||||
cursor: 'pointer',
|
||||
fontSize: 15,
|
||||
padding: '3px 10px',
|
||||
margin: 10,
|
||||
};
|
||||
|
||||
// eslint-disable-next-line react/prop-types
|
||||
export const Button = ({ children, onClick }) => (
|
||||
<button onClick={onClick} style={styles} type="button">
|
||||
{children}
|
||||
</button>
|
||||
);
|
||||
|
||||
Button.displayName = 'Button';
|
||||
Button.defaultProps = {
|
||||
onClick: () => {},
|
||||
};
|
||||
|
||||
// eslint-disable-next-line react/prop-types
|
||||
export const Welcome = ({ showApp }) => (
|
||||
<button type="button" onClick={showApp}>
|
||||
Welcome
|
||||
</button>
|
||||
);
|
||||
Welcome.displayName = 'Welcome';
|
||||
Welcome.defaultProps = {
|
||||
showApp: () => {},
|
||||
};
|
@ -1,7 +1,7 @@
|
||||
import React from 'react';
|
||||
import { storiesOf, setAddon } from '@storybook/react';
|
||||
import { linkTo } from '@storybook/addon-links';
|
||||
import { Welcome } from '@storybook/react/demo';
|
||||
import { Welcome } from './react-demo';
|
||||
|
||||
// Added deprecated setAddon tests
|
||||
setAddon({
|
||||
|
@ -1,7 +1,7 @@
|
||||
import React from 'react';
|
||||
import { linkTo } from '@storybook/addon-links';
|
||||
import { Welcome } from '@storybook/react/demo';
|
||||
import type { ComponentMeta, ComponentStory } from '@storybook/react';
|
||||
import { Welcome } from './react-demo';
|
||||
|
||||
export default {
|
||||
title: 'Welcome',
|
||||
|
@ -1,6 +1,6 @@
|
||||
import React from 'react';
|
||||
import { Button } from '@storybook/react/demo';
|
||||
import type { ComponentStory, ComponentMeta } from '@storybook/react';
|
||||
import { Button } from './react-demo';
|
||||
|
||||
export default {
|
||||
title: 'Button',
|
||||
|
37
examples/cra-ts-essentials/src/stories/react-demo.tsx
Normal file
37
examples/cra-ts-essentials/src/stories/react-demo.tsx
Normal file
@ -0,0 +1,37 @@
|
||||
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: () => {},
|
||||
};
|
37
examples/cra-ts-kitchen-sink/src/components/react-demo.tsx
Normal file
37
examples/cra-ts-kitchen-sink/src/components/react-demo.tsx
Normal file
@ -0,0 +1,37 @@
|
||||
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,6 +1,6 @@
|
||||
import React from 'react';
|
||||
import { linkTo } from '@storybook/addon-links';
|
||||
import { Welcome } from '@storybook/react/demo';
|
||||
import { Welcome } from '../components/react-demo';
|
||||
|
||||
export default {
|
||||
title: 'Welcome',
|
||||
|
37
examples/official-storybook/components/react-demo.tsx
Normal file
37
examples/official-storybook/components/react-demo.tsx
Normal file
@ -0,0 +1,37 @@
|
||||
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: () => {},
|
||||
};
|
@ -9,8 +9,8 @@ import {
|
||||
Meta,
|
||||
} from '@storybook/addon-docs';
|
||||
import { action } from '@storybook/addon-actions';
|
||||
import { Button } from '@storybook/react/demo';
|
||||
import styled from 'styled-components';
|
||||
import { Button } from '../../components/react-demo';
|
||||
import TsButton from '../../components/TsButton';
|
||||
import FlowTypeButton from '../../components/FlowTypeButton';
|
||||
import { DocgenButton } from '../../components/DocgenButton';
|
||||
|
@ -1,6 +1,6 @@
|
||||
/* eslint-disable storybook/default-exports */
|
||||
import React from 'react';
|
||||
import { Button } from '@storybook/react/demo';
|
||||
import { Button } from '../../components/react-demo';
|
||||
|
||||
// NOTE: commented out default since these stories are re-exported
|
||||
// in the primary file './csf-docs-with-mdx-docs.stories.mdx'
|
||||
|
@ -1,5 +1,5 @@
|
||||
import React from 'react';
|
||||
import { Button } from '@storybook/react/demo';
|
||||
import { Button } from '../../components/react-demo';
|
||||
|
||||
export default { title: 'Addons/Docs/Imported', component: Button };
|
||||
export const Basic = (args: any) => <Button {...args} />;
|
||||
|
@ -7,10 +7,10 @@ export default {
|
||||
parameters: { chromatic: { disable: true } },
|
||||
};
|
||||
|
||||
import { Welcome } from '@storybook/react/demo';
|
||||
import { Welcome } from '../../components/react-demo';
|
||||
|
||||
export const First = () => <Welcome showApp={action('show')} />;
|
||||
|
||||
import { Button } from '@storybook/react/demo';
|
||||
import { Button } from '../../components/react-demo';
|
||||
|
||||
export const Second = () => <Button onClick={action('click')}>Second</Button>;
|
||||
|
@ -1,5 +1,5 @@
|
||||
import { Meta, Canvas, Story } from '@storybook/addon-docs';
|
||||
import { Button } from '@storybook/react/demo';
|
||||
import { Button } from '../../components/react-demo';
|
||||
|
||||
<Meta
|
||||
title="Core/Layout MDX"
|
||||
|
@ -1,6 +1,6 @@
|
||||
import React, { useState } from 'react';
|
||||
import { action } from '@storybook/addon-actions';
|
||||
import { Button } from '@storybook/react/demo';
|
||||
import { Button } from '../../components/react-demo';
|
||||
|
||||
export default {
|
||||
title: 'Other/Demo/Button',
|
||||
|
@ -1,7 +1,7 @@
|
||||
import { useState } from 'react';
|
||||
import { action } from '@storybook/addon-actions';
|
||||
import { Button } from '@storybook/react/demo';
|
||||
import { Meta, Story, Canvas, ArgsTable } from '@storybook/addon-docs';
|
||||
import { Button } from '../../compoenents/react-demo';
|
||||
|
||||
<Meta title="Other/Demo/ButtonMdx" component={Button} />
|
||||
|
||||
|
@ -1,6 +1,6 @@
|
||||
import React from 'react';
|
||||
import { linkTo } from '@storybook/addon-links';
|
||||
import { Welcome } from '@storybook/react/demo';
|
||||
import { Welcome } from '../../components/react-demo';
|
||||
|
||||
export default {
|
||||
title: 'Other/Demo/Welcome',
|
||||
|
Loading…
x
Reference in New Issue
Block a user