- add /cool, /cool?vote=1, /cool/stage and /cool/city on the existing Nuxt/Onyx stack - wire real route/shade metrics and OSM geometry from the route bundle; city-gap data for the city view - show shade % and direct-sun minutes together; recommend Accessible for Ruth with the 15% ramp trade-off - add in-memory time/scene/round state and one anonymous vote per session, polled every 2 s - keep the retail module linked but out of the Cool City story
This commit is contained in:
1 parent
33063afbdf
commit
2bc52a314d
28 files changed
+8633
-45
No files matched your search
+12
-4
@@ -14,7 +14,14 @@ const usingMock = computed(() => {
|
||||
return value === true || value === '1' || value === 'true'
|
||||
})
|
||||
|
||||
const isPresentation = computed(() => route.path === '/stage' || route.path === '/live')
|
||||
const isCool = computed(() => route.path.startsWith('/cool'))
|
||||
const isDarkPresentation = computed(
|
||||
() => route.path === '/stage' || route.path === '/live' || route.path === '/cool/stage',
|
||||
)
|
||||
const isStandalone = computed(() => isCool.value || isDarkPresentation.value)
|
||||
const bodyClass = computed(() =>
|
||||
isDarkPresentation.value ? 'pc-presentation' : isCool.value ? 'pc-cool-presentation' : '',
|
||||
)
|
||||
|
||||
const navigation = [
|
||||
{ to: '/', label: 'Now', icon: iconHome },
|
||||
@@ -30,7 +37,7 @@ const activeLabel = computed(
|
||||
)
|
||||
|
||||
useHead(() => ({
|
||||
bodyAttrs: { class: isPresentation.value ? 'pc-presentation' : '' },
|
||||
bodyAttrs: { class: bodyClass.value },
|
||||
}))
|
||||
|
||||
// Onyx renders its overflow navigation as a `menubar` whose direct child is a
|
||||
@@ -51,7 +58,7 @@ onBeforeUnmount(() => navRoleObserver?.disconnect())
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<NuxtPage v-if="isPresentation" />
|
||||
<NuxtPage v-if="isStandalone" />
|
||||
|
||||
<OnyxAppLayout v-else>
|
||||
<template #navBar>
|
||||
@@ -78,7 +85,8 @@ onBeforeUnmount(() => navRoleObserver?.disconnect())
|
||||
<span><strong>PulseCast</strong> — staff the pulse, not the noise.</span>
|
||||
<span class="pc-small">
|
||||
Decision support, not an optimizer.
|
||||
<NuxtLink to="/about">Method & limits</NuxtLink>
|
||||
<NuxtLink to="/about">Method & limits</NuxtLink> ·
|
||||
<NuxtLink to="/cool">Cool City public module</NuxtLink>
|
||||
<template v-if="usingMock"> · demo data</template>
|
||||
</span>
|
||||
</footer>
|
||||
|
||||
@@ -0,0 +1,649 @@
|
||||
:root {
|
||||
--cc-ground: #f6f3ee;
|
||||
--cc-surface: rgba(255, 255, 255, 0.86);
|
||||
--cc-surface-solid: #fffdf9;
|
||||
--cc-ink: #121212;
|
||||
--cc-ink-2: #343434;
|
||||
--cc-muted: #6b6b6b;
|
||||
--cc-line: rgba(18, 18, 18, 0.12);
|
||||
--cc-line-strong: rgba(18, 18, 18, 0.24);
|
||||
--cc-heat: #e4572e;
|
||||
--cc-heat-text: #a83a19;
|
||||
--cc-heat-soft: #fbe8e2;
|
||||
--cc-shade: #2f6fed;
|
||||
--cc-shade-deep: #1f4fae;
|
||||
--cc-shade-soft: #e5edff;
|
||||
--cc-water: #3aa6b9;
|
||||
--cc-focus: #a83a19;
|
||||
--cc-radius: 28px;
|
||||
--cc-shadow: 0 18px 60px rgba(18, 18, 18, 0.12);
|
||||
--cc-shadow-soft: 0 8px 26px rgba(18, 18, 18, 0.07);
|
||||
--cc-font: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Inter", "Segoe UI", sans-serif;
|
||||
|
||||
--cc-dark: #0b1114;
|
||||
--cc-dark-2: #14191c;
|
||||
--cc-dark-3: #1d2428;
|
||||
--cc-dark-line: rgba(255, 255, 255, 0.14);
|
||||
--cc-dark-muted: #a3a3a3;
|
||||
--cc-heat-bright: #ff6b3d;
|
||||
--cc-shade-bright: #6fa8ff;
|
||||
--cc-water-bright: #7ad1df;
|
||||
--cc-focus-dark: #ff9b76;
|
||||
}
|
||||
|
||||
body.pc-cool-presentation {
|
||||
background: var(--cc-ground);
|
||||
color: var(--cc-ink);
|
||||
}
|
||||
|
||||
body.pc-cool-presentation,
|
||||
.cc-cool,
|
||||
.cc-stage {
|
||||
font-family: var(--cc-font);
|
||||
}
|
||||
|
||||
.cc-cool,
|
||||
.cc-cool *,
|
||||
.cc-cool *::before,
|
||||
.cc-cool *::after,
|
||||
.cc-stage,
|
||||
.cc-stage *,
|
||||
.cc-stage *::before,
|
||||
.cc-stage *::after,
|
||||
.cc-city,
|
||||
.cc-city *,
|
||||
.cc-city *::before,
|
||||
.cc-city *::after {
|
||||
box-sizing: border-box;
|
||||
font-family: var(--cc-font);
|
||||
}
|
||||
|
||||
.cc-cool {
|
||||
min-height: 100dvh;
|
||||
padding-bottom: 3rem;
|
||||
background: var(--cc-ground);
|
||||
color: var(--cc-ink);
|
||||
}
|
||||
|
||||
/* Top bar --------------------------------------------------------------- */
|
||||
|
||||
.cc-topbar {
|
||||
position: sticky;
|
||||
top: 0;
|
||||
z-index: 10;
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
align-items: center;
|
||||
gap: 0.55rem 0.9rem;
|
||||
min-height: 60px;
|
||||
padding: 0.65rem 1rem;
|
||||
border-bottom: 1px solid var(--cc-line);
|
||||
background: color-mix(in srgb, var(--cc-ground) 88%, transparent);
|
||||
backdrop-filter: blur(18px) saturate(140%);
|
||||
-webkit-backdrop-filter: blur(18px) saturate(140%);
|
||||
}
|
||||
|
||||
.cc-wordmark {
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
gap: 0.5rem;
|
||||
color: var(--cc-ink);
|
||||
font-size: 0.96rem;
|
||||
font-weight: 800;
|
||||
letter-spacing: -0.03em;
|
||||
text-decoration: none;
|
||||
}
|
||||
|
||||
.cc-mark {
|
||||
display: block;
|
||||
width: 0.55rem;
|
||||
height: 1.25rem;
|
||||
border-radius: 999px;
|
||||
background: linear-gradient(180deg, var(--cc-heat) 0 50%, var(--cc-shade) 50% 100%);
|
||||
}
|
||||
|
||||
.cc-topbar__place {
|
||||
color: var(--cc-muted);
|
||||
font-size: 0.72rem;
|
||||
font-variant-numeric: tabular-nums;
|
||||
}
|
||||
|
||||
.cc-topbar__status {
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
gap: 0.3rem;
|
||||
margin-inline-start: auto;
|
||||
color: var(--cc-muted);
|
||||
font-size: 0.62rem;
|
||||
font-weight: 600;
|
||||
letter-spacing: 0.03em;
|
||||
}
|
||||
|
||||
.cc-topbar__status i {
|
||||
display: block;
|
||||
width: 0.4rem;
|
||||
height: 0.4rem;
|
||||
border-radius: 50%;
|
||||
background: var(--cc-shade);
|
||||
}
|
||||
|
||||
/* Phone ----------------------------------------------------------------- */
|
||||
|
||||
.cc-phone {
|
||||
display: flex;
|
||||
width: 100%;
|
||||
max-width: 35rem;
|
||||
flex-direction: column;
|
||||
gap: 1rem;
|
||||
margin-inline: auto;
|
||||
padding: 1rem;
|
||||
}
|
||||
|
||||
.cc-ruth {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 0.45rem;
|
||||
padding: 0.4rem 0 0.7rem;
|
||||
}
|
||||
|
||||
.cc-ruth__label {
|
||||
margin: 0;
|
||||
color: var(--cc-muted);
|
||||
font-size: 0.72rem;
|
||||
font-weight: 650;
|
||||
letter-spacing: 0.06em;
|
||||
text-transform: uppercase;
|
||||
}
|
||||
|
||||
.cc-ruth h1 {
|
||||
max-width: 13ch;
|
||||
margin: 0;
|
||||
font-size: clamp(2.6rem, 10.8vw, 4.2rem);
|
||||
font-weight: 850;
|
||||
letter-spacing: -0.06em;
|
||||
line-height: 0.9;
|
||||
text-wrap: balance;
|
||||
}
|
||||
|
||||
.cc-ruth__copy {
|
||||
max-width: 46ch;
|
||||
margin: 0.15rem 0 0;
|
||||
color: var(--cc-muted);
|
||||
font-size: 0.98rem;
|
||||
line-height: 1.5;
|
||||
}
|
||||
|
||||
.cc-ruth__tag {
|
||||
display: inline-flex;
|
||||
width: fit-content;
|
||||
margin-top: 0.25rem;
|
||||
padding: 0.18rem 0.5rem;
|
||||
border: 1px solid var(--cc-line);
|
||||
border-radius: 999px;
|
||||
color: var(--cc-muted);
|
||||
font-size: 0.6rem;
|
||||
font-weight: 600;
|
||||
letter-spacing: 0.02em;
|
||||
}
|
||||
|
||||
.cc-panel {
|
||||
padding: 1rem;
|
||||
border: 1px solid var(--cc-line);
|
||||
border-radius: var(--cc-radius);
|
||||
background: var(--cc-surface);
|
||||
box-shadow: var(--cc-shadow-soft);
|
||||
backdrop-filter: blur(18px) saturate(140%);
|
||||
-webkit-backdrop-filter: blur(18px) saturate(140%);
|
||||
}
|
||||
|
||||
.cc-time__head {
|
||||
display: flex;
|
||||
align-items: baseline;
|
||||
justify-content: space-between;
|
||||
gap: 0.7rem;
|
||||
margin-bottom: 0.55rem;
|
||||
}
|
||||
|
||||
.cc-time__head h2 {
|
||||
margin: 0;
|
||||
color: var(--cc-muted);
|
||||
font-size: 0.72rem;
|
||||
font-weight: 650;
|
||||
letter-spacing: 0.06em;
|
||||
text-transform: uppercase;
|
||||
}
|
||||
|
||||
.cc-time__head strong {
|
||||
font-size: clamp(2.6rem, 10vw, 3.6rem);
|
||||
font-weight: 850;
|
||||
letter-spacing: -0.06em;
|
||||
line-height: 0.9;
|
||||
font-variant-numeric: tabular-nums;
|
||||
}
|
||||
|
||||
.cc-time :deep(.onyx-slider__marks),
|
||||
.cc-time :deep(.onyx-slider__mark-label) {
|
||||
color: var(--cc-muted);
|
||||
font-family: var(--cc-font);
|
||||
font-size: 0.65rem;
|
||||
font-variant-numeric: tabular-nums;
|
||||
}
|
||||
|
||||
.cc-time :deep(.onyx-slider__track) {
|
||||
accent-color: var(--cc-shade);
|
||||
}
|
||||
|
||||
.cc-routes {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 0.2rem;
|
||||
}
|
||||
|
||||
.cc-routes__head {
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
align-items: baseline;
|
||||
justify-content: space-between;
|
||||
gap: 0.45rem;
|
||||
}
|
||||
|
||||
.cc-routes__head h2 {
|
||||
margin: 0;
|
||||
font-size: 1.55rem;
|
||||
font-weight: 800;
|
||||
letter-spacing: -0.04em;
|
||||
line-height: 1;
|
||||
}
|
||||
|
||||
.cc-model {
|
||||
margin: 0;
|
||||
color: var(--cc-muted);
|
||||
font-size: 0.72rem;
|
||||
line-height: 1.35;
|
||||
}
|
||||
|
||||
.cc-model strong {
|
||||
color: var(--cc-ink);
|
||||
font-weight: 750;
|
||||
}
|
||||
|
||||
.cc-vote {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
}
|
||||
|
||||
.cc-vote__head {
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
align-items: baseline;
|
||||
justify-content: space-between;
|
||||
gap: 0.45rem;
|
||||
}
|
||||
|
||||
.cc-vote__head h2 {
|
||||
margin: 0;
|
||||
font-size: 1.45rem;
|
||||
font-weight: 800;
|
||||
letter-spacing: -0.04em;
|
||||
}
|
||||
|
||||
.cc-vote__lede {
|
||||
max-width: 52ch;
|
||||
margin: 0.35rem 0 0.8rem;
|
||||
color: var(--cc-muted);
|
||||
font-size: 0.84rem;
|
||||
line-height: 1.45;
|
||||
}
|
||||
|
||||
.cc-vote__lede strong {
|
||||
color: var(--cc-ink);
|
||||
}
|
||||
|
||||
.cc-vote__status {
|
||||
margin: 0.5rem 0 0;
|
||||
color: var(--cc-muted);
|
||||
font-size: 0.86rem;
|
||||
line-height: 1.45;
|
||||
}
|
||||
|
||||
.cc-vote__status strong {
|
||||
color: var(--cc-ink);
|
||||
}
|
||||
|
||||
.cc-vote-only {
|
||||
display: flex;
|
||||
min-height: calc(100dvh - 62px);
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
padding: 2rem 1rem 3rem;
|
||||
}
|
||||
|
||||
.cc-vote-only__inner {
|
||||
width: 100%;
|
||||
max-width: 34rem;
|
||||
}
|
||||
|
||||
.cc-vote-only h1 {
|
||||
max-width: 10ch;
|
||||
margin: 0;
|
||||
font-size: clamp(3rem, 12vw, 5rem);
|
||||
font-weight: 850;
|
||||
letter-spacing: -0.06em;
|
||||
line-height: 0.9;
|
||||
}
|
||||
|
||||
.cc-vote-only__lede {
|
||||
max-width: 34ch;
|
||||
margin: 0.8rem 0 1.4rem;
|
||||
color: var(--cc-muted);
|
||||
font-size: 1rem;
|
||||
line-height: 1.45;
|
||||
}
|
||||
|
||||
.cc-vote-only__buttons {
|
||||
display: grid;
|
||||
grid-template-columns: minmax(0, 1fr);
|
||||
gap: 0.5rem;
|
||||
}
|
||||
|
||||
.cc-vote-only__confirmation {
|
||||
padding: 1rem;
|
||||
border: 1px solid var(--cc-line);
|
||||
border-radius: 24px;
|
||||
background: var(--cc-surface);
|
||||
}
|
||||
|
||||
.cc-vote-only__confirmation p {
|
||||
margin: 0;
|
||||
font-size: 1rem;
|
||||
line-height: 1.45;
|
||||
}
|
||||
|
||||
.cc-details {
|
||||
border: 1px solid var(--cc-line);
|
||||
border-radius: 24px;
|
||||
background: var(--cc-surface);
|
||||
}
|
||||
|
||||
.cc-details summary:focus-visible,
|
||||
.cc-city__method summary:focus-visible {
|
||||
outline: 2px solid var(--cc-focus);
|
||||
outline-offset: 2px;
|
||||
}
|
||||
|
||||
.cc-details summary {
|
||||
padding: 0.9rem 1rem;
|
||||
color: var(--cc-ink);
|
||||
font-size: 0.82rem;
|
||||
font-weight: 650;
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
.cc-details__body {
|
||||
display: grid;
|
||||
gap: 0.6rem;
|
||||
padding: 0 1rem 1rem;
|
||||
color: var(--cc-muted);
|
||||
font-size: 0.82rem;
|
||||
line-height: 1.55;
|
||||
}
|
||||
|
||||
.cc-details__body p {
|
||||
margin: 0;
|
||||
}
|
||||
|
||||
.cc-details__body strong {
|
||||
color: var(--cc-ink);
|
||||
}
|
||||
|
||||
.cc-details__links {
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
gap: 0.8rem;
|
||||
padding-top: 0.3rem;
|
||||
}
|
||||
|
||||
.cc-details__links a {
|
||||
color: var(--cc-ink);
|
||||
font-weight: 700;
|
||||
}
|
||||
|
||||
.cc-phone__footer {
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
justify-content: space-between;
|
||||
gap: 0.4rem 1rem;
|
||||
padding-top: 1.1rem;
|
||||
border-top: 1px solid var(--cc-line);
|
||||
color: var(--cc-muted);
|
||||
font-size: 0.68rem;
|
||||
line-height: 1.45;
|
||||
}
|
||||
|
||||
/* Onyx theming on the phone --------------------------------------------- */
|
||||
|
||||
.cc-cool {
|
||||
--onyx-font-family-paragraph: var(--cc-font);
|
||||
--onyx-font-family-h1: var(--cc-font);
|
||||
--onyx-font-family-h2: var(--cc-font);
|
||||
--onyx-font-family-h3: var(--cc-font);
|
||||
--onyx-font-family-h4: var(--cc-font);
|
||||
--onyx-font-family-data: var(--cc-font);
|
||||
--onyx-radius-component-button: 999px;
|
||||
--onyx-radius-component-container-soft: var(--cc-radius);
|
||||
--onyx-radius-component-input: 999px;
|
||||
--onyx-color-base-primary-500: var(--cc-ink);
|
||||
--onyx-color-base-primary-600: var(--cc-ink);
|
||||
--onyx-color-base-primary-900: var(--cc-ink);
|
||||
--onyx-color-component-cta-default: var(--cc-ink);
|
||||
--onyx-color-component-cta-default-hover: #000;
|
||||
--onyx-color-text-icons-neutral-button: #fff;
|
||||
--onyx-color-component-focus-primary: var(--cc-heat);
|
||||
}
|
||||
|
||||
.cc-cool :deep(.onyx-button) {
|
||||
min-height: 52px;
|
||||
border-radius: 999px;
|
||||
font-family: var(--cc-font);
|
||||
font-weight: 650;
|
||||
letter-spacing: -0.01em;
|
||||
}
|
||||
|
||||
.cc-cool :deep(.onyx-button--outline) {
|
||||
border-color: var(--cc-line-strong);
|
||||
color: var(--cc-ink);
|
||||
}
|
||||
|
||||
.cc-cool :deep(.onyx-button--outline:hover) {
|
||||
background: var(--cc-ink);
|
||||
border-color: var(--cc-ink);
|
||||
color: var(--cc-ground);
|
||||
}
|
||||
|
||||
.cc-cool :deep(.onyx-button__label) {
|
||||
font-size: 0.92rem;
|
||||
}
|
||||
|
||||
.cc-vote__buttons,
|
||||
.cc-vote-only__buttons {
|
||||
display: grid;
|
||||
grid-template-columns: repeat(3, minmax(0, 1fr));
|
||||
gap: 0.45rem;
|
||||
}
|
||||
|
||||
.cc-vote__buttons :deep(.onyx-button),
|
||||
.cc-vote-only__buttons :deep(.onyx-button) {
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
.cc-vote__buttons :deep(.onyx-button__label) {
|
||||
font-size: 0.84rem;
|
||||
}
|
||||
|
||||
/* Stage ----------------------------------------------------------------- */
|
||||
|
||||
.cc-stage {
|
||||
position: relative;
|
||||
display: flex;
|
||||
height: 100dvh;
|
||||
flex-direction: column;
|
||||
overflow: hidden;
|
||||
background: var(--cc-dark);
|
||||
color: var(--cc-ink);
|
||||
}
|
||||
|
||||
.cc-stage__top {
|
||||
position: relative;
|
||||
z-index: 4;
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
align-items: baseline;
|
||||
gap: 0.7rem;
|
||||
padding: 0.65rem clamp(1rem, 2.4vw, 2.4rem);
|
||||
border-bottom: 1px solid var(--cc-line);
|
||||
background: color-mix(in srgb, var(--cc-dark) 86%, transparent);
|
||||
backdrop-filter: blur(16px);
|
||||
-webkit-backdrop-filter: blur(16px);
|
||||
}
|
||||
|
||||
.cc-stage__wordmark {
|
||||
color: var(--cc-ink);
|
||||
}
|
||||
|
||||
.cc-stage__place {
|
||||
color: var(--cc-muted);
|
||||
font-size: 0.72rem;
|
||||
font-weight: 600;
|
||||
letter-spacing: 0.06em;
|
||||
text-transform: uppercase;
|
||||
}
|
||||
|
||||
.cc-stage__round {
|
||||
margin-inline-start: auto;
|
||||
color: var(--cc-muted);
|
||||
font-size: 0.7rem;
|
||||
font-variant-numeric: tabular-nums;
|
||||
letter-spacing: 0.03em;
|
||||
}
|
||||
|
||||
.cc-dark {
|
||||
--cc-ground: #0b1114;
|
||||
--cc-surface: rgba(23, 28, 31, 0.88);
|
||||
--cc-surface-solid: #131a1e;
|
||||
--cc-ink: #f5f3ef;
|
||||
--cc-ink-2: #dedbd4;
|
||||
--cc-muted: #a3a3a3;
|
||||
--cc-line: rgba(255, 255, 255, 0.14);
|
||||
--cc-line-strong: rgba(255, 255, 255, 0.26);
|
||||
--cc-heat: #ff6b3d;
|
||||
--cc-heat-text: #ff9b76;
|
||||
--cc-heat-soft: #2b1711;
|
||||
--cc-shade: #6fa8ff;
|
||||
--cc-shade-deep: #a9c8ff;
|
||||
--cc-shade-soft: #142238;
|
||||
--cc-water: #7ad1df;
|
||||
--cc-focus: #ff9b76;
|
||||
--cc-shadow: 0 24px 80px rgba(0, 0, 0, 0.45);
|
||||
--cc-shadow-soft: 0 10px 30px rgba(0, 0, 0, 0.3);
|
||||
color: var(--cc-ink);
|
||||
}
|
||||
|
||||
.cc-dark .cc-wordmark {
|
||||
color: var(--cc-ink);
|
||||
}
|
||||
|
||||
.cc-dark .cc-topbar {
|
||||
background: color-mix(in srgb, var(--cc-dark) 86%, transparent);
|
||||
}
|
||||
|
||||
@media (min-width: 900px) {
|
||||
.cc-phone {
|
||||
display: grid;
|
||||
max-width: 72rem;
|
||||
grid-template-columns: minmax(0, 0.92fr) minmax(0, 1.08fr);
|
||||
grid-template-areas:
|
||||
"ruth routes"
|
||||
"time routes"
|
||||
"vote routes"
|
||||
"details details"
|
||||
"footer footer";
|
||||
gap: 1rem 1.5rem;
|
||||
align-items: start;
|
||||
padding: 1.5rem 1.5rem 3rem;
|
||||
}
|
||||
|
||||
.cc-ruth {
|
||||
grid-area: ruth;
|
||||
padding-top: 0.5rem;
|
||||
}
|
||||
|
||||
.cc-ruth h1 {
|
||||
font-size: clamp(3rem, 4.6vw, 4.8rem);
|
||||
}
|
||||
|
||||
.cc-time {
|
||||
grid-area: time;
|
||||
}
|
||||
|
||||
.cc-vote {
|
||||
grid-area: vote;
|
||||
}
|
||||
|
||||
.cc-routes {
|
||||
grid-area: routes;
|
||||
}
|
||||
|
||||
.cc-routes__head h2 {
|
||||
font-size: 2rem;
|
||||
}
|
||||
|
||||
.cc-routes .cc-route-list {
|
||||
gap: 0.75rem;
|
||||
}
|
||||
|
||||
.cc-details {
|
||||
grid-area: details;
|
||||
margin-top: 0.5rem;
|
||||
}
|
||||
|
||||
.cc-phone__footer {
|
||||
grid-area: footer;
|
||||
grid-column: 1 / -1;
|
||||
margin-top: 0.5rem;
|
||||
}
|
||||
}
|
||||
|
||||
@media (max-width: 460px) {
|
||||
.cc-topbar {
|
||||
min-height: 56px;
|
||||
padding: 0.55rem 0.8rem;
|
||||
}
|
||||
|
||||
.cc-topbar__place {
|
||||
font-size: 0.66rem;
|
||||
}
|
||||
|
||||
.cc-topbar__status {
|
||||
font-size: 0.58rem;
|
||||
}
|
||||
|
||||
.cc-phone {
|
||||
padding-inline: 0.8rem;
|
||||
}
|
||||
|
||||
.cc-vote__buttons {
|
||||
grid-template-columns: minmax(0, 1fr);
|
||||
}
|
||||
|
||||
.cc-vote__buttons :deep(.onyx-button) {
|
||||
min-height: 48px;
|
||||
}
|
||||
}
|
||||
|
||||
@media (prefers-reduced-motion: reduce) {
|
||||
.cc-topbar,
|
||||
.cc-panel {
|
||||
backdrop-filter: none;
|
||||
-webkit-backdrop-filter: none;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,155 @@
|
||||
<script setup lang="ts">
|
||||
import type { CoolCityCatchment, CoolCityPlace } from '#shared/cool'
|
||||
import { createProjection, pathFromCoordinates } from '~/utils/cool-map'
|
||||
|
||||
const props = withDefaults(
|
||||
defineProps<{
|
||||
places: CoolCityPlace[]
|
||||
catchments?: CoolCityCatchment[]
|
||||
selectedRank?: number | null
|
||||
showCatchments?: boolean
|
||||
stage?: boolean
|
||||
}>(),
|
||||
{ catchments: () => [], selectedRank: null, showCatchments: false, stage: false },
|
||||
)
|
||||
|
||||
const allPoints = computed(() => {
|
||||
const placePoints = props.places.map((place) => ({ lat: place.lat, lon: place.lon }))
|
||||
const centers = props.catchments.map((catchment) => catchment.center)
|
||||
return [...placePoints, ...centers]
|
||||
})
|
||||
|
||||
const project = computed(() => createProjection(allPoints.value, 1200, 800, 90))
|
||||
const dots = computed(() =>
|
||||
props.places.map((place) => ({
|
||||
...place,
|
||||
position: project.value({ lat: place.lat, lon: place.lon }),
|
||||
})),
|
||||
)
|
||||
const rings = computed(() =>
|
||||
props.catchments.map((catchment) => {
|
||||
const ring = catchment.geometry.coordinates?.[0] ?? []
|
||||
const path = ring.length
|
||||
? pathFromCoordinates(
|
||||
ring.map(([lon, lat]) => [lon, lat] as [number, number]),
|
||||
project.value,
|
||||
)
|
||||
: ''
|
||||
return {
|
||||
...catchment,
|
||||
path,
|
||||
centerPoint: project.value(catchment.center),
|
||||
selected: props.selectedRank === catchment.rank,
|
||||
}
|
||||
}),
|
||||
)
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<figure class="cc-placesmap" :class="{ 'cc-placesmap--stage': props.stage }">
|
||||
<svg
|
||||
class="cc-placesmap__canvas"
|
||||
viewBox="0 0 1200 800"
|
||||
preserveAspectRatio="xMidYMid meet"
|
||||
role="img"
|
||||
:aria-label="`Map of ${places.length} cool places near the eight Heilbronn sensor catchments.`"
|
||||
>
|
||||
<defs>
|
||||
<pattern id="cc-places-grid" width="44" height="44" patternUnits="userSpaceOnUse">
|
||||
<circle cx="1" cy="1" r="1" fill="currentColor" />
|
||||
</pattern>
|
||||
</defs>
|
||||
<rect class="cc-placesmap__ground" x="0" y="0" width="1200" height="800" />
|
||||
<rect class="cc-placesmap__grid" x="0" y="0" width="1200" height="800" fill="url(#cc-places-grid)" />
|
||||
|
||||
<g v-if="props.showCatchments">
|
||||
<path
|
||||
v-for="ring in rings"
|
||||
:key="ring.sensor_id"
|
||||
class="cc-placesmap__ring"
|
||||
:class="{ 'is-selected': ring.selected }"
|
||||
:d="ring.path"
|
||||
/>
|
||||
<g v-for="ring in rings" :key="`${ring.sensor_id}-label`" class="cc-placesmap__rank">
|
||||
<text :x="ring.centerPoint.x" :y="ring.centerPoint.y + 6" text-anchor="middle">{{ ring.rank }}</text>
|
||||
</g>
|
||||
</g>
|
||||
|
||||
<g class="cc-placesmap__dots">
|
||||
<circle
|
||||
v-for="dot in dots"
|
||||
:key="`${dot.name}-${dot.lat}-${dot.lon}`"
|
||||
:cx="dot.position.x"
|
||||
:cy="dot.position.y"
|
||||
:r="props.stage ? 9 : 6"
|
||||
/>
|
||||
</g>
|
||||
</svg>
|
||||
|
||||
<p class="cc-placesmap__stamp">Relative map · OSM cool places · no heatmap</p>
|
||||
</figure>
|
||||
</template>
|
||||
|
||||
<style scoped>
|
||||
.cc-placesmap {
|
||||
position: relative;
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
min-height: 24rem;
|
||||
margin: 0;
|
||||
overflow: hidden;
|
||||
color: var(--cc-line);
|
||||
}
|
||||
|
||||
.cc-placesmap__canvas {
|
||||
display: block;
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
}
|
||||
|
||||
.cc-placesmap__ground {
|
||||
fill: var(--cc-ground, #f6f3ee);
|
||||
}
|
||||
|
||||
.cc-placesmap__grid {
|
||||
color: var(--cc-line, rgba(18, 18, 18, 0.12));
|
||||
opacity: 0.5;
|
||||
}
|
||||
|
||||
.cc-placesmap__ring {
|
||||
fill: color-mix(in srgb, var(--cc-shade) 8%, transparent);
|
||||
stroke: var(--cc-line);
|
||||
stroke-width: 1.5;
|
||||
}
|
||||
|
||||
.cc-placesmap__ring.is-selected {
|
||||
fill: color-mix(in srgb, var(--cc-heat) 14%, transparent);
|
||||
stroke: var(--cc-heat);
|
||||
stroke-width: 3;
|
||||
}
|
||||
|
||||
.cc-placesmap__rank text {
|
||||
fill: var(--cc-muted);
|
||||
font-size: 17px;
|
||||
font-weight: 750;
|
||||
}
|
||||
|
||||
.cc-placesmap__dots circle {
|
||||
fill: var(--cc-shade);
|
||||
stroke: var(--cc-ground, #f6f3ee);
|
||||
stroke-width: 2;
|
||||
}
|
||||
|
||||
.cc-placesmap__stamp {
|
||||
position: absolute;
|
||||
right: 1rem;
|
||||
bottom: 0.8rem;
|
||||
margin: 0;
|
||||
color: var(--cc-muted);
|
||||
font-family: var(--cc-font);
|
||||
font-size: 0.62rem;
|
||||
letter-spacing: 0.03em;
|
||||
}
|
||||
|
||||
|
||||
</style>
|
||||
@@ -0,0 +1,200 @@
|
||||
<script setup lang="ts">
|
||||
import type { CoolRouteOption, CoolRouteValues } from '#shared/cool'
|
||||
import { coolDistance, coolMinutes, coolShade, coolStops, coolValues, coolYesNo } from '~/utils/cool'
|
||||
|
||||
const props = withDefaults(
|
||||
defineProps<{
|
||||
route: CoolRouteOption
|
||||
values: CoolRouteValues | null
|
||||
recommended?: boolean
|
||||
selected?: boolean
|
||||
selectable?: boolean
|
||||
}>(),
|
||||
{ recommended: false, selected: false, selectable: false },
|
||||
)
|
||||
|
||||
const emit = defineEmits<{ select: [id: CoolRouteOption['id']] }>()
|
||||
const data = computed(() => coolValues(props.values))
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<component
|
||||
:is="selectable ? 'button' : 'article'"
|
||||
class="cc-route-card"
|
||||
:class="[
|
||||
`cc-route-card--${route.id}`,
|
||||
{ 'cc-route-card--recommended': recommended, 'cc-route-card--selected': selected },
|
||||
]"
|
||||
:type="selectable ? 'button' : undefined"
|
||||
:aria-pressed="selectable ? selected : undefined"
|
||||
@click="selectable ? emit('select', route.id) : undefined"
|
||||
>
|
||||
<span class="cc-route-card__line" aria-hidden="true" />
|
||||
<span class="cc-route-card__head">
|
||||
<span class="cc-route-card__label">{{ route.label }}</span>
|
||||
<span v-if="recommended" class="cc-route-card__tag">Accessible for Ruth</span>
|
||||
<span v-else-if="selected" class="cc-route-card__tag cc-route-card__tag--quiet">Selected</span>
|
||||
</span>
|
||||
<span class="cc-route-card__desc">{{ route.description }}</span>
|
||||
|
||||
<span class="cc-route-card__primary">
|
||||
<strong>{{ coolShade(data.shadePct) }}</strong> shade
|
||||
<span class="cc-route-card__modeled">modelled</span>
|
||||
<span class="cc-route-card__divider">·</span>
|
||||
<strong>{{ coolMinutes(data.directSunMin) }}</strong> direct sun
|
||||
</span>
|
||||
|
||||
<span class="cc-route-card__secondary">
|
||||
{{ coolDistance(data.distanceM) }} · {{ coolMinutes(data.durationMin) }} ·
|
||||
<template v-if="route.ramp">{{ route.ramp.incline.replace('.0%', '%') }} ramp</template>
|
||||
<template v-else>no ramp</template>
|
||||
</span>
|
||||
|
||||
<span class="cc-route-card__access">
|
||||
Step-free {{ coolYesNo(data.stepFree) }} · Water {{ coolStops(data.waterStops) }} ·
|
||||
Benches {{ coolStops(data.benchStops) }}
|
||||
</span>
|
||||
</component>
|
||||
</template>
|
||||
|
||||
<style scoped>
|
||||
.cc-route-card {
|
||||
display: flex;
|
||||
width: 100%;
|
||||
min-width: 0;
|
||||
flex-direction: column;
|
||||
gap: 0.3rem;
|
||||
padding: 0.95rem 1rem 0.85rem;
|
||||
border: 1px solid var(--cc-line);
|
||||
border-radius: 24px;
|
||||
background: var(--cc-surface, rgba(255, 255, 255, 0.86));
|
||||
box-shadow: var(--cc-shadow-soft);
|
||||
color: var(--cc-ink);
|
||||
font: inherit;
|
||||
text-align: left;
|
||||
}
|
||||
|
||||
button.cc-route-card {
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
button.cc-route-card:hover {
|
||||
border-color: var(--cc-line-strong);
|
||||
}
|
||||
|
||||
.cc-route-card:focus-visible {
|
||||
outline: 3px solid var(--cc-focus);
|
||||
outline-offset: 2px;
|
||||
}
|
||||
|
||||
.cc-route-card--selected {
|
||||
border-color: var(--cc-ink);
|
||||
box-shadow: 0 0 0 2px var(--cc-ink), var(--cc-shadow-soft);
|
||||
}
|
||||
|
||||
.cc-route-card--recommended {
|
||||
border-color: var(--cc-shade);
|
||||
}
|
||||
|
||||
.cc-route-card__line {
|
||||
display: block;
|
||||
width: 100%;
|
||||
height: 4px;
|
||||
margin-bottom: 0.25rem;
|
||||
border-radius: 999px;
|
||||
background: var(--cc-ink);
|
||||
}
|
||||
|
||||
.cc-route-card--shortest .cc-route-card__line {
|
||||
background: var(--cc-heat);
|
||||
}
|
||||
|
||||
.cc-route-card--shaded .cc-route-card__line {
|
||||
background: var(--cc-shade);
|
||||
}
|
||||
|
||||
.cc-route-card--accessible .cc-route-card__line {
|
||||
background: var(--cc-ink);
|
||||
}
|
||||
|
||||
.cc-route-card__head {
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
align-items: center;
|
||||
gap: 0.45rem;
|
||||
}
|
||||
|
||||
.cc-route-card__label {
|
||||
font-size: 1.18rem;
|
||||
font-weight: 800;
|
||||
letter-spacing: -0.02em;
|
||||
}
|
||||
|
||||
.cc-route-card__tag {
|
||||
margin-inline-start: auto;
|
||||
padding: 0.16rem 0.42rem;
|
||||
border-radius: 999px;
|
||||
background: var(--cc-shade);
|
||||
color: #fff;
|
||||
font-size: 0.6rem;
|
||||
font-weight: 750;
|
||||
letter-spacing: 0.04em;
|
||||
}
|
||||
|
||||
.cc-route-card__tag--quiet {
|
||||
background: var(--cc-ink);
|
||||
}
|
||||
|
||||
.cc-route-card__desc {
|
||||
color: var(--cc-muted);
|
||||
font-size: 0.8rem;
|
||||
line-height: 1.35;
|
||||
}
|
||||
|
||||
.cc-route-card__primary {
|
||||
margin-top: 0.25rem;
|
||||
color: var(--cc-ink);
|
||||
font-size: 1.05rem;
|
||||
font-weight: 500;
|
||||
line-height: 1.35;
|
||||
font-variant-numeric: tabular-nums;
|
||||
}
|
||||
|
||||
.cc-route-card__primary strong {
|
||||
font-size: 1.35rem;
|
||||
font-weight: 800;
|
||||
letter-spacing: -0.03em;
|
||||
}
|
||||
|
||||
.cc-route-card__modeled {
|
||||
margin-inline-start: 0.2rem;
|
||||
color: var(--cc-muted);
|
||||
font-size: 0.58rem;
|
||||
font-weight: 600;
|
||||
letter-spacing: 0.03em;
|
||||
text-transform: uppercase;
|
||||
}
|
||||
|
||||
.cc-route-card__divider {
|
||||
margin-inline: 0.25rem;
|
||||
color: var(--cc-line-strong);
|
||||
}
|
||||
|
||||
.cc-route-card__secondary,
|
||||
.cc-route-card__access {
|
||||
color: var(--cc-muted);
|
||||
font-size: 0.72rem;
|
||||
line-height: 1.4;
|
||||
font-variant-numeric: tabular-nums;
|
||||
}
|
||||
|
||||
.cc-route-card__access {
|
||||
font-size: 0.68rem;
|
||||
}
|
||||
|
||||
@media (min-width: 760px) {
|
||||
.cc-route-card {
|
||||
padding: 1.05rem 1.1rem;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
@@ -0,0 +1,216 @@
|
||||
<script setup lang="ts">
|
||||
import type { CoolRouteBundle, CoolRouteId } from '#shared/cool'
|
||||
import { createProjection, pathFromCoordinates } from '~/utils/cool-map'
|
||||
|
||||
const props = defineProps<{
|
||||
bundle: CoolRouteBundle
|
||||
selectedRoute?: CoolRouteId | null
|
||||
stage?: boolean
|
||||
}>()
|
||||
|
||||
const allPoints = computed(() => {
|
||||
const routePoints = props.bundle.routes.flatMap((route) =>
|
||||
route.geometry.map(([lon, lat]) => ({ lat, lon })),
|
||||
)
|
||||
const water = props.bundle.water.map((point) => ({ lat: point.lat, lon: point.lon }))
|
||||
return [...routePoints, ...water]
|
||||
})
|
||||
|
||||
const project = computed(() => createProjection(allPoints.value))
|
||||
const routes = computed(() =>
|
||||
props.bundle.routes.map((route) => ({
|
||||
...route,
|
||||
path: pathFromCoordinates(route.geometry, project.value),
|
||||
isSelected: props.selectedRoute === route.id,
|
||||
})),
|
||||
)
|
||||
const origin = computed(() => {
|
||||
const lat = props.bundle.origin.lat
|
||||
const lon = props.bundle.origin.lon
|
||||
return lat !== undefined && lon !== undefined ? project.value({ lat, lon }) : null
|
||||
})
|
||||
const destination = computed(() => {
|
||||
const lat = props.bundle.destination.lat
|
||||
const lon = props.bundle.destination.lon
|
||||
return lat !== undefined && lon !== undefined ? project.value({ lat, lon }) : null
|
||||
})
|
||||
const water = computed(() =>
|
||||
props.bundle.water.map((point) => ({ ...point, position: project.value({ lat: point.lat, lon: point.lon }) })),
|
||||
)
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<figure class="cc-routemap" :class="{ 'cc-routemap--stage': props.stage }">
|
||||
<svg
|
||||
class="cc-routemap__canvas"
|
||||
viewBox="0 0 1200 800"
|
||||
preserveAspectRatio="xMidYMid meet"
|
||||
role="img"
|
||||
:aria-label="`Route map from ${props.bundle.origin.name} to ${props.bundle.destination.name}. Shortest, shaded and accessible routes with modelled shade.`"
|
||||
>
|
||||
<defs>
|
||||
<pattern id="cc-route-grid" width="48" height="48" patternUnits="userSpaceOnUse">
|
||||
<circle cx="1" cy="1" r="1" fill="currentColor" />
|
||||
</pattern>
|
||||
</defs>
|
||||
<rect class="cc-routemap__ground" x="0" y="0" width="1200" height="800" />
|
||||
<rect class="cc-routemap__grid" x="0" y="0" width="1200" height="800" fill="url(#cc-route-grid)" />
|
||||
|
||||
<path
|
||||
v-for="route in routes"
|
||||
:key="route.id"
|
||||
class="cc-routemap__route"
|
||||
:class="[
|
||||
`cc-routemap__route--${route.id}`,
|
||||
{ 'is-selected': route.isSelected, 'is-dim': props.selectedRoute && !route.isSelected },
|
||||
]"
|
||||
:d="route.path"
|
||||
pathLength="1"
|
||||
fill="none"
|
||||
vector-effect="non-scaling-stroke"
|
||||
/>
|
||||
|
||||
<g v-for="point in water" :key="point.name" class="cc-routemap__water">
|
||||
<circle :cx="point.position.x" :cy="point.position.y" r="7" />
|
||||
</g>
|
||||
|
||||
<g v-if="origin" class="cc-routemap__endpoint">
|
||||
<circle :cx="origin.x" :cy="origin.y" r="16" />
|
||||
<text :x="origin.x" :y="origin.y + 5" text-anchor="middle" class="cc-routemap__letter">S</text>
|
||||
<text :x="origin.x" :y="origin.y + 44" text-anchor="middle" class="cc-routemap__place">{{ props.bundle.origin.name }}</text>
|
||||
</g>
|
||||
<g v-if="destination" class="cc-routemap__endpoint">
|
||||
<circle :cx="destination.x" :cy="destination.y" r="16" />
|
||||
<text :x="destination.x" :y="destination.y + 5" text-anchor="middle" class="cc-routemap__letter">M</text>
|
||||
<text :x="destination.x" :y="destination.y - 30" text-anchor="middle" class="cc-routemap__place">{{ props.bundle.destination.name }}</text>
|
||||
</g>
|
||||
</svg>
|
||||
|
||||
<p class="cc-routemap__stamp">OSM route geometry · modelled shade · no basemap</p>
|
||||
</figure>
|
||||
</template>
|
||||
|
||||
<style scoped>
|
||||
.cc-routemap {
|
||||
position: relative;
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
min-height: 24rem;
|
||||
margin: 0;
|
||||
overflow: hidden;
|
||||
color: var(--cc-line);
|
||||
}
|
||||
|
||||
.cc-routemap__canvas {
|
||||
display: block;
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
}
|
||||
|
||||
.cc-routemap__ground {
|
||||
fill: var(--cc-ground, #f6f3ee);
|
||||
}
|
||||
|
||||
.cc-routemap__grid {
|
||||
color: var(--cc-line, rgba(18, 18, 18, 0.12));
|
||||
opacity: 0.55;
|
||||
}
|
||||
|
||||
.cc-routemap__route {
|
||||
stroke-linecap: round;
|
||||
stroke-linejoin: round;
|
||||
opacity: 0.9;
|
||||
transition: opacity 240ms ease;
|
||||
animation: cc-route-draw 1.1s cubic-bezier(0.22, 1, 0.36, 1) both;
|
||||
}
|
||||
|
||||
.cc-routemap__route--shortest {
|
||||
stroke: var(--cc-heat);
|
||||
stroke-width: 5;
|
||||
}
|
||||
|
||||
.cc-routemap__route--shaded {
|
||||
stroke: var(--cc-shade);
|
||||
stroke-width: 6;
|
||||
}
|
||||
|
||||
.cc-routemap__route--accessible {
|
||||
stroke: var(--cc-ink);
|
||||
stroke-width: 7;
|
||||
}
|
||||
|
||||
.cc-routemap__route.is-selected {
|
||||
opacity: 1;
|
||||
stroke-width: 9;
|
||||
}
|
||||
|
||||
.cc-routemap__route.is-dim {
|
||||
opacity: 0.38;
|
||||
}
|
||||
|
||||
.cc-routemap__water circle {
|
||||
fill: var(--cc-shade);
|
||||
stroke: var(--cc-ground, #f6f3ee);
|
||||
stroke-width: 3;
|
||||
}
|
||||
|
||||
.cc-routemap__endpoint circle {
|
||||
fill: var(--cc-ink);
|
||||
stroke: var(--cc-ground, #f6f3ee);
|
||||
stroke-width: 4;
|
||||
}
|
||||
|
||||
.cc-routemap__letter {
|
||||
fill: var(--cc-ground, #f6f3ee);
|
||||
font-size: 16px;
|
||||
font-weight: 800;
|
||||
}
|
||||
|
||||
.cc-routemap__place {
|
||||
fill: var(--cc-ink);
|
||||
font-size: 26px;
|
||||
font-weight: 800;
|
||||
letter-spacing: -0.03em;
|
||||
}
|
||||
|
||||
.cc-routemap__stamp {
|
||||
position: absolute;
|
||||
right: 1rem;
|
||||
bottom: 0.8rem;
|
||||
margin: 0;
|
||||
color: var(--cc-muted);
|
||||
font-family: var(--cc-font);
|
||||
font-size: 0.62rem;
|
||||
letter-spacing: 0.03em;
|
||||
}
|
||||
|
||||
.cc-routemap--stage {
|
||||
min-height: 100%;
|
||||
}
|
||||
|
||||
.cc-routemap--stage .cc-routemap__place,
|
||||
.cc-routemap--stage .cc-routemap__endpoint {
|
||||
display: none;
|
||||
}
|
||||
|
||||
.cc-routemap--stage .cc-routemap__letter {
|
||||
font-size: 20px;
|
||||
}
|
||||
|
||||
@keyframes cc-route-draw {
|
||||
from {
|
||||
stroke-dasharray: 1;
|
||||
stroke-dashoffset: 1;
|
||||
}
|
||||
to {
|
||||
stroke-dasharray: 1;
|
||||
stroke-dashoffset: 0;
|
||||
}
|
||||
}
|
||||
|
||||
@media (prefers-reduced-motion: reduce) {
|
||||
.cc-routemap__route {
|
||||
animation: none;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
@@ -0,0 +1,8 @@
|
||||
import type { CoolCityBundle } from '#shared/cool'
|
||||
|
||||
export async function useCoolCityData() {
|
||||
const { data } = await useFetch<CoolCityBundle>('/cool-city/city-gap.json', {
|
||||
key: 'cool-city-gap',
|
||||
})
|
||||
return { city: data }
|
||||
}
|
||||
@@ -0,0 +1,72 @@
|
||||
import { defaultCoolState, emptyCoolTally } from '#shared/cool'
|
||||
import type { CoolDemoState, CoolRound, CoolVoteTally } from '#shared/cool'
|
||||
|
||||
/** State + tally polling for the stage and phone. 2 s is the demo fallback. */
|
||||
export function useCoolDemo(
|
||||
round: Ref<CoolRound>,
|
||||
initialState?: CoolDemoState | null,
|
||||
initialTally?: CoolVoteTally | null,
|
||||
) {
|
||||
const state = ref<CoolDemoState>(initialState ?? defaultCoolState(round.value))
|
||||
const tally = ref<CoolVoteTally>(initialTally ?? emptyCoolTally(round.value))
|
||||
const feedError = ref(false)
|
||||
let timer: ReturnType<typeof setInterval> | undefined
|
||||
|
||||
watch(round, () => {
|
||||
state.value = defaultCoolState(round.value)
|
||||
tally.value = emptyCoolTally(round.value)
|
||||
void poll()
|
||||
})
|
||||
|
||||
async function poll() {
|
||||
const [stateResult, tallyResult] = await Promise.allSettled([
|
||||
$fetch<CoolDemoState>('/api/cool/state', {
|
||||
query: { round: round.value },
|
||||
headers: { accept: 'application/json', 'cache-control': 'no-cache' },
|
||||
}),
|
||||
$fetch<CoolVoteTally>('/api/cool/vote', {
|
||||
query: { round: round.value },
|
||||
headers: { accept: 'application/json', 'cache-control': 'no-cache' },
|
||||
}),
|
||||
])
|
||||
if (stateResult.status === 'fulfilled') state.value = stateResult.value
|
||||
if (tallyResult.status === 'fulfilled') tally.value = tallyResult.value
|
||||
feedError.value = stateResult.status === 'rejected' || tallyResult.status === 'rejected'
|
||||
}
|
||||
|
||||
async function update(patch: Partial<Pick<CoolDemoState, 'time' | 'selectedRoute' | 'scene' | 'voteOpen'>>) {
|
||||
state.value = { ...state.value, ...patch, updatedAt: new Date().toISOString() }
|
||||
try {
|
||||
const next = await $fetch<CoolDemoState>('/api/cool/state', {
|
||||
method: 'POST',
|
||||
body: { round: round.value, ...patch },
|
||||
})
|
||||
state.value = next
|
||||
} catch {
|
||||
feedError.value = true
|
||||
}
|
||||
}
|
||||
|
||||
async function reset() {
|
||||
try {
|
||||
const result = await $fetch<{ state: CoolDemoState; tally: CoolVoteTally }>('/api/cool/reset', {
|
||||
method: 'POST',
|
||||
body: { round: round.value },
|
||||
})
|
||||
state.value = result.state
|
||||
tally.value = result.tally
|
||||
feedError.value = false
|
||||
} catch {
|
||||
feedError.value = true
|
||||
}
|
||||
}
|
||||
|
||||
onMounted(() => {
|
||||
timer = setInterval(() => void poll(), 2000)
|
||||
})
|
||||
onBeforeUnmount(() => {
|
||||
if (timer) clearInterval(timer)
|
||||
})
|
||||
|
||||
return { state, tally, feedError, update, reset, poll }
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
import { pendingCoolRouteBundle } from '#shared/cool'
|
||||
import type { CoolRouteBundle, CoolRouteId, CoolRouteValues, CoolTime } from '#shared/cool'
|
||||
|
||||
export async function useCoolRouteData() {
|
||||
const { data } = await useFetch<CoolRouteBundle>('/cool-city/route.json', {
|
||||
key: 'cool-route-bundle',
|
||||
})
|
||||
const bundle = computed(() => data.value ?? pendingCoolRouteBundle())
|
||||
const pending = computed(() => bundle.value.status !== 'ready')
|
||||
|
||||
function routeForTime(time: CoolTime | string): CoolRouteId {
|
||||
return bundle.value.recommendationByTime[time] ?? 'shortest'
|
||||
}
|
||||
|
||||
function valuesFor(routeId: CoolRouteId, time: CoolTime | string): CoolRouteValues | null {
|
||||
return bundle.value.routes.find((route) => route.id === routeId)?.values[time] ?? null
|
||||
}
|
||||
|
||||
return { bundle, pending, routeForTime, valuesFor }
|
||||
}
|
||||
@@ -0,0 +1,72 @@
|
||||
import { isCoolRouteId } from '#shared/cool'
|
||||
import type { CoolRouteId, CoolRound, CoolVoteResponse, CoolVoteTally } from '#shared/cool'
|
||||
|
||||
const SESSION_KEY = 'cool-city-session-v1'
|
||||
|
||||
/** One anonymous vote per browser and round. No PII. */
|
||||
export function useCoolVote(round: Ref<CoolRound>) {
|
||||
const mounted = ref(false)
|
||||
const sessionId = ref('')
|
||||
const myVote = ref<CoolRouteId | ''>('')
|
||||
const busy = ref(false)
|
||||
const error = ref('')
|
||||
const tally = ref<CoolVoteTally | null>(null)
|
||||
|
||||
function voteKey(value: CoolRound) {
|
||||
return `cool-city-vote-v1:${value}`
|
||||
}
|
||||
|
||||
function makeSessionId(): string {
|
||||
if (typeof crypto !== 'undefined' && 'randomUUID' in crypto) return crypto.randomUUID()
|
||||
return `cool_${Math.random().toString(36).slice(2)}${Date.now().toString(36)}`
|
||||
}
|
||||
|
||||
function readStoredVote(value: CoolRound): CoolRouteId | '' {
|
||||
const stored = localStorage.getItem(voteKey(value))
|
||||
return isCoolRouteId(stored) ? stored : ''
|
||||
}
|
||||
|
||||
onMounted(() => {
|
||||
let storedSession = localStorage.getItem(SESSION_KEY)
|
||||
if (!storedSession || storedSession.length < 8) {
|
||||
storedSession = makeSessionId()
|
||||
localStorage.setItem(SESSION_KEY, storedSession)
|
||||
}
|
||||
sessionId.value = storedSession
|
||||
myVote.value = readStoredVote(round.value)
|
||||
mounted.value = true
|
||||
})
|
||||
|
||||
watch(round, (value) => {
|
||||
if (!mounted.value) return
|
||||
myVote.value = readStoredVote(value)
|
||||
tally.value = null
|
||||
error.value = ''
|
||||
})
|
||||
|
||||
async function vote(route: CoolRouteId) {
|
||||
if (!mounted.value || busy.value || myVote.value || !sessionId.value) return
|
||||
busy.value = true
|
||||
error.value = ''
|
||||
try {
|
||||
const response = await $fetch<CoolVoteResponse>('/api/cool/vote', {
|
||||
method: 'POST',
|
||||
body: { route, sessionId: sessionId.value, round: round.value },
|
||||
})
|
||||
myVote.value = response.yourRoute
|
||||
tally.value = response.tally
|
||||
localStorage.setItem(voteKey(round.value), response.yourRoute)
|
||||
} catch (cause) {
|
||||
const status = (cause as { statusCode?: number; status?: number })?.statusCode ??
|
||||
(cause as { status?: number })?.status
|
||||
error.value =
|
||||
status === 409
|
||||
? 'Voting is not open right now.'
|
||||
: 'The vote could not be recorded. Try again.'
|
||||
} finally {
|
||||
busy.value = false
|
||||
}
|
||||
}
|
||||
|
||||
return { mounted, myVote, busy, error, tally, vote }
|
||||
}
|
||||
@@ -0,0 +1,450 @@
|
||||
<script setup lang="ts">
|
||||
import { isCoolRound } from '#shared/cool'
|
||||
import type { CoolCityCatchment } from '#shared/cool'
|
||||
import { formatPercent } from '~/utils/format'
|
||||
|
||||
const route = useRoute()
|
||||
const round = isCoolRound(route.query.round) ? route.query.round : 'preselection'
|
||||
const { city } = await useCoolCityData()
|
||||
const selectedRank = ref(1)
|
||||
|
||||
const catchments = computed(() => city.value?.catchments ?? [])
|
||||
const selected = computed<CoolCityCatchment | undefined>(
|
||||
() => catchments.value.find((item) => item.rank === selectedRank.value) ?? catchments.value[0],
|
||||
)
|
||||
const top = computed(() => catchments.value[0])
|
||||
const maxIndex = computed(() => Math.max(...catchments.value.map((item) => item.scores.gap_index), 0.001))
|
||||
const places = computed(() => city.value?.official_cool_places ?? [])
|
||||
|
||||
const help = computed(() => {
|
||||
const item = selected.value
|
||||
if (!item) return []
|
||||
const result: string[] = []
|
||||
if (item.inputs.shade.tree_canopy_share_of_land_proxy < 0.05) result.push('Shade')
|
||||
if (item.inputs.access.nearest_public_drinking_water_m > 150) result.push('Water')
|
||||
if (item.inputs.access.nearest_bench_m > 100) result.push('Bench')
|
||||
if (item.inputs.access.nearest_step_free_anchor_m > 100) result.push('Step-free access')
|
||||
return result.length ? result : ['Maintain access']
|
||||
})
|
||||
|
||||
const helpReason = computed(() => {
|
||||
const item = selected.value
|
||||
if (!item) return ''
|
||||
return `p95 ${item.inputs.footfall.p95.toFixed(1)} · canopy ${formatPercent(item.inputs.shade.tree_canopy_share_of_land_proxy * 100, 1)} · water ${Math.round(item.inputs.access.nearest_public_drinking_water_m)} m`
|
||||
})
|
||||
|
||||
useHead({
|
||||
title: 'Cool City — where the city should act first',
|
||||
meta: [
|
||||
{
|
||||
name: 'description',
|
||||
content:
|
||||
'A relative cooling-gap index across eight Heilbronn sensor catchments. Ranked priorities for shade, water and benches; not a temperature map.',
|
||||
},
|
||||
{ name: 'theme-color', content: '#f6f3ee' },
|
||||
],
|
||||
})
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<div class="cc-city">
|
||||
<header class="cc-topbar">
|
||||
<NuxtLink to="/cool" class="cc-wordmark">
|
||||
<span class="cc-mark" aria-hidden="true" />
|
||||
Cool City
|
||||
</NuxtLink>
|
||||
<span class="cc-topbar__place">Heilbronn · city view</span>
|
||||
<NuxtLink class="cc-city__back" :to="{ path: '/cool/stage', query: { round } }">Back to route</NuxtLink>
|
||||
</header>
|
||||
|
||||
<main class="cc-city__main">
|
||||
<header class="cc-city__head">
|
||||
<p class="cc-city__kicker">Cooling gap · relative model</p>
|
||||
<h1>Where the city should act first.</h1>
|
||||
<p class="cc-city__lede">
|
||||
Eight sensor catchments, ranked by footfall, shade deficit, access deficit and vulnerability.
|
||||
It is a relative priority list, not a temperature map.
|
||||
</p>
|
||||
</header>
|
||||
|
||||
<div class="cc-city__grid">
|
||||
<section class="cc-city__map" aria-label="Map of sensor catchments and official cool places">
|
||||
<CoolPlacesMap
|
||||
:places="places"
|
||||
:catchments="catchments"
|
||||
:selected-rank="selectedRank"
|
||||
show-catchments
|
||||
/>
|
||||
</section>
|
||||
|
||||
<aside class="cc-city__list" aria-labelledby="ranked-title">
|
||||
<h2 id="ranked-title">Ranked catchments</h2>
|
||||
<div class="cc-city__rows">
|
||||
<button
|
||||
v-for="item in catchments"
|
||||
:key="item.sensor_id"
|
||||
type="button"
|
||||
class="cc-city__row"
|
||||
:class="{ 'is-selected': selectedRank === item.rank }"
|
||||
:aria-pressed="selectedRank === item.rank"
|
||||
@click="selectedRank = item.rank"
|
||||
>
|
||||
<span class="cc-city__rank">{{ item.rank }}</span>
|
||||
<span class="cc-city__name">{{ item.sensor_name }}</span>
|
||||
<span class="cc-city__bar"><i :style="{ width: `${(item.scores.gap_index / maxIndex) * 100}%` }" /></span>
|
||||
<span class="cc-city__score">{{ item.scores.gap_index.toFixed(3) }}</span>
|
||||
<span class="cc-city__reason">{{ item.reason }}</span>
|
||||
</button>
|
||||
</div>
|
||||
</aside>
|
||||
</div>
|
||||
|
||||
<section v-if="selected" class="cc-city__detail" aria-labelledby="help-title">
|
||||
<div class="cc-city__detail-copy">
|
||||
<p class="cc-city__kicker">Rank {{ selected.rank }} · {{ selected.sensor_name }}</p>
|
||||
<h2 id="help-title">What would help</h2>
|
||||
<p class="cc-city__lede">{{ selected.reason }}</p>
|
||||
<ul class="cc-city__help">
|
||||
<li v-for="item in help" :key="item">{{ item }}</li>
|
||||
</ul>
|
||||
<p class="cc-city__fine">{{ helpReason }}</p>
|
||||
</div>
|
||||
<dl class="cc-city__facts">
|
||||
<div><dt>Gap index</dt><dd>{{ selected.scores.gap_index.toFixed(3) }}</dd></div>
|
||||
<div><dt>Nearest cool place</dt><dd>{{ selected.nearest_cool_place?.name ?? '—' }}</dd></div>
|
||||
<div><dt>Distance</dt><dd>{{ selected.nearest_cool_place ? `${Math.round(selected.nearest_cool_place.distance_m)} m` : '—' }}</dd></div>
|
||||
<div><dt>Ranking note</dt><dd>Top 2 are co-priority</dd></div>
|
||||
</dl>
|
||||
</section>
|
||||
|
||||
<details class="cc-city__method">
|
||||
<summary>How the gap is calculated</summary>
|
||||
<div>
|
||||
<p>Gap index = 0.40 × footfall + 0.30 × shade deficit + 0.20 × access deficit + 0.10 × vulnerability. The weights are deliberative, not calibrated against heat outcomes.</p>
|
||||
<p>Footfall is a relative device index, not people. Shade is modeled from building footprints and tree-canopy proxies. Access combines distance to water, benches, toilets and step-free anchors within 300 m.</p>
|
||||
<p><strong>Vulnerability is constant across all eight catchments</strong> in this dataset (17.26% aged 65+), so it does not differentiate the ranking.</p>
|
||||
<p>Catchment = 300 m Euclidean radius, not a network isochrone. No city-wide heatmap. Top ranks 1 and 2 differ by 2.5%; treat them as co-priority.</p>
|
||||
</div>
|
||||
</details>
|
||||
|
||||
<footer class="cc-city__footer">
|
||||
<span>Cool City · {{ city?.meta.generated ?? '—' }} · {{ places.length }} official cool places</span>
|
||||
<NuxtLink :to="{ path: '/cool/stage', query: { round } }">Back to route</NuxtLink>
|
||||
</footer>
|
||||
</main>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<style scoped>
|
||||
.cc-city {
|
||||
min-height: 100dvh;
|
||||
background: var(--cc-ground);
|
||||
color: var(--cc-ink);
|
||||
}
|
||||
|
||||
.cc-city__back {
|
||||
margin-inline-start: auto;
|
||||
color: var(--cc-ink);
|
||||
font-size: 0.7rem;
|
||||
font-weight: 650;
|
||||
text-decoration: none;
|
||||
}
|
||||
|
||||
.cc-city__main {
|
||||
width: 100%;
|
||||
max-width: 78rem;
|
||||
margin-inline: auto;
|
||||
padding: 1.3rem 1.2rem 2.5rem;
|
||||
}
|
||||
|
||||
.cc-city__head {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 0.7rem;
|
||||
padding-bottom: 1.1rem;
|
||||
}
|
||||
|
||||
.cc-city__kicker {
|
||||
margin: 0;
|
||||
color: var(--cc-muted);
|
||||
font-size: 0.7rem;
|
||||
font-weight: 650;
|
||||
letter-spacing: 0.06em;
|
||||
text-transform: uppercase;
|
||||
}
|
||||
|
||||
.cc-city__head h1 {
|
||||
max-width: 15ch;
|
||||
margin: 0;
|
||||
font-size: clamp(2.8rem, 6vw, 5.2rem);
|
||||
font-weight: 850;
|
||||
letter-spacing: -0.06em;
|
||||
line-height: 0.9;
|
||||
}
|
||||
|
||||
.cc-city__lede {
|
||||
max-width: 64ch;
|
||||
margin: 0;
|
||||
color: var(--cc-muted);
|
||||
font-size: 0.95rem;
|
||||
line-height: 1.5;
|
||||
}
|
||||
|
||||
.cc-city__grid {
|
||||
display: grid;
|
||||
grid-template-columns: minmax(0, 1.15fr) minmax(20rem, 0.85fr);
|
||||
gap: 1rem;
|
||||
align-items: stretch;
|
||||
}
|
||||
|
||||
.cc-city__map {
|
||||
min-height: 30rem;
|
||||
overflow: hidden;
|
||||
border-radius: 28px;
|
||||
background: var(--cc-ground);
|
||||
}
|
||||
|
||||
.cc-city__list {
|
||||
padding: 1rem;
|
||||
border: 1px solid var(--cc-line);
|
||||
border-radius: 28px;
|
||||
background: var(--cc-surface);
|
||||
}
|
||||
|
||||
.cc-city__list h2 {
|
||||
margin: 0 0 0.6rem;
|
||||
font-size: 1.2rem;
|
||||
font-weight: 800;
|
||||
letter-spacing: -0.03em;
|
||||
}
|
||||
|
||||
.cc-city__rows {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
}
|
||||
|
||||
.cc-city__row {
|
||||
display: grid;
|
||||
grid-template-columns: 1.6rem minmax(0, 1fr) 3.2rem;
|
||||
grid-template-rows: auto auto auto;
|
||||
gap: 0.15rem 0.45rem;
|
||||
align-items: center;
|
||||
width: 100%;
|
||||
padding: 0.55rem 0.2rem;
|
||||
border: 0;
|
||||
border-bottom: 1px solid var(--cc-line);
|
||||
background: transparent;
|
||||
color: var(--cc-ink);
|
||||
font: inherit;
|
||||
text-align: left;
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
.cc-city__rank {
|
||||
grid-row: 1 / 4;
|
||||
}
|
||||
|
||||
.cc-city__name {
|
||||
grid-column: 2;
|
||||
grid-row: 1;
|
||||
}
|
||||
|
||||
.cc-city__score {
|
||||
grid-column: 3;
|
||||
grid-row: 1;
|
||||
}
|
||||
|
||||
.cc-city__bar {
|
||||
grid-column: 2 / 4;
|
||||
grid-row: 2;
|
||||
}
|
||||
|
||||
.cc-city__reason {
|
||||
grid-column: 2 / 4;
|
||||
grid-row: 3;
|
||||
overflow: hidden;
|
||||
color: var(--cc-muted);
|
||||
font-size: 0.66rem;
|
||||
line-height: 1.3;
|
||||
text-overflow: ellipsis;
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
.cc-city__row:hover {
|
||||
background: color-mix(in srgb, var(--cc-shade) 7%, transparent);
|
||||
}
|
||||
|
||||
.cc-city__row.is-selected {
|
||||
background: color-mix(in srgb, var(--cc-heat) 8%, transparent);
|
||||
}
|
||||
|
||||
.cc-city__row:focus-visible {
|
||||
outline: 2px solid var(--cc-focus);
|
||||
outline-offset: 1px;
|
||||
}
|
||||
|
||||
.cc-city__rank {
|
||||
color: var(--cc-muted);
|
||||
font-size: 0.76rem;
|
||||
font-weight: 800;
|
||||
font-variant-numeric: tabular-nums;
|
||||
}
|
||||
|
||||
.cc-city__name {
|
||||
overflow: hidden;
|
||||
font-size: 0.82rem;
|
||||
font-weight: 650;
|
||||
text-overflow: ellipsis;
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
.cc-city__bar {
|
||||
height: 0.55rem;
|
||||
overflow: hidden;
|
||||
border-radius: 999px;
|
||||
background: var(--cc-line);
|
||||
}
|
||||
|
||||
.cc-city__bar i {
|
||||
display: block;
|
||||
height: 100%;
|
||||
border-radius: inherit;
|
||||
background: var(--cc-heat);
|
||||
}
|
||||
|
||||
.cc-city__score {
|
||||
color: var(--cc-muted);
|
||||
font-size: 0.68rem;
|
||||
text-align: right;
|
||||
font-variant-numeric: tabular-nums;
|
||||
}
|
||||
|
||||
.cc-city__detail {
|
||||
display: grid;
|
||||
grid-template-columns: minmax(0, 1.2fr) minmax(18rem, 0.8fr);
|
||||
gap: 1rem;
|
||||
margin-top: 1rem;
|
||||
padding: 1rem;
|
||||
border: 1px solid var(--cc-line);
|
||||
border-radius: 28px;
|
||||
background: var(--cc-surface);
|
||||
}
|
||||
|
||||
.cc-city__detail-copy h2 {
|
||||
margin: 0;
|
||||
font-size: 1.7rem;
|
||||
font-weight: 800;
|
||||
letter-spacing: -0.04em;
|
||||
}
|
||||
|
||||
.cc-city__help {
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
gap: 0.4rem;
|
||||
margin: 0.7rem 0 0;
|
||||
padding: 0;
|
||||
list-style: none;
|
||||
}
|
||||
|
||||
.cc-city__help li {
|
||||
padding: 0.25rem 0.6rem;
|
||||
border-radius: 999px;
|
||||
background: var(--cc-heat-soft);
|
||||
color: var(--cc-heat-text);
|
||||
font-size: 0.8rem;
|
||||
font-weight: 700;
|
||||
}
|
||||
|
||||
.cc-city__fine {
|
||||
margin: 0.4rem 0 0;
|
||||
color: var(--cc-muted);
|
||||
font-size: 0.72rem;
|
||||
font-variant-numeric: tabular-nums;
|
||||
}
|
||||
|
||||
.cc-city__facts {
|
||||
display: grid;
|
||||
grid-template-columns: repeat(2, minmax(0, 1fr));
|
||||
gap: 0.7rem;
|
||||
margin: 0;
|
||||
}
|
||||
|
||||
.cc-city__facts dt {
|
||||
color: var(--cc-muted);
|
||||
font-size: 0.65rem;
|
||||
letter-spacing: 0.04em;
|
||||
text-transform: uppercase;
|
||||
}
|
||||
|
||||
.cc-city__facts dd {
|
||||
margin: 0.2rem 0 0;
|
||||
font-size: 0.82rem;
|
||||
font-weight: 650;
|
||||
line-height: 1.3;
|
||||
}
|
||||
|
||||
.cc-city__method {
|
||||
margin-top: 1rem;
|
||||
padding: 0.9rem 1rem;
|
||||
border: 1px solid var(--cc-line);
|
||||
border-radius: 24px;
|
||||
background: var(--cc-surface);
|
||||
}
|
||||
|
||||
.cc-city__method summary {
|
||||
color: var(--cc-ink);
|
||||
font-size: 0.82rem;
|
||||
font-weight: 650;
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
.cc-city__method div {
|
||||
display: grid;
|
||||
gap: 0.5rem;
|
||||
padding-top: 0.7rem;
|
||||
color: var(--cc-muted);
|
||||
font-size: 0.82rem;
|
||||
line-height: 1.5;
|
||||
}
|
||||
|
||||
.cc-city__method p {
|
||||
margin: 0;
|
||||
}
|
||||
|
||||
.cc-city__method strong {
|
||||
color: var(--cc-ink);
|
||||
}
|
||||
|
||||
.cc-city__footer {
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
justify-content: space-between;
|
||||
gap: 0.5rem 1rem;
|
||||
margin-top: 1rem;
|
||||
padding-top: 0.8rem;
|
||||
border-top: 1px solid var(--cc-line);
|
||||
color: var(--cc-muted);
|
||||
font-size: 0.7rem;
|
||||
}
|
||||
|
||||
.cc-city__footer a {
|
||||
color: var(--cc-ink);
|
||||
font-weight: 650;
|
||||
}
|
||||
|
||||
@media (max-width: 900px) {
|
||||
.cc-city__grid,
|
||||
.cc-city__detail {
|
||||
grid-template-columns: minmax(0, 1fr);
|
||||
}
|
||||
|
||||
.cc-city__map {
|
||||
min-height: 22rem;
|
||||
}
|
||||
|
||||
.cc-city__name {
|
||||
overflow: visible;
|
||||
white-space: normal;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
@@ -0,0 +1,411 @@
|
||||
<script setup lang="ts">
|
||||
import { COOL_ROUTE_IDS, COOL_ROUTE_LABELS, COOL_TIMES, isCoolRound } from '#shared/cool'
|
||||
import type { CoolDemoState, CoolRouteId, CoolRound, CoolVoteTally } from '#shared/cool'
|
||||
|
||||
const route = useRoute()
|
||||
const round = ref<CoolRound>(isCoolRound(route.query.round) ? route.query.round : 'preselection')
|
||||
const voteOnly = computed(() => route.query.vote === '1')
|
||||
|
||||
const { bundle } = await useCoolRouteData()
|
||||
const { data: initialState } = await useFetch<CoolDemoState>('/api/cool/state', {
|
||||
query: computed(() => ({ round: round.value })),
|
||||
})
|
||||
const { data: initialTally } = await useFetch<CoolVoteTally>('/api/cool/vote', {
|
||||
query: computed(() => ({ round: round.value })),
|
||||
})
|
||||
const { state, update } = useCoolDemo(round, initialState.value, initialTally.value)
|
||||
const { myVote, busy, error: voteError, tally, mounted, vote } = useCoolVote(round)
|
||||
|
||||
const timeIndex = computed({
|
||||
get: () => Math.max(0, COOL_TIMES.indexOf(state.value.time)),
|
||||
set: (index: number) => {
|
||||
const time = COOL_TIMES[index] ?? '10:00'
|
||||
const nextRoute = bundle.value.recommendationByTime[time] ?? state.value.selectedRoute
|
||||
void update({ time, selectedRoute: nextRoute })
|
||||
},
|
||||
})
|
||||
const timeMarks = COOL_TIMES.map((time, index) => ({ value: index, label: time }))
|
||||
const modelLabel = computed(() => bundle.value.modelLabel)
|
||||
const selectedLabel = computed(() => COOL_ROUTE_LABELS[state.value.selectedRoute])
|
||||
const orderedRoutes = computed(() => {
|
||||
const recommended = bundle.value.routes.find((item) => item.id === 'accessible')
|
||||
return recommended
|
||||
? [recommended, ...bundle.value.routes.filter((item) => item.id !== 'accessible')]
|
||||
: bundle.value.routes
|
||||
})
|
||||
const myVoteLabel = computed(() => (myVote.value ? COOL_ROUTE_LABELS[myVote.value] : ''))
|
||||
const voteStatus = computed(() => {
|
||||
if (myVote.value) {
|
||||
return `${myVoteLabel.value} recorded${tally.value ? ` · ${tally.value.total} ${tally.value.total === 1 ? 'vote' : 'votes'} in this room` : ''}.`
|
||||
}
|
||||
if (state.value.scene === 'locked' || state.value.scene === 'coda') return 'The vote is closed. The stage has the result.'
|
||||
return 'The vote opens when the presenter starts it.'
|
||||
})
|
||||
|
||||
function tooltipTime(value: number): string {
|
||||
return COOL_TIMES[value] ?? ''
|
||||
}
|
||||
|
||||
function selectRoute(id: CoolRouteId) {
|
||||
void update({ selectedRoute: id })
|
||||
}
|
||||
|
||||
function onSubmit(routeId: CoolRouteId) {
|
||||
void vote(routeId)
|
||||
}
|
||||
|
||||
watch(
|
||||
() => route.query.round,
|
||||
(value) => {
|
||||
if (isCoolRound(value)) round.value = value
|
||||
},
|
||||
)
|
||||
|
||||
useHead({
|
||||
title: voteOnly.value ? 'Vote — Cool City' : 'Cool City — a heat-safe route through Heilbronn',
|
||||
meta: [
|
||||
{
|
||||
name: 'description',
|
||||
content: voteOnly.value
|
||||
? 'Which route for Ruth? One anonymous vote for the Cool City demo.'
|
||||
: 'Cool City is Heilbronn’s public heat-safe route: shortest, shaded and accessible options from Stadtgalerie to Marktplatz, with modelled shade.',
|
||||
},
|
||||
{ name: 'theme-color', content: '#f6f3ee' },
|
||||
],
|
||||
})
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<div class="cc-cool">
|
||||
<header class="cc-topbar">
|
||||
<NuxtLink to="/cool" class="cc-wordmark">
|
||||
<span class="cc-mark" aria-hidden="true" />
|
||||
Cool City
|
||||
</NuxtLink>
|
||||
<span class="cc-topbar__place">Heilbronn <span aria-hidden="true">·</span> {{ state.time }}</span>
|
||||
<span class="cc-topbar__status"><i aria-hidden="true" /> Public route</span>
|
||||
</header>
|
||||
|
||||
<main v-if="voteOnly" class="cc-vote-only">
|
||||
<div class="cc-vote-only__inner">
|
||||
<p class="cc-kicker">The room is voting</p>
|
||||
<h1>Which route for Ruth?</h1>
|
||||
<p class="cc-vote-only__lede">Shortest, shaded, or accessible? One tap. No name, no location.</p>
|
||||
|
||||
<div v-if="!myVote && state.voteOpen" class="cc-vote-only__buttons">
|
||||
<OnyxButton
|
||||
v-for="id in COOL_ROUTE_IDS"
|
||||
:key="id"
|
||||
:label="COOL_ROUTE_LABELS[id]"
|
||||
mode="outline"
|
||||
:disabled="busy"
|
||||
@click="onSubmit(id)"
|
||||
/>
|
||||
</div>
|
||||
<div v-else class="cc-vote-only__confirmation" role="status">
|
||||
<p v-if="myVote">You chose <strong>{{ myVoteLabel }}</strong>.</p>
|
||||
<p v-else>{{ voteStatus }}</p>
|
||||
<p class="cc-fine">Aggregate only. One vote per browser and round.</p>
|
||||
</div>
|
||||
|
||||
<p v-if="voteError" class="cc-error" role="alert">{{ voteError }}</p>
|
||||
<p v-if="!mounted" class="cc-fine">Preparing your anonymous vote…</p>
|
||||
</div>
|
||||
</main>
|
||||
|
||||
<main v-else class="cc-phone">
|
||||
<section class="cc-ruth" aria-labelledby="ruth-title">
|
||||
<p class="cc-ruth__label">Ruth, 78 · lives alone</p>
|
||||
<h1 id="ruth-title">Ruth, 78, needs to reach Marktplatz.</h1>
|
||||
<p class="cc-ruth__copy">It is a hot day in Heilbronn. She needs bread. The city knows where the cool places are; it does not give her a way there.</p>
|
||||
<span class="cc-ruth__tag">Composite persona — illustrative, not a real person</span>
|
||||
</section>
|
||||
|
||||
<section class="cc-panel cc-time" aria-labelledby="time-title">
|
||||
<div class="cc-time__head">
|
||||
<h2 id="time-title">When?</h2>
|
||||
<strong>{{ state.time }}</strong>
|
||||
</div>
|
||||
<OnyxSlider
|
||||
v-model="timeIndex"
|
||||
label="Time of day"
|
||||
:min="0"
|
||||
:max="COOL_TIMES.length - 1"
|
||||
:step="1"
|
||||
:marks="timeMarks"
|
||||
:tooltip="{ formatter: tooltipTime }"
|
||||
/>
|
||||
<p class="cc-fine">Modeled shade, not measured. The stage follows this time.</p>
|
||||
</section>
|
||||
|
||||
<section class="cc-routes" aria-labelledby="routes-title">
|
||||
<div class="cc-routes__head">
|
||||
<h2 id="routes-title">Three ways to Marktplatz.</h2>
|
||||
<p class="cc-model">Model recommendation: <strong>{{ modelLabel }}</strong></p>
|
||||
</div>
|
||||
<p class="cc-routes__hint">Shade percentage and direct-sun minutes are different. Tap a route to highlight it on the stage.</p>
|
||||
|
||||
<div class="cc-route-list">
|
||||
<CoolRouteCard
|
||||
v-for="routeOption in orderedRoutes"
|
||||
:key="routeOption.id"
|
||||
:route="routeOption"
|
||||
:values="routeOption.values[state.time] ?? null"
|
||||
:recommended="routeOption.id === 'accessible'"
|
||||
:selected="state.selectedRoute === routeOption.id"
|
||||
selectable
|
||||
@select="selectRoute"
|
||||
/>
|
||||
</div>
|
||||
<p class="cc-fine">Selected: {{ selectedLabel }}. The stage and this phone share the same route and time.</p>
|
||||
</section>
|
||||
|
||||
<section class="cc-panel cc-vote" aria-labelledby="vote-title">
|
||||
<div class="cc-vote__head">
|
||||
<h2 id="vote-title">Which route for Ruth?</h2>
|
||||
<span class="cc-chip">One vote per browser</span>
|
||||
</div>
|
||||
<p class="cc-vote__lede">The room chooses. The model recommends <strong>{{ modelLabel }}</strong>.</p>
|
||||
|
||||
<div v-if="!myVote && state.voteOpen" class="cc-vote__buttons">
|
||||
<OnyxButton
|
||||
v-for="id in COOL_ROUTE_IDS"
|
||||
:key="id"
|
||||
:label="COOL_ROUTE_LABELS[id]"
|
||||
mode="outline"
|
||||
:disabled="busy"
|
||||
@click="onSubmit(id)"
|
||||
/>
|
||||
</div>
|
||||
<p v-else class="cc-vote__status" role="status">
|
||||
<template v-if="myVote">You chose <strong>{{ myVoteLabel }}</strong>.</template>
|
||||
<template v-else>{{ voteStatus }}</template>
|
||||
</p>
|
||||
<p v-if="tally && myVote" class="cc-fine">{{ tally.total }} {{ tally.total === 1 ? 'vote' : 'votes' }} in this room. Aggregate only.</p>
|
||||
<p v-if="voteError" class="cc-error" role="alert">{{ voteError }}</p>
|
||||
</section>
|
||||
|
||||
<details class="cc-details">
|
||||
<summary>Details</summary>
|
||||
<div class="cc-details__body">
|
||||
<p><strong>Shade is modeled, not measured.</strong> The model uses NOAA solar position, building footprints and tree canopies on 14 Aug 2026, a 35°C clear-sky day.</p>
|
||||
<p><strong>Shade percentage is not the whole exposure.</strong> At 16:00 the shaded route has 50.0% shade but 4.9 direct-sun minutes because it is 732 m / 9.8 min. The shortest is 359 m / 4.8 min, 43.8% shade, 2.7 direct-sun minutes, but it has a 15% ramp at the Marktplatz tram crossing. The accessible route is 438 m / 5.8 min, 43.8% shade, 3.3 direct-sun minutes, no ramp, water and benches.</p>
|
||||
<p><strong>The city data is a relative index.</strong> Estimated devices, not people. No city-wide heatmap.</p>
|
||||
<p class="cc-details__links">
|
||||
<NuxtLink to="/cool/city">How this works</NuxtLink>
|
||||
<NuxtLink to="/plan">Retail module</NuxtLink>
|
||||
<NuxtLink to="/cool/stage">Stage</NuxtLink>
|
||||
</p>
|
||||
</div>
|
||||
</details>
|
||||
|
||||
<footer class="cc-phone__footer">
|
||||
<span>Cool City · Heilbronn</span>
|
||||
<span>Modeled shade, not measured. Estimated devices, not people.</span>
|
||||
</footer>
|
||||
</main>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<style scoped>
|
||||
.cc-kicker {
|
||||
margin: 0 0 0.7rem;
|
||||
color: var(--cc-muted);
|
||||
font-size: 0.78rem;
|
||||
font-weight: 600;
|
||||
letter-spacing: 0.04em;
|
||||
text-transform: uppercase;
|
||||
}
|
||||
|
||||
.cc-routes__hint {
|
||||
max-width: 52ch;
|
||||
margin: 0 0 0.8rem;
|
||||
color: var(--cc-muted);
|
||||
font-size: 0.82rem;
|
||||
line-height: 1.45;
|
||||
}
|
||||
|
||||
.cc-route-list {
|
||||
display: grid;
|
||||
gap: 0.65rem;
|
||||
}
|
||||
|
||||
.cc-fine {
|
||||
margin: 0.35rem 0 0;
|
||||
color: var(--cc-muted);
|
||||
font-size: 0.7rem;
|
||||
line-height: 1.45;
|
||||
}
|
||||
|
||||
.cc-error {
|
||||
margin: 0.45rem 0 0;
|
||||
color: var(--cc-heat-text);
|
||||
font-size: 0.78rem;
|
||||
}
|
||||
|
||||
.cc-chip {
|
||||
padding: 0.2rem 0.5rem;
|
||||
border: 1px solid var(--cc-line);
|
||||
border-radius: 999px;
|
||||
color: var(--cc-muted);
|
||||
font-size: 0.62rem;
|
||||
font-weight: 650;
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
.cc-selected {
|
||||
color: var(--cc-ink);
|
||||
font-size: 0.78rem;
|
||||
font-weight: 600;
|
||||
}
|
||||
|
||||
.cc-vote__lede {
|
||||
max-width: 52ch;
|
||||
margin: 0.3rem 0 0.8rem;
|
||||
color: var(--cc-muted);
|
||||
font-size: 0.85rem;
|
||||
line-height: 1.45;
|
||||
}
|
||||
|
||||
.cc-vote__lede strong {
|
||||
color: var(--cc-ink);
|
||||
}
|
||||
|
||||
.cc-vote__buttons,
|
||||
.cc-vote-only__buttons {
|
||||
display: grid;
|
||||
grid-template-columns: repeat(3, minmax(0, 1fr));
|
||||
gap: 0.45rem;
|
||||
}
|
||||
|
||||
.cc-vote__buttons :deep(.onyx-button),
|
||||
.cc-vote-only__buttons :deep(.onyx-button) {
|
||||
width: 100%;
|
||||
min-height: 52px;
|
||||
border-radius: 999px;
|
||||
font-size: 0.92rem;
|
||||
}
|
||||
|
||||
.cc-vote__status {
|
||||
margin: 0;
|
||||
color: var(--cc-muted);
|
||||
font-size: 0.85rem;
|
||||
line-height: 1.45;
|
||||
}
|
||||
|
||||
.cc-vote__status strong {
|
||||
color: var(--cc-ink);
|
||||
}
|
||||
|
||||
.cc-vote-only {
|
||||
display: flex;
|
||||
min-height: calc(100dvh - 60px);
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
padding: 2rem 1rem 3rem;
|
||||
}
|
||||
|
||||
.cc-vote-only__inner {
|
||||
width: 100%;
|
||||
max-width: 34rem;
|
||||
}
|
||||
|
||||
.cc-vote-only h1 {
|
||||
max-width: 10ch;
|
||||
margin: 0;
|
||||
font-size: clamp(3rem, 12vw, 5rem);
|
||||
font-weight: 850;
|
||||
letter-spacing: -0.05em;
|
||||
line-height: 0.9;
|
||||
}
|
||||
|
||||
.cc-vote-only__lede {
|
||||
max-width: 34ch;
|
||||
margin: 0.8rem 0 1.4rem;
|
||||
color: var(--cc-muted);
|
||||
font-size: 1rem;
|
||||
line-height: 1.45;
|
||||
}
|
||||
|
||||
.cc-vote-only__buttons {
|
||||
grid-template-columns: minmax(0, 1fr);
|
||||
}
|
||||
|
||||
.cc-vote-only__confirmation {
|
||||
padding: 1rem;
|
||||
border: 1px solid var(--cc-line);
|
||||
border-radius: 24px;
|
||||
background: var(--cc-surface);
|
||||
}
|
||||
|
||||
.cc-vote-only__confirmation p {
|
||||
margin: 0;
|
||||
font-size: 1rem;
|
||||
line-height: 1.45;
|
||||
}
|
||||
|
||||
.cc-details {
|
||||
border: 1px solid var(--cc-line);
|
||||
border-radius: 24px;
|
||||
background: var(--cc-surface);
|
||||
}
|
||||
|
||||
.cc-details summary {
|
||||
padding: 0.9rem 1rem;
|
||||
color: var(--cc-ink);
|
||||
font-size: 0.82rem;
|
||||
font-weight: 650;
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
.cc-details__body {
|
||||
display: grid;
|
||||
gap: 0.6rem;
|
||||
padding: 0 1rem 1rem;
|
||||
color: var(--cc-muted);
|
||||
font-size: 0.82rem;
|
||||
line-height: 1.55;
|
||||
}
|
||||
|
||||
.cc-details__body p {
|
||||
margin: 0;
|
||||
}
|
||||
|
||||
.cc-details__body strong {
|
||||
color: var(--cc-ink);
|
||||
}
|
||||
|
||||
.cc-details__links {
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
gap: 0.8rem;
|
||||
padding-top: 0.3rem;
|
||||
}
|
||||
|
||||
.cc-details__links a {
|
||||
color: var(--cc-ink);
|
||||
font-weight: 700;
|
||||
}
|
||||
|
||||
.cc-phone__footer {
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
justify-content: space-between;
|
||||
gap: 0.4rem 1rem;
|
||||
padding-top: 1.1rem;
|
||||
border-top: 1px solid var(--cc-line);
|
||||
color: var(--cc-muted);
|
||||
font-size: 0.68rem;
|
||||
line-height: 1.45;
|
||||
}
|
||||
|
||||
@media (max-width: 420px) {
|
||||
.cc-vote__buttons {
|
||||
grid-template-columns: minmax(0, 1fr);
|
||||
}
|
||||
|
||||
.cc-vote__buttons :deep(.onyx-button) {
|
||||
min-height: 48px;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
File diff suppressed because it is too large.
Load diff
@@ -0,0 +1,44 @@
|
||||
export interface GeoPoint {
|
||||
lat: number
|
||||
lon: number
|
||||
}
|
||||
|
||||
export interface ProjectedPoint {
|
||||
x: number
|
||||
y: number
|
||||
}
|
||||
|
||||
export function createProjection(
|
||||
points: GeoPoint[],
|
||||
width = 1200,
|
||||
height = 800,
|
||||
padding = 80,
|
||||
): (point: GeoPoint) => ProjectedPoint {
|
||||
const lats = points.map((point) => point.lat)
|
||||
const lons = points.map((point) => point.lon)
|
||||
const minLat = Math.min(...lats)
|
||||
const maxLat = Math.max(...lats)
|
||||
const minLon = Math.min(...lons)
|
||||
const maxLon = Math.max(...lons)
|
||||
const spanLat = Math.max(maxLat - minLat, 0.0001)
|
||||
const spanLon = Math.max(maxLon - minLon, 0.0001)
|
||||
const innerW = width - padding * 2
|
||||
const innerH = height - padding * 2
|
||||
|
||||
return (point: GeoPoint) => ({
|
||||
x: padding + ((point.lon - minLon) / spanLon) * innerW,
|
||||
y: padding + ((maxLat - point.lat) / spanLat) * innerH,
|
||||
})
|
||||
}
|
||||
|
||||
export function pathFromCoordinates(
|
||||
coordinates: Array<[number, number]>,
|
||||
project: (point: GeoPoint) => ProjectedPoint,
|
||||
): string {
|
||||
return coordinates
|
||||
.map(([lon, lat], index) => {
|
||||
const point = project({ lat, lon })
|
||||
return `${index === 0 ? 'M' : 'L'} ${point.x.toFixed(1)} ${point.y.toFixed(1)}`
|
||||
})
|
||||
.join(' ')
|
||||
}
|
||||
@@ -0,0 +1,51 @@
|
||||
import type { CoolRouteValues } from '#shared/cool'
|
||||
|
||||
export function coolValue(value: number | null | undefined, suffix = ''): string {
|
||||
if (value === null || value === undefined || Number.isNaN(value)) return 'TBD'
|
||||
return `${value}${suffix}`
|
||||
}
|
||||
|
||||
export function coolShade(value: number | null | undefined): string {
|
||||
if (value === null || value === undefined) return 'TBD'
|
||||
return `${value.toFixed(1)}%`
|
||||
}
|
||||
|
||||
export function coolDistance(value: number | null | undefined): string {
|
||||
if (value === null || value === undefined) return 'TBD'
|
||||
if (value >= 1000) return `${(value / 1000).toFixed(2)} km`
|
||||
return `${Math.floor(value)} m`
|
||||
}
|
||||
|
||||
export function coolMinutes(value: number | null | undefined): string {
|
||||
if (value === null || value === undefined) return 'TBD'
|
||||
return `${value.toFixed(1)} min`
|
||||
}
|
||||
|
||||
export function coolYesNo(value: boolean | null | undefined): string {
|
||||
if (value === null || value === undefined) return 'TBD'
|
||||
return value ? 'Yes' : 'No'
|
||||
}
|
||||
|
||||
export function coolStops(value: number | null | undefined): string {
|
||||
if (value === null || value === undefined) return 'TBD'
|
||||
return String(value)
|
||||
}
|
||||
|
||||
export function coolValues(values: CoolRouteValues | null | undefined): CoolRouteValues {
|
||||
return (
|
||||
values ?? {
|
||||
shadePct: null,
|
||||
directSunMin: null,
|
||||
distanceM: null,
|
||||
durationMin: null,
|
||||
stepFree: null,
|
||||
waterStops: null,
|
||||
benchStops: null,
|
||||
}
|
||||
)
|
||||
}
|
||||
|
||||
export function coolTallyPct(count: number, total: number): number {
|
||||
if (!total) return 0
|
||||
return Math.round((count / total) * 100)
|
||||
}
|
||||
Reference in new issue
Block a user