SOURCE / PINNED RELEASE
Made of little things.
Clock
- Release
- 2f6bf444f0c4…
- Author-recorded commit
- Not provided
- License
- Check the original source
- Author’s source link
- Open external source ↗May change independently of this release
The hash-verified playable HTML, which may contain bundled or minified code. This view does not execute it.
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8"><meta name="viewport" content="width=device-width,initial-scale=1">
<title>Clock</title>
<style>
:root{color-scheme:light;--bg:#fdfcf9;--fg:#1c1c1a;--faint:#706f69;--line:#e2e0d8;--ember:#b45437;--lava:#e87655;--gold:#e6a25e;--raised:#fff;--tick:#b7aea4;--tick-strong:#746a61}
@media(prefers-color-scheme:dark){:root{color-scheme:dark;--bg:#1a1d21;--fg:#e7e5df;--faint:#9a9b99;--line:#34383e;--ember:#e87655;--lava:#e87655;--gold:#ffbc65;--raised:#24272c;--tick:#5a504b;--tick-strong:#c3a28b}}
*{box-sizing:border-box}html,body{width:100%;height:100%;margin:0}body{font-family:system-ui,-apple-system,'Noto Sans JP',sans-serif;color:var(--fg);background:var(--bg);container:clock / size;overflow:hidden}
main{height:100%;display:grid;grid-template-rows:auto minmax(0,1fr) auto;gap:clamp(2px,1cqh,12px);padding:clamp(10px,2.5cqw,30px);background:radial-gradient(ellipse 70% 67% at 50% 50%,color-mix(in srgb,var(--lava) 4%,transparent),transparent 80%)}
header{display:flex;gap:10px;align-items:center;justify-content:space-between;min-width:0}.eyebrow,.tz{font-size:clamp(10px,1.25cqw,12px);font-weight:650;letter-spacing:.14em;color:var(--faint);text-transform:uppercase}
.eyebrow{display:flex;align-items:center;gap:9px}.dot{height:6px;width:6px;flex:none;background:var(--lava);border-radius:100%;box-shadow:0 0 0 4px color-mix(in srgb,var(--lava) 12%,transparent)}.tz{overflow:hidden;text-overflow:ellipsis;white-space:nowrap;letter-spacing:.08em;max-width:55%;font-weight:450}
.center{position:relative;display:flex;align-items:center;justify-content:center;min-width:0;min-height:0;isolation:isolate;container-type:size}
.instrument{position:relative;display:grid;place-items:center;--diameter:min(89vw,83vh,100cqmin);flex:none;width:var(--diameter);height:var(--diameter);aspect-ratio:1;border-radius:50%;background:radial-gradient(circle at center,color-mix(in srgb,var(--lava) 5%,var(--bg)) 0%,var(--bg) 63%,color-mix(in srgb,var(--gold) 2%,var(--bg)) 100%);box-shadow:inset 0 0 0 1px color-mix(in srgb,var(--tick) 24%,transparent),0 0 0 1px color-mix(in srgb,var(--tick) 8%,transparent)}
.dial{position:absolute;inset:0;width:100%;height:100%;overflow:visible;pointer-events:none}.dial .track{fill:none;stroke:var(--tick);stroke-width:.75;opacity:.55}.dial .inner{fill:none;stroke:var(--tick);stroke-width:.7;opacity:.21;stroke-dasharray:1.7 7}
.tick{stroke:var(--tick);stroke-width:2.4;stroke-linecap:round;opacity:.85}.tick.hour{stroke:var(--tick-strong);stroke-width:3.6;opacity:1}.tick.cardinal{stroke:var(--ember);stroke-width:4.1;opacity:.97}
.hand{transform-origin:150px 150px;transition:transform .28s cubic-bezier(.3,1.6,.5,1)}.hand.jump{transition:none}.hand line{stroke-linecap:round}
.hand.h line{stroke:var(--fg);stroke-width:8}.hand.m line{stroke:var(--fg);stroke-width:5}.hand.s line{stroke:var(--ember);stroke-width:2.2}.hand.s .tail{stroke-width:3.6}.hand .edge{stroke:var(--bg);stroke-width:11;opacity:.85}.hand.m .edge{stroke-width:8}.hand.s .edge{stroke-width:5}
.hub{fill:var(--ember);stroke:var(--bg);stroke-width:2.4}.hubcore{fill:var(--bg)}
.readout{position:absolute;left:0;top:58%;display:flex;flex-direction:column;align-items:center;justify-content:center;gap:clamp(2px,.6vh,8px);width:100%;min-width:0;z-index:1;text-align:center}
.dayline{font-size:clamp(11px,1.9vw,18px);font-weight:600;paint-order:stroke fill;-webkit-text-stroke:3px var(--bg);text-shadow:0 0 6px var(--bg);letter-spacing:.1em;text-transform:uppercase;color:color-mix(in srgb,var(--fg) 82%,var(--bg));white-space:nowrap;max-width:90%;overflow:hidden;text-overflow:ellipsis}
.clockrow{display:flex;align-items:baseline;justify-content:center;gap:clamp(3px,1vw,12px);font-variant-numeric:tabular-nums lining-nums;white-space:nowrap;max-width:86%}
#time{paint-order:stroke fill;-webkit-text-stroke:4px var(--bg);font-size:clamp(22px,min(11.5vw,16vh),100px);line-height:.99;font-weight:400;text-shadow:0 0 6px var(--bg),0 0 12px var(--bg);letter-spacing:-.075em;padding-right:.04em}
footer{min-height:34px}
@container clock (max-width:290px){.instrument{--diameter:min(94vw,77vh,100cqmin)}.dayline{font-size:11px;letter-spacing:.04em}.clockrow{max-width:94%}}
@container clock (max-height:230px){.readout{gap:2px;top:55%}#time{paint-order:stroke fill;-webkit-text-stroke:4px var(--bg);font-size:clamp(18px,12vh,28px)}.dayline{display:none}.instrument{--diameter:min(82vw,71vh,100cqmin)}footer{min-height:25px}}
@media(prefers-reduced-motion:reduce){.hand{transition:none}}
</style>
</head>
<body>
<main>
<header><div class="eyebrow"><i class="dot" aria-hidden="true"></i><span id="caption">Local time</span></div><span class="tz" id="zone"></span></header>
<section class="center" aria-label="Clock"><div class="instrument"><svg class="dial" viewBox="0 0 300 300" aria-hidden="true"><circle class="track" cx="150" cy="150" r="138"/><circle class="inner" cx="150" cy="150" r="108"/><g id="ticks"></g><g class="hand h" id="hh"><line class="edge" x1="150" y1="162" x2="150" y2="84"/><line x1="150" y1="162" x2="150" y2="84"/></g><g class="hand m" id="hm"><line class="edge" x1="150" y1="166" x2="150" y2="38"/><line x1="150" y1="166" x2="150" y2="38"/></g><g class="hand s" id="hs"><line class="tail" x1="150" y1="150" x2="150" y2="172"/><line x1="150" y1="150" x2="150" y2="18"/></g><circle class="hub" cx="150" cy="150" r="8"/><circle class="hubcore" cx="150" cy="150" r="2.6"/></svg>
<div class="readout"><div class="dayline" id="date"></div><div class="clockrow"><time id="time"></time></div></div></div></section>
<footer aria-hidden="true"></footer>
</main>
<script>
const $=s=>document.querySelector(s),time=$('#time'),date=$('#date'),hands={h:$('#hh'),m:$('#hm'),s:$('#hs')},reduced=matchMedia('(prefers-reduced-motion:reduce)');
const words={en:{local:'Local time'},ja:{local:'現在時刻'}};
let lang=navigator.language,timer=0,inView=true;const pad=n=>String(n).padStart(2,'0');
// Exactly 60 marks. Every fifth is the longer, weighted hour index; quadrants carry a warm datum.
const ticks=$('#ticks'),NS='http://www.w3.org/2000/svg';for(let i=0;i<60;i++){const theta=i*Math.PI/30-Math.PI/2,cardinal=i%15===0,hour=i%5===0,r1=cardinal?114:hour?118:125,r2=137;const mark=document.createElementNS(NS,'line');mark.setAttribute('x1',String(150+Math.cos(theta)*r1));mark.setAttribute('y1',String(150+Math.sin(theta)*r1));mark.setAttribute('x2',String(150+Math.cos(theta)*r2));mark.setAttribute('y2',String(150+Math.sin(theta)*r2));mark.setAttribute('class',`tick${hour?' hour':''}${cardinal?' cardinal':''}`);ticks.append(mark)}
function active(){return !document.hidden&&inView}
// Angles (deg): hour 30/h + .5/min, minute 6/min + .1/s, second 6/s. Whole seconds: the hand ticks once a second
// (a short spring unless reduced motion). The angle is also exposed as data-angle for tests.
const prev={};
function pointer(now){const sec=now.getSeconds(),a={s:sec*6,m:now.getMinutes()*6+sec*.1,h:(now.getHours()%12)*30+now.getMinutes()*.5};
for(const k in hands){const el=hands[k];el.classList.toggle('jump',!(a[k]>prev[k]));el.style.transform=`rotate(${a[k]}deg)`;el.dataset.angle=a[k];prev[k]=a[k]}}
function render(){if(!active())return;const now=new Date(),hour=now.getHours(),txt=words[lang.startsWith('ja')?'ja':'en'];time.textContent=`${pad(hour)}:${pad(now.getMinutes())}`;
date.textContent=new Intl.DateTimeFormat(lang,innerWidth<=330||innerHeight<=330?{weekday:'short',month:'short',day:'numeric'}:{weekday:'long',month:'long',day:'numeric'}).format(now);time.dateTime=now.toISOString();time.setAttribute('aria-label',new Intl.DateTimeFormat(lang,{hour:'numeric',minute:'2-digit',second:'2-digit',hourCycle:'h23'}).format(now));
$('#caption').textContent=txt.local;$('#zone').textContent=Intl.DateTimeFormat().resolvedOptions().timeZone?.replaceAll('_',' ')||'LOCAL';
pointer(now);timer=setTimeout(render,Math.max(25,1000-Date.now()%1000))}
function wake(){clearTimeout(timer);timer=0;if(active()){for(const k in prev)delete prev[k];render()}}
document.addEventListener('visibilitychange',wake);new IntersectionObserver(([entry])=>{inView=entry.isIntersecting&&entry.intersectionRatio>0;wake()}).observe(document.querySelector('main'));
window.addEventListener('pagehide',()=>{clearTimeout(timer)});window.addEventListener('pageshow',wake);addEventListener('resize',wake);reduced.addEventListener('change',wake);
function theme(t){if(!t?.colors)return;const keys={background:'bg',text:'fg',faint:'faint',line:'line',raised:'raised'};for(const [name,target] of Object.entries(keys)){const c=t.colors[name];if(/^#[0-9a-f]{6}$/i.test(c||''))document.documentElement.style.setProperty('--'+target,c)}if(t.lang)lang=t.lang;wake()}
window.napplet?.theme?.get().then(theme,()=>{});window.napplet?.theme?.onChanged(theme);wake();
</script>
</body>
</html>
