05굴러 들어오는 빈 장바구니
장바구니가 왼쪽에서 굴러 들어와 가운데에서 한 번 기울었다가, 왔던 길 그대로 다시 왼쪽으로 굴러 나갑니다.
쓰임결제 전 장바구니가 비어 있어 담으러 돌아가야 하는 커머스 화면
translateXrotatetransform-origin

<main class="stage">
<section class="ct is-demo" aria-labelledby="ct-t">
<div class="ct__track">
<span class="ct__cart" aria-hidden="true"><svg viewBox="0 0 256 256" width="1em" height="1em"><g fill="currentColor"><path d="m232 72l-25.63 92.28A16 16 0 0 1 191 176H92.16a16 16 0 0 1-15.41-11.72L51.11 72Z" opacity=".2"/><path d="M104 216a16 16 0 1 1-16-16a16 16 0 0 1 16 16m88-16a16 16 0 1 0 16 16a16 16 0 0 0-16-16m47.71-125.86l-25.64 92.28A24.06 24.06 0 0 1 191 184H92.16A24.06 24.06 0 0 1 69 166.42L33.92 40H16a8 8 0 0 1 0-16h24a8 8 0 0 1 7.71 5.86L57.19 64H232a8 8 0 0 1 7.71 10.14M221.47 80H61.64l22.81 82.14a8 8 0 0 0 7.71 5.86H191a8 8 0 0 0 7.71-5.86Z"/></g></svg></span>
</div>
<h2 class="ct__title" id="ct-t">장바구니가 비었습니다</h2>
<p class="ct__sub" id="ct-s" data-fmt="담은 상품 {n}개 · {won}원" aria-live="polite">담은 상품 0개 · 0원</p>
<button class="ct__btn" type="button" id="ct-b" data-more="하나 더 담기">쇼핑 계속하기</button>
</section>
</main>@use "../../../../site/static/demo-tokens" as *;
$duration: $dur-loop;
$easing: $ease-spring;
$color: $subject-cream;
@include stage($stage-ink);
.ct {
box-sizing: border-box;
width: min(248px, 86vw);
display: flex;
flex-direction: column;
align-items: center;
gap: $sp-2;
font-family: -apple-system, "Segoe UI", "Noto Sans KR", sans-serif;
text-align: center;
color: $color;
}
.ct__track {
box-sizing: border-box;
width: 100%;
height: 64px;
display: grid;
place-items: center;
border-bottom: 1px dashed rgba(255, 247, 230, .28);
overflow: hidden;
}
.ct__cart {
display: block;
font-size: clamp(36px, 11vw, 48px);
line-height: 0;
color: $color;
transform-origin: 50% 78%; // 규칙8: 수레 바퀴점 피벗
}
.ct__title {
margin: 0;
font-size: clamp(12px, 4vw, 14px);
line-height: 1.3;
font-weight: 800;
}
.ct__sub {
margin: 0;
min-height: 14px;
font-size: 11px;
line-height: 14px;
font-weight: 600;
color: rgba(255, 247, 230, .62);
}
.ct.is-filled .ct__sub { color: $color; }
.ct__btn {
height: 28px;
margin: 0;
padding: 0 $sp-4;
border: 0;
border-radius: $r-pill;
background: $subject-blue-deep;
color: $color;
font-family: inherit;
font-size: 11px;
font-weight: 700;
cursor: pointer;
}
.ct__btn:focus-visible { outline: 2px solid $color; outline-offset: 2px; }
// ── 자동 루프: 왼쪽에서 굴러 들어와 한 번 기울었다가 같은 길로 굴러 나간다. 0% 와 100% 가 같은 자리 ──
.ct.is-demo .ct__cart { animation: ct-roll $duration $easing infinite; }
@keyframes ct-roll {
0%, 100% { transform: translateX(-74px) rotate(-14deg); }
38% { transform: translateX(0) rotate(0deg); }
52% { transform: translateX(0) rotate(-9deg); }
66% { transform: translateX(0) rotate(0deg); }
}
@media (prefers-reduced-motion: reduce) {
.ct.is-demo .ct__cart { animation: none !important; transform: translateX(0); }
}html, body {
margin: 0;
overflow: hidden;
}
.stage {
box-sizing: border-box;
min-height: 100vh;
display: grid;
place-items: center;
margin: 0;
background: #17141a;
font-family: -apple-system, "Segoe UI", "Noto Sans KR", sans-serif;
padding: clamp(8px, 4vw, 24px);
}
.ct {
box-sizing: border-box;
width: min(248px, 86vw);
display: flex;
flex-direction: column;
align-items: center;
gap: 8px;
font-family: -apple-system, "Segoe UI", "Noto Sans KR", sans-serif;
text-align: center;
color: #fff7e6;
}
.ct__track {
box-sizing: border-box;
width: 100%;
height: 64px;
display: grid;
place-items: center;
border-bottom: 1px dashed rgba(255, 247, 230, 0.28);
overflow: hidden;
}
.ct__cart {
display: block;
font-size: clamp(36px, 11vw, 48px);
line-height: 0;
color: #fff7e6;
transform-origin: 50% 78%;
}
.ct__title {
margin: 0;
font-size: clamp(12px, 4vw, 14px);
line-height: 1.3;
font-weight: 800;
}
.ct__sub {
margin: 0;
min-height: 14px;
font-size: 11px;
line-height: 14px;
font-weight: 600;
color: rgba(255, 247, 230, 0.62);
}
.ct.is-filled .ct__sub {
color: #fff7e6;
}
.ct__btn {
height: 28px;
margin: 0;
padding: 0 16px;
border: 0;
border-radius: 999px;
background: #0a4fe8;
color: #fff7e6;
font-family: inherit;
font-size: 11px;
font-weight: 700;
cursor: pointer;
}
.ct__btn:focus-visible {
outline: 2px solid #fff7e6;
outline-offset: 2px;
}
.ct.is-demo .ct__cart {
animation: ct-roll 2s cubic-bezier(0.2, 0.8, 0.2, 1) infinite;
}
@keyframes ct-roll {
0%, 100% {
transform: translateX(-74px) rotate(-14deg);
}
38% {
transform: translateX(0) rotate(0deg);
}
52% {
transform: translateX(0) rotate(-9deg);
}
66% {
transform: translateX(0) rotate(0deg);
}
}
@media (prefers-reduced-motion: reduce) {
.ct.is-demo .ct__cart {
animation: none !important;
transform: translateX(0);
}
}// 실제 동작: 버튼을 누를 때마다 상품 하나가 실제로 담기고 합계가 다시 계산된다.
var card = document.querySelector('.ct');
var btn = document.getElementById('ct-b');
var sub = document.getElementById('ct-s');
var items = 0;
btn.addEventListener('click', function () {
card.classList.remove('is-demo');
items += 1;
card.classList.toggle('is-filled', items > 0);
sub.textContent = sub.dataset.fmt.replace('{n}', items).replace('{won}', (items * 12000).toLocaleString());
btn.textContent = btn.dataset.more;
});import { useState } from "react";
import type { CSSProperties } from "react";
import styles from "./EmptyCartCard.module.scss";
export type EmptyCartCardProps = {
title?: string;
fmt?: string;
action?: string;
more?: string;
unitPrice?: number;
duration?: number;
easing?: string;
color?: string;
};
type Vars = CSSProperties & { "--duration"?: string; "--easing"?: string; "--color"?: string };
export default function EmptyCartCard({
title = "Your cart is empty",
fmt = "{n} items · {won} KRW",
action = "Keep shopping",
more = "Add one more",
unitPrice = 12000,
duration = 2000,
easing = "cubic-bezier(.2,.8,.2,1)",
color = "#fff7e6",
}: EmptyCartCardProps) {
const [items, setItems] = useState(0);
const [loop, setLoop] = useState(true);
const vars: Vars = { "--duration": `${duration}ms`, "--easing": easing, "--color": color };
const sub = fmt.replace("{n}", String(items)).replace("{won}", (items * unitPrice).toLocaleString());
const cls = [styles.ct, loop ? styles.isDemo : "", items > 0 ? styles.isFilled : ""].join(" ");
return (
<section className={cls} style={vars}>
<div className={styles.track}>
<span className={styles.cart} aria-hidden="true">
<svg viewBox="0 0 256 256" width="1em" height="1em">
<g fill="currentColor">
<path d="m232 72l-25.63 92.28A16 16 0 0 1 191 176H92.16a16 16 0 0 1-15.41-11.72L51.11 72Z" opacity=".2" />
<path d="M104 216a16 16 0 1 1-16-16a16 16 0 0 1 16 16m88-16a16 16 0 1 0 16 16a16 16 0 0 0-16-16m47.71-125.86l-25.64 92.28A24.06 24.06 0 0 1 191 184H92.16A24.06 24.06 0 0 1 69 166.42L33.92 40H16a8 8 0 0 1 0-16h24a8 8 0 0 1 7.71 5.86L57.19 64H232a8 8 0 0 1 7.71 10.14M221.47 80H61.64l22.81 82.14a8 8 0 0 0 7.71 5.86H191a8 8 0 0 0 7.71-5.86Z" />
</g>
</svg>
</span>
</div>
<h2 className={styles.title}>{title}</h2>
<p className={styles.sub} aria-live="polite">{sub}</p>
<button
className={styles.btn}
type="button"
onClick={() => { setLoop(false); setItems(items + 1); }}
>
{items > 0 ? more : action}
</button>
</section>
);
}05 굴러 들어오는 빈 장바구니 — 측정 누적면적 2.624% · 움직인 프레임 23/23GODRICH 원작 · zip 에 SCSS·React 포함 · 빈 화면 디자인 9종 — CSS로 그리는 빈 상태 카드
이 데모가 속한 글
빈 화면 디자인 9종 — CSS로 그리는 빈 상태 카드빈 화면 디자인은 목록에 표시할 데이터가 하나도 없을 때 그 빈 자리를 대신 채우는 화면입니다. 여기 아홉 개 중 하나는 데이터가 없어서가 아니라 볼 권한이 없어서 비어 있고, 그 차이를 자물쇠 하나로 구분해 말합니 이 글의 데모 전부 보기


