feat(site): redesign promotion experience

This commit is contained in:
Yun Chan 2026-08-30 17:52:54 +09:00
parent 6930906583
commit 13dd160c16
39 changed files with 5764 additions and 5738 deletions

View file

@ -5,99 +5,133 @@ interface Props {
copiedLabel: string;
note?: string;
}
const { command, copyLabel, copiedLabel, note } = Astro.props;
---
{/* 명령어를 담는 액자. 유리를 쓰는 세 자리 중 하나다 */}
<div class="cmd-shell frame">
<div class="cmd-shell">
<div class="cmd">
<code class="cmd-text">{command}</code>
<button type="button" class="btn btn-solid cmd-copy" data-copy={command} data-copied={copiedLabel}>
<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>
<span class="cmd-copy-icon" aria-hidden="true">
<svg viewBox="0 0 16 16" width="12" height="12" fill="none">
<path d="M5.5 10.5L10.5 5.5M10.5 5.5H6.5M10.5 5.5V9.5"
stroke="currentColor" stroke-width="1.4" stroke-linecap="round" stroke-linejoin="round"/>
</svg>
</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 { max-width: 30em; min-width: 0; }
.cmd {
display: flex;
.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) var(--space-2) var(--space-2) var(--space-3);
padding: var(--space-2);
}
.cmd-text {
flex: 1 1 0;
min-width: 0;
overflow-x: auto;
white-space: nowrap;
padding-inline: var(--space-2);
color: var(--ink);
}
.cmd-text::before {
content: "$ ";
color: var(--ink-muted);
line-height: var(--control-h);
white-space: nowrap;
scrollbar-width: thin;
}
/* 높이·패딩·웨이트·전환은 .btn 이 정한다. 여기서는 이 자리에만
필요한 것만 더한다 — 아이콘이 오른쪽 안쪽에 붙어야 해서 그쪽만 좁다 */
.cmd-copy {
flex: 0 0 auto;
padding-right: var(--space-2);
font-family: inherit;
}
.cmd-copy-icon {
display: inline-flex;
align-items: center;
justify-content: center;
width: 26px;
height: 26px;
border-radius: var(--radius-sm);
background: color-mix(in oklab, var(--accent-ink) 18%, transparent);
.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 .cmd-copy-icon { transform: translate(2px, -2px); }
.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-0);
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((btn) => {
const label = btn.querySelector<HTMLSpanElement>(".cmd-copy-label");
if (!label) return;
btn.addEventListener("click", async () => {
const text = btn.dataset["copy"] ?? "";
const done = btn.dataset["copied"] ?? "OK";
const original = label.textContent;
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(text);
await navigator.clipboard.writeText(command);
label.textContent = copied;
announce(document.documentElement.lang === "ko"
? "설치 명령을 클립보드에 복사했어요."
: "Install command copied to the clipboard.");
} catch {
// 클립보드 권한이 없으면 선택 상태로 만들어 사용자가 직접 복사하게 둔다
const code = btn.parentElement?.querySelector(".cmd-text");
if (code) {
const range = document.createRange();
range.selectNodeContents(code);
const sel = getSelection();
sel?.removeAllRanges();
sel?.addRange(range);
}
return;
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.");
}
label.textContent = done;
label.setAttribute("aria-live", "polite");
setTimeout(() => { label.textContent = original; }, 1600);
resetTimer = window.setTimeout(() => {
label.textContent = original;
}, 1600);
});
});
</script>