-
Notifications
You must be signed in to change notification settings - Fork 63
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* π Rename to .tsx extension * β»οΈ Rewrite to typescript. No argsTable is showing * π Add stories for chips
- Loading branch information
Showing
5 changed files
with
157 additions
and
156 deletions.
There are no files selected for viewing
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,151 @@ | ||
import React from 'react' | ||
import { action } from '@storybook/addon-actions' | ||
import styled from 'styled-components' | ||
import { Icon, Chip, ChipProps, Avatar } from '@equinor/eds-core-react' | ||
import { Meta, Story } from '@storybook/react' | ||
import { save } from '@equinor/eds-icons' | ||
|
||
const icons = { | ||
save, | ||
} | ||
|
||
Icon.add(icons) | ||
|
||
const Wrapper = styled.div` | ||
display: grid; | ||
grid-gap: 32px; | ||
grid-template-columns: repeat(3, fit-content(100%)); | ||
` | ||
|
||
export default { | ||
title: 'Components/Chips', | ||
component: Chip, | ||
} as Meta | ||
|
||
const handleDelete = action('onDelete') | ||
const handleClick = action('onClick') | ||
|
||
const CatImage = () => ( | ||
<Avatar src={'https://i.imgur.com/UM3mrju.jpg'} alt="cat" /> | ||
) | ||
|
||
export const Default: Story<ChipProps> = (args) => ( | ||
<Chip {...args}>Play with me</Chip> | ||
) | ||
|
||
export const Text: Story<ChipProps> = () => ( | ||
<Wrapper> | ||
<Chip>normal</Chip> | ||
<Chip variant="active">active</Chip> | ||
<Chip variant="active" onDelete={handleDelete}> | ||
active + deletable | ||
</Chip> | ||
<Chip variant="error">error</Chip> | ||
<Chip variant="error" onDelete={handleDelete}> | ||
error + deletable | ||
</Chip> | ||
<Chip variant="error" onDelete={handleDelete} onClick={handleClick}> | ||
error + deletable + clickable | ||
</Chip> | ||
<Chip onClick={handleClick}>clickable</Chip> | ||
<Chip onDelete={handleDelete}>deletable</Chip> | ||
<Chip onDelete={handleDelete} onClick={handleClick}> | ||
deletable + clickable | ||
</Chip> | ||
<Chip onDelete={handleDelete} disabled> | ||
disabled | ||
</Chip> | ||
</Wrapper> | ||
) | ||
|
||
export const TextAndIcon: Story<ChipProps> = () => ( | ||
<Wrapper> | ||
<Chip> | ||
<Icon name="save" /> | ||
normal | ||
</Chip> | ||
<Chip variant="active"> | ||
<Icon name="save" /> | ||
active | ||
</Chip> | ||
<Chip variant="active" onDelete={handleDelete}> | ||
<Icon name="save" /> | ||
active + deletable | ||
</Chip> | ||
<Chip variant="error"> | ||
<Icon name="save" /> | ||
error | ||
</Chip> | ||
<Chip variant="error" onDelete={handleDelete}> | ||
<Icon name="save" /> | ||
error + deletable | ||
</Chip> | ||
<Chip variant="error" onDelete={handleDelete} onClick={handleClick}> | ||
<Icon name="save" /> | ||
error + deletable + clickable | ||
</Chip> | ||
<Chip onClick={handleClick}> | ||
<Icon name="save" /> | ||
clickable | ||
</Chip> | ||
<Chip onDelete={handleDelete}> | ||
<Icon name="save" /> | ||
deletable | ||
</Chip> | ||
<Chip onDelete={handleDelete} onClick={handleClick}> | ||
<Icon name="save" /> | ||
deletable + clickable | ||
</Chip> | ||
<Chip onDelete={handleDelete} disabled> | ||
<Icon name="save" /> | ||
disabled | ||
</Chip> | ||
</Wrapper> | ||
) | ||
export const TextAndAvatar: Story<ChipProps> = () => ( | ||
<Wrapper> | ||
<Chip> | ||
<CatImage /> | ||
normal | ||
</Chip> | ||
<Chip variant="active"> | ||
<CatImage /> | ||
active | ||
</Chip> | ||
<Chip variant="active" onDelete={handleDelete}> | ||
<CatImage /> | ||
active + deletable | ||
</Chip> | ||
<Chip variant="error"> | ||
<CatImage /> | ||
error | ||
</Chip> | ||
<Chip variant="error" onDelete={handleDelete}> | ||
<CatImage /> | ||
error + deletable | ||
</Chip> | ||
<Chip variant="error" onDelete={handleDelete} onClick={handleClick}> | ||
<CatImage /> | ||
error + deletable + clickable | ||
</Chip> | ||
<Chip onClick={handleClick}> | ||
<CatImage /> | ||
clickable | ||
</Chip> | ||
<Chip onDelete={handleDelete}> | ||
<CatImage /> | ||
deletable | ||
</Chip> | ||
<Chip onDelete={handleDelete} onClick={handleClick}> | ||
<CatImage /> | ||
deletable + clickable | ||
</Chip> | ||
<Chip onDelete={handleDelete} disabled> | ||
<CatImage /> | ||
disabled | ||
</Chip> | ||
</Wrapper> | ||
) | ||
|
||
TextAndIcon.storyName = 'Text and icon' | ||
TextAndAvatar.storyName = 'Text and avatar' |
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 +1 @@ | ||
export { Chip } from './Chip' | ||
export * from './Chip' |
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