game-village-politics-frontend/app/pages/index.vue

129 lines
5.9 KiB
Vue
Raw Permalink Normal View History

<script setup lang="ts">
import type { BuildingType } from '~/types/game'
import type { SceneInset } from '~/diorama/scene'
// The public face for visitors: what Kronland is, the game's own village as the picture,
// what sets it apart, how a day plays, and the way in. Logged-in players never land here:
// auth.global sends them on to their worlds.
const { t } = useI18n()
const demo = demoVillage()
useSeoMeta({
title: () => t('landing.meta.title'),
description: () => t('landing.meta.description'),
ogTitle: () => t('landing.meta.title'),
ogDescription: () => t('landing.meta.description'),
ogType: 'website',
})
/** What sets the game apart, each shown by the building it is about. */
const POINTS: { key: string; type: BuildingType; level: number }[] = [
{ key: 'space', type: 'headquarters', level: 15 },
{ key: 'roles', type: 'timber_camp', level: 15 },
{ key: 'workers', type: 'farm', level: 15 },
{ key: 'raiders', type: 'watchtower', level: 15 },
{ key: 'volley', type: 'workshop', level: 15 },
{ key: 'seasons', type: 'academy', level: 15 },
{ key: 'tribes', type: 'rally_point', level: 1 },
{ key: 'market', type: 'market', level: 15 },
]
const DAY_STEPS = 4
// The hero: a band with the name and the way in over the village, full width. A phone
// is too narrow for the whole village at a readable size, so there the picture runs past
// the sides (a negative inset) and the village core shows larger.
const hero = ref<HTMLElement | null>(null)
const band = ref<HTMLElement | null>(null)
const inset = ref<SceneInset>({ top: 0, right: 0, bottom: 0, left: 0 })
const PHONE_BLEED = 0.15
function measure() {
const el = band.value
const h = hero.value
if (!el || !h) return
// The band lays out as a row from @3xl on and stacks only on phones.
const bleed = getComputedStyle(el).display === 'flex' ? 0 : -Math.round(h.clientWidth * PHONE_BLEED)
// A new inset rebuilds the scene, so only a real change sets one.
if (inset.value.left !== bleed) inset.value = { top: 0, right: bleed, bottom: 0, left: bleed }
}
let observer: ResizeObserver | undefined
onMounted(() => {
measure()
observer = new ResizeObserver(measure)
if (hero.value) observer.observe(hero.value)
})
onBeforeUnmount(() => observer?.disconnect())
</script>
<template>
<div class="@container">
<section ref="hero" class="border-b-2 border-wood-900">
<div class="bg-parchment-100">
<div ref="band" class="mx-auto max-w-[1100px] px-4 pt-5 pb-4 @3xl:flex @3xl:items-end @3xl:justify-between @3xl:gap-8 @3xl:py-6">
<div class="min-w-0 @3xl:max-w-[38rem]">
<h1 class="font-display text-5xl leading-none font-semibold text-wood-900 @5xl:text-6xl" style="font-variant: small-caps">{{ t('app.title') }}</h1>
<p class="mt-3 text-lg leading-snug text-ink-900">{{ t('landing.hero.line') }}</p>
</div>
<div class="shrink-0">
<div class="mt-5 flex flex-wrap gap-2 @3xl:mt-0">
<NuxtLink to="/register" class="btn btn-primary px-5 py-2 text-base">{{ t('landing.cta.register') }}</NuxtLink>
<NuxtLink to="/login" class="btn btn-outline px-5 py-2 text-base">{{ t('landing.cta.login') }}</NuxtLink>
</div>
<p class="mt-3 text-sm text-ink-500">{{ t('landing.hero.free') }}</p>
</div>
</div>
</div>
<div
class="h-[clamp(16rem,50cqw,26rem)] border-t-2 border-wood-900 bg-[#6a7049] @3xl:h-[clamp(24rem,calc(100dvh-17rem),36rem)]"
role="img"
:aria-label="t('landing.hero.picture')"
>
<div class="h-full" inert>
<VillageDiorama :village="demo" :seconds-until="() => 0" fill still :inset="inset" />
</div>
</div>
</section>
<div class="mx-auto flex max-w-[1100px] flex-col gap-4 px-3 py-6 @3xl:gap-6 @3xl:px-4 @3xl:py-8">
<section class="panel" aria-labelledby="landing-different">
<div class="panel-head">
<h2 id="landing-different" class="panel-title">{{ t('landing.different.title') }}</h2>
</div>
<ul class="grid gap-px bg-parchment-300 @3xl:grid-cols-2">
<li v-for="p in POINTS" :key="p.key" class="flex gap-3 bg-parchment-50 p-3">
<VillagePortraitTile :type="p.type" :level="p.level" class="size-14 @3xl:size-16" />
<div class="min-w-0">
<h3 class="font-semibold text-wood-900">{{ t(`landing.different.${p.key}.title`) }}</h3>
<p class="mt-0.5 text-sm text-ink-700">{{ t(`landing.different.${p.key}.text`) }}</p>
</div>
</li>
</ul>
</section>
<section class="panel" aria-labelledby="landing-day">
<div class="panel-head">
<h2 id="landing-day" class="panel-title">{{ t('landing.day.title') }}</h2>
</div>
<ol class="grid gap-x-6 gap-y-3 p-3 text-sm @3xl:grid-cols-2 @3xl:p-4 @5xl:grid-cols-4">
<li v-for="n in DAY_STEPS" :key="n" class="flex gap-3">
<span class="grid size-8 shrink-0 place-items-center border-2 border-wood-900 bg-wood-800 font-display text-lg text-gold-400" aria-hidden="true">{{ n }}</span>
<span>{{ t(`landing.day.step${n}`) }}</span>
</li>
</ol>
</section>
<section class="frame float flex flex-col gap-4 p-4 @3xl:flex-row @3xl:items-center @3xl:justify-between @3xl:p-5" aria-labelledby="landing-start">
<div class="min-w-0">
<h2 id="landing-start" class="font-display text-2xl font-semibold text-wood-900" style="font-variant: small-caps">{{ t('landing.start.title') }}</h2>
<p class="mt-1 max-w-[40rem] text-sm text-ink-700">{{ t('landing.start.text') }}</p>
</div>
<div class="flex shrink-0 flex-wrap gap-2">
<NuxtLink to="/register" class="btn btn-primary px-5 py-2 text-base">{{ t('landing.cta.register') }}</NuxtLink>
<NuxtLink to="/login" class="btn btn-outline px-5 py-2 text-base">{{ t('landing.cta.login') }}</NuxtLink>
</div>
</section>
</div>
<GameFooter />
</div>
</template>