From 3fa7ccf0c1b2f9d4826ac7a6b38c47e0930b84f3 Mon Sep 17 00:00:00 2001 From: thepaperpilot Date: Sun, 27 Mar 2022 13:47:36 -0500 Subject: [PATCH] Added collapsibles --- src/components/layout/Collapsible.vue | 51 +++++++++++++++++++++++++++ src/util/vue.tsx | 18 +++++++++- 2 files changed, 68 insertions(+), 1 deletion(-) create mode 100644 src/components/layout/Collapsible.vue diff --git a/src/components/layout/Collapsible.vue b/src/components/layout/Collapsible.vue new file mode 100644 index 0000000..a9554cc --- /dev/null +++ b/src/components/layout/Collapsible.vue @@ -0,0 +1,51 @@ + + + + + diff --git a/src/util/vue.tsx b/src/util/vue.tsx index f11e63f..7606e55 100644 --- a/src/util/vue.tsx +++ b/src/util/vue.tsx @@ -5,7 +5,8 @@ import { Component as ComponentKey, GatherProps, GenericComponent, - JSXFunction + JSXFunction, + Visibility } from "features/feature"; import { Component, @@ -121,6 +122,21 @@ export function setupHoldToClick( return { start, stop, handleHolding }; } +export function getFirstFeature }>( + features: T[], + filter: (feature: T) => boolean +): { firstFeature: Ref; hiddenFeatures: Ref } { + const filteredFeatures = computed(() => + features.filter( + feature => unref(feature.visibility) === Visibility.Visible && filter(feature) + ) + ); + return { + firstFeature: computed(() => filteredFeatures.value[0]), + hiddenFeatures: computed(() => filteredFeatures.value.slice(1)) + }; +} + export function computeComponent( component: Ref>, defaultWrapper = "div"