Skip to content

Commit b92ff21

Browse files
Bill LeoutsakosBill Leoutsakos
authored andcommitted
fix: resolve design-diff theme and EMCN conventions
1 parent 458a515 commit b92ff21

5 files changed

Lines changed: 72 additions & 1 deletion

File tree

design-diff.config.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,7 @@
7676
"clsx",
7777
"classnames",
7878
"tailwind-merge",
79+
"@sim/emcn",
7980
"@sim/emcn/lib/cn",
8081
"@/lib/utils",
8182
"@/lib/cn"

scripts/design-diff/README.md

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -202,3 +202,29 @@ are whole commits, including ancillary changes, rather than only their headline
202202

203203
These comparisons validate source-policy behavior, not rendered pixels or recall over all
204204
historical PRs. Screenshot capture, AI interpretation and Slack delivery are separate stages.
205+
206+
### Incremental smoke test on PR #7742
207+
208+
Five temporary commits were created directly on `458a515cbed7fbcf127ce72348ff755c5308ce13`,
209+
each changing one existing source file. Comparing that commit with each temporary head
210+
isolated the test edit from the implementation PR's own dependency changes. No temporary
211+
UI edits were checked out, pushed or included in the PR.
212+
213+
| Incremental edit | Observed result after fixes |
214+
| --- | --- |
215+
| EMCN Button `rounded-[5px]` to `rounded-none` | Flagged; a `shape-effects` finding identifies `buttonVariants` |
216+
| Send button token `bg-[#383838]` to `bg-[#E11D48]` | Flagged; `colour` review evidence reaches the unchanged `SendButton` consumer |
217+
| Send button token `p-0` to `p-2` | Flagged; `dimensions` review evidence reaches the unchanged consumer |
218+
| TSDoc wording only in EMCN Button | Clean; zero findings |
219+
| Add `translate-x-2` to the send button token | Flagged for review; movement is not proven harmless in this runtime context |
220+
221+
The experiment exposed and fixed dropped semicolons between CSS custom-variant statements
222+
and missing recognition of the repository's `cn` import from `@sim/emcn`. Regression tests
223+
cover both. All five overall flagging decisions matched expectations. One stricter category
224+
assertion did not: generated translation declarations currently receive the broader `layout`
225+
category, rather than `movement`; the conservative review decision is retained.
226+
227+
Report noise remains substantial: the shared shape edit generated 2 static flags and 2,205
228+
review findings; each local token edit generated 93 review findings. These counts describe
229+
potential effects, not independently verified visual regressions. Conditional consumers
230+
still require review. This validates local engine behavior, not cloud workflow activation.

scripts/design-diff/tailwind.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ export class TailwindNormalizer {
4949
root.each((node) => {
5050
if (node.type !== 'atrule') return
5151
if (['theme', 'custom-variant', 'utility'].includes(node.name))
52-
chunks.push(node.toString())
52+
chunks.push(`${node.toString()}${node.nodes ? '' : ';'}`)
5353
if (['plugin', 'config'].includes(node.name))
5454
limitations.push('Application JavaScript plugins/configuration are not executed')
5555
if (node.name === 'import') {

scripts/design-diff/tests/resolve.test.ts

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,26 @@ it('does not collapse class composition order', async () => {
105105
expect(report.flagged).toBe(true)
106106
})
107107

108+
it.each([
109+
['bg-[#383838]', 'bg-[#E11D48]', 'colour'],
110+
['p-0', 'p-2', 'dimensions'],
111+
])('resolves imported %s through the EMCN root cn export', async (before, after, category) => {
112+
const report = await compareFiles(
113+
{
114+
[token]: `export const classes = '${before}'`,
115+
[consumer]:
116+
'import {cn} from "@sim/emcn"; import {classes} from "./token"; export const A=()=> <button className={cn("rounded-full", classes)}/>',
117+
},
118+
{ [token]: `export const classes = '${after}'` },
119+
{ ...config, themes: [] }
120+
)
121+
const finding = report.findings.find((finding) => finding.after?.location.file === consumer)
122+
expect(finding?.decision).toBe('flag')
123+
expect(finding?.category).toBe(category)
124+
expect(finding?.limitations).toEqual([])
125+
expect(finding?.dependencies).toContain(token)
126+
})
127+
108128
it('reviews unsupported class helpers instead of executing or trusting their names', async () => {
109129
const source = (value: string) =>
110130
`import {clsx} from 'untrusted-helper'; export const A=()=> <div className={clsx('${value}')}/>`

scripts/design-diff/tests/tailwind.test.ts

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,30 @@ it('preserves dark/responsive/state variants', async () => {
3939
expect(JSON.stringify(report.findings)).toContain('hover')
4040
})
4141

42+
it('preserves statement boundaries between selector and block custom variants', async () => {
43+
const report = await compareFiles(
44+
{
45+
[theme]: `
46+
@custom-variant dark (&:where(.dark, .dark *):not(:where(.light, .light *)));
47+
@custom-variant hover (&:hover);
48+
@custom-variant hover-hover {
49+
@media (hover: hover) and (pointer: fine) { &:hover { @slot; } }
50+
}
51+
@theme { --color-brand: #383838; }
52+
`,
53+
[file]: 'export const A=()=> <div className="dark:bg-brand hover:bg-brand hover-hover:p-2"/>',
54+
},
55+
{
56+
[file]: 'export const A=()=> <div className="dark:bg-brand hover:bg-brand hover-hover:p-4"/>',
57+
}
58+
)
59+
const finding = report.findings.find((finding) => finding.after?.location.file === file)
60+
expect(finding?.decision).toBe('flag')
61+
expect(finding?.category).toBe('dimensions')
62+
expect(finding?.limitations).toEqual([])
63+
expect(JSON.stringify(finding?.after?.value)).toContain('(pointer: fine)')
64+
})
65+
4266
it('flags unchanged consumers of changed global theme variables', async () => {
4367
const report = await compareFiles(
4468
{

0 commit comments

Comments
 (0)