also looking at this
fix(ui): align component palette and contain homepage hero
#16
7 files
+157
-13
| @@ -0,0 +1,29 @@ | ||
| 1 | import { describe, expect, test } from 'bun:test' | |
| 2 | import theme from '../../config/crosswind' | |
| 3 | import stx from '../../stx.config' | |
| 4 | // STX exposes its selected CSS engine through these installed files. | |
| 5 | import { loadCssEngine } from '../../node_modules/@stacksjs/stx/dist/dev-server/ts-css.js' | |
| 6 | import { SEMANTIC_TOKENS, SHAPE_TOKENS } from '../../node_modules/@stacksjs/stx/dist/theme-tokens.js' | |
| 7 | import { mergeCssConfig } from '../../node_modules/@stacksjs/stx/dist/ts-css-config.js' | |
| 8 | ||
| 9 | describe('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 | }) | |