room groups and grouping.

This commit is contained in:
2023-09-06 20:25:57 +02:00
parent 07c9398414
commit 4fc7d2d475
7 changed files with 315 additions and 90 deletions
+26 -9
View File
@@ -1,31 +1,48 @@
<script lang="ts">
import DeviceIcon from "$lib/components/DeviceIcon.svelte";
import Lamp, { DARK_COLOR } from "$lib/components/Lamp.svelte";
import MetaLamp from "$lib/components/MetaLamp.svelte";
import RoomHeader from "$lib/components/RoomHeader.svelte";
import { getStateContext } from "$lib/contexts/StateContext.svelte";
import { rgb } from "$lib/models/color";
const {deviceList, roomList} = getStateContext();
const {roomList} = getStateContext();
$: console.log($roomList);
</script>
<div class="page">
{#each $deviceList as device (device.id) }
<Lamp compact={device.name.includes("Square")} device={device} />
{#each $roomList as room (room.name)}
<RoomHeader devices={room.devices} name={room.name} />
<div class="devices">
{#each room.devices as device (device.id) }
<Lamp device={device} />
{/each}
</div>
<div class="devices">
{#each room.groups as group (group.name)}
<MetaLamp name={group.name} devices={group.devices} />
{/each}
</div>
{/each}
</div>
<div class="page" style="font-size: 8em">
<DeviceIcon name="hue_go" brightColor={rgb(0.517,0.537,1.000)} darkColor={DARK_COLOR} />
</div>
<style>
div.page {
margin: 0 auto;
width: 100ch;
width: 200ch;
max-width: 95%;
margin-top: 1em;
font-size: 2em;
font-size: 1.33rem;
}
div.devices {
display: flex;
flex-direction: row;
flex-wrap: wrap;
}
div.devices + div.devices {
margin-top: 0.25em;
}
</style>