Compare commits

..

1 Commits

Author SHA1 Message Date
jaybe a476756a6c feat(exporter): 다크모드 대비 보강(a 링크/호버, 버튼/CTA, FAQ 텍스트) + 테스트
Auto PR / open-pr (push) Successful in 23s
CI / test (pull_request) Failing after 11m12s
Auto Label PR / add-automerge-label (pull_request) Failing after 11m17s
2025-11-14 22:54:34 +09:00
5 changed files with 94 additions and 13 deletions
+13 -6
View File
@@ -20,15 +20,22 @@ jobs:
echo "CI_TOKEN not set; skipping labeling"; exit 0; fi
OWNER=$(echo "$REPO" | cut -d'/' -f1)
NAME=$(echo "$REPO" | cut -d'/' -f2)
echo "Resolving existing label id for 'automerge' in $OWNER/$NAME (no creation)"
echo "Resolving label id for 'automerge' in $OWNER/$NAME"
curl -sS -o /tmp/labels.json -H "Authorization: token ${CI_TOKEN}" \
"${GITEA_BASE_URL}/api/v1/repos/${OWNER}/${NAME}/labels?limit=1000" || true
# Extract all ids whose name == automerge, prefer the smallest id (oldest)
LID=$(tr '\n' ' ' < /tmp/labels.json | \
grep -o '"id":[0-9][0-9]*[^\}]*"name":"automerge"' | \
sed -E 's/.*"id":([0-9]+).*/\1/' | sort -n | head -n1 || true)
# Robust parse without jq: find the id preceding name "automerge"
LID=$(tr '\n' ' ' < /tmp/labels.json | grep -o '"id":[0-9][0-9]*[^\}]*"name":"automerge"' | head -n1 | sed -E 's/.*"id":([0-9]+).*/\1/' || true)
if [ -z "${LID:-}" ]; then
echo "No existing 'automerge' label found; skipping labeling"; exit 0; fi
echo "Label 'automerge' not found. Creating..."
curl -sS -o /tmp/create_label.json -X POST \
-H "Content-Type: application/json" \
-H "Authorization: token ${CI_TOKEN}" \
"${GITEA_BASE_URL}/api/v1/repos/${OWNER}/${NAME}/labels" \
-d '{"name":"automerge","color":"#0ea5e9"}'
LID=$(tr '\n' ' ' < /tmp/create_label.json | sed -E 's/.*"id":([0-9]+).*/\1/' | head -n1 || true)
fi
if [ -z "${LID:-}" ]; then
echo "Failed to resolve or create label id; skipping"; exit 0; fi
echo "Labeling PR #$PR_NUMBER with id $LID"
curl -sS -X POST \
-H "Content-Type: application/json" \
+13 -6
View File
@@ -55,12 +55,19 @@ jobs:
done
if [ -n "${PR_NUMBER:-}" ]; then
echo "Resolving existing label id for 'automerge' (no creation)"
echo "Resolving label id for 'automerge' in $OWNER/$NAME"
curl -sS -o /tmp/labels.json -H "Authorization: token ${CI_TOKEN}" \
"${GITEA_BASE_URL}/api/v1/repos/${OWNER}/${NAME}/labels?limit=1000" || true
LID=$(tr '\n' ' ' < /tmp/labels.json | \
grep -o '"id":[0-9][0-9]*[^\}]*"name":"automerge"' | \
sed -E 's/.*"id":([0-9]+).*/\1/' | sort -n | head -n1 || true)
"${GITEA_BASE_URL}/api/v1/repos/${OWNER}/${NAME}/labels"
LID=$(awk 'BEGIN{RS=","} /"name":"automerge"/ {if (match($0,/"id":([0-9]+)/,m)) {print m[1]; exit}}' /tmp/labels.json || true)
if [ -z "${LID:-}" ]; then
echo "Label 'automerge' not found. Creating..."
curl -sS -o /tmp/create_label.json -X POST \
-H "Content-Type: application/json" \
-H "Authorization: token ${CI_TOKEN}" \
"${GITEA_BASE_URL}/api/v1/repos/${OWNER}/${NAME}/labels" \
-d '{"name":"automerge","color":"#0ea5e9"}'
LID=$(sed -n 's/.*"id":\([0-9]*\).*/\1/p' /tmp/create_label.json | head -n1 || true)
fi
if [ -n "${LID:-}" ]; then
echo "Adding 'automerge' (id=$LID) label to PR #$PR_NUMBER"
curl -sS -X POST \
@@ -69,7 +76,7 @@ jobs:
"${GITEA_BASE_URL}/api/v1/repos/${OWNER}/${NAME}/issues/${PR_NUMBER}/labels" \
-d '{"labels":['"${LID}"']}' || true
else
echo "No existing 'automerge' label found; skipping label add"
echo "Failed to resolve label id; skipping label add"
fi
else
echo "PR number could not be determined; skipping label add"
@@ -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)
})
})
+37
View File
@@ -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)
})
})
+1 -1
View File
@@ -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 } }
`
}