-
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
8553fd1
commit 27a1445
Showing
5 changed files
with
143 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
35 changes: 35 additions & 0 deletions
35
ui/design-tokens/src/Colors/ZendeskColor/ZendeskColor.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,35 @@ | ||
import React from 'react'; | ||
import { ControlTypes } from '@component-controls/core'; | ||
import { ZendeskColor, ZendeskColorPalette } from './ZendeskColor'; | ||
import { ColorProps } from '../../types'; | ||
|
||
export default { | ||
title: 'Design Tokens/Colors/ZendeskColor', | ||
component: ZendeskColor, | ||
}; | ||
|
||
export const overview = ({ name, color }: ColorProps) => ( | ||
<ZendeskColor name={name} color={color} /> | ||
); | ||
|
||
overview.controls = { | ||
name: 'Rich Purple', | ||
color: { type: ControlTypes.COLOR, value: '#503291' }, | ||
}; | ||
|
||
export const palette = () => ( | ||
<ZendeskColorPalette | ||
palette={{ | ||
support: '#00A656', | ||
message: '#37B8AF', | ||
explore: '#30AABC', | ||
gather: '#F6C8BE', | ||
guide: '#FF6224', | ||
connect: '#FF6224', | ||
chat: '#F79A3E', | ||
talk: '#EFC93D', | ||
sell: '#C38F00', | ||
'100 ': '#F8F9F9', | ||
}} | ||
/> | ||
); |
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,64 @@ | ||
/** @jsx jsx */ | ||
import { FC } from 'react'; | ||
import { jsx, Theme } from 'theme-ui'; | ||
import { CopyContainer } from '@component-controls/components'; | ||
import { colorToStr } from '../utils'; | ||
import { ColorBlockProps } from '../../types'; | ||
import { GridContainerProps, GridContainer } from '../../components'; | ||
|
||
/** | ||
* Color item displaying the color as a small block with the color name and hex value. | ||
* Design inspired from [Zendesk Garden](https://zendeskgarden.github.io/react-components/theming/#!/PALETTE). | ||
*/ | ||
export const ZendeskColor: FC<ColorBlockProps> = ({ name, color }) => { | ||
const colorValue = typeof color === 'string' ? color : color.value; | ||
const { hex } = colorToStr(colorValue); | ||
return ( | ||
<div | ||
sx={{ | ||
display: 'flex', | ||
flexDirection: 'column', | ||
bg: 'background', | ||
minWidth: 70, | ||
fontSize: 0, | ||
maxWidth: 120, | ||
border: (t: Theme) => `1px solid ${t.colors?.shadow}`, | ||
borderRadius: 1, | ||
boxShadow: (t: Theme) => `0px 8px 12px 0px ${t.colors?.shadow}`, | ||
}} | ||
> | ||
<CopyContainer value={hex} name={name}> | ||
<div | ||
sx={{ | ||
bg: colorValue, | ||
':after': { | ||
content: '""', | ||
display: 'block', | ||
paddingBottom: '100%', | ||
}, | ||
}} | ||
/> | ||
</CopyContainer> | ||
<div sx={{ p: 1, display: 'flex', flexDirection: 'column' }}> | ||
<div sx={{ fontWeight: 'heading' }}>{name}</div> | ||
<div>{hex}</div> | ||
</div> | ||
</div> | ||
); | ||
}; | ||
|
||
/** | ||
* | ||
* palette displayed with ZendeskColor items | ||
* using a css grid for the dsplay | ||
*/ | ||
export const ZendeskColorPalette: FC<Omit< | ||
GridContainerProps, | ||
'children' | ||
>> = props => ( | ||
<GridContainer width={80} gap={2} {...props}> | ||
{({ name, value }) => ( | ||
<ZendeskColor 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 './ZendeskColor'; |
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