mirror of
https://github.com/bilawalsidhu/gods-eye-view.git
synced 2026-11-20 02:02:21 +00:00
The Data, Authoring, Weather, Recent Imagery, Context, CCTV, Street Level and Radio panels each wrote the same frame by hand. They are now one kit component, UiPanel, with a title, badge/actions/default slots and v-model:collapsed, drawing Core's panel markup and classes beside the kit's; props cover the differences (sideways, glow, scroll, railScroller, tag, toggleWords). RailPanel binds it to the panel chrome store: v-panel-state writes its state classes at once, and its button's clicks reach PanelChrome. UiPanelToggle is the collapse button UiPanel and PanelCollapseButton share. UiPanel's collapsed drives the button and ui-panel--collapsed only; the owner hides the body by writing the root's collapsed class, since the rails measure a panel in the task that opens it. PanelCollapseButton takes startCollapsed instead of initial and initialTitle, so a button shows its state's glyph and words before startup presents the panel. Titles render through t() instead of data-i18n, and the unused "Expand panel" string is pruned. v-panel-state redraws the presented state after a re-render, in case a root's class binding ever changes.
42 lines
1.3 KiB
Vue
42 lines
1.3 KiB
Vue
<script setup>
|
|
import { storeToRefs } from 'pinia';
|
|
import { computed } from 'vue';
|
|
import UiPanel from '../kit/UiPanel.vue';
|
|
import { usePanelChromeStore } from '../stores/panelChrome.js';
|
|
import { vPanelState } from './panelState.js';
|
|
|
|
// A panel PanelChrome owns: a collapsible UiPanel whose state classes
|
|
// (vPanelState) and collapse button follow the panel chrome store, with the
|
|
// button's clicks forwarded to PanelChrome. Every other prop, attribute and
|
|
// slot passes through to UiPanel.
|
|
defineOptions({ inheritAttrs: false });
|
|
const props = defineProps({
|
|
id: { type: String, required: true },
|
|
/** Whether the markup starts collapsed, until PanelChrome presents it. */
|
|
startCollapsed: { type: Boolean, default: false },
|
|
});
|
|
|
|
const chrome = usePanelChromeStore();
|
|
const { panels } = storeToRefs(chrome);
|
|
const collapsedNow = computed(
|
|
() => panels.value[props.id]?.collapsed ?? props.startCollapsed,
|
|
);
|
|
</script>
|
|
|
|
<template>
|
|
<UiPanel
|
|
v-panel-state="props.id"
|
|
v-bind="$attrs"
|
|
:id="props.id"
|
|
:class="{ collapsed: props.startCollapsed }"
|
|
:data-panel-id="props.id"
|
|
collapsible
|
|
:collapsed="collapsedNow"
|
|
@update:collapsed="chrome.act('toggle', props.id)"
|
|
>
|
|
<template v-for="(_, name) in $slots" #[name]
|
|
><slot :name="name"
|
|
/></template>
|
|
</UiPanel>
|
|
</template>
|