-
Notifications
You must be signed in to change notification settings - Fork 0
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 #12 from BrahimS/shared-ui/icones
Shared UI/icones
- Loading branch information
Showing
15 changed files
with
1,487 additions
and
10 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
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
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
Empty file.
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,33 @@ | ||
import React from 'react'; | ||
import type { Preview } from '@storybook/react'; | ||
import { GlobalStyle } from '../src/lib/styles/GlobalStyle'; | ||
|
||
const withGlobalStyle = (storyFn: () => JSX.Element) => ( | ||
<> | ||
<GlobalStyle /> | ||
{storyFn()} | ||
</> | ||
); | ||
|
||
const preview: Preview = { | ||
globalTypes: { | ||
theme: { | ||
description: 'Global theme for components', | ||
toolbar: { | ||
// The label to show for this toolbar item | ||
title: 'Theme', | ||
icon: 'circlehollow', | ||
// Array of plain string values or MenuItem shape (see below) | ||
items: ['light', 'dark'], | ||
// Change title based on selected value | ||
dynamicTitle: true, | ||
}, | ||
}, | ||
}, | ||
initialGlobals: { | ||
theme: 'light', | ||
}, | ||
decorators: [withGlobalStyle], | ||
}; | ||
|
||
export default preview; |
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,88 @@ | ||
import styled, { css } from 'styled-components'; | ||
import { Icon, IconProps } from './Icon'; | ||
import { icons } from './paths'; | ||
|
||
const Meta = styled.div` | ||
color: #666; | ||
font-size: 12px; | ||
`; | ||
|
||
const Item = styled.li<{ minimal?: boolean }>` | ||
display: inline-flex; | ||
flex-direction: row; | ||
align-items: center; | ||
flex: 0 1 16%; | ||
min-width: 120px; | ||
margin: 16px; | ||
svg { | ||
margin-right: 6px; | ||
width: 14px; | ||
height: 14px; | ||
} | ||
${(props) => | ||
props.minimal && | ||
css` | ||
flex: none; | ||
min-width: auto; | ||
padding: 0; | ||
background: #fff; | ||
margin: 16px; | ||
svg { | ||
display: block; | ||
margin-right: 0; | ||
width: 14px; | ||
height: 14px; | ||
} | ||
`}; | ||
`; | ||
|
||
const List = styled.ul` | ||
display: flex; | ||
flex-flow: row wrap; | ||
list-style: none; | ||
padding: 0; | ||
margin: 0; | ||
`; | ||
|
||
const Header = styled.h2` | ||
font-size: 16px; | ||
margin: 16px; | ||
`; | ||
|
||
export default { | ||
title: 'Icon', | ||
component: Icon, | ||
}; | ||
|
||
export const Basic = (args: IconProps) => <Icon {...args} />; | ||
Basic.args = { icon: 'watch' }; | ||
|
||
export const Labels = () => ( | ||
<> | ||
<Header>{Object.keys(icons).length} icons</Header> | ||
<List> | ||
{Object.keys(icons).map((key) => ( | ||
<Item key={key}> | ||
<Icon icon={key as keyof typeof icons} aria-hidden /> | ||
<Meta>{key}</Meta> | ||
</Item> | ||
))} | ||
</List> | ||
</> | ||
); | ||
|
||
export const NoLabels = () => ( | ||
<> | ||
<Header>{Object.keys(icons).length} icons</Header> | ||
<List> | ||
{Object.keys(icons).map((key) => ( | ||
<Item minimal key={key}> | ||
<Icon icon={key as keyof typeof icons} aria-label={key} /> | ||
</Item> | ||
))} | ||
</List> | ||
</> | ||
); |
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,27 @@ | ||
import React from 'react'; | ||
import styled from 'styled-components'; | ||
import { icons } from './paths'; | ||
export type IconType = keyof typeof icons; | ||
|
||
export interface IconProps { | ||
icon: IconType; | ||
} | ||
|
||
const Svg = styled.svg` | ||
display: inline-block; | ||
shape-rendering: inherit; | ||
transform: translate3d(0, 0, 0); | ||
vertical-align: middle; | ||
path { | ||
fill: currentColor; | ||
} | ||
`; | ||
|
||
export const Icon: React.FC<IconProps> = ({ icon, ...props }: IconProps) => { | ||
return ( | ||
<Svg viewBox="0 0 16 16" width="16px" height="16px" {...props}> | ||
{icons[icon]} | ||
</Svg> | ||
); | ||
}; |
Oops, something went wrong.