Skip to content

Commit

Permalink
feat: Add initial documentation for colour palette (#1060)
Browse files Browse the repository at this point in the history
Co-authored-by: Aram <[email protected]>
  • Loading branch information
VincentSmedinga and alimpens authored Jan 31, 2024
1 parent 0e663bd commit bc23b43
Show file tree
Hide file tree
Showing 3 changed files with 127 additions and 0 deletions.
36 changes: 36 additions & 0 deletions storybook/storybook-docs/src/color.stories.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
import tokens from "@amsterdam/design-system-tokens/dist/index.tokens.json";
import { Meta } from "@storybook/blocks";
import { ColorPalette } from "./components/ColorPalette";

<Meta title="Docs/Assets/Colour" />

# Colour

The basic colours of Amsterdam are white, red, and black.
We have 8 additional colours and 3 shades of grey.

<ColorPalette>
<ColorPalette.Section>
<ColorPalette.Tile color={tokens.amsterdam.color["primary-white"]} name="white" />
<ColorPalette.Tile color={tokens.amsterdam.color["primary-red"]} name="red" />
<ColorPalette.Tile color={tokens.amsterdam.color["primary-black"]} name="black" />
</ColorPalette.Section>
<ColorPalette.Section>
<ColorPalette.Tile color={tokens.amsterdam.color["green"]} name="green" />
<ColorPalette.Tile color={tokens.amsterdam.color["dark-green"]} name="dark green" />
<ColorPalette.Tile color={tokens.amsterdam.color["blue"]} name="blue" />
<ColorPalette.Tile color={tokens.amsterdam.color["primary-blue"]} name="dark blue" />
<ColorPalette.Tile color={tokens.amsterdam.color["dark-blue"]} name="darker blue" />
</ColorPalette.Section>
<ColorPalette.Section>
<ColorPalette.Tile color={tokens.amsterdam.color["yellow"]} name="yellow" />
<ColorPalette.Tile color={tokens.amsterdam.color["orange"]} name="orange" />
<ColorPalette.Tile color={tokens.amsterdam.color["magenta"]} name="magenta" />
<ColorPalette.Tile color={tokens.amsterdam.color["purple"]} name="purple" />
</ColorPalette.Section>
<ColorPalette.Section>
<ColorPalette.Tile color={tokens.amsterdam.color["neutral-grey1"]} name="light grey" />
<ColorPalette.Tile color={tokens.amsterdam.color["neutral-grey2"]} name="grey" />
<ColorPalette.Tile color={tokens.amsterdam.color["neutral-grey3"]} name="dark grey" />
</ColorPalette.Section>
</ColorPalette>
41 changes: 41 additions & 0 deletions storybook/storybook-docs/src/components/ColorPalette.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
import './color-palette.css'
import { forwardRef } from 'react'
import type { ForwardedRef, ForwardRefExoticComponent, HTMLAttributes, PropsWithChildren, RefAttributes } from 'react'

export type DivProps = PropsWithChildren<HTMLAttributes<HTMLDivElement>>

type ColorPaletteComponent = {
Section: typeof ColorPaletteSection
Tile: typeof ColorPaletteTile
} & ForwardRefExoticComponent<DivProps & RefAttributes<HTMLDivElement>>

export const ColorPalette = forwardRef(({ children, ...restProps }: DivProps, ref: ForwardedRef<HTMLDivElement>) => (
<div {...restProps} ref={ref} className="amsterdam-storybook-color-palette">
{children}
</div>
)) as ColorPaletteComponent

export const ColorPaletteSection = ({ children }: DivProps) => (
<div className="amsterdam-storybook-color-palette__section">{children}</div>
)

type ColourPaletteTileProps = {
color: string
name: string
}

export const ColorPaletteTile = ({ name, color }: ColourPaletteTileProps) => (
<div className="amsterdam-storybook-color-palette__tile">
<div className="amsterdam-storybook-color-palette__example" style={{ backgroundColor: color }} />
<dl className="sb-unstyled amsterdam-storybook-color-palette__description">
<dt className="amsterdam-storybook-color-palette__name">{name}</dt>
<dd className="amsterdam-storybook-color-palette__color">{color}</dd>
</dl>
</div>
)

ColorPalette.Section = ColorPaletteSection
ColorPalette.Tile = ColorPaletteTile
ColorPalette.displayName = 'ColourPalette'
ColorPaletteSection.displayName = 'ColourPalette.Section'
ColorPaletteTile.displayName = 'ColourPalette.Tile'
50 changes: 50 additions & 0 deletions storybook/storybook-docs/src/components/color-palette.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
.amsterdam-storybook-color-palette {
display: flex;
flex-direction: column;
gap: 2rem;
}

.amsterdam-storybook-color-palette__section {
align-items: start;
display: grid;
gap: 2rem;
grid-template-columns: repeat(5, 1fr);
}

.amsterdam-storybook-color-palette__tile {
display: flex;
flex-direction: column;
gap: 0.25rem;
}

.amsterdam-storybook-color-palette__example {
aspect-ratio: 16 / 9;
border: 1px solid rgb(0 0 0 / 12.5%);
grid-area: example;
}

.amsterdam-storybook-color-palette__description,
.amsterdam-storybook-color-palette__name,
.amsterdam-storybook-color-palette__color {
margin-block: 0;
margin-inline: 0;
padding-block: 0;
padding-inline: 0;
}

.amsterdam-storybook-color-palette__description {
color: #000;
column-gap: 1ch;
display: flex;
flex-wrap: wrap;
font-family: "Amsterdam Sans", "Arial", sans-serif;
justify-content: space-between;
}

.amsterdam-storybook-color-palette__name {
font-weight: 800;
}

.amsterdam-storybook-color-palette__color {
text-align: end;
}

0 comments on commit bc23b43

Please sign in to comment.