designpaca/apps/site/src/components/CopyCommand.astro
Yun Chan 8e3cdb0d3b
Some checks are pending
ci / build (push) Waiting to run
feat(site): rework 19 marketing showcases for composition diversity
Measured convergence before: split hero 13/19, top-bar nav 19/19,
one-line notice footer 14/19, body Pretendard 17/21, 10 similarity
pairs above 0.78. Each showcase got a pre-assigned hero family, nav
form, footer form, type pair, background, accent hue, radius, motion
grammar and material from outputs/rework-2026-10-06/plan.md; direction
cards and the chosen reason are recorded in every design.md.

After: 0 similarity warnings, 19 distinct display faces, 7 hero
families, 5 nav forms, 5 footer forms, no scroll reveals, 5 showcases
with SVG filter materials. Example contact values replace bracket
placeholders under the existing fictional-brand notices. Thumbnails,
OG images, card copy and three e2e assertions updated; dead CSS in
dure-enrollment and hannam-jari removed; similarity.mjs learns the new
font families.
2026-10-06 16:55:50 +09:00

137 lines
4 KiB
Text

---
interface Props {
command: string;
copyLabel: string;
copiedLabel: string;
note?: string;
}
const { command, copyLabel, copiedLabel, note } = Astro.props;
---
<div class="cmd-shell">
<div class="cmd">
<code class="cmd-text" translate="no"><span aria-hidden="true">$ </span>{command}</code>
<button type="button" class="btn btn-primary cmd-copy" data-copy={command} data-copied={copiedLabel}>
<span class="cmd-copy-label">{copyLabel}</span>
<svg viewBox="0 0 16 16" width="15" height="15" aria-hidden="true">
<path d="M5.5 10.5 10.5 5.5M6.5 5.5h4v4" />
</svg>
</button>
</div>
<span class="copy-status sr-only" aria-live="polite"></span>
</div>
{note && <p class="cmd-note muted">{note}</p>}
<style>
.cmd-shell {
min-width: 0;
max-width: 32rem;
border: var(--line-width) solid var(--line-strong);
border-radius: var(--radius-sm);
background: var(--surface-raised);
}
.cmd {
min-width: 0;
display: grid;
grid-template-columns: minmax(0, 1fr) auto;
align-items: center;
gap: var(--space-2);
padding: var(--space-2);
}
.cmd-text {
min-width: 0;
overflow-x: auto;
padding-inline: var(--space-2);
color: var(--ink);
line-height: var(--control-h);
white-space: nowrap;
scrollbar-width: thin;
}
.cmd-text span { color: var(--ink-muted); }
.cmd-copy { white-space: nowrap; }
.cmd-copy svg {
fill: none;
stroke: currentColor;
stroke-width: 1.5;
stroke-linecap: round;
stroke-linejoin: round;
transition: transform var(--dur-quick) var(--ease-out);
}
.cmd-copy:hover svg,
.cmd-copy:focus-visible svg { transform: translate(2px, -2px); }
@media (prefers-reduced-motion: reduce) {
.cmd-copy svg {
transition: none;
transform: none;
}
.cmd-copy:hover svg,
.cmd-copy:focus-visible svg { transform: none; }
}
.cmd-note {
max-width: 32rem;
margin-top: var(--space-2);
font-size: var(--step--1);
}
@media (max-width: 26rem) {
.cmd { grid-template-columns: minmax(0, 1fr); }
.cmd-copy { width: 100%; }
}
</style>
<script>
document.querySelectorAll<HTMLButtonElement>(".cmd-copy").forEach((button) => {
if (button.dataset["copyReady"] === "true") return;
button.dataset["copyReady"] = "true";
const label = button.querySelector<HTMLSpanElement>(".cmd-copy-label");
const shell = button.closest<HTMLElement>(".cmd-shell");
const status = shell?.querySelector<HTMLElement>(".copy-status");
const code = shell?.querySelector<HTMLElement>(".cmd-text");
if (!label || !status || !code) return;
const original = label.textContent ?? "";
let resetTimer: number | undefined;
let announceTimer: number | undefined;
const announce = (message: string) => {
window.clearTimeout(announceTimer);
status.textContent = "";
announceTimer = window.setTimeout(() => {
status.textContent = message;
}, 20);
};
button.addEventListener("click", async () => {
const command = button.dataset["copy"] ?? "";
const copied = button.dataset["copied"] ?? "Copied";
window.clearTimeout(resetTimer);
try {
await navigator.clipboard.writeText(command);
label.textContent = copied;
announce(document.documentElement.lang === "ko"
? "설치 명령을 클립보드에 복사했습니다."
: "Install command copied to the clipboard.");
} catch {
const range = document.createRange();
range.selectNodeContents(code);
const selection = getSelection();
selection?.removeAllRanges();
selection?.addRange(range);
announce(document.documentElement.lang === "ko"
? "설치 명령을 선택했습니다. 복사 단축키를 눌러 주세요."
: "The install command is selected. Use your copy shortcut.");
}
resetTimer = window.setTimeout(() => {
label.textContent = original;
}, 1600);
});
});
</script>