generated from storybookjs/addon-kit
-
Notifications
You must be signed in to change notification settings - Fork 72
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #340 from storybookjs/yann/update-storybook-example
Update storybook example to vite and typescript
- Loading branch information
Showing
18 changed files
with
2,267 additions
and
2,214 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,50 +1,48 @@ | ||
import React from 'react'; | ||
import PropTypes from 'prop-types'; | ||
import './button.css'; | ||
|
||
/** | ||
* Primary UI component for user interaction | ||
*/ | ||
export const Button = ({ primary, backgroundColor, size, label, ...props }) => { | ||
const mode = primary ? 'storybook-button--primary' : 'storybook-button--secondary'; | ||
return ( | ||
<button | ||
type="button" | ||
className={['storybook-button', `storybook-button--${size}`, mode].join(' ')} | ||
style={backgroundColor && { backgroundColor }} | ||
{...props} | ||
> | ||
{label} | ||
</button> | ||
); | ||
}; | ||
|
||
Button.propTypes = { | ||
interface ButtonProps { | ||
/** | ||
* Is this the principal call to action on the page? | ||
*/ | ||
primary: PropTypes.bool, | ||
primary?: boolean; | ||
/** | ||
* What background color to use | ||
*/ | ||
backgroundColor: PropTypes.string, | ||
backgroundColor?: string; | ||
/** | ||
* How large should the button be? | ||
*/ | ||
size: PropTypes.oneOf(['small', 'medium', 'large']), | ||
size?: 'small' | 'medium' | 'large'; | ||
/** | ||
* Button contents | ||
*/ | ||
label: PropTypes.string.isRequired, | ||
label: string; | ||
/** | ||
* Optional click handler | ||
*/ | ||
onClick: PropTypes.func, | ||
}; | ||
onClick?: () => void; | ||
} | ||
|
||
Button.defaultProps = { | ||
backgroundColor: null, | ||
primary: false, | ||
size: 'medium', | ||
onClick: undefined, | ||
/** | ||
* Primary UI component for user interaction | ||
*/ | ||
export const Button = ({ | ||
primary = false, | ||
size = 'medium', | ||
backgroundColor, | ||
label, | ||
...props | ||
}: ButtonProps) => { | ||
const mode = primary ? 'storybook-button--primary' : 'storybook-button--secondary'; | ||
return ( | ||
<button | ||
type="button" | ||
className={['storybook-button', `storybook-button--${size}`, mode].join(' ')} | ||
style={{ backgroundColor }} | ||
{...props} | ||
> | ||
{label} | ||
</button> | ||
); | ||
}; |
File renamed without changes.
File renamed without changes.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
import type { Meta, StoryObj } from '@storybook/react'; | ||
|
||
import { Header } from './Header'; | ||
|
||
const meta = { | ||
component: Header, | ||
parameters: { | ||
layout: 'fullscreen', | ||
}, | ||
} satisfies Meta<typeof Header>; | ||
|
||
export default meta; | ||
type Story = StoryObj<typeof meta>; | ||
|
||
export const LoggedIn: Story = { | ||
args: { | ||
user: { | ||
name: 'Jane Doe', | ||
}, | ||
}, | ||
}; | ||
|
||
export const LoggedOut: Story = {}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.