ci / check (push) Successful in 55s
- 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
451 lines
11 KiB
Vue
451 lines
11 KiB
Vue
<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>
|