Skip to content

Commit 38e4c48

Browse files
committed
test(components): pin the surface invariant and drop the class no component used
1 parent 2283cd9 commit 38e4c48

2 files changed

Lines changed: 23 additions & 9 deletions

File tree

packages/ui/src/utils/base-styles.ts

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -145,15 +145,6 @@ export const baseStyles = css`
145145
font-size: var(--roxy-text-sm, 0.875rem);
146146
}
147147
148-
/* Opt-in component backdrop. A component that paints content directly (table,
149-
* grid, prose) adds this to its root so it sits on an owned, theme-aware
150-
* surface rather than inheriting the page background, which may not match the
151-
* resolved token theme and would render text on a same-tone background. */
152-
.roxy-surface {
153-
background: var(--roxy-surface, #fff);
154-
color: var(--roxy-fg, #0a0a0a);
155-
}
156-
157148
:host(:focus-within) .roxy-card {
158149
outline: 2px solid var(--roxy-ring, rgba(245, 158, 11, 0.4));
159150
outline-offset: 2px;

packages/ui/tests/components.test.ts

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@ import { describe, expect, test } from 'bun:test';
55
// so the order matters: setup -> import.
66
import '../src/index.js';
77
import { FAMILY_ORDER } from '../src/components/yoga-list.js';
8+
import { ROXY_COMPONENTS } from '../src/manifest.js';
9+
import { baseStyles } from '../src/utils/base-styles.js';
810

911
/** `updateComplete` lives on LitElement, not on the `HTMLElement` that `createElement` returns, and every call site was reaching it through the same double cast. One helper, one place to change. */
1012
const settled = (el: Element): Promise<void> =>
@@ -5713,3 +5715,24 @@ describe('roxy-hd-penta draws the ladder', () => {
57135715
el.remove();
57145716
});
57155717
});
5718+
5719+
describe('component surfaces', () => {
5720+
// A component renders inside whatever container the page gives it, so its own
5721+
// root paints the surface instead of inheriting the page background. Shared
5722+
// base styles are excluded: they reach every component and would pass this
5723+
// for a component that paints nothing of its own.
5724+
test('every component paints a surface in its own styles', () => {
5725+
const unpainted = ROXY_COMPONENTS.filter((c) => {
5726+
const ctor = customElements.get(c.tag) as unknown as {
5727+
elementStyles?: ReadonlyArray<{ cssText: string }>;
5728+
};
5729+
const own = (ctor?.elementStyles ?? [])
5730+
.map((sheet) => sheet.cssText)
5731+
.filter((text) => text !== baseStyles.cssText);
5732+
return !/background:\s*var\(--roxy-(surface|bg)/.test(own.join('\n'));
5733+
}).map((c) => c.tag);
5734+
5735+
expect(ROXY_COMPONENTS.length).toBeGreaterThan(50);
5736+
expect(unpainted).toEqual([]);
5737+
});
5738+
});

0 commit comments

Comments
 (0)