From 5b8ca3c38eaa3545e805f910ca1c2b2946d07a86 Mon Sep 17 00:00:00 2001 From: upsiflu Date: Tue, 25 Mar 2025 11:05:37 +0100 Subject: [PATCH] fix(front): small things --- front/src/composables/width.ts | 8 ++------ front/src/ui/composables/useTags.ts | 15 +++++++++++++++ 2 files changed, 17 insertions(+), 6 deletions(-) create mode 100644 front/src/ui/composables/useTags.ts diff --git a/front/src/composables/width.ts b/front/src/composables/width.ts index 5d4285d0d..52068960f 100644 --- a/front/src/composables/width.ts +++ b/front/src/composables/width.ts @@ -42,16 +42,12 @@ const styles = { ...widths, ...sizes } as const satisfies Record string)> -const getStyle = (props: Partial) => (key: Key): string => - // @ts-expect-error Typescript is hard +const getStyle = (props: Partial) => (key: Key) => typeof styles[key] === 'function' && key in props - // @ts-expect-error Typescript is hard ? styles[key]( - // TODO: Make the typescript compiler understand `key in props` - // @ts-expect-error Typescript is hard + // @ts-expect-error Typescript is hard. Make the typescript compiler understand `key in props` props[key] ) - : styles[key] // All keys are exclusive diff --git a/front/src/ui/composables/useTags.ts b/front/src/ui/composables/useTags.ts new file mode 100644 index 000000000..1f90fb68b --- /dev/null +++ b/front/src/ui/composables/useTags.ts @@ -0,0 +1,15 @@ +import { computed, ref } from 'vue' +import { useStore } from '~/store' + +/** + * Load and cache all tags + * + * @param current + */ +export const useTags = (current = ref([])) => { + const store = useStore() + + const tags = computed(() => store.state.ui.tags) +} + +// alternative ways to generate tags