-
Notifications
You must be signed in to change notification settings - Fork 8
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
1 parent
c973790
commit 683b617
Showing
14 changed files
with
236 additions
and
30 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
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
54 changes: 54 additions & 0 deletions
54
ui/design-tokens/src/Colors/ColorBlock6/ColorBlock6.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 |
---|---|---|
@@ -0,0 +1,54 @@ | ||
import React from 'react'; | ||
import { ColorBlock6, ColorBlock6Palette } from './ColorBlock6'; | ||
import { ColorProps } from '../types'; | ||
|
||
export default { | ||
title: 'Design Tokens/Colors/ColorBlock6', | ||
component: ColorBlock6, | ||
}; | ||
|
||
export const overview = ({ name, color }: ColorProps) => ( | ||
<ColorBlock6 name={name} color={color} /> | ||
); | ||
|
||
overview.controls = { | ||
name: { type: 'text', value: 'Brand' }, | ||
color: { | ||
type: 'object', | ||
value: { | ||
value: { type: 'color', value: '#2270ee' }, | ||
name: { type: 'text', value: 'Blue400' }, | ||
}, | ||
}, | ||
}; | ||
|
||
export const name = () => ( | ||
<ColorBlock6 name="Critical" color={{ name: 'brand', value: '#f94d32' }} /> | ||
); | ||
|
||
export const rgb = () => <ColorBlock6 name="text" color="rgb(0, 0, 0)" />; | ||
|
||
export const rgba = () => ( | ||
<ColorBlock6 name="shadow" color="rgba(0, 0, 0, 0.1)" /> | ||
); | ||
|
||
export const hsl = () => ( | ||
<ColorBlock6 name="accent" color="hsl(12, 10%, 50%)" /> | ||
); | ||
|
||
export const hsla = () => ( | ||
<ColorBlock6 name="accent" color="hsl(12, 10%, 50%, .3)" /> | ||
); | ||
|
||
export const palette = () => ( | ||
<ColorBlock6Palette | ||
palette={{ | ||
'Poppy surprise': { value: '#FF5630', name: 'R300' }, | ||
'Golden state': { value: '#FFAB00', name: 'Y300' }, | ||
'Fine pine': { value: '#36B37E', name: 'G300' }, | ||
Tamarama: { value: '#00B8D9', name: 'T300' }, | ||
"Da' juice": { value: '#6554C0', name: 'P300' }, | ||
Critical: { value: '#f94d32', name: 'Red400' }, | ||
}} | ||
/> | ||
); |
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,99 @@ | ||
/** @jsx jsx */ | ||
import { FC } from 'react'; | ||
import { jsx, Box } from 'theme-ui'; | ||
import { CopyContainer } from '@component-controls/components'; | ||
import simpleColorConverter from 'simple-color-converter'; | ||
import { colorToStr } from '../utils'; | ||
import { ColorBlockProps } from '../types'; | ||
import { GridContainerProps, GridContainer } from '../GridContainer'; | ||
|
||
/** | ||
* Color item displaying the color as a block and color aliases for various standard is Pantone, CMYK. | ||
* Design inspired from [Audi Design System](https://www.audi.com/ci/en/intro/basics/colours.html). | ||
*/ | ||
export const ColorBlock6: FC<ColorBlockProps> = ({ name, color, sx }) => { | ||
const colorValue = typeof color === 'string' ? color : color.value; | ||
const { hex, rgba } = colorToStr(colorValue); | ||
const { color: cmyk } = new simpleColorConverter({ | ||
rgba, | ||
to: 'cmyk', | ||
}); | ||
const { color: ral } = new simpleColorConverter({ | ||
rgba, | ||
to: 'ral', | ||
}); | ||
const { color: pantone } = new simpleColorConverter({ | ||
rgba, | ||
to: 'pantone', | ||
}); | ||
return ( | ||
<Box | ||
sx={{ | ||
display: 'flex', | ||
flexDirection: 'column', | ||
minWidth: 180, | ||
maxWidth: 450, | ||
}} | ||
> | ||
<CopyContainer value={hex} name={name}> | ||
<Box | ||
sx={{ | ||
bg: colorValue, | ||
':after': { | ||
content: '""', | ||
display: 'block', | ||
paddingBottom: '100%', | ||
}, | ||
}} | ||
/> | ||
</CopyContainer> | ||
<Box | ||
sx={{ | ||
display: 'flex', | ||
flexDirection: 'column', | ||
lineHeight: '16px', | ||
bg: 'muted', | ||
p: 3, | ||
fontSize: 2, | ||
...sx, | ||
}} | ||
> | ||
<Box | ||
sx={{ | ||
display: 'flex', | ||
flexDirection: 'column', | ||
}} | ||
> | ||
<Box sx={{ pt: 1, pb: 2, fontWeight: 'bold' }}>{name || hex}</Box> | ||
</Box> | ||
<div sx={{ lineHeight: 1.5 }}> | ||
<div> | ||
{`RGB: ${rgba.r}/${rgba.g}/${rgba.b}${ | ||
rgba.a !== 1 ? `/${rgba.a}` : '' | ||
}`} | ||
</div> | ||
<div>{`HEX: ${hex}`}</div> | ||
<div>{`CMYK: ${cmyk.c}/${cmyk.m}/${cmyk.y}/${cmyk.k}`}</div> | ||
<div sx={{ mb: 1 }}>{`${pantone ? `Pantone ${pantone}` : '--'}`}</div> | ||
<div>{`RAL: ${ral.ral}`}</div> | ||
</div> | ||
</Box> | ||
</Box> | ||
); | ||
}; | ||
|
||
/** | ||
* | ||
* palette displayed with ColorBlock6 items | ||
* using a css grid for the dsplay | ||
*/ | ||
export const ColorBlock6Palette: FC<Omit< | ||
GridContainerProps, | ||
'children' | ||
>> = props => ( | ||
<GridContainer {...props}> | ||
{({ name, value }) => ( | ||
<ColorBlock6 key={`color_item_${name}}`} name={name} color={value} /> | ||
)} | ||
</GridContainer> | ||
); |
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 @@ | ||
export * from './ColorBlock6'; |
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.