-
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
10296e1
commit c303439
Showing
5 changed files
with
154 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
41 changes: 41 additions & 0 deletions
41
ui/design-tokens/src/Colors/VanillaColor/VanillaColor.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,41 @@ | ||
import React from 'react'; | ||
import { ControlTypes } from '@component-controls/core'; | ||
import { VanillaColor, VanillaColorPalette } from './VanillaColor'; | ||
import { ColorProps } from '../../types'; | ||
|
||
export default { | ||
title: 'Design Tokens/Colors/VanillaColor', | ||
component: VanillaColor, | ||
}; | ||
|
||
export const overview = ({ name, color }: ColorProps) => ( | ||
<VanillaColor name={name} color={color} /> | ||
); | ||
|
||
overview.controls = { | ||
name: 'negative', | ||
color: { | ||
type: ControlTypes.OBJECT, | ||
value: { | ||
value: { type: ControlTypes.COLOR, value: '#C7162B' }, | ||
sass: '$color-negative', | ||
}, | ||
}, | ||
}; | ||
|
||
export const palette = () => ( | ||
<VanillaColorPalette | ||
palette={{ | ||
'x-light': { value: '#FFF', sass: '$color-x-light' }, | ||
brand: { value: '#333', sass: '$color-brand' }, | ||
caution: { value: '#F99B11', sass: '$color-caution' }, | ||
negative: { value: '#C7162B', sass: '$color-negative' }, | ||
positive: { value: '#0E8420', sass: '$color-positive' }, | ||
information: { value: '#06C', sass: '$color-information' }, | ||
'navigation-background': { | ||
value: '#FFF', | ||
sass: '$color-navigation-background', | ||
}, | ||
}} | ||
/> | ||
); |
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,69 @@ | ||
/** @jsx jsx */ | ||
import { FC } from 'react'; | ||
import { jsx, Theme } from 'theme-ui'; | ||
import { CopyContainer } from '@component-controls/components'; | ||
import { ColorBlockProps, ColorValue } from '../../types'; | ||
import { GridContainerProps, GridContainer } from '../../components'; | ||
|
||
/** | ||
* Color item displaying the color as a color block with sass variable name and hex color value. | ||
* Design inspired from [Vanilla](https://vanillaframework.io/docs/settings/color-settings). | ||
*/ | ||
export const VanillaColor: FC<ColorBlockProps> = ({ name, color }) => { | ||
const colorObj: ColorValue = | ||
typeof color === 'string' ? { value: color } : color; | ||
const { value: colorValue, sass } = colorObj; | ||
return ( | ||
<div | ||
sx={{ | ||
display: 'flex', | ||
flexDirection: 'column', | ||
bg: 'background', | ||
minWidth: 100, | ||
maxWidth: 320, | ||
border: (t: Theme) => `1px solid ${t.colors?.shadow}`, | ||
}} | ||
> | ||
<CopyContainer | ||
value={colorValue} | ||
name={name} | ||
sx={{ | ||
border: (t: Theme) => `1px solid ${t.colors?.shadow}`, | ||
bg: colorValue, | ||
':after': { | ||
content: '""', | ||
display: 'block', | ||
paddingBottom: '30%', | ||
}, | ||
}} | ||
/> | ||
<div | ||
sx={{ | ||
display: 'flex', | ||
flexDirection: 'column', | ||
p: 2, | ||
fontSize: 2, | ||
}} | ||
> | ||
<div>{sass}</div> | ||
<div>{colorValue}</div> | ||
</div> | ||
</div> | ||
); | ||
}; | ||
|
||
/** | ||
* | ||
* palette displayed with VanillaColor items | ||
* using a css grid for the dsplay | ||
*/ | ||
export const VanillaColorPalette: FC<Omit< | ||
GridContainerProps, | ||
'children' | ||
>> = props => ( | ||
<GridContainer width={150} gap={3} {...props}> | ||
{({ name, value }) => ( | ||
<VanillaColor 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 './VanillaColor'; |
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