-
Notifications
You must be signed in to change notification settings - Fork 4.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Tidy up storybook and add more examples
- Loading branch information
1 parent
996d33b
commit c951910
Showing
12 changed files
with
439 additions
and
124 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,10 @@ | ||
export const parameters = { | ||
options: { | ||
storySort: { | ||
order: ['Select', ['Basic', 'Animated']], | ||
order: [ | ||
'Select', | ||
['BasicSingle', 'BasicMulti', 'AnimatedMulti', 'Grouped', 'Creatable'], | ||
], | ||
}, | ||
}, | ||
}; |
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,44 @@ | ||
import * as React from 'react'; | ||
|
||
type FieldProps = { | ||
label?: string; | ||
secondaryLabel?: string; | ||
children: React.ReactNode; | ||
htmlFor: string; | ||
}; | ||
|
||
export function Field({ | ||
children, | ||
htmlFor, | ||
label = 'Select', | ||
secondaryLabel, | ||
}: FieldProps) { | ||
return ( | ||
<div | ||
style={{ | ||
display: 'flex', | ||
flexDirection: 'column', | ||
fontFamily: 'system-ui', | ||
gap: '0.5rem', | ||
}} | ||
> | ||
<label | ||
htmlFor={htmlFor} | ||
style={{ | ||
fontWeight: 500, | ||
display: 'flex', | ||
flexDirection: 'column', | ||
gap: '0.5rem', | ||
}} | ||
> | ||
<span>{label}</span> | ||
{secondaryLabel && ( | ||
<span style={{ fontWeight: 400, opacity: 0.7 }}> | ||
{secondaryLabel} | ||
</span> | ||
)} | ||
</label> | ||
{children} | ||
</div> | ||
); | ||
} |
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 |
---|---|---|
@@ -0,0 +1,30 @@ | ||
import { ComponentMeta, ComponentStory } from '@storybook/react'; | ||
import * as React from 'react'; | ||
import Select from 'react-select'; | ||
|
||
import { Field } from '../components/field'; | ||
import { colourOptions, defaultArgs } from '../data'; | ||
|
||
export default { | ||
title: 'Select/BasicMulti', | ||
component: Select, | ||
argTypes: {}, | ||
} as ComponentMeta<typeof Select>; | ||
|
||
const Template: ComponentStory<typeof Select> = ({ | ||
inputId = 'react-select', | ||
...props | ||
}) => { | ||
return ( | ||
<Field htmlFor={inputId} label="Basic Multi Select"> | ||
<Select inputId={inputId} {...props} /> | ||
</Field> | ||
); | ||
}; | ||
|
||
export const BasicMulti = Template.bind({}); | ||
BasicMulti.args = { | ||
...defaultArgs, | ||
defaultValue: [colourOptions[0], colourOptions[1], colourOptions[2]], | ||
isMulti: true, | ||
}; |
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.