04일주일 범위 안에서 제자리를 찾는 5일 예보 막대
다섯 날짜의 최저에서 최고까지 온도 막대가 주간 전체 범위 안에서 제자리에 놓이고, 변폭이 큰 날은 막대와 숫자 간격이 그만큼 넓어집니다.
쓰임주간 예보 리스트, 의상·짐 준비 안내
leftwidthtabular-nums

<main class="stage stage--paper">
<section class="dr is-demo" id="dr" aria-label="5일 예보">
<p class="dr__title">5일 예보</p>
<ul class="dr__list">
<li><button class="dr__row is-sel" type="button" data-lo="18" data-hi="27" aria-pressed="true" aria-label="오늘, 최저 18도, 최고 27도">
<span class="dr__day">오늘</span>
<svg viewBox="0 0 256 256" width="15" height="15" fill="currentColor" aria-hidden="true" class="dr__i dr__i--sun"><path d="M184,128a56,56,0,1,1-56-56A56,56,0,0,1,184,128Z" opacity="0.2"/><path d="M120,40V16a8,8,0,0,1,16,0V40a8,8,0,0,1-16,0Zm72,88a64,64,0,1,1-64-64A64.07,64.07,0,0,1,192,128Zm-16,0a48,48,0,1,0-48,48A48.05,48.05,0,0,0,176,128ZM58.34,69.66A8,8,0,0,0,69.66,58.34l-16-16A8,8,0,0,0,42.34,53.66Zm0,116.68-16,16a8,8,0,0,0,11.32,11.32l16-16a8,8,0,0,0-11.32-11.32ZM192,72a8,8,0,0,0,5.66-2.34l16-16a8,8,0,0,0-11.32-11.32l-16,16A8,8,0,0,0,192,72Zm5.66,114.34a8,8,0,0,0-11.32,11.32l16,16a8,8,0,0,0,11.32-11.32ZM48,128a8,8,0,0,0-8-8H16a8,8,0,0,0,0,16H40A8,8,0,0,0,48,128Zm80,80a8,8,0,0,0-8,8v24a8,8,0,0,0,16,0V216A8,8,0,0,0,128,208Zm112-88H216a8,8,0,0,0,0,16h24a8,8,0,0,0,0-16Z"/></svg>
<span class="dr__lo">18</span><span class="dr__track"><span class="dr__bar"></span></span><span class="dr__hi">27</span>
</button></li>
<li><button class="dr__row" type="button" data-lo="16" data-hi="25" aria-pressed="false" aria-label="내일, 최저 16도, 최고 25도">
<span class="dr__day">내일</span>
<svg viewBox="0 0 256 256" width="15" height="15" fill="currentColor" aria-hidden="true" class="dr__i dr__i--cloudsun"><path d="M139.84,84.41v0a68.22,68.22,0,0,0-41.65,46v-.11a44.08,44.08,0,0,0-38.54,5h0a48,48,0,1,1,80.19-50.94Z" opacity="0.2"/><path d="M164,72a76.2,76.2,0,0,0-20.26,2.73,55.63,55.63,0,0,0-9.41-11.54l9.51-13.57a8,8,0,1,0-13.11-9.18L121.22,54A55.9,55.9,0,0,0,96,48c-.58,0-1.16,0-1.74,0L91.37,31.71a8,8,0,1,0-15.75,2.77L78.5,50.82A56.1,56.1,0,0,0,55.23,65.67L41.61,56.14a8,8,0,1,0-9.17,13.11L46,78.77A55.55,55.55,0,0,0,40,104c0,.57,0,1.15,0,1.72L23.71,108.6a8,8,0,0,0,1.38,15.88,8.24,8.24,0,0,0,1.39-.12l16.32-2.88a55.74,55.74,0,0,0,5.86,12.42A52,52,0,0,0,84,224h80a76,76,0,0,0,0-152ZM56,104a40,40,0,0,1,72.54-23.24,76.26,76.26,0,0,0-35.62,40,52.14,52.14,0,0,0-31,4.17A40,40,0,0,1,56,104ZM164,208H84a36,36,0,1,1,4.78-71.69c-.37,2.37-.63,4.79-.77,7.23a8,8,0,0,0,16,.92,58.91,58.91,0,0,1,1.88-11.81c0-.16.09-.32.12-.48A60.06,60.06,0,1,1,164,208Z"/></svg>
<span class="dr__lo">16</span><span class="dr__track"><span class="dr__bar"></span></span><span class="dr__hi">25</span>
</button></li>
<li><button class="dr__row" type="button" data-lo="15" data-hi="23" aria-pressed="false" aria-label="금요일, 최저 15도, 최고 23도">
<span class="dr__day">금</span>
<svg viewBox="0 0 256 256" width="15" height="15" fill="currentColor" aria-hidden="true" class="dr__i dr__i--cloud"><path d="M240,128a80,80,0,0,1-80,80H72A56,56,0,1,1,85.92,97.74l0,.1A80,80,0,0,1,240,128Z" opacity="0.2"/><path d="M160,40A88.09,88.09,0,0,0,81.29,88.67,64,64,0,1,0,72,216h88a88,88,0,0,0,0-176Zm0,160H72a48,48,0,0,1,0-96c1.1,0,2.2,0,3.29.11A88,88,0,0,0,72,128a8,8,0,0,0,16,0,72,72,0,1,1,72,72Z"/></svg>
<span class="dr__lo">15</span><span class="dr__track"><span class="dr__bar"></span></span><span class="dr__hi">23</span>
</button></li>
<li><button class="dr__row" type="button" data-lo="17" data-hi="29" aria-pressed="false" aria-label="토요일, 최저 17도, 최고 29도">
<span class="dr__day">토</span>
<svg viewBox="0 0 256 256" width="15" height="15" fill="currentColor" aria-hidden="true" class="dr__i dr__i--sun"><path d="M184,128a56,56,0,1,1-56-56A56,56,0,0,1,184,128Z" opacity="0.2"/><path d="M120,40V16a8,8,0,0,1,16,0V40a8,8,0,0,1-16,0Zm72,88a64,64,0,1,1-64-64A64.07,64.07,0,0,1,192,128Zm-16,0a48,48,0,1,0-48,48A48.05,48.05,0,0,0,176,128ZM58.34,69.66A8,8,0,0,0,69.66,58.34l-16-16A8,8,0,0,0,42.34,53.66Zm0,116.68-16,16a8,8,0,0,0,11.32,11.32l16-16a8,8,0,0,0-11.32-11.32ZM192,72a8,8,0,0,0,5.66-2.34l16-16a8,8,0,0,0-11.32-11.32l-16,16A8,8,0,0,0,192,72Zm5.66,114.34a8,8,0,0,0-11.32,11.32l16,16a8,8,0,0,0,11.32-11.32ZM48,128a8,8,0,0,0-8-8H16a8,8,0,0,0,0,16H40A8,8,0,0,0,48,128Zm80,80a8,8,0,0,0-8,8v24a8,8,0,0,0,16,0V216A8,8,0,0,0,128,208Zm112-88H216a8,8,0,0,0,0,16h24a8,8,0,0,0,0-16Z"/></svg>
<span class="dr__lo">17</span><span class="dr__track"><span class="dr__bar"></span></span><span class="dr__hi">29</span>
</button></li>
<li><button class="dr__row" type="button" data-lo="12" data-hi="20" aria-pressed="false" aria-label="일요일, 최저 12도, 최고 20도">
<span class="dr__day">일</span>
<svg viewBox="0 0 256 256" width="15" height="15" fill="currentColor" aria-hidden="true" class="dr__i dr__i--rain"><path d="M224,92a68,68,0,0,1-68,68H76A44,44,0,1,1,90.2,74.34v.11A68.06,68.06,0,0,1,224,92Z" opacity="0.2"/><path d="M158.66,196.44l-32,48a8,8,0,1,1-13.32-8.88l32-48a8,8,0,0,1,13.32,8.88ZM232,92a76.08,76.08,0,0,1-76,76H132.28l-29.62,44.44a8,8,0,1,1-13.32-8.88L113.05,168H76A52,52,0,1,1,76,64a53.26,53.26,0,0,1,8.92.76A76.08,76.08,0,0,1,232,92Zm-16,0A60.06,60.06,0,0,0,96,88.46a8,8,0,0,1-16-.92q.21-3.66.77-7.23A38.11,38.11,0,0,0,76,80a36,36,0,0,0,0,72h80A60.07,60.07,0,0,0,216,92Z"/></svg>
<span class="dr__lo">12</span><span class="dr__track"><span class="dr__bar"></span></span><span class="dr__hi">20</span>
</button></li>
</ul>
<p class="dr__detail" aria-live="polite">오늘 · 일교차 9도</p>
</section>
</main>@use "../../../../site/static/demo-tokens" as *;
// 5일 예보 — 막대의 left/width 는 JS 가 주간 범위 안 비율로 계산해 정적으로 놓는다(레이아웃 애니메이션 아님).
// 등장은 clip-path 위프: width 를 물리면 레이아웃이 다시 계산되고, scaleX 로 물리면 둥근 끝이 눌린다.
$duration: $dur-loop;
$easing: $ease-out;
$color: $subject-blue;
@include stage($stage-paper);
.dr {
box-sizing: border-box;
display: grid;
gap: $sp-1;
width: min(292px, 92vw);
padding: $sp-2;
border: 1px solid rgba(23, 20, 26, .12);
border-radius: $r-card;
background: $stage-paper;
color: $subject-ink;
box-shadow: $shadow-press;
}
.dr * { box-sizing: border-box; }
.dr__title {
margin: 0;
padding: 0 $sp-1;
font-size: 13px;
font-weight: 700;
line-height: 1.3;
}
.dr__list {
display: grid;
gap: $sp-1;
margin: 0;
padding: 0;
list-style: none;
}
.dr__row {
display: grid;
// 버튼은 display:grid 여도 폭이 fit-content 라 li 를 못 채운다 — 1fr 트랙이 0 으로 접혀 막대가 사라진다
width: 100%;
grid-template-columns: 26px 16px 20px 1fr 20px;
align-items: center;
gap: $sp-1;
padding: $sp-1;
border: 0;
border-radius: $r-control;
background: rgba(23, 20, 26, 0);
font-variant-numeric: tabular-nums;
cursor: pointer;
&:focus-visible { outline: 2px solid $subject-blue; outline-offset: 2px; }
&.is-sel { background: rgba(110, 200, 255, .22); }
}
.dr__day {
font-size: 10px;
font-weight: 700;
line-height: 1.3;
color: rgba($subject-ink, .72);
}
.is-sel .dr__day { color: $subject-ink; }
.dr__i--sun { color: #ba9f72; }
.dr__i--cloudsun { color: #b59c6a; }
.dr__i--cloud { color: #5b6478; }
.dr__i--rain { color: $subject-blue; }
.dr__lo, .dr__hi {
font-size: 11px;
font-weight: 700;
line-height: 1.3;
}
.dr__hi { text-align: right; }
.dr__lo { color: rgba($subject-ink, .72); }
// 온도 범위 트랙 — 막대는 안쪽 비율로 놓인다
.dr__track {
position: relative;
height: 6px;
border-radius: $r-pill;
background: rgba(23, 20, 26, .08);
}
.dr__bar {
position: absolute;
top: 0;
bottom: 0;
border-radius: $r-pill;
background: linear-gradient(90deg, #c4d6e2, #d2bea4);
}
.dr__detail {
margin: 0;
padding: 0 $sp-1;
font-size: 11px;
font-weight: 700;
line-height: 1.4;
color: rgba($subject-ink, .72);
}
// ── 격자 미리보기 루프 (2초) ──
// 다섯 막대가 시차를 두고 좌에서 우로 펴지고(0~44%), 88% 에 컷으로 접힌 뒤 다시 시작 — 복귀는 90% 안.
@keyframes dr-wipe {
0% { clip-path: inset(0 100% 0 0); }
36%, 86% { clip-path: inset(0 0 0 0); }
88%, 100% { clip-path: inset(0 100% 0 0); }
}
@keyframes dr-num {
0% { transform: translateY(6px); opacity: 0; }
30%, 86% { transform: translateY(0); opacity: 1; }
88%, 100% { transform: translateY(6px); opacity: 0; }
}
.dr.is-demo {
// 차례는 li 로 센다 — .dr__row 는 li 의 유일한 자식이라 :nth-child 를 버튼에 걸면 전부 1번이 된다
.dr__list > li:nth-child(1) .dr__bar { animation-name: dr-wipe; animation-delay: 0s; }
.dr__list > li:nth-child(2) .dr__bar { animation-name: dr-wipe; animation-delay: .12s; }
.dr__list > li:nth-child(3) .dr__bar { animation-name: dr-wipe; animation-delay: .24s; }
.dr__list > li:nth-child(4) .dr__bar { animation-name: dr-wipe; animation-delay: .36s; }
.dr__list > li:nth-child(5) .dr__bar { animation-name: dr-wipe; animation-delay: .48s; }
.dr__bar {
animation-duration: $duration;
animation-timing-function: $easing;
animation-iteration-count: infinite;
animation-fill-mode: backwards;
}
.dr__list > li:nth-child(1) .dr__hi, .dr__list > li:nth-child(1) .dr__lo { animation-name: dr-num; animation-delay: 0s; }
.dr__list > li:nth-child(3) .dr__hi, .dr__list > li:nth-child(3) .dr__lo { animation-name: dr-num; animation-delay: .12s; }
.dr__list > li:nth-child(5) .dr__hi, .dr__list > li:nth-child(5) .dr__lo { animation-name: dr-num; animation-delay: .24s; }
.dr__lo, .dr__hi {
animation-duration: $duration;
animation-timing-function: $ease-out;
animation-iteration-count: infinite;
animation-fill-mode: backwards;
}
}
@media (max-width: 340px) {
.dr { padding: $sp-1; }
.dr__row { grid-template-columns: 22px 14px 18px 1fr 18px; padding: 0 $sp-1; }
}
@media (prefers-reduced-motion: reduce) {
.dr.is-demo .dr__bar,
.dr.is-demo .dr__lo,
.dr.is-demo .dr__hi {
animation: none !important;
transform: none !important;
opacity: 1 !important;
clip-path: none !important;
}
}html, body {
margin: 0;
overflow: hidden;
}
.stage {
box-sizing: border-box;
min-height: 100vh;
display: grid;
place-items: center;
margin: 0;
background: #ffffff;
font-family: -apple-system, "Segoe UI", "Noto Sans KR", sans-serif;
padding: clamp(8px, 4vw, 24px);
}
.dr {
box-sizing: border-box;
display: grid;
gap: 4px;
width: min(292px, 92vw);
padding: 8px;
border: 1px solid rgba(23, 20, 26, 0.12);
border-radius: 16px;
background: #ffffff;
color: #17141a;
box-shadow: 0 6px 12px rgba(23, 20, 26, 0.32);
}
.dr * {
box-sizing: border-box;
}
.dr__title {
margin: 0;
padding: 0 4px;
font-size: 13px;
font-weight: 700;
line-height: 1.3;
}
.dr__list {
display: grid;
gap: 4px;
margin: 0;
padding: 0;
list-style: none;
}
.dr__row {
display: grid;
width: 100%;
grid-template-columns: 26px 16px 20px 1fr 20px;
align-items: center;
gap: 4px;
padding: 4px;
border: 0;
border-radius: 12px;
background: rgba(23, 20, 26, 0);
font-variant-numeric: tabular-nums;
cursor: pointer;
}
.dr__row:focus-visible {
outline: 2px solid #2f6df6;
outline-offset: 2px;
}
.dr__row.is-sel {
background: rgba(110, 200, 255, 0.22);
}
.dr__day {
font-size: 10px;
font-weight: 700;
line-height: 1.3;
color: rgba(23, 20, 26, 0.72);
}
.is-sel .dr__day {
color: #17141a;
}
.dr__i--sun {
color: #ba9f72;
}
.dr__i--cloudsun {
color: #b59c6a;
}
.dr__i--cloud {
color: #5b6478;
}
.dr__i--rain {
color: #2f6df6;
}
.dr__lo, .dr__hi {
font-size: 11px;
font-weight: 700;
line-height: 1.3;
}
.dr__hi {
text-align: right;
}
.dr__lo {
color: rgba(23, 20, 26, 0.72);
}
.dr__track {
position: relative;
height: 6px;
border-radius: 999px;
background: rgba(23, 20, 26, 0.08);
}
.dr__bar {
position: absolute;
top: 0;
bottom: 0;
border-radius: 999px;
background: linear-gradient(90deg, #c4d6e2, #d2bea4);
}
.dr__detail {
margin: 0;
padding: 0 4px;
font-size: 11px;
font-weight: 700;
line-height: 1.4;
color: rgba(23, 20, 26, 0.72);
}
@keyframes dr-wipe {
0% {
clip-path: inset(0 100% 0 0);
}
36%, 86% {
clip-path: inset(0 0 0 0);
}
88%, 100% {
clip-path: inset(0 100% 0 0);
}
}
@keyframes dr-num {
0% {
transform: translateY(6px);
opacity: 0;
}
30%, 86% {
transform: translateY(0);
opacity: 1;
}
88%, 100% {
transform: translateY(6px);
opacity: 0;
}
}
.dr.is-demo .dr__list > li:nth-child(1) .dr__bar {
animation-name: dr-wipe;
animation-delay: 0s;
}
.dr.is-demo .dr__list > li:nth-child(2) .dr__bar {
animation-name: dr-wipe;
animation-delay: 0.12s;
}
.dr.is-demo .dr__list > li:nth-child(3) .dr__bar {
animation-name: dr-wipe;
animation-delay: 0.24s;
}
.dr.is-demo .dr__list > li:nth-child(4) .dr__bar {
animation-name: dr-wipe;
animation-delay: 0.36s;
}
.dr.is-demo .dr__list > li:nth-child(5) .dr__bar {
animation-name: dr-wipe;
animation-delay: 0.48s;
}
.dr.is-demo .dr__bar {
animation-duration: 2s;
animation-timing-function: ease-out;
animation-iteration-count: infinite;
animation-fill-mode: backwards;
}
.dr.is-demo .dr__list > li:nth-child(1) .dr__hi, .dr.is-demo .dr__list > li:nth-child(1) .dr__lo {
animation-name: dr-num;
animation-delay: 0s;
}
.dr.is-demo .dr__list > li:nth-child(3) .dr__hi, .dr.is-demo .dr__list > li:nth-child(3) .dr__lo {
animation-name: dr-num;
animation-delay: 0.12s;
}
.dr.is-demo .dr__list > li:nth-child(5) .dr__hi, .dr.is-demo .dr__list > li:nth-child(5) .dr__lo {
animation-name: dr-num;
animation-delay: 0.24s;
}
.dr.is-demo .dr__lo, .dr.is-demo .dr__hi {
animation-duration: 2s;
animation-timing-function: ease-out;
animation-iteration-count: infinite;
animation-fill-mode: backwards;
}
@media (max-width: 340px) {
.dr {
padding: 4px;
}
.dr__row {
grid-template-columns: 22px 14px 18px 1fr 18px;
padding: 0 4px;
}
}
@media (prefers-reduced-motion: reduce) {
.dr.is-demo .dr__bar,
.dr.is-demo .dr__lo,
.dr.is-demo .dr__hi {
animation: none !important;
transform: none !important;
opacity: 1 !important;
clip-path: none !important;
}
}// 막대의 left/width 는 주간 전체 범위 안에서 비율로 계산한다 — 값이 바뀌어도 자리가 저절로 맞는다.
var drRoot = document.getElementById('dr');
var drRows = drRoot.querySelectorAll('.dr__row');
var drMin = Infinity;
var drMax = -Infinity;
var drDays = [];
for (var i = 0; i < drRows.length; i++) {
var lo = Number(drRows[i].getAttribute('data-lo'));
var hi = Number(drRows[i].getAttribute('data-hi'));
drDays.push({ row: drRows[i], lo: lo, hi: hi });
drMin = Math.min(drMin, lo);
drMax = Math.max(drMax, hi);
}
var drSpan = drMax - drMin;
for (var j = 0; j < drDays.length; j++) {
var d = drDays[j];
var bar = d.row.querySelector('.dr__bar');
bar.style.left = ((d.lo - drMin) / drSpan * 100) + '%';
bar.style.width = ((d.hi - d.lo) / drSpan * 100) + '%';
}
// 상세 문장은 날짜마다 미리 써 둔 전체 문장에서 뽑는다 — 언어팩 사본에서 통째로 바뀐다
var drDetails = [
'오늘 · 일교차 9도',
'내일 · 일교차 9도',
'금요일 · 일교차 8도',
'토요일 · 일교차 12도',
'일요일 · 일교차 8도'
];
function drPick(idx) {
for (var k = 0; k < drRows.length; k++) {
var on = k === idx;
drRows[k].classList.toggle('is-sel', on);
drRows[k].setAttribute('aria-pressed', on ? 'true' : 'false');
}
drRoot.querySelector('.dr__detail').textContent = drDetails[idx];
}
drRoot.addEventListener('click', function (e) {
var row = e.target.closest('.dr__row');
if (!row) return;
drRoot.classList.remove('is-demo');
for (var m = 0; m < drDays.length; m++) {
if (drDays[m].row === row) { drPick(m); break; }
}
});import { useState } from "react";
import type { CSSProperties } from "react";
import styles from "./WeatherDailyRange.module.scss";
// vanilla 판(run/281/demo/04-weather-daily-range/index.html) 의 React 포트.
// 막대의 left/width 는 주간 전체 범위 안에서 비율로 계산한다 — 값이 바뀌어도 자리가 저절로 맞는다.
export type DrDay = {
/** 날짜 낱말("오늘", "금" …) — 언어팩이 통째로 바꾼다 */
day: string;
icon: "sun" | "cloudsun" | "cloud" | "rain";
lo: number;
hi: number;
/** 아래 상세 문장 전체 — 날짜마다 미리 써 둔다 */
detail: string;
/** 낭독기용 전체 문장 */
ariaLabel: string;
};
export type WeatherDailyRangeProps = {
title?: string;
groupLabel?: string;
days?: DrDay[];
/** 격자 미리보기 2초 자동 루프. 사람이 손대면 꺼진다 */
demo?: boolean;
duration?: number;
easing?: string;
color?: string;
};
type Vars = CSSProperties & { "--duration"?: string; "--easing"?: string; "--color"?: string };
const DEFAULT_DAYS: DrDay[] = [
{ day: "오늘", icon: "sun", lo: 18, hi: 27, detail: "오늘 · 일교차 9도", ariaLabel: "오늘, 최저 18도, 최고 27도" },
{ day: "내일", icon: "cloudsun", lo: 16, hi: 25, detail: "내일 · 일교차 9도", ariaLabel: "내일, 최저 16도, 최고 25도" },
{ day: "금", icon: "cloud", lo: 15, hi: 23, detail: "금요일 · 일교차 8도", ariaLabel: "금요일, 최저 15도, 최고 23도" },
{ day: "토", icon: "sun", lo: 17, hi: 29, detail: "토요일 · 일교차 12도", ariaLabel: "토요일, 최저 17도, 최고 29도" },
{ day: "일", icon: "rain", lo: 12, hi: 20, detail: "일요일 · 일교차 8도", ariaLabel: "일요일, 최저 12도, 최고 20도" },
];
function SunIcon() {
return (
<svg viewBox="0 0 256 256" width="15" height="15" fill="currentColor" aria-hidden="true"><path d="M184,128a56,56,0,1,1-56-56A56,56,0,0,1,184,128Z" opacity="0.2"/><path d="M120,40V16a8,8,0,0,1,16,0V40a8,8,0,0,1-16,0Zm72,88a64,64,0,1,1-64-64A64.07,64.07,0,0,1,192,128Zm-16,0a48,48,0,1,0-48,48A48.05,48.05,0,0,0,176,128ZM58.34,69.66A8,8,0,0,0,69.66,58.34l-16-16A8,8,0,0,0,42.34,53.66Zm0,116.68-16,16a8,8,0,0,0,11.32,11.32l16-16a8,8,0,0,0-11.32-11.32ZM192,72a8,8,0,0,0,5.66-2.34l16-16a8,8,0,0,0-11.32-11.32l-16,16A8,8,0,0,0,192,72Zm5.66,114.34a8,8,0,0,0-11.32,11.32l16,16a8,8,0,0,0,11.32-11.32ZM48,128a8,8,0,0,0-8-8H16a8,8,0,0,0,0,16H40A8,8,0,0,0,48,128Zm80,80a8,8,0,0,0-8,8v24a8,8,0,0,0,16,0V216A8,8,0,0,0,128,208Zm112-88H216a8,8,0,0,0,0,16h24a8,8,0,0,0,0-16Z"/></svg>
);
}
function CloudSunIcon() {
return (
<svg viewBox="0 0 256 256" width="15" height="15" fill="currentColor" aria-hidden="true"><path d="M139.84,84.41v0a68.22,68.22,0,0,0-41.65,46v-.11a44.08,44.08,0,0,0-38.54,5h0a48,48,0,1,1,80.19-50.94Z" opacity="0.2"/><path d="M164,72a76.2,76.2,0,0,0-20.26,2.73,55.63,55.63,0,0,0-9.41-11.54l9.51-13.57a8,8,0,1,0-13.11-9.18L121.22,54A55.9,55.9,0,0,0,96,48c-.58,0-1.16,0-1.74,0L91.37,31.71a8,8,0,1,0-15.75,2.77L78.5,50.82A56.1,56.1,0,0,0,55.23,65.67L41.61,56.14a8,8,0,1,0-9.17,13.11L46,78.77A55.55,55.55,0,0,0,40,104c0,.57,0,1.15,0,1.72L23.71,108.6a8,8,0,0,0,1.38,15.88,8.24,8.24,0,0,0,1.39-.12l16.32-2.88a55.74,55.74,0,0,0,5.86,12.42A52,52,0,0,0,84,224h80a76,76,0,0,0,0-152ZM56,104a40,40,0,0,1,72.54-23.24,76.26,76.26,0,0,0-35.62,40,52.14,52.14,0,0,0-31,4.17A40,40,0,0,1,56,104ZM164,208H84a36,36,0,1,1,4.78-71.69c-.37,2.37-.63,4.79-.77,7.23a8,8,0,0,0,16,.92,58.91,58.91,0,0,1,1.88-11.81c0-.16.09-.32.12-.48A60.06,60.06,0,1,1,164,208Z"/></svg>
);
}
function CloudIcon() {
return (
<svg viewBox="0 0 256 256" width="15" height="15" fill="currentColor" aria-hidden="true"><path d="M240,128a80,80,0,0,1-80,80H72A56,56,0,1,1,85.92,97.74l0,.1A80,80,0,0,1,240,128Z" opacity="0.2"/><path d="M160,40A88.09,88.09,0,0,0,81.29,88.67,64,64,0,1,0,72,216h88a88,88,0,0,0,0-176Zm0,160H72a48,48,0,0,1,0-96c1.1,0,2.2,0,3.29.11A88,88,0,0,0,72,128a8,8,0,0,0,16,0,72,72,0,1,1,72,72Z"/></svg>
);
}
function RainIcon() {
return (
<svg viewBox="0 0 256 256" width="15" height="15" fill="currentColor" aria-hidden="true"><path d="M224,92a68,68,0,0,1-68,68H76A44,44,0,1,1,90.2,74.34v.11A68.06,68.06,0,0,1,224,92Z" opacity="0.2"/><path d="M158.66,196.44l-32,48a8,8,0,1,1-13.32-8.88l32-48a8,8,0,0,1,13.32,8.88ZM232,92a76.08,76.08,0,0,1-76,76H132.28l-29.62,44.44a8,8,0,1,1-13.32-8.88L113.05,168H76A52,52,0,1,1,76,64a53.26,53.26,0,0,1,8.92.76A76.08,76.08,0,0,1,232,92Zm-16,0A60.06,60.06,0,0,0,96,88.46a8,8,0,0,1-16-.92q.21-3.66.77-7.23A38.11,38.11,0,0,0,76,80a36,36,0,0,0,0,72h80A60.07,60.07,0,0,0,216,92Z"/></svg>
);
}
function DayIcon({ kind }: { kind: DrDay["icon"] }) {
if (kind === "cloudsun") return <CloudSunIcon />;
if (kind === "cloud") return <CloudIcon />;
if (kind === "rain") return <RainIcon />;
return <SunIcon />;
}
export default function WeatherDailyRange({
title = "5일 예보",
groupLabel = "5일 예보",
days = DEFAULT_DAYS,
demo = true,
duration = 2000,
easing = "ease-out",
color = "#2f6df6",
}: WeatherDailyRangeProps) {
const [sel, setSel] = useState(0);
const [live, setLive] = useState(demo);
const vars: Vars = { "--duration": `${duration}ms`, "--easing": easing, "--color": color };
// 주간 전체 범위 안 비율 — 값이 바뀌어도 자리가 저절로 맞는다
const min = days.reduce((m: number, d: DrDay) => Math.min(m, d.lo), Infinity);
const max = days.reduce((m: number, d: DrDay) => Math.max(m, d.hi), -Infinity);
const span = max - min;
const barVars = (d: DrDay): Vars => ({
left: `${((d.lo - min) / span) * 100}%`,
width: `${((d.hi - d.lo) / span) * 100}%`,
});
const iconCls = (kind: DrDay["icon"]): string => {
if (kind === "sun") return `${styles.i} ${styles["i--sun"]}`;
if (kind === "cloudsun") return `${styles.i} ${styles["i--cloudsun"]}`;
if (kind === "cloud") return `${styles.i} ${styles["i--cloud"]}`;
return `${styles.i} ${styles["i--rain"]}`;
};
function pick(index: number): void {
setLive(false);
setSel(index);
}
const cls = [styles.dr, live ? styles.isDemo : ""].filter(Boolean).join(" ");
return (
<main className={styles.stage}>
<section className={cls} style={vars} aria-label={groupLabel}>
<p className={styles.title}>{title}</p>
<ul className={styles.list}>
{days.map((d: DrDay, i: number) => (
<li key={d.day}>
<button
className={[styles.row, i === sel ? styles.isSel : ""].filter(Boolean).join(" ")}
type="button"
aria-pressed={i === sel ? "true" : "false"}
aria-label={d.ariaLabel}
onClick={() => pick(i)}
>
<span className={styles.day}>{d.day}</span>
<span className={iconCls(d.icon)} aria-hidden="true"><DayIcon kind={d.icon} /></span>
<span className={styles.lo}>{d.lo}</span>
<span className={styles.track}><span className={styles.bar} style={barVars(d)} /></span>
<span className={styles.hi}>{d.hi}</span>
</button>
</li>
))}
</ul>
<p className={styles.detail} aria-live="polite">{days[sel].detail}</p>
</section>
</main>
);
}04 일주일 범위 안에서 제자리를 찾는 5일 예보 막대 — 측정 누적면적 2.409% · 움직인 프레임 18/23GODRICH 원작 · zip 에 SCSS·React 포함 · 날씨 위젯 9종 — 복붙하면 되는 온도·시계·아이콘 코드
이 데모가 속한 글
날씨 위젯 9종 — 복붙하면 되는 온도·시계·아이콘 코드날씨 위젯은 사이트에 붙이는 순간 가장 먼저 보이는 작은 화면 묶음입니다. 「날씨 위젯」 을 검색하는 사람이 원하는 건 큰 그림이 아니라 온도 카드·시간별 띠·해의 길 같은 부품 하나인데, 여기 모은 아홉 벌은 복붙 이 글의 데모 전부 보기


