diff --git a/examples/stories/src/tutorial/design/tokens/colors.mdx b/examples/stories/src/tutorial/design/tokens/colors.mdx index 80b6613a3..4b86d9197 100644 --- a/examples/stories/src/tutorial/design/tokens/colors.mdx +++ b/examples/stories/src/tutorial/design/tokens/colors.mdx @@ -38,6 +38,7 @@ import { PajamasColorPalette, PatternFlyColorPalette, PhotonColorPalette, + PrimerColorPalette, } from '@component-controls/design-tokens'; # Overview @@ -1474,3 +1475,33 @@ import { PhotonColorPalette } from '@component-controls/design-tokens'; }} /> +## PrimerColor + +The [PrimerColor](/api/design-tokens-colors-primercolor--overview) component displays the color as a row, with sass variable name. Separate visualization (header) for primary color. + +Design inspired from GitHub's [Primer](https://styleguide.github.com/primer/support/color-system/). + +``` +import { PrimerColorPalette } from '@component-controls/design-tokens'; + + +``` + + + diff --git a/ui/design-tokens/src/Colors/PrimerColor/PrimerColor.stories.tsx b/ui/design-tokens/src/Colors/PrimerColor/PrimerColor.stories.tsx new file mode 100644 index 000000000..3df086287 --- /dev/null +++ b/ui/design-tokens/src/Colors/PrimerColor/PrimerColor.stories.tsx @@ -0,0 +1,42 @@ +import React from 'react'; +import { PrimerColor, PrimerColorPalette } from './PrimerColor'; +import { ColorProps } from '../../types'; + +export default { + title: 'Design Tokens/Colors/PrimerColor', + component: PrimerColor, +}; + +export const overview = ({ name, color }: ColorProps) => ( + +); + +overview.controls = { + name: 'Yellow', + color: { + type: 'object', + value: { + value: { type: 'color', value: '#ffd33d' }, + sass: '$yellow-500', + primary: { type: 'boolean', value: true }, + }, + }, +}; + +export const palette = () => ( + +); diff --git a/ui/design-tokens/src/Colors/PrimerColor/PrimerColor.tsx b/ui/design-tokens/src/Colors/PrimerColor/PrimerColor.tsx new file mode 100644 index 000000000..695fa82f3 --- /dev/null +++ b/ui/design-tokens/src/Colors/PrimerColor/PrimerColor.tsx @@ -0,0 +1,78 @@ +/** @jsx jsx */ +import { FC } from 'react'; +import { jsx } from 'theme-ui'; +import { CopyContainer } from '@component-controls/components'; +import { colorToStr, mostReadable } from '../utils'; +import { ColorBlockProps, ColorValue } from '../../types'; +import { FlexContainerProps, FlexContainer } from '../../components'; + +/** + * Color item displaying the color as a row, with sass variable name. Separate visualization (header) for primary color. + * Design inspired from GitHub's [Primer](https://styleguide.github.com/primer/support/color-system/). + */ + +export const PrimerColor: FC = ({ name, color }) => { + const colorObj: ColorValue = + typeof color === 'string' ? { value: color } : color; + const { value: colorValue, primary, sass } = colorObj; + + const { hex } = colorToStr(colorValue); + const textColor = mostReadable(hex); + + return ( +
+ +
+ {primary &&
{name}
} +
+
+ {sass} +
+
{hex}
+
+
+
+
+ ); +}; + +/** + * + * palette displayed with PrimerColor items + * using a css flex display direction column + */ +export const PrimerColorPalette: FC> = props => ( + + {({ name, value }) => ( + + )} + +); diff --git a/ui/design-tokens/src/Colors/PrimerColor/index.ts b/ui/design-tokens/src/Colors/PrimerColor/index.ts new file mode 100644 index 000000000..a38f77149 --- /dev/null +++ b/ui/design-tokens/src/Colors/PrimerColor/index.ts @@ -0,0 +1 @@ +export * from './PrimerColor'; diff --git a/ui/design-tokens/src/Colors/index.ts b/ui/design-tokens/src/Colors/index.ts index bb3c74b76..f222df440 100644 --- a/ui/design-tokens/src/Colors/index.ts +++ b/ui/design-tokens/src/Colors/index.ts @@ -25,3 +25,4 @@ export * from './OPatternColor'; export * from './PajamasColor'; export * from './PatternFlyColor'; export * from './PhotonColor'; +export * from './PrimerColor';