From e347a4334dd55d2118f4e5c0429077ead6c59dac Mon Sep 17 00:00:00 2001 From: Josh Knapp Date: Wed, 7 Oct 2026 12:50:47 -0700 Subject: [PATCH] feat(site-builder): tokenise remaining component design colours (Navbar, Menu, Footer, SocialLinks, StickyCallBar, BackgroundSection, ContentSlider, Countdown, HeroSimple) Refs #44 Co-Authored-By: Claude Sonnet 5.5 --- .../components/basic/Footer.toHtml.test.ts | 10 ++++++ craft/src/components/basic/Footer.tsx | 6 ++-- .../src/components/basic/Menu.toHtml.test.ts | 10 ++++++ craft/src/components/basic/Menu.tsx | 14 ++++---- .../components/basic/Navbar.toHtml.test.ts | 10 ++++++ craft/src/components/basic/Navbar.tsx | 33 ++++++++++++------- .../basic/SocialLinks.toHtml.test.ts | 10 ++++++ craft/src/components/basic/SocialLinks.tsx | 13 ++++---- .../business/StickyCallBar.toHtml.test.ts | 10 ++++++ .../src/components/business/StickyCallBar.tsx | 6 ++-- .../layout/BackgroundSection.toHtml.test.ts | 10 ++++++ .../components/layout/BackgroundSection.tsx | 7 ++-- .../sections/ContentSlider.toHtml.test.ts | 10 ++++++ .../src/components/sections/ContentSlider.tsx | 21 +++++++----- .../sections/Countdown.toHtml.test.ts | 10 ++++++ craft/src/components/sections/Countdown.tsx | 23 ++++++++----- .../sections/HeroSimple.toHtml.test.ts | 21 ++++++++++++ craft/src/components/sections/HeroSimple.tsx | 32 +++++++++--------- .../templates/definitions.tokens-B.test.ts | 2 +- 19 files changed, 190 insertions(+), 68 deletions(-) diff --git a/craft/src/components/basic/Footer.toHtml.test.ts b/craft/src/components/basic/Footer.toHtml.test.ts index c663e66..49db533 100644 --- a/craft/src/components/basic/Footer.toHtml.test.ts +++ b/craft/src/components/basic/Footer.toHtml.test.ts @@ -31,3 +31,13 @@ describe('Footer (F4: box-model + animation + visibility props on craft.props)', expect(craftProps).toHaveProperty('hideOnMobile', false); }); }); + +describe('Footer.toHtml design tokens (#44)', () => { + test('default craft props export var(--wsb-*) and none of the old design hex', () => { + const props = { ...((Footer as any).craft.props as object) }; + const { html } = (((Footer) as any).toHtml)(props, '', 'node-tok'); + const lower = html.toLowerCase(); + for (const t of ['text', 'bg']) expect(html, `token ${t}`).toContain(`var(--wsb-${t})`); + for (const hex of ['#18181b', '#a1a1aa']) expect(lower, `old ${hex}`).not.toContain(hex.toLowerCase()); + }); +}); diff --git a/craft/src/components/basic/Footer.tsx b/craft/src/components/basic/Footer.tsx index b3dd2f3..b4be91e 100644 --- a/craft/src/components/basic/Footer.tsx +++ b/craft/src/components/basic/Footer.tsx @@ -1,6 +1,7 @@ import React, { CSSProperties, useCallback, useRef, useEffect } from 'react'; import { useNode, UserComponent } from '@craftjs/core'; import { cssPropsToString } from '../../utils/style-helpers'; +import { tokenRef } from '../../utils/tokens'; import { escapeHtml } from '../../utils/escape'; interface FooterProps { @@ -92,8 +93,9 @@ Footer.craft = { props: { text: '© 2026 MySite. All rights reserved.', style: { - backgroundColor: '#18181b', - color: '#a1a1aa', + // Dark band: text token as the band, bg token as its (contrast-safe) text. + backgroundColor: tokenRef('text'), + color: tokenRef('bg'), fontSize: '14px', padding: '24px 20px', }, diff --git a/craft/src/components/basic/Menu.toHtml.test.ts b/craft/src/components/basic/Menu.toHtml.test.ts index 0661456..f2776fd 100644 --- a/craft/src/components/basic/Menu.toHtml.test.ts +++ b/craft/src/components/basic/Menu.toHtml.test.ts @@ -107,3 +107,13 @@ describe('Menu.toHtml dropdowns (#53)', () => { expect((Menu as any).craft.props.followPages).toBe(false); }); }); + +describe('Menu.toHtml design tokens (#44)', () => { + test('default craft props export var(--wsb-*) and none of the old design hex', () => { + const props = { ...((Menu as any).craft.props as object) }; + const { html } = (((Menu) as any).toHtml)(props, '', 'node-tok'); + const lower = html.toLowerCase(); + for (const t of ['text', 'bg']) expect(html, `token ${t}`).toContain(`var(--wsb-${t})`); + for (const hex of ['#3f3f46']) expect(lower, `old ${hex}`).not.toContain(hex.toLowerCase()); + }); +}); diff --git a/craft/src/components/basic/Menu.tsx b/craft/src/components/basic/Menu.tsx index 2697c25..1a73dfd 100644 --- a/craft/src/components/basic/Menu.tsx +++ b/craft/src/components/basic/Menu.tsx @@ -43,10 +43,10 @@ const defaultLinks: MenuLink[] = [ export const Menu: UserComponent = ({ links = defaultLinks, alignment = 'right', - linkColor = '#3f3f46', + linkColor = tokenRef('text'), linkHoverColor = tokenRef('primary'), ctaBgColor = tokenRef('primary'), - ctaTextColor = '#ffffff', + ctaTextColor = tokenRef('bg'), gap = '24px', orientation = 'horizontal', fontSize = '14px', @@ -139,7 +139,7 @@ export const Menu: UserComponent = ({ const SUB_STYLE: CSSProperties = { position: 'absolute', top: '100%', left: 0, zIndex: 1001, minWidth: 180, margin: 0, padding: '8px 0', - listStyle: 'none', background: 'var(--wsb-bg, #ffffff)', borderRadius: 6, boxShadow: '0 8px 24px rgba(0,0,0,0.12)', + listStyle: 'none', background: tokenRef('bg'), borderRadius: 6, boxShadow: '0 8px 24px rgba(0,0,0,0.12)', }; const SUB_STATIC_STYLE: CSSProperties = { margin: 0, padding: '4px 0 0 12px', listStyle: 'none' }; @@ -151,10 +151,10 @@ Menu.craft = { links: defaultLinks, followPages: false, alignment: 'right', - linkColor: '#3f3f46', + linkColor: tokenRef('text'), linkHoverColor: tokenRef('primary'), ctaBgColor: tokenRef('primary'), - ctaTextColor: '#ffffff', + ctaTextColor: tokenRef('bg'), gap: '24px', orientation: 'horizontal', fontSize: '14px', @@ -179,10 +179,10 @@ Menu.craft = { // string-interpolation sinks below (hoverCol goes into a breakout -> arbitrary