From 0be83f2169b0b6d9b78495e7592a267c5aa47261 Mon Sep 17 00:00:00 2001 From: atanasster Date: Fri, 25 Sep 2020 18:46:57 -0400 Subject: [PATCH] feat: add fishtank color token --- .../src/tutorial/design/tokens/colors.mdx | 44 ++++++++++++ .../FishTankColor/FishTankColor.stories.tsx | 53 ++++++++++++++ .../Colors/FishTankColor/FishTankColor.tsx | 72 +++++++++++++++++++ .../src/Colors/FishTankColor/index.ts | 1 + ui/design-tokens/src/Colors/index.ts | 1 + 5 files changed, 171 insertions(+) create mode 100644 ui/design-tokens/src/Colors/FishTankColor/FishTankColor.stories.tsx create mode 100644 ui/design-tokens/src/Colors/FishTankColor/FishTankColor.tsx create mode 100644 ui/design-tokens/src/Colors/FishTankColor/index.ts diff --git a/examples/stories/src/tutorial/design/tokens/colors.mdx b/examples/stories/src/tutorial/design/tokens/colors.mdx index e688de686..8065638aa 100644 --- a/examples/stories/src/tutorial/design/tokens/colors.mdx +++ b/examples/stories/src/tutorial/design/tokens/colors.mdx @@ -25,6 +25,7 @@ import { DuetColorPalette, ETradeColorPalette, FinestraColorPalette, + FishTankColorPalette, } from '@component-controls/design-tokens'; # Overview @@ -773,3 +774,46 @@ import { FinestraColorPalette } from '@component-controls/design-tokens'; }} /> +## FishTankColor + +The [FishTankColor](/api/design-tokens-colors-fishtankcolor--overview) component displays the color as a row with the sass var name and hex color. + +Design inspired from Blooomberg BNA's [FishTank](https://fishtank.bna.com/colors). + +``` +import { FishTankColorPalette } from '@component-controls/design-tokens'; + + +``` + + diff --git a/ui/design-tokens/src/Colors/FishTankColor/FishTankColor.stories.tsx b/ui/design-tokens/src/Colors/FishTankColor/FishTankColor.stories.tsx new file mode 100644 index 000000000..77c1200b8 --- /dev/null +++ b/ui/design-tokens/src/Colors/FishTankColor/FishTankColor.stories.tsx @@ -0,0 +1,53 @@ +import React from 'react'; +import { FishTankColor, FishTankColorPalette } from './FishTankColor'; +import { ColorProps } from '../types'; + +export default { + title: 'Design Tokens/Colors/FishTankColor', + component: FishTankColor, +}; + +export const overview = ({ name, color }: ColorProps) => ( + +); + +overview.controls = { + color: { + type: 'object', + value: { + value: { type: 'color', value: '#0A7DAF' }, + sass: { type: 'color', value: '$color-selected-darkest' }, + }, + }, +}; + +export const palette = () => ( + +); diff --git a/ui/design-tokens/src/Colors/FishTankColor/FishTankColor.tsx b/ui/design-tokens/src/Colors/FishTankColor/FishTankColor.tsx new file mode 100644 index 000000000..9209f11ca --- /dev/null +++ b/ui/design-tokens/src/Colors/FishTankColor/FishTankColor.tsx @@ -0,0 +1,72 @@ +/** @jsx jsx */ +import { FC } from 'react'; +import { jsx, Theme } from 'theme-ui'; +import { CopyContainer } from '@component-controls/components'; +import { colorToStr, mostReadable } from '../utils'; +import { ColorBlockProps, ColorValue } from '../types'; +import { FlexContainerProps, FlexContainer } from '../FlexContainer'; + +/** + * Color item displaying the color as a row with the sass var name and hex color. + * Design inspired from Blooomberg BNA's [FishTank](https://fishtank.bna.com/colors). + */ + +export const FishTankColor: FC = ({ name, color }) => { + const colorObj: ColorValue = + typeof color === 'string' ? { value: color } : color; + const { value: colorValue, sass } = colorObj; + + const { hex } = colorToStr(colorValue); + const textColor = mostReadable(hex); + return ( +
+ +
+
{sass}
+
+ {hex.toUpperCase()} +
+
+
+
+ ); +}; + +/** + * + * palette displayed with FishTankColor items + * using a css flex display direction column + */ +export const FishTankColorPalette: FC> = props => ( + `0 2px 10px 3px ${t.colors?.shadow}`, + }} + {...props} + > + {({ name, value }) => ( + + )} + +); diff --git a/ui/design-tokens/src/Colors/FishTankColor/index.ts b/ui/design-tokens/src/Colors/FishTankColor/index.ts new file mode 100644 index 000000000..95265dd48 --- /dev/null +++ b/ui/design-tokens/src/Colors/FishTankColor/index.ts @@ -0,0 +1 @@ +export * from './FishTankColor'; diff --git a/ui/design-tokens/src/Colors/index.ts b/ui/design-tokens/src/Colors/index.ts index 787646a38..924cab5f1 100644 --- a/ui/design-tokens/src/Colors/index.ts +++ b/ui/design-tokens/src/Colors/index.ts @@ -14,3 +14,4 @@ export * from './CometColor'; export * from './DuetColor'; export * from './ETradeColor'; export * from './FinestraColor'; +export * from './FishTankColor';