-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
53 additions
and
0 deletions.
There are no files selected for viewing
53 changes: 53 additions & 0 deletions
53
src/controls/Dropdown/stories/Dropdown.Theming.stories.mdx
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,53 @@ | ||
import {ArgsTable, Meta, Canvas, Story} from "@storybook/addon-docs"; | ||
import { ThemeProvider } from 'styled-components'; | ||
import { Theme } from '../../../styles'; | ||
import {Dropdown} from '../Dropdown'; | ||
import {Icon} from '../../Icon'; | ||
import {Form} from '../../Form'; | ||
import {Label} from '../../Label'; | ||
|
||
# Dropdown: Theming | ||
. | ||
|
||
<Meta | ||
title="Controls/Dropdown/Theming" | ||
component={Dropdown} | ||
subcomponents={{ 'Dropdown.Column': Dropdown.Column }} | ||
argTypes={{ | ||
className: { table: { disable: true } } | ||
}} | ||
/> | ||
|
||
export const domains = [{id: 1, name: '.com'}, {id: 2, name:'.net'}, {id: 3, name:'.org'}, {id: 4, name:'.online'}, {id: 5, name:'.xyz'}, {id: 6, name:'.software'}, {id: 7, name:'.io'}, {id: 8, name:'.edu'}, {id: 9, name:'.tech'}]; | ||
export const people = [{id: 1, name: 'John', relation: 'friend'}, {id: 2, name:'Zachary', relation: 'uncle'}, {id: 3, name:'Deke', relation: 'friend'}]; | ||
|
||
## Columns | ||
|
||
A dropdown can show multiple columns. Each `Dropdown.Column` must have | ||
a single child that is a formatting function for an item, e.g. | ||
`(item) => item.name` | ||
|
||
export const ColumnsTemplate = (args) => | ||
<div style={{height: '250px', padding: '30px', background: '#406A8C'}}> | ||
<ThemeProvider theme={{...Theme, normalColor: '#aaa', background: '#305A7C', fontColor: '#fff' }}> | ||
<Form data={{}} onChange={() => {}} onValidate={() => {}}> | ||
<Form.Field | ||
name="person" | ||
value={null} | ||
control={<Dropdown {...args}> | ||
<Dropdown.Column>{(item) => item.name}</Dropdown.Column> | ||
<Dropdown.Column>{(item) => (<Label>{item.relation}</Label>)}</Dropdown.Column> | ||
</Dropdown>} | ||
/> | ||
</Form> | ||
</ThemeProvider> | ||
</div> | ||
|
||
<Canvas> | ||
<Story | ||
name="Columns" | ||
args={{data: people, alwaysDown: true, maxItems: 4, placeholder: "Select person", label: (item) => item.name, onSearch: null}}> | ||
{ColumnsTemplate.bind({})} | ||
</Story> | ||
</Canvas> | ||
|