-
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
e3ed82d
commit 505c541
Showing
5 changed files
with
203 additions
and
0 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
47 changes: 47 additions & 0 deletions
47
ui/design-tokens/src/Colors/BeelineColor/BeelineColor.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,47 @@ | ||
import React from 'react'; | ||
import { BeelineColor, BeelineColorPalette } from './BeelineColor'; | ||
import { ColorProps } from '../types'; | ||
|
||
export default { | ||
title: 'Design Tokens/Colors/BeelineColor', | ||
component: BeelineColor, | ||
}; | ||
|
||
export const overview = ({ name, color }: ColorProps) => ( | ||
<BeelineColor name={name} color={color} /> | ||
); | ||
|
||
overview.controls = { | ||
name: { type: 'text', value: 'Brand' }, | ||
color: { type: 'color', value: '#2270ee' }, | ||
}; | ||
|
||
export const name = () => <BeelineColor name="Critical" color="#f94d32" />; | ||
|
||
export const rgb = () => <BeelineColor name="text" color="rgb(0, 0, 0)" />; | ||
|
||
export const rgba = () => ( | ||
<BeelineColor name="shadow" color="rgba(0, 0, 0, 0.1)" /> | ||
); | ||
|
||
export const hsl = () => ( | ||
<BeelineColor name="accent" color="hsl(12, 10%, 50%)" /> | ||
); | ||
|
||
export const hsla = () => ( | ||
<BeelineColor name="accent" color="hsl(12, 10%, 50%, .3)" /> | ||
); | ||
|
||
export const palette = () => ( | ||
<BeelineColorPalette | ||
palette={{ | ||
'Blue 5': { value: '#001b38' }, | ||
'Blue Accessibility': { value: '#0352a0' }, | ||
'Blue Primary': { value: '#0575e6' }, | ||
'Blue 1': { value: '#4fa7ff' }, | ||
'Blue 2': { value: '#85dfff' }, | ||
'Blue 3': { value: '#ecf5ff' }, | ||
'Blue 4': { value: '#FBFDFF' }, | ||
}} | ||
/> | ||
); |
118 changes: 118 additions & 0 deletions
118
ui/design-tokens/src/Colors/BeelineColor/BeelineColor.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,118 @@ | ||
/** @jsx jsx */ | ||
import { FC } from 'react'; | ||
import { jsx, Box, Theme } 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 with values for rgb and Pantone colors. | ||
* Design inspired from [Beeline Design System](http://beelinedesignsystem.com/color-palette/). | ||
*/ | ||
export const BeelineColor: FC<ColorBlockProps> = ({ name, color }) => { | ||
const colorValue = typeof color === 'string' ? color : color.value; | ||
const { hex, rgba } = colorToStr(colorValue); | ||
const { color: pantone } = new simpleColorConverter({ | ||
rgba, | ||
to: 'pantone', | ||
}); | ||
return ( | ||
<Box | ||
sx={{ | ||
display: 'flex', | ||
flexDirection: 'column', | ||
bg: 'background', | ||
minWidth: 120, | ||
maxWidth: 320, | ||
border: (t: Theme) => `1px solid ${t.colors?.shadow}`, | ||
borderRadius: 1, | ||
boxShadow: (t: Theme) => `0 1px 2px 0 ${t.colors?.shadow}`, | ||
}} | ||
> | ||
<CopyContainer value={hex} name={name} sxStyle={{ px: 2, pt: 2 }}> | ||
<Box | ||
sx={{ | ||
bg: colorValue, | ||
':after': { | ||
content: '""', | ||
display: 'block', | ||
paddingBottom: '60%', | ||
}, | ||
}} | ||
/> | ||
</CopyContainer> | ||
<Box | ||
sx={{ | ||
display: 'flex', | ||
flexDirection: 'column', | ||
p: 2, | ||
fontSize: 2, | ||
}} | ||
> | ||
<Box | ||
sx={{ | ||
display: 'flex', | ||
flexDirection: 'column', | ||
}} | ||
> | ||
<Box sx={{ pb: 2, fontSize: 3 }}>{name || hex}</Box> | ||
</Box> | ||
<div sx={{ fontSize: 0 }}> | ||
<div | ||
sx={{ | ||
display: 'flex', | ||
flexDirection: 'row', | ||
alignItems: 'center', | ||
}} | ||
> | ||
<div sx={{ fontWeight: 'bold', mr: 1 }}>HEX:</div> | ||
<div>{hex}:</div> | ||
</div> | ||
<div | ||
sx={{ | ||
display: 'flex', | ||
flexDirection: 'row', | ||
alignItems: 'center', | ||
}} | ||
> | ||
<div sx={{ fontWeight: 'bold', mr: 1 }}>RGB:</div> | ||
<div> | ||
{`rgb(${rgba.r},${rgba.g},${rgba.b}${ | ||
rgba.a !== 1 ? `,${rgba.a}` : '' | ||
})`} | ||
: | ||
</div> | ||
</div> | ||
<div | ||
sx={{ | ||
display: 'flex', | ||
flexDirection: 'row', | ||
alignItems: 'center', | ||
}} | ||
> | ||
<div sx={{ fontWeight: 'bold', mr: 1 }}>Pantone:</div> | ||
<div>{pantone || '--'}:</div> | ||
</div> | ||
</div> | ||
</Box> | ||
</Box> | ||
); | ||
}; | ||
|
||
/** | ||
* | ||
* palette displayed with BeelineColor items | ||
* using a css grid for the dsplay | ||
*/ | ||
export const BeelineColorPalette: FC<Omit< | ||
GridContainerProps, | ||
'children' | ||
>> = props => ( | ||
<GridContainer width={170} gap={3} {...props}> | ||
{({ name, value }) => ( | ||
<BeelineColor 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 './BeelineColor'; |
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