diff --git a/client/src/tokens/colors.stories.tsx b/client/src/tokens/colors.stories.tsx new file mode 100644 index 0000000000..e0e76b91d7 --- /dev/null +++ b/client/src/tokens/colors.stories.tsx @@ -0,0 +1,93 @@ +import React from 'react'; +import colors, { Hues, Shade } from './colors'; + +const description = ` +Wagtail’s color palette is structured as design tokens, available as CSS classes. +`; + +interface PaletteProps { + color: string; + hues: Hues; +} + +/** + * Generates a contrast grid URL from our color palette. + */ +const getContrastGridLink = () => { + const url = 'https://contrast-grid.eightshapes.com/'; + const parameters = + '?version=1.1.0&es-color-form__tile-size=compact&es-color-form__show-contrast=aaa&es-color-form__show-contrast=aa&es-color-form__show-contrast=aa18'; + const bg = []; + const fg = []; + Object.values(colors).forEach((hues: Hues) => { + Object.values(hues).forEach((shade: Shade) => { + const color = `${shade.hex}, ${shade.textUtility.replace('w-text-', '')}`; + bg.push(color); + + if (!shade.usage.toLowerCase().includes('background only')) { + fg.push(color); + } + }); + }); + + return `${url}${parameters}&background-colors=${encodeURIComponent( + bg.join('\r\n'), + )}&foreground-colors=${encodeURIComponent(fg.join('\r\n'))}`; +}; + +const Palette = ({ color, hues }: PaletteProps) => ( +
+ {Object.entries(hues).map(([name, shade]) => ( +
+

{`${color} ${name === 'DEFAULT' ? '' : name}`}

+
+ {shade.textUtility} + {shade.bgUtility} + {shade.hex} +
+

{shade.usage}

+
+ ))} +
+); + +/** + * Displays all icons within our sprite. + */ +const ColorPalette = () => ( + <> +

+ View Contrast Grid +

+ {Object.entries(colors).map(([color, hues]) => ( +
+

{color}

+ +
+ ))} + +); + +export default { + title: 'Foundation / Colors', + parameters: { + docs: { + extractComponentDescription: () => description, + }, + }, + // argTypes: { + // color: { + // description: 'Only intended for demo purposes', + // }, + // }, +}; + +export const AllColors = (args) => ; + +AllColors.args = {}; diff --git a/wagtail/admin/templates/wagtailadmin/shared/icons.stories.tsx b/wagtail/admin/templates/wagtailadmin/shared/icons.stories.tsx index c5837762d7..e66546154c 100644 --- a/wagtail/admin/templates/wagtailadmin/shared/icons.stories.tsx +++ b/wagtail/admin/templates/wagtailadmin/shared/icons.stories.tsx @@ -1,6 +1,12 @@ import React, { useState, useEffect } from 'react'; import { getTemplatePattern } from 'storybook-django/src/react'; +const description = ` +Wagtail comes with a base icon set, which can be extended by site implementers. + +Here is a list of all available icons, auto-generated from our SVG sprite. +`; + /** * Displays all icons within our sprite. */ @@ -48,6 +54,12 @@ const IconsTable = ({ color }: { color: string }) => { }; export default { + title: 'Foundation / Icons', + parameters: { + docs: { + extractComponentDescription: () => description, + }, + }, argTypes: { color: { description: 'Only intended for demo purposes', @@ -55,8 +67,8 @@ export default { }, }; -export const Icons = (args) => ; +export const AllIcons = (args) => ; -Icons.args = { +AllIcons.args = { color: 'currentColor', };