feat: 카드뉴스 포스트(관리자 admin/, /v1/card API, 피드 이미지 슬라이드), 인스타 홍보 기획 문서
This commit is contained in:
1 parent
96cbd19c61
commit
739a8c59eb
107 files changed
+17684
-19
No files matched your search
@@ -0,0 +1,32 @@
|
||||
import type { CSSProperties, ReactNode } from 'react'
|
||||
import { themeVars } from './themes'
|
||||
|
||||
/** 줄바꿈(\n)은 카드에서도 줄바꿈, *별표* 사이는 강조색 */
|
||||
export function Lines({ text }: { text: string }) {
|
||||
return text.split('\n').map((line, i) => (
|
||||
<span className="line" key={i}>
|
||||
{line.split(/(\*[^*]+\*)/).map((part, j) => (part.startsWith('*') && part.endsWith('*') ? <strong key={j}>{part.slice(1, -1)}</strong> : part))}
|
||||
</span>
|
||||
))
|
||||
}
|
||||
|
||||
export function Frame({ page, total, theme, skin, className = '', style, children }: { page: number; total: number; theme?: string; skin?: string; className?: string; style?: CSSProperties; children: ReactNode }) {
|
||||
return (
|
||||
<section className={`slide ${className}`} data-skin={skin || 'star'} style={{ ...themeVars(theme), ...style }}>
|
||||
<header className="topbar">
|
||||
<div className="brand">
|
||||
<i className="brand-mark" aria-hidden="true" />
|
||||
날씨각
|
||||
</div>
|
||||
{total > 1 && (
|
||||
<div className="pagination" aria-hidden="true">
|
||||
{Array.from({ length: total }, (_, i) => (
|
||||
<i key={i} className={i === page ? 'active' : ''} />
|
||||
))}
|
||||
</div>
|
||||
)}
|
||||
</header>
|
||||
{children}
|
||||
</section>
|
||||
)
|
||||
}
|
||||
@@ -0,0 +1,482 @@
|
||||
/* 인스타 카드 1080×1350. 브랜드 색·서체는 서비스(frontend b.css)와 같다 */
|
||||
.slide {
|
||||
--ink: #28304a;
|
||||
--paper: #f7fbff;
|
||||
--orange: #ff7a45;
|
||||
--rust: #d4552a;
|
||||
--blue: #4f97e3;
|
||||
--muted: #546078;
|
||||
--accent: var(--rust);
|
||||
--tint: #fff0e5;
|
||||
--soft: #ffd7bd;
|
||||
--stage: #e1efff;
|
||||
position: relative;
|
||||
width: 1080px;
|
||||
height: 1350px;
|
||||
overflow: hidden;
|
||||
background: var(--paper);
|
||||
color: var(--ink);
|
||||
font-family: 'Pretendard Variable', Pretendard, sans-serif;
|
||||
isolation: isolate;
|
||||
word-break: keep-all;
|
||||
-webkit-font-smoothing: antialiased;
|
||||
}
|
||||
.slide h1,
|
||||
.slide h2,
|
||||
.slide p,
|
||||
.slide ol {
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
font-weight: 400;
|
||||
}
|
||||
.slide .line {
|
||||
display: block;
|
||||
}
|
||||
.slide strong {
|
||||
color: var(--accent);
|
||||
font-weight: inherit;
|
||||
}
|
||||
|
||||
/* 공통 머리 */
|
||||
.slide .topbar {
|
||||
position: absolute;
|
||||
top: 85px;
|
||||
left: 80px;
|
||||
right: 80px;
|
||||
height: 53px;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
z-index: 5;
|
||||
}
|
||||
.slide .brand {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 12px;
|
||||
font: 40px/1 Jua, sans-serif;
|
||||
letter-spacing: -1px;
|
||||
}
|
||||
.slide .brand-mark {
|
||||
position: relative;
|
||||
display: block;
|
||||
width: 30px;
|
||||
height: 30px;
|
||||
border-radius: 50%;
|
||||
background: var(--orange);
|
||||
box-shadow: 0 4px 0 var(--rust);
|
||||
}
|
||||
.slide .brand-mark::after {
|
||||
content: '';
|
||||
position: absolute;
|
||||
right: -7px;
|
||||
bottom: -2px;
|
||||
width: 23px;
|
||||
height: 12px;
|
||||
border-radius: 10px;
|
||||
background: #bddbfb;
|
||||
border: 3px solid var(--paper);
|
||||
}
|
||||
.slide .pagination {
|
||||
display: flex;
|
||||
gap: 10px;
|
||||
}
|
||||
.slide .pagination i {
|
||||
display: block;
|
||||
width: 10px;
|
||||
height: 10px;
|
||||
border-radius: 50%;
|
||||
background: #cbd7e7;
|
||||
}
|
||||
.slide .pagination i.active {
|
||||
width: 30px;
|
||||
border-radius: 8px;
|
||||
background: var(--accent);
|
||||
}
|
||||
.slide .meta {
|
||||
position: absolute;
|
||||
top: 174px;
|
||||
left: 80px;
|
||||
font-size: 32px;
|
||||
font-weight: 600;
|
||||
color: var(--muted);
|
||||
letter-spacing: -0.6px;
|
||||
}
|
||||
.slide .meta.right {
|
||||
top: 92px;
|
||||
left: auto;
|
||||
right: 88px;
|
||||
}
|
||||
.slide .sparkle {
|
||||
position: absolute;
|
||||
width: 44px;
|
||||
height: 44px;
|
||||
background: var(--orange);
|
||||
clip-path: polygon(50% 0, 64% 36%, 100% 50%, 64% 64%, 50% 100%, 36% 64%, 0 50%, 36% 36%);
|
||||
z-index: 2;
|
||||
}
|
||||
|
||||
/* OOTD */
|
||||
.ootd .meta {
|
||||
top: 168px;
|
||||
}
|
||||
.ootd-title {
|
||||
position: absolute;
|
||||
top: 214px;
|
||||
left: 80px;
|
||||
right: 80px;
|
||||
font: 104px/1.1 Jua, sans-serif;
|
||||
letter-spacing: -3px;
|
||||
white-space: nowrap;
|
||||
}
|
||||
.ootd-stage {
|
||||
position: absolute;
|
||||
top: 350px;
|
||||
left: 80px;
|
||||
width: 920px;
|
||||
height: 840px;
|
||||
border-radius: 44px;
|
||||
overflow: hidden;
|
||||
background: var(--stage);
|
||||
}
|
||||
.ootd-stage > img {
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
object-fit: cover;
|
||||
}
|
||||
.ootd-labels {
|
||||
position: absolute;
|
||||
inset: 24px;
|
||||
display: grid;
|
||||
grid-template-columns: auto auto;
|
||||
align-content: space-between;
|
||||
justify-content: space-between;
|
||||
justify-items: start;
|
||||
gap: 16px;
|
||||
}
|
||||
.ootd-labels span:nth-child(even) {
|
||||
justify-self: end;
|
||||
}
|
||||
.ootd-labels span {
|
||||
padding: 8px 20px;
|
||||
border-radius: 99px;
|
||||
background: #fff;
|
||||
font-size: 30px;
|
||||
font-weight: 700;
|
||||
box-shadow: 0 6px 16px #28304a1f;
|
||||
}
|
||||
.ootd-labels.only {
|
||||
inset: 60px;
|
||||
flex-direction: column;
|
||||
flex-wrap: nowrap;
|
||||
align-content: center;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
gap: 28px;
|
||||
}
|
||||
.ootd-labels.only span {
|
||||
padding: 18px 44px;
|
||||
font: 60px/1.2 Jua, sans-serif;
|
||||
}
|
||||
/* 날씨 타로 표지·마지막 장 */
|
||||
.cover-title {
|
||||
position: absolute;
|
||||
top: 170px;
|
||||
left: 100px;
|
||||
width: 880px;
|
||||
text-align: center;
|
||||
font-family: Jua, sans-serif;
|
||||
line-height: 1.07;
|
||||
letter-spacing: -4px;
|
||||
z-index: 3;
|
||||
}
|
||||
.cover-title .line:first-child {
|
||||
font-size: 64px;
|
||||
}
|
||||
.cover-title .line + .line {
|
||||
margin-top: 10px;
|
||||
font-size: 124px;
|
||||
color: var(--rust);
|
||||
text-shadow: 0 6px 0 var(--soft);
|
||||
}
|
||||
/* 타로 질문: 이 질문에 카드가 답한다 */
|
||||
.slide .cover-question {
|
||||
position: absolute;
|
||||
top: 400px;
|
||||
left: 50%;
|
||||
transform: translateX(-50%);
|
||||
width: max-content;
|
||||
max-width: 900px;
|
||||
padding: 14px 28px;
|
||||
border-radius: 99px;
|
||||
background: #fff;
|
||||
box-shadow: 0 6px 0 var(--soft), 0 14px 26px #28304a10;
|
||||
text-align: center;
|
||||
font-size: 34px;
|
||||
font-weight: 700;
|
||||
line-height: 1.3;
|
||||
letter-spacing: -1.2px;
|
||||
white-space: nowrap;
|
||||
z-index: 5;
|
||||
}
|
||||
.slide .cover-question b {
|
||||
margin-right: 10px;
|
||||
font: 38px/1 'Bagel Fat One', sans-serif;
|
||||
color: var(--rust);
|
||||
}
|
||||
.cover-stage {
|
||||
position: absolute;
|
||||
top: 600px;
|
||||
left: 92px;
|
||||
width: 896px;
|
||||
height: 500px;
|
||||
border-radius: 50%;
|
||||
background: var(--stage);
|
||||
}
|
||||
.back-card {
|
||||
position: absolute;
|
||||
width: 250px;
|
||||
height: 375px;
|
||||
border-radius: 22px;
|
||||
box-shadow: 0 13px 0 #b8cce1, 0 23px 26px #28304a1c;
|
||||
z-index: 3;
|
||||
}
|
||||
.back-card img {
|
||||
display: block;
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
border-radius: 22px;
|
||||
object-fit: cover;
|
||||
}
|
||||
.back-card .number {
|
||||
position: absolute;
|
||||
top: 42px;
|
||||
left: calc(50% - 44px);
|
||||
width: 88px;
|
||||
height: 88px;
|
||||
padding-bottom: 6px;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
border-radius: 50%;
|
||||
font: 67px/1 'Bagel Fat One', sans-serif;
|
||||
color: var(--ink);
|
||||
background: var(--paper);
|
||||
border: 5px solid #ffb76f;
|
||||
box-shadow: 0 5px 0 #171f37;
|
||||
}
|
||||
.back-card.big.card-1 { left: 117px; top: 651px; transform: rotate(-9deg); }
|
||||
.back-card.big.card-2 { left: 415px; top: 588px; transform: rotate(1deg); }
|
||||
.back-card.big.card-3 { left: 713px; top: 651px; transform: rotate(9deg); }
|
||||
.tarot-cover .rabbit,
|
||||
.tarot-cover .bear {
|
||||
position: absolute;
|
||||
top: 1120px;
|
||||
width: 120px;
|
||||
height: 120px;
|
||||
z-index: 4;
|
||||
}
|
||||
.tarot-cover .rabbit { left: 145px; transform: rotate(-10deg); }
|
||||
.tarot-cover .bear { right: 143px; top: 1128px; transform: rotate(9deg); }
|
||||
.cover-date {
|
||||
position: absolute;
|
||||
top: 1200px;
|
||||
left: 190px;
|
||||
width: 700px;
|
||||
text-align: center;
|
||||
font-size: 30px;
|
||||
font-weight: 600;
|
||||
letter-spacing: -0.6px;
|
||||
color: var(--muted);
|
||||
}
|
||||
.tarot-cover .sparkle.a { left: 167px; top: 260px; width: 55px; height: 55px; transform: rotate(13deg); }
|
||||
.tarot-cover .sparkle.b { right: 166px; top: 374px; width: 40px; height: 40px; background: var(--blue); }
|
||||
.tarot-cover .sparkle.c { left: 508px; top: 1108px; width: 54px; height: 54px; }
|
||||
|
||||
/* 날씨 타로 결과 장 */
|
||||
|
||||
|
||||
/* 주제별 꾸밈 (topics.json skin): 반짝이(.sparkle)와 표지 장식(.deco) 모양만 바뀐다 */
|
||||
.slide .deco {
|
||||
position: absolute;
|
||||
width: 30px;
|
||||
height: 30px;
|
||||
background: var(--orange);
|
||||
clip-path: polygon(50% 0, 64% 36%, 100% 50%, 64% 64%, 50% 100%, 36% 64%, 0 50%, 36% 36%);
|
||||
opacity: 0.85;
|
||||
z-index: 2;
|
||||
}
|
||||
.slide .deco.d1 { left: 74px; top: 560px; width: 30px; height: 30px; }
|
||||
.slide .deco.d2 { right: 70px; top: 520px; width: 38px; height: 38px; background: var(--blue); }
|
||||
.slide .deco.d3 { left: 58px; top: 905px; width: 26px; height: 26px; background: var(--blue); }
|
||||
.slide .deco.d4 { right: 64px; top: 880px; width: 32px; height: 32px; }
|
||||
.slide .deco.d5 { left: 330px; top: 1160px; width: 24px; height: 24px; background: var(--blue); }
|
||||
.slide .deco.d6 { right: 330px; top: 1175px; width: 28px; height: 28px; }
|
||||
|
||||
.slide[data-skin='heart'] :is(.sparkle, .deco) {
|
||||
clip-path: none;
|
||||
-webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M12 21.5s-7.8-4.7-10-9.4C.4 8.6 2.5 4.4 6.4 4.4c2.3 0 3.8 1.3 5.6 3.4 1.8-2.1 3.3-3.4 5.6-3.4 3.9 0 6 4.2 4.4 7.7-2.2 4.7-10 9.4-10 9.4z'/%3E%3C/svg%3E") center / contain no-repeat;
|
||||
mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M12 21.5s-7.8-4.7-10-9.4C.4 8.6 2.5 4.4 6.4 4.4c2.3 0 3.8 1.3 5.6 3.4 1.8-2.1 3.3-3.4 5.6-3.4 3.9 0 6 4.2 4.4 7.7-2.2 4.7-10 9.4-10 9.4z'/%3E%3C/svg%3E") center / contain no-repeat;
|
||||
}
|
||||
.slide[data-skin='coin'] :is(.sparkle, .deco) {
|
||||
clip-path: none;
|
||||
border-radius: 50%;
|
||||
background: radial-gradient(circle, var(--orange) 0 52%, var(--rust) 53% 62%, var(--orange) 63%);
|
||||
}
|
||||
.slide[data-skin='clover'] :is(.sparkle, .deco) {
|
||||
clip-path: none;
|
||||
-webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Ccircle cx='8' cy='8' r='5'/%3E%3Ccircle cx='16' cy='8' r='5'/%3E%3Ccircle cx='8' cy='16' r='5'/%3E%3Ccircle cx='16' cy='16' r='5'/%3E%3C/svg%3E") center / contain no-repeat;
|
||||
mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Ccircle cx='8' cy='8' r='5'/%3E%3Ccircle cx='16' cy='8' r='5'/%3E%3Ccircle cx='8' cy='16' r='5'/%3E%3Ccircle cx='16' cy='16' r='5'/%3E%3C/svg%3E") center / contain no-repeat;
|
||||
}
|
||||
|
||||
/* 날씨 타로: 대주제(skin)마다 한 번 만든 배경 그림(src/assets/tarot-bg) 위에 카드·글만 갈아 끼운다 */
|
||||
.slide .tarot-bg {
|
||||
position: absolute;
|
||||
inset: 0;
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
object-fit: cover;
|
||||
z-index: 0;
|
||||
}
|
||||
.tarot-result > :not(.tarot-bg):not(.topbar) { position: relative; z-index: 1; }
|
||||
|
||||
/* 결과 장: 틀·장식 없이 카드 그림과 리딩이 화면을 채운다. 배경 그림이 없을 땐 아래쪽에 옅은 색 번짐만 */
|
||||
.tarot-result {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
padding: 150px 80px 64px;
|
||||
gap: 24px;
|
||||
background:
|
||||
radial-gradient(60% 34% at 85% 96%, var(--tint) 0%, transparent 70%),
|
||||
radial-gradient(40% 24% at 8% 78%, var(--tint) 0%, transparent 70%),
|
||||
var(--paper);
|
||||
}
|
||||
.tarot-result .topbar { z-index: 5; }
|
||||
.result-head {
|
||||
display: flex;
|
||||
align-items: flex-end;
|
||||
gap: 18px;
|
||||
}
|
||||
.slide .card-no {
|
||||
margin-bottom: 14px;
|
||||
padding: 8px 16px;
|
||||
border-radius: 99px;
|
||||
background: var(--tint);
|
||||
font: 700 30px/1 'Pretendard Variable', Pretendard, sans-serif;
|
||||
color: var(--accent);
|
||||
letter-spacing: -0.5px;
|
||||
}
|
||||
.slide .card-name {
|
||||
font: 96px/1 Jua, sans-serif;
|
||||
letter-spacing: -3px;
|
||||
}
|
||||
.result-body {
|
||||
display: grid;
|
||||
grid-template-columns: 520px minmax(0, 1fr);
|
||||
gap: 32px;
|
||||
align-items: stretch;
|
||||
}
|
||||
.slide .card-art {
|
||||
width: 520px;
|
||||
height: 780px;
|
||||
object-fit: cover;
|
||||
border-radius: 30px;
|
||||
box-shadow: 0 12px 0 var(--tint), 0 22px 40px #28304a22;
|
||||
}
|
||||
.slide .card-art-fallback {
|
||||
display: grid;
|
||||
place-items: center;
|
||||
background: var(--tint);
|
||||
}
|
||||
.slide .card-art-fallback img {
|
||||
width: 280px;
|
||||
height: 280px;
|
||||
object-fit: contain;
|
||||
}
|
||||
.result-text {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 22px;
|
||||
}
|
||||
.slide .card-keyword {
|
||||
font: 700 34px/1.3 'Pretendard Variable', Pretendard, sans-serif;
|
||||
color: var(--accent);
|
||||
letter-spacing: -1px;
|
||||
}
|
||||
.slide .reading {
|
||||
font: 500 38px/1.55 'Pretendard Variable', Pretendard, sans-serif;
|
||||
letter-spacing: -1px;
|
||||
/* 단어(어절) 단위로만 줄을 바꾸고, 마지막 줄에 한 어절만 남지 않게 */
|
||||
word-break: keep-all;
|
||||
overflow-wrap: normal;
|
||||
text-wrap: pretty;
|
||||
}
|
||||
.slide .reading .line { display: inline; }
|
||||
.slide .reading strong {
|
||||
font-weight: 750;
|
||||
color: var(--accent);
|
||||
}
|
||||
.slide .lucky {
|
||||
margin-top: 18px;
|
||||
padding: 24px 32px;
|
||||
border-radius: 24px;
|
||||
background: var(--tint);
|
||||
font: 700 34px/1.35 'Pretendard Variable', Pretendard, sans-serif;
|
||||
letter-spacing: -0.8px;
|
||||
color: var(--accent);
|
||||
}
|
||||
.slide .lucky::before {
|
||||
content: '행운 포인트 · ';
|
||||
opacity: 0.7;
|
||||
}
|
||||
/* 맨 위: 이 장이 답하는 질문 → 카드 번호·이름 → 그림 순으로 읽힌다 */
|
||||
.slide .result-question {
|
||||
display: flex;
|
||||
gap: 14px;
|
||||
align-items: baseline;
|
||||
font: 600 30px/1.4 'Pretendard Variable', Pretendard, sans-serif;
|
||||
letter-spacing: -0.8px;
|
||||
color: var(--muted);
|
||||
word-break: keep-all;
|
||||
}
|
||||
.slide .result-question b {
|
||||
font: 32px/1 'Bagel Fat One', sans-serif;
|
||||
color: var(--accent);
|
||||
}
|
||||
.slide .footnote {
|
||||
margin-top: auto;
|
||||
font-size: 28px;
|
||||
font-weight: 600;
|
||||
color: var(--muted);
|
||||
}
|
||||
|
||||
/* 코디 장 아래: 오늘 날씨 한 줄 */
|
||||
.slide .ootd-weather {
|
||||
position: absolute;
|
||||
left: 80px;
|
||||
right: 80px;
|
||||
bottom: 64px;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 18px;
|
||||
font: 600 36px/1.2 'Pretendard Variable', Pretendard, sans-serif;
|
||||
letter-spacing: -1px;
|
||||
color: var(--ink);
|
||||
}
|
||||
.slide .ootd-weather img {
|
||||
width: 64px;
|
||||
height: 64px;
|
||||
object-fit: contain;
|
||||
}
|
||||
.slide .ootd-weather b {
|
||||
font: 700 40px/1 'Pretendard Variable', Pretendard, sans-serif;
|
||||
color: var(--rust);
|
||||
}
|
||||
|
||||
/* 마지막 장은 표지와 같은 틀. 안내 문구만 캐릭터 사이에 두 줄로 */
|
||||
.tarot-closing .cover-date {
|
||||
left: 290px;
|
||||
width: 500px;
|
||||
top: 1192px;
|
||||
font-size: 27px;
|
||||
line-height: 1.4;
|
||||
}
|
||||
@@ -0,0 +1,41 @@
|
||||
import '../api/setup'
|
||||
import { loadCardData } from './data'
|
||||
import { neededImages } from './images'
|
||||
import { templateById } from './templates'
|
||||
import type { Copy } from './templates'
|
||||
|
||||
/** Claude 기획 요청에 넘기는 재료: 템플릿 설명·칸·지금 문구·오늘 날씨. 관리자 서버(/api/plan)가 불러 쓴다 */
|
||||
export async function planContext(templateId: string, current: Copy = {}) {
|
||||
const template = templateById(templateId)
|
||||
if (!template) throw new Error(`템플릿 '${templateId}' 이 없어요`)
|
||||
const d = await loadCardData()
|
||||
const defaults = template.defaults(d)
|
||||
return {
|
||||
template: { id: template.id, name: template.name, about: template.about, how: template.how },
|
||||
fields: template.fields,
|
||||
defaults,
|
||||
current: { ...defaults, ...current },
|
||||
weather: {
|
||||
date: d.dateLabel,
|
||||
headline: d.headline,
|
||||
morningC: d.morningC,
|
||||
maxC: d.maxC,
|
||||
minC: d.minC,
|
||||
rainy: d.rainy,
|
||||
오늘_각_점수: d.gaks.map((g) => ({ code: g.code, name: g.name, score: g.score, summary: g.summary })),
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
/** 이 카드에 아직 없는 그림 (all 이면 다시 그릴 그림 전부). 관리자 서버(/api/gen-image)가 쓴다 */
|
||||
export async function missingImages(templateId: string, copy: Copy = {}, all = false) {
|
||||
return neededImages(templateId, await loadCardData(), copy, all)
|
||||
}
|
||||
|
||||
/** 날씨각 피드 포스트 제목·설명 (npm run card --post 처럼 화면 밖에서 올릴 때) */
|
||||
export async function postText(templateId: string, copy: Copy = {}) {
|
||||
const template = templateById(templateId)
|
||||
if (!template) throw new Error(`템플릿 '${templateId}' 이 없어요`)
|
||||
const d = await loadCardData()
|
||||
return template.post(d, { ...template.defaults(d), ...copy })
|
||||
}
|
||||
@@ -0,0 +1,86 @@
|
||||
import { useQuery } from '@tanstack/react-query'
|
||||
import { getWeatherToday, listIndices } from '../api/client'
|
||||
import type { IndexSummary, WeatherSlot } from '../api/client'
|
||||
import { RainType } from '../api/client'
|
||||
|
||||
/** 인스타 카드는 지역을 고르지 않고 서울(중구) 예보 하나로 만든다. 카드에 지역 이름은 나가지 않는다 */
|
||||
export const BASE_REGION = '1114000000'
|
||||
|
||||
/** 템플릿이 쓰는 그날 데이터. 웹 화면과 대화로 만드는 이미지가 같은 값을 쓴다 */
|
||||
export type CardData = {
|
||||
regionCode: string
|
||||
regionName: string
|
||||
day: string
|
||||
/** '10.21 화' */
|
||||
dateLabel: string
|
||||
headline: string
|
||||
top3: IndexSummary[]
|
||||
/** 오늘 각 전체 (점수 높은 순) — 날씨 타로가 카드로 쓴다 */
|
||||
gaks: IndexSummary[]
|
||||
morningC: number
|
||||
maxC: number
|
||||
minC: number
|
||||
rainy: boolean
|
||||
}
|
||||
|
||||
const WEEKDAY = ['일', '월', '화', '수', '목', '금', '토']
|
||||
|
||||
export function dateLabel(day: string) {
|
||||
const d = day ? new Date(`${day}T00:00:00+09:00`) : new Date()
|
||||
return `${d.getMonth() + 1}.${d.getDate()} ${WEEKDAY[d.getDay()]}`
|
||||
}
|
||||
|
||||
/** 아침 6시~밤 9시 예보로 아침 기온·낮 최고·비 여부 */
|
||||
function temps(slots: WeatherSlot[]) {
|
||||
const hour = (s: WeatherSlot) => new Date(s.at).getHours()
|
||||
const withTemp = slots.filter((s) => s.temp_c != null)
|
||||
const day = withTemp.filter((s) => hour(s) >= 6 && hour(s) <= 21)
|
||||
const t = day.length ? day : withTemp
|
||||
const values = t.map((s) => s.temp_c as number)
|
||||
const morning = t.find((s) => hour(s) === 6) ?? t[0]
|
||||
return {
|
||||
morningC: Math.round(morning?.temp_c ?? 0),
|
||||
maxC: Math.round(Math.max(...values)),
|
||||
minC: Math.round(Math.min(...values)),
|
||||
rainy: t.some((s) => (s.rain_type != null && s.rain_type !== RainType.NONE) || (s.rain_prob ?? 0) >= 60),
|
||||
}
|
||||
}
|
||||
|
||||
type Indices = NonNullable<Awaited<ReturnType<typeof listIndices>>['data']>
|
||||
type Weather = NonNullable<Awaited<ReturnType<typeof getWeatherToday>>['data']>
|
||||
|
||||
/** 날씨각 API 는 실패를 200 + result.success=false 로 알린다 */
|
||||
function okOrThrow<T extends { result?: { success?: boolean; desc?: string } }>(data: T | undefined, what: string): T {
|
||||
if (!data || data.result?.success === false) throw new Error(`${what} 을(를) 받지 못했어요 (${data?.result?.desc ?? '응답 없음'})`)
|
||||
return data
|
||||
}
|
||||
const fetchIndices = (region: string) => listIndices({ query: { region } }).then((r) => okOrThrow(r.data, '오늘의 각'))
|
||||
const fetchWeather = (region: string) => getWeatherToday({ query: { region } }).then((r) => okOrThrow(r.data, '오늘 예보'))
|
||||
|
||||
function buildCardData(regionCode: string, indices: Indices, weather: Weather): CardData {
|
||||
const day = weather.day ?? ''
|
||||
return {
|
||||
regionCode,
|
||||
regionName: weather.region_name ?? '',
|
||||
day,
|
||||
dateLabel: dateLabel(day),
|
||||
headline: weather.headline ?? '',
|
||||
top3: indices.top3 ?? [],
|
||||
gaks: [...(indices.items ?? [])].sort((a, b) => b.score - a.score),
|
||||
...temps(weather.slots ?? []),
|
||||
}
|
||||
}
|
||||
|
||||
/** 화면 밖(기획 요청)에서 같은 데이터를 받을 때 */
|
||||
export async function loadCardData(regionCode = BASE_REGION) {
|
||||
const [indices, weather] = await Promise.all([fetchIndices(regionCode), fetchWeather(regionCode)])
|
||||
return buildCardData(regionCode, indices, weather)
|
||||
}
|
||||
|
||||
export function useCardData(regionCode: string) {
|
||||
const indices = useQuery({ queryKey: ['cards', 'indices', regionCode], queryFn: () => fetchIndices(regionCode), enabled: !!regionCode })
|
||||
const weather = useQuery({ queryKey: ['cards', 'weather', regionCode], queryFn: () => fetchWeather(regionCode), enabled: !!regionCode })
|
||||
const error = indices.error ?? weather.error
|
||||
if (!indices.data || !weather.data) return { data: null, error, loading: indices.isLoading || weather.isLoading }
|
||||
return { data: buildCardData(regionCode, indices.data, weather.data), error, loading: false }
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
import defs from '../../../backend/seed/index_definition.json'
|
||||
|
||||
/** 날씨 타로 카드 덱 = 날씨각 각 카드 (서비스와 같은 목록) */
|
||||
export type GakCard = { code: string; name: string; icon: string; meaning: string }
|
||||
export const GAK_DECK: GakCard[] = defs.map((g) => ({ code: g.code, name: g.name, icon: g.icon, meaning: g.description }))
|
||||
export const gakByCode = (code?: string) => GAK_DECK.find((g) => g.code === code)
|
||||
|
||||
// 각 카드 앞면 그림 (Codex, npm run gen-image -- gak-card <code>). 없으면 각 아이콘
|
||||
const ART = import.meta.glob<string>('../assets/gak-card/*.webp', { eager: true, import: 'default' })
|
||||
export const gakArt = (code?: string) => (code ? ART[`../assets/gak-card/${code}.webp`] : undefined)
|
||||
@@ -0,0 +1,2 @@
|
||||
/** 카드 아이콘: 서비스 각·날씨 아이콘(/icons, ../frontend/public/icons) */
|
||||
export const iconUrl = (name: string) => `/icons/${name}.png`
|
||||
@@ -0,0 +1,28 @@
|
||||
import type { CardData } from './data'
|
||||
import { gakArt } from './gaks'
|
||||
import { hasTarotBg } from './templates'
|
||||
import { ootdBand, ootdOutfits } from './ootd'
|
||||
import type { Copy } from './templates'
|
||||
|
||||
export type ImageNeed = { kind: string; ids: string[] }
|
||||
|
||||
/** 이 카드에 필요한 그림 중 아직 없는 것 (all 이면 전부). kind 는 image-prompts/<kind>.json, 그날 필요한 것만 Codex로 만든다. 타로는 그날 뽑힌 각 카드 그림 */
|
||||
export function neededImages(templateId: string, d: CardData, copy: Copy, all = false): ImageNeed[] {
|
||||
if (templateId === 'ootd') {
|
||||
const style = copy.style || 'casual'
|
||||
const band = ootdBand(d.maxC).id
|
||||
const ids = ootdOutfits(d.maxC, style)
|
||||
.filter((o) => all || !o.image)
|
||||
.map((o) => `${band}-${o.persona}-${style}`)
|
||||
return ids.length ? [{ kind: 'ootd', ids }] : []
|
||||
}
|
||||
if (templateId === 'tarot') {
|
||||
const out: ImageNeed[] = []
|
||||
const ids = ['c1', 'c2', 'c3'].map((k) => copy[k]).filter((id) => id && (all || !gakArt(id)))
|
||||
if (ids.length) out.push({ kind: 'gak-card', ids })
|
||||
// 대주제 배경은 한 번만 만들고 다시 쓴다
|
||||
if (copy.skin && (all || !hasTarotBg(copy.skin))) out.push({ kind: 'tarot-bg', ids: [copy.skin] })
|
||||
return out
|
||||
}
|
||||
return []
|
||||
}
|
||||
@@ -0,0 +1,34 @@
|
||||
import spec from '../../image-prompts/ootd.json'
|
||||
|
||||
/** 낮 최고기온 구간 × 스타일 × 사람별 옷. 옷 목록·카드 글자는 image-prompts/ootd.json 한 곳에서 정한다.
|
||||
* 그림은 src/assets/ootd/<구간>-<사람>-<스타일>.webp 가 있으면 자동으로 붙는다 (npm run gen-image -- ootd <구간|스타일>) */
|
||||
export type Outfit = { persona: string; label: string; labels: string[]; outer: string; image?: string }
|
||||
export type OotdBand = { id: string; from: number }
|
||||
|
||||
const IMAGES = import.meta.glob<string>('../assets/ootd/*.webp', { eager: true, import: 'default' })
|
||||
|
||||
type Persona = keyof typeof spec.personas
|
||||
type StyleId = keyof typeof spec.styles
|
||||
const PERSONAS = Object.keys(spec.personas) as Persona[]
|
||||
|
||||
export const OOTD_STYLES = (Object.keys(spec.styles) as StyleId[]).map((id) => ({ id, label: spec.styles[id].label }))
|
||||
export const DEFAULT_STYLE: StyleId = 'casual'
|
||||
const styleOf = (id?: string): StyleId => (id && id in spec.styles ? (id as StyleId) : DEFAULT_STYLE)
|
||||
export const styleLabel = (id?: string) => spec.styles[styleOf(id)].label
|
||||
|
||||
export const OOTD_BANDS: OotdBand[] = spec.bands.map((b) => ({ id: b.id, from: b.from }))
|
||||
|
||||
export function ootdBand(maxC: number) {
|
||||
return OOTD_BANDS.find((b) => maxC >= b.from) ?? OOTD_BANDS[OOTD_BANDS.length - 1]
|
||||
}
|
||||
|
||||
/** 그 구간·스타일의 6명 옷 */
|
||||
/** 그 구간·스타일의 6명 옷. bandId 를 주면 기온 대신 그 구간 (예시 카드용) */
|
||||
export function ootdOutfits(maxC: number, style?: string, bandId?: string): Outfit[] {
|
||||
const band = spec.bands.find((b) => b.id === (bandId || ootdBand(maxC).id))!
|
||||
const st = styleOf(style)
|
||||
return PERSONAS.map((p) => {
|
||||
const o = band.outfits[st][p]
|
||||
return { persona: p, label: spec.personas[p].label, labels: o.labels, outer: o.outer, image: IMAGES[`../assets/ootd/${band.id}-${p}-${st}.webp`] }
|
||||
})
|
||||
}
|
||||
@@ -0,0 +1,26 @@
|
||||
import type { Copy } from './templates'
|
||||
|
||||
/** 고친 문구를 주소에 싣는 꼴 (/render?copy=...). npm run card --copy 도 같은 꼴을 쓴다 */
|
||||
export function encodeCopy(copy: Copy) {
|
||||
const bytes = new TextEncoder().encode(JSON.stringify(copy))
|
||||
return btoa(String.fromCharCode(...bytes)).replace(/\+/g, '-').replace(/\//g, '_').replace(/=+$/, '')
|
||||
}
|
||||
|
||||
export function decodeCopy(value: string | null): Copy {
|
||||
if (!value) return {}
|
||||
try {
|
||||
const bin = atob(value.replace(/-/g, '+').replace(/_/g, '/'))
|
||||
return JSON.parse(new TextDecoder().decode(Uint8Array.from(bin, (c) => c.charCodeAt(0))))
|
||||
} catch (e) {
|
||||
console.warn('copy 값을 읽지 못해 기본 문구로 그립니다', e)
|
||||
return {}
|
||||
}
|
||||
}
|
||||
|
||||
/** 이미지가 다 그려지고 글꼴이 다 받아진 뒤 */
|
||||
export async function whenPainted(root: HTMLElement) {
|
||||
await document.fonts.ready
|
||||
await Promise.all(
|
||||
Array.from(root.querySelectorAll('img'), (img) => (img.complete ? Promise.resolve() : img.decode().catch(() => undefined))),
|
||||
)
|
||||
}
|
||||
@@ -0,0 +1,223 @@
|
||||
import type { ReactNode } from 'react'
|
||||
import tarotBack from '../assets/tarot-back.webp'
|
||||
import type { CardData } from './data'
|
||||
import { Frame, Lines } from './Frame'
|
||||
import { tidy } from './text'
|
||||
import { DEFAULT_STYLE, ootdBand, ootdOutfits, styleLabel } from './ootd'
|
||||
import { gakArt } from './gaks'
|
||||
|
||||
// 대주제(skin)마다 한 번 만든 배경 그림 (npm run gen-image -- tarot-bg <skin>). 없으면 민무늬 배경
|
||||
const TAROT_BG = import.meta.glob<string>('../assets/tarot-bg/*.webp', { eager: true, import: 'default' })
|
||||
const tarotBg = (skin?: string) => (skin ? TAROT_BG[`../assets/tarot-bg/${skin}.webp`] : undefined)
|
||||
export const hasTarotBg = (skin?: string) => !!tarotBg(skin)
|
||||
import { iconUrl } from './icons'
|
||||
import { toneVars } from './themes'
|
||||
|
||||
|
||||
export type Copy = Record<string, string>
|
||||
export type Field = { key: string; label: string }
|
||||
|
||||
/** 포스트 종류 하나 = 템플릿 하나. 웹 화면과 대화(npm run card)가 같은 템플릿으로 그린다 */
|
||||
export type Template = {
|
||||
id: string
|
||||
name: string
|
||||
about: string
|
||||
/** 이 카드를 어떻게 만드는지 (데이터·계산·문구 규칙). 관리자 화면과 기획 요청에 같이 쓴다 */
|
||||
how: string[]
|
||||
fields: Field[]
|
||||
defaults: (d: CardData) => Copy
|
||||
slides: (d: CardData, c: Copy) => ReactNode[]
|
||||
/** 이대로 올리면 안 되는 이유 (그림 없음 등) */
|
||||
warnings?: (d: CardData, c: Copy) => string[]
|
||||
/** Claude 기획으로 채워지는 템플릿 (화면은 만들기를 눌러야 기획, npm run card 는 기획부터 한다) */
|
||||
autoPlan?: boolean
|
||||
/** 처음 열 때 보여 주는 미리 만든 예시 문구 (그림도 미리 만들어 둠). 만들기를 누르면 그날 카드로 바뀐다 */
|
||||
example?: Copy
|
||||
/** 날씨각 피드 포스트 제목·설명 */
|
||||
post: (d: CardData, c: Copy) => { title: string; caption: string }
|
||||
}
|
||||
|
||||
|
||||
const ootd: Template = {
|
||||
id: 'ootd',
|
||||
name: '오늘의 코디',
|
||||
about: '캐주얼·세미정장·정장·스트릿·꾸안꾸 중 하나 · 20대·30대·40대~ 여자·남자 6장 · 서울 낮 최고기온 구간별',
|
||||
how: [
|
||||
'서울(중구) 오늘 예보의 아침 6시~밤 9시 중 가장 높은 기온으로 7개 구간(28도 이상 · 23 · 17 · 12 · 9 · 5 · 그 아래) 중 하나를 고른다.',
|
||||
'스타일(캐주얼·세미정장·정장·스트릿·꾸안꾸)을 고르면 바로 그 옷으로 바뀐다. Claude 기획은 쓰지 않는다.',
|
||||
'구간 × 스타일 × 사람(20대·30대·40대~ 여자·남자)마다 옷 4가지가 image-prompts/ootd.json에 정해져 있고, 같은 파일의 문장으로 Codex가 그린 그림(src/assets/ootd/<구간>-<사람>-<스타일>.webp)을 붙인다. 그림이 없으면 옷 이름만 나간다.',
|
||||
'카드에 지역 이름은 넣지 않는다.',
|
||||
],
|
||||
fields: [{ key: 'title', label: '제목 (사람·스타일 뒤에 붙음)' }],
|
||||
// 제목은 '20대 여자 세미정장'까지만 (한 줄에 들어가야 함). 제목 칸에 쓴 말은 그 뒤에 붙는다
|
||||
defaults: () => ({ title: '', style: DEFAULT_STYLE }),
|
||||
// 예시: 17~22도 캐주얼 (Codex 그림 6장)
|
||||
example: { style: 'casual', band: 'mild', theme: 'berry' },
|
||||
post: (d, c) => ({ title: `오늘의 코디 · ${styleLabel(c.style)}`, caption: `낮 최고 ${d.maxC}도, 20대부터 40대~까지 오늘 입을 옷을 넘겨 보세요` }),
|
||||
warnings: (d, c) => {
|
||||
const missing = ootdOutfits(d.maxC, c.style).filter((o) => !o.image)
|
||||
const id = `${ootdBand(d.maxC).id}`
|
||||
return missing.length
|
||||
? [`낮 최고 ${d.maxC}도 · ${styleLabel(c.style)}에 ${missing.map((o) => o.label).join(', ')} 옷 그림이 아직 없어요. 옷 이름만 나갑니다. (npm run gen-image -- ootd ${id} ${c.style ?? DEFAULT_STYLE})`]
|
||||
: []
|
||||
},
|
||||
slides: (d, c) =>
|
||||
ootdOutfits(d.maxC, c.style, c.band).map((o, i, all) => (
|
||||
<Frame page={i} total={all.length} theme={c.theme} className="ootd" key={o.persona}>
|
||||
<p className="meta">{d.dateLabel} · 오늘의 코디</p>
|
||||
<h1 className="ootd-title">
|
||||
<Lines text={`*${o.label}* ${styleLabel(c.style)}${c.title ? ` ${c.title}` : ''}`} />
|
||||
</h1>
|
||||
<div className="ootd-stage">
|
||||
{o.image ? <img src={o.image} alt="" /> : null}
|
||||
<div className={o.image ? 'ootd-labels' : 'ootd-labels only'}>
|
||||
{o.labels.map((l) => (
|
||||
<span key={l}>{l}</span>
|
||||
))}
|
||||
</div>
|
||||
</div>
|
||||
<p className="ootd-weather">
|
||||
<img src={iconUrl(d.rainy ? 'rain' : d.maxC - d.morningC >= 8 ? 'sun_cloud' : 'sun')} alt="" />
|
||||
<span>
|
||||
오늘 아침 <b>{d.morningC}°</b> · 낮 <b>{d.maxC}°</b>
|
||||
{d.rainy ? ' · 비 소식 있어요' : d.maxC - d.morningC >= 8 ? ' · 일교차 커요' : ' · 비 안 와요'}
|
||||
</span>
|
||||
</p>
|
||||
</Frame>
|
||||
)),
|
||||
}
|
||||
|
||||
const tarot: Template = {
|
||||
id: 'tarot',
|
||||
post: (_d, c) => ({ title: c.title.replaceAll('\n', ' ').replaceAll('*', ''), caption: `Q. ${c.question} 1·2·3 중 한 장을 골라 보세요` }),
|
||||
name: '날씨 타로',
|
||||
autoPlan: true,
|
||||
about: '주제를 바꿔 가며 · 3장 중 고르기, 뒷면은 오늘 날씨',
|
||||
how: [
|
||||
'카드는 날씨각의 각 카드다(산책각·빨래각·치맥각… 53장). 타로 덱(컵·펜타클 등)은 쓰지 않는다.',
|
||||
'표지 질문(question)에 1·2·3번 각 카드로 답한다. 소주제마다 질문이 정해져 있다(topics.json questions).',
|
||||
'카드는 오늘 서울(중구) 예보로 점수가 높은 각, 즉 오늘 실제로 하기 좋은 각 가운데 질문과 엮을 수 있는 것을 고른다. 세 장은 서로 다른 각.',
|
||||
'리딩(r)은 진짜 타로 리더 말투로 3문장(70~95자): 그 사람의 겉과 속 → 한 번 꺾기(다만) → 오늘 할 행동 하나(각 카드의 활동). 질문자는 "님", 상대는 "그 사람". 규칙과 좋은·나쁜 예는 scripts/plan.mjs TAROT_TONE.',
|
||||
'행운 포인트(l)는 한 줄: 그 각이 좋은 오늘의 시간·기온·날씨 사실.',
|
||||
'카드 그림은 Codex가 그린 각 카드 그림(그날 뽑힌 카드만 그리고 다시 씀, 없으면 각 아이콘), 카드 이름은 각 이름 그대로.',
|
||||
'질문·카드·리딩은 각각 관리자가 직접 정하거나 Claude에게 맡길 수 있다. 카드를 직접 고르면 Claude는 그 카드로 리딩만 한다.',
|
||||
'지켜야 할 것: 투자 권유(종목·매수·매도·수익)·건강 단정·사고·재난·정치는 쓰지 않는다. 마지막 장에 "재미로"를 남긴다.',
|
||||
'관리자가 주제를 고르고 만들기를 눌러야 만들어진다(화면을 열 때 자동으로 만들지 않는다). 색은 만들 때마다 6가지 테마 중 무작위, 고를 수도 있다.',
|
||||
],
|
||||
fields: [
|
||||
{ key: 'title', label: '표지 제목' },
|
||||
{ key: 'question', label: '질문 (카드가 답할 질문)' },
|
||||
{ key: 'prompt', label: '표지 안내' },
|
||||
...[1, 2, 3].flatMap((n) => [
|
||||
{ key: `n${n}`, label: `${n}번 각 카드` },
|
||||
{ key: `k${n}`, label: `${n}번 키워드 (한 줄)` },
|
||||
{ key: `r${n}`, label: `${n}번 리딩 (질문에 대한 답)` },
|
||||
{ key: `l${n}`, label: `${n}번 행운 포인트` },
|
||||
]),
|
||||
{ key: 'ask', label: '마지막 장 질문' },
|
||||
{ key: 'cta', label: '마지막 장 버튼' },
|
||||
{ key: 'note', label: '마지막 장 안내' },
|
||||
],
|
||||
// 카드 3장은 Claude가 기획해야 채워진다 (autoPlan). 기획 전에는 비워 두고 화면이 가린다
|
||||
// 예시: 연애·썸 (각 카드 그림은 Codex로 미리 그림)
|
||||
example: {
|
||||
title: '오늘의\n썸 타로', question: '지금 썸 타는 그 사람과 오늘 한 발 가까워질까요?', topic: '연애 썸', skin: 'heart', theme: 'berry',
|
||||
c1: 'iced_hot', n1: '뜨아각', i1: 'iced_hot', k1: '커피 사진 한 장',
|
||||
r1: '아침부터 그 사람 생각났죠. 상대도 비슷해요. 다만 마음이 식어서가 아니라 하루 시작이 바빠서 조용한 거예요. 오늘은 커피 사진 한 장만 보내세요. 그 이상은 저녁에.', l1: '아침 8시, 따뜻한 커피가 당기는 날씨',
|
||||
c2: 'walk', n2: '산책각', i2: 'walk', k2: '잠깐 걸을래?',
|
||||
r2: '오늘 그 사람, 님 생각보다 가까이 와 있어요. 겉으론 평소랑 똑같이 굴어도 말 걸 타이밍만 재는 중이거든요. 해 지고 선선해질 때 "잠깐 걸을래?" 한마디면 돼요. 길게 쓰지 마세요.', l2: '저녁 8시, 17도로 걷기 딱 좋아요',
|
||||
c3: 'yajang', n3: '야장각', i3: 'yajang', k3: '둘만 있는 바깥 자리',
|
||||
r3: '오늘 밤 한 발 가까워지는 그림이 보여요. 조건이 하나 있어요, 둘만 있는 자리일 것. 여럿이 모인 데서는 이 사람 티를 안 내거든요. 2차 얘기 나오면 님이 먼저 "밖에 앉자" 하세요.', l3: '밤 9시, 16도로 바깥이 포근해요',
|
||||
},
|
||||
// 만들기 전 빈 카드. 관리자가 주제를 고르고 만들면 Claude가 채운다
|
||||
defaults: () => ({
|
||||
title: '오늘의\n날씨 타로',
|
||||
question: '오늘 나에게 좋은 일이 생길까요?',
|
||||
prompt: '1·2·3 중 한 장을 골라 보세요',
|
||||
...Object.fromEntries([1, 2, 3].flatMap((n) => [[`c${n}`, ''], [`n${n}`, ''], [`i${n}`, 'sun'], [`k${n}`, ''], [`r${n}`, ''], [`l${n}`, '']])),
|
||||
ask: '몇 번 골랐어요?\n*댓글로 알려 주세요*',
|
||||
cta: '내 동네 오늘의 각은\n프로필 링크에서',
|
||||
note: '재미로 보는 날씨 타로 · 카드 뒷면은 실제 날씨로 계산했어요',
|
||||
}),
|
||||
slides: (d, c) => {
|
||||
const backs = (cls: string) =>
|
||||
[1, 2, 3].map((n) => (
|
||||
<div className={`back-card ${cls} card-${n}`} key={n}>
|
||||
<img src={tarotBack} alt="" />
|
||||
<span className="number">{n}</span>
|
||||
</div>
|
||||
))
|
||||
return [
|
||||
<Frame page={0} total={5} theme={c.theme} skin={c.skin} className="tarot-cover" key="cover">
|
||||
{[1, 2, 6].map((n) => (
|
||||
<i className={`deco d${n}`} aria-hidden="true" key={n} />
|
||||
))}
|
||||
<i className="sparkle a" />
|
||||
<i className="sparkle b" />
|
||||
<i className="sparkle c" />
|
||||
<h1 className="cover-title">
|
||||
<Lines text={c.title} />
|
||||
</h1>
|
||||
<p className="cover-question">
|
||||
<b>Q.</b>
|
||||
{c.question}
|
||||
</p>
|
||||
<div className="cover-stage" aria-hidden="true" />
|
||||
{backs('big')}
|
||||
<img className="rabbit" src="/icons/rabbit.png" alt="" />
|
||||
<img className="bear" src="/icons/bear.png" alt="" />
|
||||
<p className="cover-date">
|
||||
{d.dateLabel} · {c.prompt}
|
||||
</p>
|
||||
</Frame>,
|
||||
...[0, 1, 2].map((i) => (
|
||||
<Frame page={i + 1} total={5} theme={c.theme} skin={c.skin} style={toneVars(c.theme, i)} className="tarot-result" key={i}>
|
||||
{tarotBg(c.skin) && <img className="tarot-bg" src={tarotBg(c.skin)} alt="" />}
|
||||
<p className="result-question">
|
||||
<b>Q.</b>
|
||||
<span>{c.question}</span>
|
||||
</p>
|
||||
<div className="result-head">
|
||||
<span className="card-no">{i + 1}번 카드</span>
|
||||
<span className="card-name">{c[`n${i + 1}`]}</span>
|
||||
</div>
|
||||
<div className="result-body">
|
||||
{gakArt(c[`c${i + 1}`]) ? (
|
||||
<img className="card-art" src={gakArt(c[`c${i + 1}`])} alt="" />
|
||||
) : (
|
||||
<div className="card-art card-art-fallback">
|
||||
<img src={iconUrl(c[`i${i + 1}`] || 'sun')} alt="" />
|
||||
</div>
|
||||
)}
|
||||
<div className="result-text">
|
||||
{c[`k${i + 1}`] && <p className="card-keyword">{c[`k${i + 1}`]}</p>}
|
||||
<p className="reading">
|
||||
<Lines text={tidy(c[`r${i + 1}`])} />
|
||||
</p>
|
||||
{c[`l${i + 1}`] && <p className="lucky">{c[`l${i + 1}`]}</p>}
|
||||
</div>
|
||||
</div>
|
||||
<p className="footnote">재미로 보는 날씨 타로 · 카드 뒷면은 실제 날씨로 계산했어요</p>
|
||||
</Frame>
|
||||
)),
|
||||
<Frame page={4} total={5} theme={c.theme} skin={c.skin} className="tarot-cover tarot-closing" key="closing">
|
||||
{[1, 2, 6].map((n) => (
|
||||
<i className={`deco d${n}`} aria-hidden="true" key={n} />
|
||||
))}
|
||||
<h2 className="cover-title">
|
||||
<Lines text={c.ask.replaceAll('*', '')} />
|
||||
</h2>
|
||||
<p className="cover-question">{c.cta.replaceAll('\n', ' ')}</p>
|
||||
<div className="cover-stage" aria-hidden="true" />
|
||||
{backs('big')}
|
||||
<img className="rabbit" src="/icons/rabbit.png" alt="" />
|
||||
<img className="bear" src="/icons/bear.png" alt="" />
|
||||
<p className="cover-date">{c.note}</p>
|
||||
</Frame>,
|
||||
]
|
||||
},
|
||||
}
|
||||
|
||||
export const TEMPLATES: Template[] = [tarot, ootd]
|
||||
|
||||
export const templateById = (id: string) => TEMPLATES.find((t) => t.id === id)
|
||||
@@ -0,0 +1,3 @@
|
||||
/** 한 글자 어절(그·더·안·못·꼭…)은 다음 어절에 붙여 줄 끝에 혼자 남지 않게 한다 */
|
||||
export const tidy = (text: string) => text.replace(/(^|\s)([가-힣])\s(?=[가-힣])/g, '$1$2\u00a0')
|
||||
|
||||
@@ -0,0 +1,40 @@
|
||||
import type { CSSProperties } from 'react'
|
||||
|
||||
/** 카드 색 테마. 만들 때마다 하나를 무작위로 고르고, 화면·명령(--color)에서 직접 고를 수도 있다.
|
||||
* tones: 날씨 타로 1·2·3번 카드 색 (hue = 카드 앞면 틀 그림을 돌릴 각도) */
|
||||
type Tone = { accent: string; tint: string; hue: number }
|
||||
export type Theme = { id: string; name: string; paper: string; main: string; deep: string; soft: string; stage: string; second: string; tones: [Tone, Tone, Tone] }
|
||||
|
||||
const ORANGE: Tone = { accent: '#d4552a', tint: '#fff0e5', hue: 0 }
|
||||
const BLUE: Tone = { accent: '#317dc6', tint: '#e6f1ff', hue: 185 }
|
||||
const PURPLE: Tone = { accent: '#6556ac', tint: '#eeeaff', hue: 234 }
|
||||
const GREEN: Tone = { accent: '#1d8a5e', tint: '#e2f6ec', hue: 120 }
|
||||
const PINK: Tone = { accent: '#c43d6d', tint: '#fde6ee', hue: 320 }
|
||||
const MUSTARD: Tone = { accent: '#a87108', tint: '#fff2cc', hue: 25 }
|
||||
|
||||
export const THEMES: Theme[] = [
|
||||
{ id: 'sunset', name: '노을', paper: '#f7fbff', main: '#ff7a45', deep: '#d4552a', soft: '#ffd7bd', stage: '#e1efff', second: '#4f97e3', tones: [ORANGE, BLUE, PURPLE] },
|
||||
{ id: 'sky', name: '하늘', paper: '#f4f9ff', main: '#4f97e3', deep: '#2b6cb8', soft: '#cfe3fb', stage: '#e3efff', second: '#ff7a45', tones: [BLUE, GREEN, PURPLE] },
|
||||
{ id: 'mint', name: '민트', paper: '#f4fbf8', main: '#2fbf87', deep: '#1d8a5e', soft: '#c8f0de', stage: '#dff5ea', second: '#4f97e3', tones: [GREEN, BLUE, ORANGE] },
|
||||
{ id: 'berry', name: '베리', paper: '#fff7fa', main: '#ef6a96', deep: '#c43d6d', soft: '#fbd0de', stage: '#fde6ee', second: '#8b7be0', tones: [PINK, PURPLE, ORANGE] },
|
||||
{ id: 'lemon', name: '레몬', paper: '#fffbef', main: '#f5b82e', deep: '#a87108', soft: '#ffe7a3', stage: '#fff2cc', second: '#2fbf87', tones: [MUSTARD, GREEN, BLUE] },
|
||||
{ id: 'lavender', name: '라벤더', paper: '#f8f6ff', main: '#8b7be0', deep: '#6556ac', soft: '#ddd6fb', stage: '#eeeaff', second: '#ef6a96', tones: [PURPLE, PINK, BLUE] },
|
||||
]
|
||||
|
||||
export const themeById = (id?: string) => THEMES.find((t) => t.id === id) ?? THEMES[0]
|
||||
|
||||
export const randomTheme = (except?: string) => {
|
||||
const pool = THEMES.filter((t) => t.id !== except)
|
||||
return pool[Math.floor(Math.random() * pool.length)].id
|
||||
}
|
||||
|
||||
/** .slide 에 거는 색 변수 */
|
||||
export function themeVars(id?: string): CSSProperties {
|
||||
const t = themeById(id)
|
||||
return { '--paper': t.paper, '--orange': t.main, '--rust': t.deep, '--soft': t.soft, '--stage': t.stage, '--blue': t.second } as CSSProperties
|
||||
}
|
||||
|
||||
export function toneVars(id: string | undefined, i: number): CSSProperties {
|
||||
const tone = themeById(id).tones[i]
|
||||
return { '--accent': tone.accent, '--tint': tone.tint, '--hue': `${tone.hue}deg` } as CSSProperties
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
import spec from '../../topics.json'
|
||||
|
||||
/** 날씨 타로 주제(대주제 > 소주제). 대주제마다 꾸밈(skin)·기본 색·먼저 고를 아이콘이 정해져 있다 (topics.json) */
|
||||
export type Category = (typeof spec.categories)[number]
|
||||
export const CATEGORIES: Category[] = spec.categories
|
||||
|
||||
/** '이별', '연애 이별', '연애' 처럼 들어온 주제에서 대주제를 찾는다 */
|
||||
export function categoryOf(topic: string) {
|
||||
const t = topic.trim()
|
||||
return CATEGORIES.find((c) => t.includes(c.name) || c.subtopics.some((s) => t.includes(s)))
|
||||
}
|
||||
|
||||
/** 그 주제의 타로 질문 (소주제 질문, 없으면 대주제 질문) */
|
||||
export function questionOf(topic: string) {
|
||||
const c = categoryOf(topic)
|
||||
if (!c) return ''
|
||||
const sub = c.subtopics.find((x) => topic.includes(x))
|
||||
const q = c.questions as Record<string, string | undefined>
|
||||
return q[sub ?? ''] ?? q[''] ?? ''
|
||||
}
|
||||
Reference in new issue
Block a user