From e4f4d847cff4c5c94a246a5c3dd64d7a48c00521 Mon Sep 17 00:00:00 2001 From: HZ991 Date: Tue, 19 Nov 2024 16:25:21 +1100 Subject: [PATCH 1/6] add: brand font weight table --- .../brand-font-weight.component.tsx | 127 ++++++++++++++++++ .../brand-font-weight.preview.tsx | 11 ++ .../brand-font-weight.styles.ts | 8 ++ .../component-blocks/foundation-blocks.tsx | 4 + .../font/design/brand-font/content.mdoc | 2 + 5 files changed, 152 insertions(+) create mode 100644 apps/site/src/components/component-blocks/components/brand-font-weight/brand-font-weight.component.tsx create mode 100644 apps/site/src/components/component-blocks/components/brand-font-weight/brand-font-weight.preview.tsx create mode 100644 apps/site/src/components/component-blocks/components/brand-font-weight/brand-font-weight.styles.ts diff --git a/apps/site/src/components/component-blocks/components/brand-font-weight/brand-font-weight.component.tsx b/apps/site/src/components/component-blocks/components/brand-font-weight/brand-font-weight.component.tsx new file mode 100644 index 000000000..cbd3bc6ec --- /dev/null +++ b/apps/site/src/components/component-blocks/components/brand-font-weight/brand-font-weight.component.tsx @@ -0,0 +1,127 @@ +'use client'; + +import { + Table, + TableBody, + TableCaption, + TableCell, + TableHeader, + TableHeaderCell, + TableHeaderRow, + TableRow, +} from '@westpac/ui'; +import clsx from 'clsx'; +import React from 'react'; + +import { useBrand } from '@/app/design-system/hooks/use-brand'; + +import { styles as BrandFontWeightStyles } from './brand-font-weight.styles'; + +interface BrandFontWeightProps { + caption: string; + type: 'brand' | 'body'; +} + +const FONT_LIGHT = 'font-light'; +const FONT_REGULAR = 'font-regular'; +const FONT_BOLD = 'font-bold'; + +const FONTS_PER_BRAND = { + bom: [ + { + fontWeight: 'Light', + className: FONT_LIGHT, + }, + { + fontWeight: 'Regular', + className: FONT_REGULAR, + }, + { + fontWeight: 'Bold', + className: FONT_BOLD, + }, + ], + bsa: [ + { + fontWeight: 'Light', + className: FONT_LIGHT, + }, + { + fontWeight: 'Bold', + className: FONT_BOLD, + }, + ], + rams: [ + { + fontWeight: 'Regular', + className: FONT_REGULAR, + }, + { + fontWeight: 'Semi-bold', //600 + className: 'font-semibold', + }, + { + fontWeight: 'Bold', // 700 900 + className: FONT_BOLD, + }, + ], + stg: [ + { + fontWeight: 'Bold', + className: FONT_BOLD, + }, + ], + wbc: [ + { + fontWeight: 'Bold', + className: FONT_BOLD, + }, + ], + wbg: [ + { + fontWeight: 'Light', //100 - 300 + className: FONT_LIGHT, + }, + { + fontWeight: 'Regular', //400 - 600 + className: FONT_REGULAR, + }, + { + fontWeight: 'Bold', //700 - 900 + className: FONT_BOLD, + }, + ], +} as const; + +export function BrandFontWeight({ type, caption }: BrandFontWeightProps) { + const brand = useBrand(); + const fonts = FONTS_PER_BRAND[brand?.key || 'wbc']; + + return ( +
+ + GEL brand font weight tokens + + + Token + Font weight + Tailwind class + + + + {fonts.map(i => ( + + + {i.className.replace('font-', '')} + + + {i.fontWeight} {brand?.fontName} + + {i.className} + + ))} + +
+
+ ); +} diff --git a/apps/site/src/components/component-blocks/components/brand-font-weight/brand-font-weight.preview.tsx b/apps/site/src/components/component-blocks/components/brand-font-weight/brand-font-weight.preview.tsx new file mode 100644 index 000000000..97e9d30db --- /dev/null +++ b/apps/site/src/components/component-blocks/components/brand-font-weight/brand-font-weight.preview.tsx @@ -0,0 +1,11 @@ +import { NotEditable, component, fields } from '@keystatic/core'; + +export const brandFontWeight = component({ + preview: () => ( + +
Brand Font Weight
+
+ ), + label: 'Brand Font Weight', + schema: {}, +}); diff --git a/apps/site/src/components/component-blocks/components/brand-font-weight/brand-font-weight.styles.ts b/apps/site/src/components/component-blocks/components/brand-font-weight/brand-font-weight.styles.ts new file mode 100644 index 000000000..1ee23cc0a --- /dev/null +++ b/apps/site/src/components/component-blocks/components/brand-font-weight/brand-font-weight.styles.ts @@ -0,0 +1,8 @@ +import { tv } from 'tailwind-variants'; + +export const styles = tv({ + slots: { + contentContainer: 'mb-5 mt-4 max-w-5xl bg-white p-6 pb-0', + tableContainer: 'relative -mx-6 -mt-6 border-muted-50 px-6 pb-6 pt-9', + }, +}); diff --git a/apps/site/src/components/component-blocks/foundation-blocks.tsx b/apps/site/src/components/component-blocks/foundation-blocks.tsx index 245a3fe75..1d1c322f9 100644 --- a/apps/site/src/components/component-blocks/foundation-blocks.tsx +++ b/apps/site/src/components/component-blocks/foundation-blocks.tsx @@ -5,6 +5,8 @@ import { colors } from './colors/colors.preview'; import { accessibilityDemo } from './components/accessibility-demo/accessibility-demo.preview'; import { AvailabilityContent } from './components/availability-content/availability-content.component'; import { availabilityContent } from './components/availability-content/availability-content.preview'; +import { BrandFontWeight } from './components/brand-font-weight/brand-font-weight.component'; +import { brandFontWeight } from './components/brand-font-weight/brand-font-weight.preview'; import { designSystemBodyImage } from './components/design-system-body-image'; import { LinkList } from './components/link-list'; import { linkList } from './components/link-list/link-list.preview'; @@ -32,6 +34,7 @@ export const foundationBlocks = { shortCode, accessibilityDemo, availabilityContent, + brandFontWeight, }; export const foundationBlocksComponents = { @@ -48,4 +51,5 @@ export const foundationBlocksComponents = { ), availabilityContent: (props: any) => , + brandFontWeight: (props: any) => , }; diff --git a/apps/site/src/content/design-system/foundation/font/design/brand-font/content.mdoc b/apps/site/src/content/design-system/foundation/font/design/brand-font/content.mdoc index 91290bb0f..01dd7238f 100644 --- a/apps/site/src/content/design-system/foundation/font/design/brand-font/content.mdoc +++ b/apps/site/src/content/design-system/foundation/font/design/brand-font/content.mdoc @@ -5,3 +5,5 @@ Check the [Masterbrand Guidelines](https://westpacgroup.sharepoint.com/:f:/s/O36 ***Note:*** *Never use a web font without confirmation that you have the correct licence agreement in place.* {% fonts /%} + +{% brandFontWeight /%} From 48f0701a875db92f4e7202b58cd2ea81d5a9fc04 Mon Sep 17 00:00:00 2001 From: HZ991 Date: Tue, 19 Nov 2024 16:25:21 +1100 Subject: [PATCH 2/6] add: brand font weight table --- .../brand-font-weight.component.tsx | 127 ++++++++++++++++++ .../brand-font-weight.preview.tsx | 11 ++ .../brand-font-weight.styles.ts | 8 ++ .../component-blocks/foundation-blocks.tsx | 4 + 4 files changed, 150 insertions(+) create mode 100644 apps/site/src/components/component-blocks/components/brand-font-weight/brand-font-weight.component.tsx create mode 100644 apps/site/src/components/component-blocks/components/brand-font-weight/brand-font-weight.preview.tsx create mode 100644 apps/site/src/components/component-blocks/components/brand-font-weight/brand-font-weight.styles.ts diff --git a/apps/site/src/components/component-blocks/components/brand-font-weight/brand-font-weight.component.tsx b/apps/site/src/components/component-blocks/components/brand-font-weight/brand-font-weight.component.tsx new file mode 100644 index 000000000..cbd3bc6ec --- /dev/null +++ b/apps/site/src/components/component-blocks/components/brand-font-weight/brand-font-weight.component.tsx @@ -0,0 +1,127 @@ +'use client'; + +import { + Table, + TableBody, + TableCaption, + TableCell, + TableHeader, + TableHeaderCell, + TableHeaderRow, + TableRow, +} from '@westpac/ui'; +import clsx from 'clsx'; +import React from 'react'; + +import { useBrand } from '@/app/design-system/hooks/use-brand'; + +import { styles as BrandFontWeightStyles } from './brand-font-weight.styles'; + +interface BrandFontWeightProps { + caption: string; + type: 'brand' | 'body'; +} + +const FONT_LIGHT = 'font-light'; +const FONT_REGULAR = 'font-regular'; +const FONT_BOLD = 'font-bold'; + +const FONTS_PER_BRAND = { + bom: [ + { + fontWeight: 'Light', + className: FONT_LIGHT, + }, + { + fontWeight: 'Regular', + className: FONT_REGULAR, + }, + { + fontWeight: 'Bold', + className: FONT_BOLD, + }, + ], + bsa: [ + { + fontWeight: 'Light', + className: FONT_LIGHT, + }, + { + fontWeight: 'Bold', + className: FONT_BOLD, + }, + ], + rams: [ + { + fontWeight: 'Regular', + className: FONT_REGULAR, + }, + { + fontWeight: 'Semi-bold', //600 + className: 'font-semibold', + }, + { + fontWeight: 'Bold', // 700 900 + className: FONT_BOLD, + }, + ], + stg: [ + { + fontWeight: 'Bold', + className: FONT_BOLD, + }, + ], + wbc: [ + { + fontWeight: 'Bold', + className: FONT_BOLD, + }, + ], + wbg: [ + { + fontWeight: 'Light', //100 - 300 + className: FONT_LIGHT, + }, + { + fontWeight: 'Regular', //400 - 600 + className: FONT_REGULAR, + }, + { + fontWeight: 'Bold', //700 - 900 + className: FONT_BOLD, + }, + ], +} as const; + +export function BrandFontWeight({ type, caption }: BrandFontWeightProps) { + const brand = useBrand(); + const fonts = FONTS_PER_BRAND[brand?.key || 'wbc']; + + return ( +
+ + GEL brand font weight tokens + + + Token + Font weight + Tailwind class + + + + {fonts.map(i => ( + + + {i.className.replace('font-', '')} + + + {i.fontWeight} {brand?.fontName} + + {i.className} + + ))} + +
+
+ ); +} diff --git a/apps/site/src/components/component-blocks/components/brand-font-weight/brand-font-weight.preview.tsx b/apps/site/src/components/component-blocks/components/brand-font-weight/brand-font-weight.preview.tsx new file mode 100644 index 000000000..97e9d30db --- /dev/null +++ b/apps/site/src/components/component-blocks/components/brand-font-weight/brand-font-weight.preview.tsx @@ -0,0 +1,11 @@ +import { NotEditable, component, fields } from '@keystatic/core'; + +export const brandFontWeight = component({ + preview: () => ( + +
Brand Font Weight
+
+ ), + label: 'Brand Font Weight', + schema: {}, +}); diff --git a/apps/site/src/components/component-blocks/components/brand-font-weight/brand-font-weight.styles.ts b/apps/site/src/components/component-blocks/components/brand-font-weight/brand-font-weight.styles.ts new file mode 100644 index 000000000..1ee23cc0a --- /dev/null +++ b/apps/site/src/components/component-blocks/components/brand-font-weight/brand-font-weight.styles.ts @@ -0,0 +1,8 @@ +import { tv } from 'tailwind-variants'; + +export const styles = tv({ + slots: { + contentContainer: 'mb-5 mt-4 max-w-5xl bg-white p-6 pb-0', + tableContainer: 'relative -mx-6 -mt-6 border-muted-50 px-6 pb-6 pt-9', + }, +}); diff --git a/apps/site/src/components/component-blocks/foundation-blocks.tsx b/apps/site/src/components/component-blocks/foundation-blocks.tsx index 245a3fe75..1d1c322f9 100644 --- a/apps/site/src/components/component-blocks/foundation-blocks.tsx +++ b/apps/site/src/components/component-blocks/foundation-blocks.tsx @@ -5,6 +5,8 @@ import { colors } from './colors/colors.preview'; import { accessibilityDemo } from './components/accessibility-demo/accessibility-demo.preview'; import { AvailabilityContent } from './components/availability-content/availability-content.component'; import { availabilityContent } from './components/availability-content/availability-content.preview'; +import { BrandFontWeight } from './components/brand-font-weight/brand-font-weight.component'; +import { brandFontWeight } from './components/brand-font-weight/brand-font-weight.preview'; import { designSystemBodyImage } from './components/design-system-body-image'; import { LinkList } from './components/link-list'; import { linkList } from './components/link-list/link-list.preview'; @@ -32,6 +34,7 @@ export const foundationBlocks = { shortCode, accessibilityDemo, availabilityContent, + brandFontWeight, }; export const foundationBlocksComponents = { @@ -48,4 +51,5 @@ export const foundationBlocksComponents = { ), availabilityContent: (props: any) => , + brandFontWeight: (props: any) => , }; From 3d95021a12fe4cbe48390cf2cba14052f2ca77e4 Mon Sep 17 00:00:00 2001 From: HZ991 Date: Wed, 20 Nov 2024 13:11:18 +1100 Subject: [PATCH 3/6] Add: combined fonts and fontWeight components --- .../table-of-contents.component.tsx | 4 +- apps/site/src/app/layout.tsx | 2 +- .../brand-font-weight.component.tsx | 127 ------------------ .../brand-font-weight.preview.tsx | 11 -- .../brand-font-weight.styles.ts | 8 -- .../fonts/fonts.component.tsx | 84 +++++++++--- .../component-blocks/fonts/fonts.preview.tsx | 13 +- .../component-blocks/fonts/fonts.styles.ts | 8 ++ .../component-blocks/foundation-blocks.tsx | 2 +- .../font/design/brand-font/content.mdoc | 4 +- .../src/components/symbol/symbol.stories.tsx | 8 +- .../stories/foundation/colours.stories.tsx | 16 +-- 12 files changed, 103 insertions(+), 184 deletions(-) delete mode 100644 apps/site/src/components/component-blocks/components/brand-font-weight/brand-font-weight.component.tsx delete mode 100644 apps/site/src/components/component-blocks/components/brand-font-weight/brand-font-weight.preview.tsx delete mode 100644 apps/site/src/components/component-blocks/components/brand-font-weight/brand-font-weight.styles.ts create mode 100644 apps/site/src/components/component-blocks/fonts/fonts.styles.ts diff --git a/apps/site/src/app/design-system/[brand]/[...component]/components/content-tabs/components/intro/components/table-of-contents/table-of-contents.component.tsx b/apps/site/src/app/design-system/[brand]/[...component]/components/content-tabs/components/intro/components/table-of-contents/table-of-contents.component.tsx index 9517cde09..397984f45 100644 --- a/apps/site/src/app/design-system/[brand]/[...component]/components/content-tabs/components/intro/components/table-of-contents/table-of-contents.component.tsx +++ b/apps/site/src/app/design-system/[brand]/[...component]/components/content-tabs/components/intro/components/table-of-contents/table-of-contents.component.tsx @@ -10,7 +10,7 @@ import { type TableOfContentsProps } from './table-of-contents.types'; export function TableOfContents({ contents = [] }: TableOfContentsProps) { return (