-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
#339 Apply missing tokens to Input and TagInput components
- Loading branch information
Szymon Graczyk
committed
Jul 27, 2022
1 parent
aa83ec5
commit 0b22563
Showing
5 changed files
with
86 additions
and
32 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
53 changes: 40 additions & 13 deletions
53
packages/react-components/src/components/Input/Input.stories.tsx
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,24 +1,51 @@ | ||
import * as React from 'react'; | ||
import { ComponentMeta } from '@storybook/react'; | ||
import { ComponentMeta, Story } from '@storybook/react'; | ||
|
||
import { Input as InputComponent, InputProps } from './Input'; | ||
import { StoryDescriptor } from '../../stories/components/StoryDescriptor'; | ||
|
||
import { Input, InputProps } from './Input'; | ||
|
||
const placeholderText = 'Placeholder text'; | ||
|
||
export default { | ||
title: 'Forms/Input', | ||
component: InputComponent, | ||
} as ComponentMeta<typeof InputComponent>; | ||
component: Input, | ||
} as ComponentMeta<typeof Input>; | ||
|
||
export const Input = ({ ...args }): React.ReactElement => ( | ||
<InputComponent {...args} /> | ||
export const Default: Story<InputProps> = (args: InputProps) => ( | ||
<Input {...args} /> | ||
); | ||
|
||
Input.args = { | ||
Default.storyName = 'Input'; | ||
Default.args = { | ||
size: 'medium', | ||
placeholder: 'Placeholder text', | ||
error: false, | ||
disabled: false, | ||
} as InputProps; | ||
}; | ||
|
||
export const WithIcon = () => <div>TODO</div>; | ||
export const WithArrow = () => <div>TODO</div>; | ||
export const WithIconAndArrow = () => <div>TODO</div>; | ||
export const Sizes = (): JSX.Element => ( | ||
<> | ||
<StoryDescriptor title="XSmall"> | ||
<Input size="xsmall" placeholder={placeholderText} /> | ||
</StoryDescriptor> | ||
<StoryDescriptor title="Small"> | ||
<Input size="small" placeholder={placeholderText} /> | ||
</StoryDescriptor> | ||
<StoryDescriptor title="Medium"> | ||
<Input size="medium" placeholder={placeholderText} /> | ||
</StoryDescriptor> | ||
<StoryDescriptor title="Large"> | ||
<Input size="large" placeholder={placeholderText} /> | ||
</StoryDescriptor> | ||
</> | ||
); | ||
|
||
export const States = (): JSX.Element => ( | ||
<> | ||
<StoryDescriptor title="With error"> | ||
<Input error={true} placeholder={placeholderText} /> | ||
</StoryDescriptor> | ||
<StoryDescriptor title="Disabled"> | ||
<Input disabled={true} placeholder={placeholderText} /> | ||
</StoryDescriptor> | ||
</> | ||
); |
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
51 changes: 35 additions & 16 deletions
51
packages/react-components/src/components/TagInput/TagInput.stories.tsx
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,49 +1,68 @@ | ||
import * as React from 'react'; | ||
import { ComponentMeta } from '@storybook/react'; | ||
import { ComponentMeta, Story } from '@storybook/react'; | ||
|
||
import noop from '../../utils/noop'; | ||
import { StoryDescriptor } from '../../stories/components/StoryDescriptor'; | ||
|
||
import { | ||
TagInput as TagInputComponent, | ||
TagInput, | ||
TagInputProps, | ||
EmailTagInput as EmailTagInputComponent, | ||
EmailTagInput, | ||
EmailTagInputProps, | ||
} from './index'; | ||
|
||
const placeholderText = 'Placeholder text'; | ||
|
||
export default { | ||
title: 'Forms/Tag Input', | ||
component: TagInputComponent, | ||
component: TagInput, | ||
argTypes: { | ||
tags: { | ||
control: { | ||
disable: true, | ||
}, | ||
}, | ||
}, | ||
} as ComponentMeta<typeof TagInputComponent>; | ||
} as ComponentMeta<typeof TagInput>; | ||
|
||
export const TagInput = ({ ...args }: TagInputProps): React.ReactElement => { | ||
export const DefaultTagInput: Story<TagInputProps> = ({ | ||
...args | ||
}: TagInputProps) => { | ||
const [tags, setTags] = React.useState(['tag1', 'tag2']); | ||
return ( | ||
<div> | ||
<TagInputComponent {...args} tags={tags} onChange={setTags} /> | ||
<TagInput {...args} tags={tags} onChange={setTags} /> | ||
</div> | ||
); | ||
}; | ||
|
||
TagInput.args = { | ||
placeholder: 'Tag input placeholder', | ||
} as TagInputProps; | ||
DefaultTagInput.storyName = 'TagInput'; | ||
DefaultTagInput.args = { | ||
placeholder: placeholderText, | ||
}; | ||
|
||
export const EmailTagInput = ({ | ||
export const DefaultEmailTagInput: Story<EmailTagInputProps> = ({ | ||
...args | ||
}: EmailTagInputProps): React.ReactElement => { | ||
}: EmailTagInputProps) => { | ||
const [tags, setTags] = React.useState(['[email protected]', '[email protected]']); | ||
return ( | ||
<div> | ||
<EmailTagInputComponent {...args} tags={tags} onChange={setTags} /> | ||
<EmailTagInput {...args} tags={tags} onChange={setTags} /> | ||
</div> | ||
); | ||
}; | ||
|
||
EmailTagInput.args = { | ||
DefaultEmailTagInput.storyName = 'EmailTagInput'; | ||
DefaultEmailTagInput.args = { | ||
placeholder: '[email protected]', | ||
} as TagInputProps; | ||
}; | ||
|
||
export const Sizes = (): JSX.Element => ( | ||
<> | ||
<StoryDescriptor title="Medium"> | ||
<TagInput size="medium" onChange={noop} placeholder={placeholderText} /> | ||
</StoryDescriptor> | ||
<StoryDescriptor title="Large"> | ||
<TagInput size="large" onChange={noop} placeholder={placeholderText} /> | ||
</StoryDescriptor> | ||
</> | ||
); |