Section "Grundriss (interaktiv)": floor plan with rooms, admin editor, Seebad view
- Table floor_plans (tenant_id, one per apartment, picture = website photo, rooms as JSON with corners in percent of the picture), model FloorPlan with BelongsToTenant, Property::floorPlan() - Admin › Webseite › Grundriss: room list with name, description, photos, equipment (from the equipment list), accessibility hint, visibility, and an area editor (click the corners on the picture) - Section floor_plan: base view without JavaScript (areas jump to the room list), Seebad view with room buttons, highlighted area and a cartouche per room (theme.js initFloorPlans) - Tests: tenant inheritance, point parsing, website output, admin create incl. validation; the render test for all themes now includes the floor plan - Docs: THEMES §5, ZUSAMMENARBEIT §6, STATUS §6 (incl. note for tenancy phase 5) - styles/grundriss: revised rendering, WebP renditions, room areas of the Stommer flat in percent Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
04b5189bd8
commit
f7cbc66451
26 files changed
+877
-1
No files matched your search
@@ -0,0 +1,42 @@
|
||||
{{--
|
||||
Contract: $heading, $text, $photo (App\Models\Photo, the plan picture), $rooms (Collection of arrays: key, name,
|
||||
description, hint, points = "x,y x,y …" in percent of the picture, photos = Collection<Photo>, amenities = Collection<string>).
|
||||
Base version without JavaScript: the areas on the plan jump to the room descriptions below.
|
||||
--}}
|
||||
@if ($photo && $rooms->isNotEmpty())
|
||||
<section class="mx-auto max-w-7xl px-4 py-16 sm:px-8" aria-labelledby="{{ $sectionId }}-title">
|
||||
<h2 id="{{ $sectionId }}-title" class="heading-display">{{ $heading }}</h2>
|
||||
@if ($text)<p class="mt-3 max-w-2xl text-muted">{{ $text }}</p>@endif
|
||||
|
||||
<div class="relative mt-8">
|
||||
@include('theme::partials.image', ['photo' => $photo, 'sizes' => '(min-width: 1280px) 80rem, 100vw', 'class' => 'h-auto w-full'])
|
||||
<svg viewBox="0 0 100 100" preserveAspectRatio="none" class="absolute inset-0 size-full" aria-label="Räume im Grundriss">
|
||||
@foreach ($rooms as $room)
|
||||
<a href="#{{ $room['key'] }}" aria-label="{{ $room['name'] }}">
|
||||
<polygon points="{{ $room['points'] }}" class="fill-accent/0 stroke-accent transition hover:fill-accent/20" stroke-width="0.25" vector-effect="non-scaling-stroke"><title>{{ $room['name'] }}</title></polygon>
|
||||
</a>
|
||||
@endforeach
|
||||
</svg>
|
||||
</div>
|
||||
|
||||
<ul class="mt-10 grid gap-6 sm:grid-cols-2 lg:grid-cols-3">
|
||||
@foreach ($rooms as $room)
|
||||
<li id="{{ $room['key'] }}" class="scroll-mt-24 rounded bg-surface p-6">
|
||||
@if ($room['photos']->isNotEmpty())
|
||||
@include('theme::partials.image', ['photo' => $room['photos']->first(), 'sizes' => '(min-width: 1024px) 25vw, 100vw', 'class' => 'mb-4 h-44 w-full rounded-sm object-cover'])
|
||||
@endif
|
||||
<h3 class="font-display text-2xl">{{ $room['name'] }}</h3>
|
||||
@if ($room['description'])<p class="mt-2 text-muted">{{ $room['description'] }}</p>@endif
|
||||
@if ($room['amenities']->isNotEmpty())
|
||||
<ul class="mt-3 space-y-1 text-muted">
|
||||
@foreach ($room['amenities'] as $amenity)
|
||||
<li class="flex gap-2"><span aria-hidden="true" class="text-accent">·</span>{{ $amenity }}</li>
|
||||
@endforeach
|
||||
</ul>
|
||||
@endif
|
||||
@if ($room['hint'])<p class="mt-3 border-l-2 border-accent pl-3 text-sm">{{ $room['hint'] }}</p>@endif
|
||||
</li>
|
||||
@endforeach
|
||||
</ul>
|
||||
</section>
|
||||
@endif
|
||||
@@ -50,3 +50,50 @@ function initMenuPanels() {
|
||||
}
|
||||
|
||||
initMenuPanels();
|
||||
|
||||
/**
|
||||
* Floor plan (sections/floor_plan): one room at a time. Areas and room buttons select a room; on narrow
|
||||
* screens the description below the plan is scrolled into view. Without JavaScript all rooms are listed.
|
||||
*/
|
||||
function initFloorPlans() {
|
||||
const reduceMotion = window.matchMedia('(prefers-reduced-motion: reduce)').matches;
|
||||
|
||||
document.querySelectorAll('[data-floor-plan]').forEach((plan) => {
|
||||
const rooms = [...plan.querySelectorAll('[data-floor-room]')];
|
||||
const links = [...plan.querySelectorAll('[data-floor-room-link]')];
|
||||
if (rooms.length === 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
const select = (key, scroll) => {
|
||||
rooms.forEach((room) => {
|
||||
room.hidden = room.id !== key;
|
||||
});
|
||||
links.forEach((link) => {
|
||||
const active = link.dataset.floorRoomLink === key;
|
||||
link.toggleAttribute('data-active', active);
|
||||
if (active) {
|
||||
link.setAttribute('aria-current', 'true');
|
||||
} else {
|
||||
link.removeAttribute('aria-current');
|
||||
}
|
||||
});
|
||||
const room = rooms.find((candidate) => candidate.id === key);
|
||||
if (scroll && room && room.getBoundingClientRect().top > window.innerHeight) {
|
||||
room.scrollIntoView({ behavior: reduceMotion ? 'auto' : 'smooth', block: 'nearest' });
|
||||
}
|
||||
};
|
||||
|
||||
links.forEach((link) => {
|
||||
link.addEventListener('click', (event) => {
|
||||
event.preventDefault();
|
||||
select(link.dataset.floorRoomLink, true);
|
||||
});
|
||||
});
|
||||
|
||||
const fromHash = rooms.find((room) => `#${room.id}` === window.location.hash);
|
||||
select((fromHash ?? rooms[0]).id, false);
|
||||
});
|
||||
}
|
||||
|
||||
initFloorPlans();
|
||||
@@ -0,0 +1,67 @@
|
||||
{{--
|
||||
Contract: $heading, $text, $photo, $rooms (see ostsee-licht/views/sections/floor_plan.blade.php).
|
||||
theme.js (initFloorPlans) shows one room at a time; without JavaScript all rooms are listed and the areas jump to them.
|
||||
--}}
|
||||
@if ($photo && $rooms->isNotEmpty())
|
||||
<section class="mx-auto max-w-7xl px-4 py-16 sm:px-8 sm:py-20" aria-labelledby="{{ $sectionId }}-title" data-floor-plan>
|
||||
<div class="flex flex-wrap items-end justify-between gap-x-12 gap-y-3">
|
||||
<h2 id="{{ $sectionId }}-title" class="heading-display">{{ $heading }}</h2>
|
||||
@if ($text)<p class="max-w-[44ch] text-muted">{{ $text }}</p>@endif
|
||||
</div>
|
||||
|
||||
<div class="mt-10 flex flex-wrap items-start gap-10">
|
||||
<div class="min-w-0 flex-[999_1_38rem]">
|
||||
<div class="border-2 border-ink bg-surface p-2 sm:p-4">
|
||||
<div class="relative">
|
||||
@include('theme::partials.image', ['photo' => $photo, 'sizes' => '(min-width: 1024px) 60vw, 100vw', 'class' => 'h-auto w-full'])
|
||||
<svg viewBox="0 0 100 100" preserveAspectRatio="none" class="absolute inset-0 size-full" role="group" aria-label="Räume im Grundriss">
|
||||
@foreach ($rooms as $room)
|
||||
<a href="#{{ $room['key'] }}" data-floor-room-link="{{ $room['key'] }}" aria-label="{{ $room['name'] }}" class="group">
|
||||
<polygon points="{{ $room['points'] }}" vector-effect="non-scaling-stroke"
|
||||
class="fill-accent/0 stroke-accent/50 [stroke-width:2] transition group-hover:fill-accent/15 group-focus-visible:fill-accent/20 group-data-[active]:fill-accent/25 group-data-[active]:stroke-accent group-data-[active]:[stroke-width:3]"><title>{{ $room['name'] }}</title></polygon>
|
||||
</a>
|
||||
@endforeach
|
||||
</svg>
|
||||
</div>
|
||||
</div>
|
||||
<nav aria-label="Raum wählen" class="mt-5">
|
||||
<ul class="flex flex-wrap gap-2.5">
|
||||
@foreach ($rooms as $room)
|
||||
<li><a href="#{{ $room['key'] }}" data-floor-room-link="{{ $room['key'] }}"
|
||||
class="inline-flex min-h-12 items-center rounded-full border-2 border-ink bg-surface px-5 font-semibold hover:bg-ink/5 data-[active]:bg-ink data-[active]:text-ground">{{ $room['name'] }}</a></li>
|
||||
@endforeach
|
||||
</ul>
|
||||
</nav>
|
||||
</div>
|
||||
|
||||
<div class="min-w-0 flex-[1_1_22rem] space-y-12">
|
||||
@foreach ($rooms as $room)
|
||||
<article id="{{ $room['key'] }}" data-floor-room class="cartouche scroll-mt-28 px-6 pt-10 pb-7 sm:px-7" aria-labelledby="{{ $room['key'] }}-name">
|
||||
<span class="absolute -top-0.5 -left-0.5" aria-hidden="true">@include('theme::partials.motif', ['slot' => 'bracket', 'class' => 'size-9'])</span>
|
||||
<span class="absolute -top-0.5 -right-0.5 -scale-x-100" aria-hidden="true">@include('theme::partials.motif', ['slot' => 'bracket', 'class' => 'size-9'])</span>
|
||||
@if ($room['photos']->isNotEmpty())
|
||||
@include('theme::partials.image', ['photo' => $room['photos']->first(), 'sizes' => '(min-width: 1024px) 26rem, 100vw', 'class' => 'mb-5 h-56 w-full rounded object-cover'])
|
||||
@endif
|
||||
<h3 id="{{ $room['key'] }}-name" class="font-display text-[2rem] leading-tight">{{ $room['name'] }}</h3>
|
||||
@if ($room['description'])<p class="mt-2 text-muted">{{ $room['description'] }}</p>@endif
|
||||
@if ($room['amenities']->isNotEmpty())
|
||||
<ul class="mt-4 space-y-1.5">
|
||||
@foreach ($room['amenities'] as $amenity)
|
||||
<li class="flex gap-3"><x-heroicon-o-check class="mt-1 size-5 shrink-0 text-accent" aria-hidden="true" />{{ $amenity }}</li>
|
||||
@endforeach
|
||||
</ul>
|
||||
@endif
|
||||
@if ($room['hint'])<p class="mt-5 border-l-[3px] border-accent bg-ground px-4 py-3">{{ $room['hint'] }}</p>@endif
|
||||
@if ($room['photos']->count() > 1)
|
||||
<ul class="mt-5 grid grid-cols-3 gap-2">
|
||||
@foreach ($room['photos']->skip(1) as $more)
|
||||
<li><a href="{{ $more->url('lg') }}" data-lightbox data-alt="{{ $more->alt_text }}" class="block overflow-hidden rounded">@include('theme::partials.image', ['photo' => $more, 'sizes' => '8rem', 'class' => 'h-20 w-full object-cover'])</a></li>
|
||||
@endforeach
|
||||
</ul>
|
||||
@endif
|
||||
</article>
|
||||
@endforeach
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
@endif
|
||||
@@ -0,0 +1,52 @@
|
||||
{{--
|
||||
Room area editor (FloorPlanForm): click the corners of a room on the plan picture; stored as "x,y x,y …" in
|
||||
percent of the picture. The other rooms are shown as blue outlines for orientation.
|
||||
--}}
|
||||
@php
|
||||
$planPhoto = \App\Models\Photo::query()->find($get('../../photo_id'));
|
||||
$currentRoomId = $get('id');
|
||||
$otherAreas = collect($get('../../rooms') ?? [])
|
||||
->reject(fn ($room): bool => ($room['id'] ?? null) === $currentRoomId)
|
||||
->map(fn ($room): string => collect(\App\Models\FloorPlan::points($room['points'] ?? null))->map(fn ($point): string => $point[0].','.$point[1])->implode(' '))
|
||||
->filter()
|
||||
->values();
|
||||
@endphp
|
||||
<x-dynamic-component :component="$getFieldWrapperView()" :field="$field">
|
||||
@if (! $planPhoto)
|
||||
<p style="padding:.75rem 1rem;border-radius:.5rem;background:#fef3c7;color:#92400e">Bitte oben zuerst das Grundriss-Bild wählen.</p>
|
||||
@else
|
||||
<div
|
||||
x-data="{
|
||||
state: $wire.$entangle('{{ $getStatePath() }}'),
|
||||
points() { return String(this.state ?? '').trim().split(/\s+/).filter((pair) => /^\d+(\.\d+)?,\d+(\.\d+)?$/.test(pair)) },
|
||||
add(event) {
|
||||
const box = this.$refs.plan.getBoundingClientRect()
|
||||
const x = Math.min(100, Math.max(0, Math.round((event.clientX - box.left) / box.width * 1000) / 10))
|
||||
const y = Math.min(100, Math.max(0, Math.round((event.clientY - box.top) / box.height * 1000) / 10))
|
||||
this.state = [...this.points(), x + ',' + y].join(' ')
|
||||
},
|
||||
undo() { this.state = this.points().slice(0, -1).join(' ') },
|
||||
clear() { this.state = '' },
|
||||
}"
|
||||
>
|
||||
<div x-ref="plan" x-on:click="add($event)" style="position:relative;cursor:crosshair;user-select:none;border:1px solid #e4e4e7;border-radius:.5rem;overflow:hidden">
|
||||
<img src="{{ $planPhoto->url('lg') }}" alt="" draggable="false" style="display:block;width:100%;height:auto">
|
||||
<svg viewBox="0 0 100 100" preserveAspectRatio="none" style="position:absolute;inset:0;width:100%;height:100%;pointer-events:none" aria-hidden="true">
|
||||
@foreach ($otherAreas as $area)
|
||||
<polygon points="{{ $area }}" fill="rgba(37,99,235,.10)" stroke="#2563eb" stroke-width="1.5" vector-effect="non-scaling-stroke" />
|
||||
@endforeach
|
||||
<polygon x-bind:points="points().join(' ')" fill="rgba(217,119,6,.28)" stroke="#d97706" stroke-width="2.5" vector-effect="non-scaling-stroke" />
|
||||
</svg>
|
||||
<template x-for="(point, index) in points()" x-bind:key="index">
|
||||
<span x-bind:style="`position:absolute;left:${point.split(',')[0]}%;top:${point.split(',')[1]}%;width:12px;height:12px;margin:-6px 0 0 -6px;background:#fff;border:2px solid #d97706;border-radius:2px`"></span>
|
||||
</template>
|
||||
</div>
|
||||
<div style="display:flex;flex-wrap:wrap;align-items:center;gap:.5rem;margin-top:.5rem">
|
||||
<span style="font-size:.875rem;color:#52525b" x-text="points().length + (points().length === 1 ? ' Eckpunkt' : ' Eckpunkte')"></span>
|
||||
<x-filament::button size="sm" color="gray" x-on:click="undo()" x-bind:disabled="points().length === 0">Letzten Punkt entfernen</x-filament::button>
|
||||
<x-filament::button size="sm" color="danger" outlined x-on:click="clear()" x-bind:disabled="points().length === 0">Fläche leeren</x-filament::button>
|
||||
</div>
|
||||
<p style="margin-top:.25rem;font-size:.875rem;color:#71717a">Klicken Sie nacheinander die Ecken des Raums auf dem Bild an, im Uhrzeigersinn. Blau umrandet: die anderen Räume.</p>
|
||||
</div>
|
||||
@endif
|
||||
</x-dynamic-component>
|
||||
Reference in new issue
Block a user