From 4f94e6538472e0542812dcc5638200688c1e831e Mon Sep 17 00:00:00 2001 From: Jaybe Date: Fri, 14 Nov 2025 22:54:34 +0900 Subject: [PATCH] =?UTF-8?q?feat(exporter):=20=EB=8B=A4=ED=81=AC=EB=AA=A8?= =?UTF-8?q?=EB=93=9C=20=EB=8C=80=EB=B9=84=20=EB=B3=B4=EA=B0=95(a=20?= =?UTF-8?q?=EB=A7=81=ED=81=AC/=ED=98=B8=EB=B2=84,=20=EB=B2=84=ED=8A=BC/CTA?= =?UTF-8?q?,=20FAQ=20=ED=85=8D=EC=8A=A4=ED=8A=B8)=20+=20=ED=85=8C=EC=8A=A4?= =?UTF-8?q?=ED=8A=B8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../darkContrast.hover.tokens.test.ts | 30 +++++++++++++++ lib/exporter/darkContrast.tokens.test.ts | 37 +++++++++++++++++++ lib/exporter/html.ts | 2 +- 3 files changed, 68 insertions(+), 1 deletion(-) create mode 100644 lib/exporter/darkContrast.hover.tokens.test.ts create mode 100644 lib/exporter/darkContrast.tokens.test.ts diff --git a/lib/exporter/darkContrast.hover.tokens.test.ts b/lib/exporter/darkContrast.hover.tokens.test.ts new file mode 100644 index 0000000..34f92a8 --- /dev/null +++ b/lib/exporter/darkContrast.hover.tokens.test.ts @@ -0,0 +1,30 @@ +import { describe, it, expect } from 'vitest' +import { exportPage } from '@/lib/exporter/html' +import { pageSchema, type Page } from '@/lib/schema/page' + +function makePage(): Page { + return pageSchema.parse({ + title: 'Dark Contrast Hover', + locale: 'en', + theme: { primaryColor: '#2563eb', fontFamily: 'Inter' }, + sections: [ + { type: 'hero', props: { heading: 'Welcome', subheading: 'Sub', imageUrl: 'https://img.example/h.png' } }, + { type: 'cta', props: { text: 'Call', href: '#' } }, + ], + form: { actionUrl: '', fields: [], spamProtection: { honeypotFieldName: '_hp', minSubmitSeconds: 2 } }, + seo: { title: 't', description: 'd' }, + }) +} + +describe('Exporter - dark mode hover/cta tokens', () => { + it('adds link hover underline and ensures btn-cta readable in dark', () => { + const out = exportPage(makePage()) + const css = out.css + + // underline on hover for links in dark for clearer affordance + expect(css).toMatch(/@media \(prefers-color-scheme: dark\)[\s\S]*a:hover\{[^}]*text-decoration:underline/i) + + // btn-cta has readable foreground/background in dark + expect(css).toMatch(/@media \(prefers-color-scheme: dark\)[\s\S]*\.btn-cta\{[^}]*background:[^;]+;[^}]*color:#fff/i) + }) +}) diff --git a/lib/exporter/darkContrast.tokens.test.ts b/lib/exporter/darkContrast.tokens.test.ts new file mode 100644 index 0000000..29d20d7 --- /dev/null +++ b/lib/exporter/darkContrast.tokens.test.ts @@ -0,0 +1,37 @@ +import { describe, it, expect } from 'vitest' +import { exportPage } from '@/lib/exporter/html' +import { pageSchema, type Page } from '@/lib/schema/page' + +function makePage(): Page { + return pageSchema.parse({ + title: 'Dark Contrast', + locale: 'en', + theme: { primaryColor: '#2563eb', fontFamily: 'Inter' }, + sections: [ + { type: 'hero', props: { heading: 'Welcome', subheading: 'Sub', imageUrl: 'https://img.example/h.png' } }, + { type: 'faq', props: { items: [{ q: 'Q', a: 'A' }] } }, + { type: 'cta', props: { text: 'Go', href: '#' } }, + ], + form: { actionUrl: '', fields: [], spamProtection: { honeypotFieldName: '_hp', minSubmitSeconds: 2 } }, + seo: { title: 't', description: 'd' }, + }) +} + +describe('Exporter - dark mode contrast tokens', () => { + it('includes dark mode tokens that improve contrast for links/buttons/faq text', () => { + const out = exportPage(makePage()) + const css = out.css + + // dark mode block exists + expect(css).toMatch(/@media \(prefers-color-scheme: dark\)/) + + // link color token in dark + expect(css).toMatch(/@media \(prefers-color-scheme: dark\)[\s\S]*a\{[^}]*color:#93c5fd/i) + + // button keeps readable foreground/background in dark + expect(css).toMatch(/@media \(prefers-color-scheme: dark\)[\s\S]*button\{[^}]*background:[^;]+;[^}]*color:#fff/i) + + // faq answer text brighter in dark + expect(css).toMatch(/@media \(prefers-color-scheme: dark\)[\s\S]*\.faq-a\{[^}]*color:#cbd5e1/i) + }) +}) diff --git a/lib/exporter/html.ts b/lib/exporter/html.ts index 3eff894..8368979 100644 --- a/lib/exporter/html.ts +++ b/lib/exporter/html.ts @@ -273,7 +273,7 @@ function buildCss(page: Page) { .testimonial blockquote{ margin:0; font-style:italic; color:#1f2937 } .testimonial figcaption{ color:#475569; margin-top:.25rem } @media (max-width: 640px){ .container{ padding: 1rem } h1{ font-size: 1.5rem } } - @media (prefers-color-scheme: dark){ body{ color:#e5e7eb; background:#0b1020 } .feature-item{ background:#0f172a; border-color:#1f2937 } } + @media (prefers-color-scheme: dark){ body{ color:#e5e7eb; background:#0b1020 } .feature-item{ background:#0f172a; border-color:#1f2937 } a{ color:#93c5fd } a:hover{ text-decoration:underline } button{ background: var(--primary); color:#fff } .btn-cta{ background: var(--primary); color:#fff } .faq-a{ color:#cbd5e1 } } @media (prefers-reduced-motion: reduce){ *{ transition: none !important; animation: none !important } } ` } -- 2.52.0