- 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
@@ -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>
|
||||
Reference in new issue
Block a user