diff --git a/examples/stories/src/tutorial/design/tokens/colors.mdx b/examples/stories/src/tutorial/design/tokens/colors.mdx index a0bb31896..134301765 100644 --- a/examples/stories/src/tutorial/design/tokens/colors.mdx +++ b/examples/stories/src/tutorial/design/tokens/colors.mdx @@ -26,6 +26,7 @@ import { ETradeColorPalette, FinastraColorPalette, FishTankColorPalette, + GovUKColorPalette, } from '@component-controls/design-tokens'; # Overview @@ -817,3 +818,55 @@ import { FishTankColorPalette } from '@component-controls/design-tokens'; }, }} /> + +## GovUKColor + +The [GovUKColor](/api/design-tokens-colors-govukcolor--overview) component displays the color as a row with a color circle and the sass var name and hex color. + +Design inspired from [GOV.UK Design System](https://design-system.service.gov.uk/styles/colour/). + +``` +import { GovUKColorPalette } from '@component-controls/design-tokens'; + + +``` + + diff --git a/ui/design-tokens/src/Colors/GovUKColor/GovUKColor.stories.tsx b/ui/design-tokens/src/Colors/GovUKColor/GovUKColor.stories.tsx new file mode 100644 index 000000000..88dbb8d66 --- /dev/null +++ b/ui/design-tokens/src/Colors/GovUKColor/GovUKColor.stories.tsx @@ -0,0 +1,45 @@ +import React from 'react'; +import { GovUKColor, GovUKColorPalette } from './GovUKColor'; +import { ColorProps } from '../types'; + +export default { + title: 'Design Tokens/Colors/GovUKColor', + component: GovUKColor, +}; + +export const overview = ({ name, color }: ColorProps) => ( + +); + +overview.controls = { + color: { + type: 'object', + value: { + value: { type: 'color', value: '#1d70b8' }, + sass: { type: 'color', value: '$govuk-brand-colour' }, + }, + }, +}; + +export const palette = () => ( + +); diff --git a/ui/design-tokens/src/Colors/GovUKColor/GovUKColor.tsx b/ui/design-tokens/src/Colors/GovUKColor/GovUKColor.tsx new file mode 100644 index 000000000..8376606a2 --- /dev/null +++ b/ui/design-tokens/src/Colors/GovUKColor/GovUKColor.tsx @@ -0,0 +1,74 @@ +/** @jsx jsx */ +import { FC } from 'react'; +import { jsx } from 'theme-ui'; +import { CopyContainer } from '@component-controls/components'; +import { colorToStr } from '../utils'; +import { ColorBlockProps, ColorValue } from '../types'; +import { FlexContainerProps, FlexContainer } from '../FlexContainer'; + +/** + * Color item displaying the color as a row with a color circle and the sass var name and hex color. + * Design inspired from [GOV.UK Design System](https://design-system.service.gov.uk/styles/colour/). + */ + +export const GovUKColor: FC = ({ name, color }) => { + const colorObj: ColorValue = + typeof color === 'string' ? { value: color } : color; + const { value: colorValue, sass, varName } = colorObj; + + const { hex } = colorToStr(colorValue); + return ( +
+
+ +
+ +
+
{sass || varName}
+
{hex}
+
+
+
+ ); +}; + +/** + * + * palette displayed with GovUKDS items + * using a css flex display direction column + */ +export const GovUKColorPalette: FC> = props => ( + + {({ name, value }) => ( + + )} + +); diff --git a/ui/design-tokens/src/Colors/GovUKColor/index.ts b/ui/design-tokens/src/Colors/GovUKColor/index.ts new file mode 100644 index 000000000..210c64737 --- /dev/null +++ b/ui/design-tokens/src/Colors/GovUKColor/index.ts @@ -0,0 +1 @@ +export * from './GovUKColor'; diff --git a/ui/design-tokens/src/Colors/index.ts b/ui/design-tokens/src/Colors/index.ts index 3c20fbae0..c9c67e43c 100644 --- a/ui/design-tokens/src/Colors/index.ts +++ b/ui/design-tokens/src/Colors/index.ts @@ -15,3 +15,4 @@ export * from './DuetColor'; export * from './ETradeColor'; export * from './FinastraColor'; export * from './FishTankColor'; +export * from './GovUKColor';