ReviewOS

also looking at this

stacks/commshq

fix(ui): align component palette and contain homepage hero

#16
Merged glennmichael123 wants to merge fix/commshq-component-theme into main
7 files +157 -13
tests/Unit/component-theme.test.tsadded+29-0
Changes to tests/Unit/component-theme.test.ts
@@ -0,0 +1,29 @@
1import { describe, expect, test } from 'bun:test'
2import theme from '../../config/crosswind'
3import stx from '../../stx.config'
4// STX exposes its selected CSS engine through these installed files.
5import { loadCssEngine } from '../../node_modules/@stacksjs/stx/dist/dev-server/ts-css.js'
6import { SEMANTIC_TOKENS, SHAPE_TOKENS } from '../../node_modules/@stacksjs/stx/dist/theme-tokens.js'
7import { mergeCssConfig } from '../../node_modules/@stacksjs/stx/dist/ts-css-config.js'
8
9describe('component palette contract', () => {
10 test('the root STX config delivers the component palette on every page', () => {
11 expect(stx.app?.head?.link).toContainEqual({ rel: 'stylesheet', href: '/component-tokens.css' })
12 })
13
14 test('every component color and radius emits an app-owned utility', async () => {
15 const engine = await loadCssEngine()
16 if (!engine) throw new Error('The installed STX CSS engine is required')
17 const generator = new engine.CSSGenerator(mergeCssConfig(engine.defaultConfig || engine.config, theme).config)
18 for (const role of Object.keys(SEMANTIC_TOKENS)) generator.generate(`bg-${role}`)
19 for (const role of Object.keys(SHAPE_TOKENS)) generator.generate(`rounded-${role}`)
20 const css = generator.toCSS(false, false)
21 expect(css).not.toContain('var(--stx-')
22 for (const role of Object.keys(SEMANTIC_TOKENS)) expect(css).toContain(`.bg-${role} {`)
23 for (const role of Object.keys(SHAPE_TOKENS)) expect(css).toContain(`.rounded-${role} {`)
24 expect(css).toContain('.bg-content {\n background-color: var(--panel);')
25 expect(css).toContain('.bg-accent-solid {\n background-color: var(--coral);')
26 expect(css).toContain('.rounded-control {\n border-radius: 10px;')
27 expect(css).toContain('.rounded-panel {\n border-radius: 12px;')
28 })
29})