AI-native design editor. Open-source Figma alternative.
Replace native <select> with reka-ui AppSelect component
Danila Poyarkov25233294a1eb
diff --git a/components.d.ts b/components.d.tsindex ed334ae4b..6636f3f4a 100644--- a/components.d.ts+++ b/components.d.ts@@ -14,6 +14,7 @@ declare module 'vue' {APIKeySetup: typeof import('./src/components/chat/APIKeySetup.vue')['default']AppearanceSection: typeof import('./src/components/properties/AppearanceSection.vue')['default']AppMenu: typeof import('./src/components/AppMenu.vue')['default']+ AppSelect: typeof import('./src/components/AppSelect.vue')['default']AppToast: typeof import('./src/components/AppToast.vue')['default']CanvasContextMenu: typeof import('./src/components/CanvasContextMenu.vue')['default']ChatInput: typeof import('./src/components/chat/ChatInput.vue')['default']diff --git a/src/components/AppSelect.vue b/src/components/AppSelect.vuenew file mode 100644index 000000000..06418a6de--- /dev/null+++ b/src/components/AppSelect.vue@@ -0,0 +1,52 @@+<script setup lang="ts" generic="T extends string | number">+import {+ SelectContent,+ SelectItem,+ SelectItemIndicator,+ SelectItemText,+ SelectPortal,+ SelectRoot,+ SelectTrigger,+ SelectValue,+ SelectViewport+} from 'reka-ui'++defineProps<{+ options: { value: T; label: string }[]+ placeholder?: string+}>()++const modelValue = defineModel<T>({ required: true })+</script>++<template>+ <SelectRoot v-model="modelValue">+ <SelectTrigger+ class="flex min-w-0 flex-1 cursor-pointer items-center justify-between rounded border border-border bg-input px-1.5 py-1 text-xs text-surface outline-none hover:bg-hover"+ >+ <SelectValue :placeholder="placeholder" />+ <icon-lucide-chevron-down class="ml-1 size-3 shrink-0 text-muted" />+ </SelectTrigger>+ <SelectPortal>+ <SelectContent+ position="popper"+ :side-offset="2"+ class="z-50 max-h-56 min-w-[var(--reka-select-trigger-width)] overflow-hidden rounded-md border border-border bg-panel shadow-lg"+ >+ <SelectViewport class="p-0.5">+ <SelectItem+ v-for="opt in options"+ :key="String(opt.value)"+ :value="opt.value"+ class="relative flex cursor-pointer items-center rounded py-1.5 pl-6 pr-2 text-xs text-surface outline-none data-[highlighted]:bg-hover"+ >+ <SelectItemIndicator class="absolute left-1.5 inline-flex items-center justify-center">+ <icon-lucide-check class="size-3 text-accent" />+ </SelectItemIndicator>+ <SelectItemText>{{ opt.label }}</SelectItemText>+ </SelectItem>+ </SelectViewport>+ </SelectContent>+ </SelectPortal>+ </SelectRoot>+</template>diff --git a/src/components/FontPicker.vue b/src/components/FontPicker.vueindex 173bd04f3..bdedc679f 100644--- a/src/components/FontPicker.vue+++ b/src/components/FontPicker.vue@@ -94,7 +94,15 @@ function onSelect(val: string) {<span class="truncate">{{ option }}</span></ListboxItem></ListboxVirtualizer>- <div v-if="filtered.length === 0" class="px-2 py-3 text-center text-xs text-muted">+ <div v-if="families.length === 0" class="flex h-full items-center justify-center px-3 text-center text-xs text-muted">+ <div>+ <p>No local fonts available.</p>+ <p class="mt-1">+ Use the desktop app or Chrome/Edge to access system fonts.+ </p>+ </div>+ </div>+ <div v-else-if="filtered.length === 0" class="px-2 py-3 text-center text-xs text-muted">No fonts found</div></ListboxContent>diff --git a/src/components/properties/EffectsSection.vue b/src/components/properties/EffectsSection.vueindex 23f0d4901..c3257a6da 100644--- a/src/components/properties/EffectsSection.vue+++ b/src/components/properties/EffectsSection.vue@@ -1,5 +1,6 @@<script setup lang="ts">-import { ref } from 'vue'+import { computed, ref } from 'vue'+import AppSelect from '@/components/AppSelect.vue'import ColorInput from '@/components/ColorInput.vue'import ScrubInput from '@/components/ScrubInput.vue'import { useNodeProps } from '@/composables/use-node-props'@@ -21,6 +22,7 @@ const EFFECT_LABELS: Record<string, string> = {}const EFFECT_TYPES = Object.keys(EFFECT_LABELS) as EffectType[]+const EFFECT_OPTIONS = EFFECT_TYPES.map((t) => ({ value: t, label: EFFECT_LABELS[t] }))function isShadow(type: string) {return type === 'DROP_SHADOW' || type === 'INNER_SHADOW'@@ -131,15 +133,11 @@ function toggleExpand(index: number) {<icon-lucide-blend class="size-3 text-muted" /></button>- <select- class="min-w-0 flex-1 cursor-pointer appearance-none border-none bg-transparent text-xs text-surface outline-none"- :value="effect.type"- @change="updateType(i, ($event.target as HTMLSelectElement).value as EffectType)"- >- <option v-for="t in EFFECT_TYPES" :key="t" :value="t" class="bg-panel text-surface">- {{ EFFECT_LABELS[t] }}- </option>- </select>+ <AppSelect+ :model-value="effect.type"+ :options="EFFECT_OPTIONS"+ @update:model-value="updateType(i, $event as EffectType)"+ /><buttonclass="cursor-pointer border-none bg-transparent p-0 text-muted opacity-0 transition-opacity group-hover:opacity-100 hover:text-surface"diff --git a/src/components/properties/ExportSection.vue b/src/components/properties/ExportSection.vueindex 0ecea3654..ab2711291 100644--- a/src/components/properties/ExportSection.vue+++ b/src/components/properties/ExportSection.vue@@ -1,6 +1,7 @@<script setup lang="ts">import { ref, computed, watch, onUnmounted } from 'vue'+import AppSelect from '@/components/AppSelect.vue'import { useEditorStore } from '@/stores/editor'import type { ExportFormat } from '@/engine/render-image'@@ -18,7 +19,9 @@ const showPreview = ref(false)const exporting = ref(false)const SCALES = [0.5, 0.75, 1, 1.5, 2, 3, 4] as const+const SCALE_OPTIONS = SCALES.map((s) => ({ value: s, label: s % 1 === 0 ? `${s}x` : `${s}x` }))const FORMATS: ExportFormat[] = ['PNG', 'JPG', 'WEBP']+const FORMAT_OPTIONS = FORMATS.map((f) => ({ value: f, label: f }))const nodeName = computed(() => {void store.state.sceneVersion@@ -90,9 +93,7 @@ onUnmounted(() => {if (previewUrl.value) URL.revokeObjectURL(previewUrl.value)})-function formatScale(scale: number): string {- return scale % 1 === 0 ? `${scale}x` : `${scale}x`-}+</script><template>@@ -108,25 +109,16 @@ function formatScale(scale: number): string {</div><div v-for="(setting, i) in settings" :key="i" class="flex items-center gap-1.5 py-0.5">- <select- class="min-w-0 flex-1 cursor-pointer appearance-none rounded border border-border bg-input px-1.5 py-1 text-xs text-surface outline-none"- :value="setting.scale"- @change="setting.scale = Number(($event.target as HTMLSelectElement).value)"- >- <option v-for="s in SCALES" :key="s" :value="s" class="bg-panel text-surface">- {{ formatScale(s) }}- </option>- </select>-- <select- class="min-w-0 flex-1 cursor-pointer appearance-none rounded border border-border bg-input px-1.5 py-1 text-xs text-surface outline-none"- :value="setting.format"- @change="setting.format = ($event.target as HTMLSelectElement).value as ExportFormat"- >- <option v-for="f in FORMATS" :key="f" :value="f" class="bg-panel text-surface">- {{ f }}- </option>- </select>+ <AppSelect+ :model-value="setting.scale"+ :options="SCALE_OPTIONS"+ @update:model-value="setting.scale = Number($event)"+ />+ <AppSelect+ :model-value="setting.format"+ :options="FORMAT_OPTIONS"+ @update:model-value="setting.format = $event as ExportFormat"+ /><buttonclass="flex size-5 shrink-0 cursor-pointer items-center justify-center rounded border-none bg-transparent text-sm leading-none text-muted hover:bg-hover hover:text-surface"diff --git a/src/components/properties/TypographySection.vue b/src/components/properties/TypographySection.vueindex 25f3fb091..5971bdb45 100644--- a/src/components/properties/TypographySection.vue+++ b/src/components/properties/TypographySection.vue@@ -1,6 +1,7 @@<script setup lang="ts">import { computed, onMounted } from 'vue'+import AppSelect from '@/components/AppSelect.vue'import FontPicker from '@/components/FontPicker.vue'import ScrubInput from '@/components/ScrubInput.vue'import { useNodeFontStatus } from '@/composables/use-font-status'@@ -86,13 +87,11 @@ onMounted(async () => {<!-- Weight + Size --><div class="mb-1.5 flex gap-1.5">- <select- class="min-w-0 flex-1 cursor-pointer rounded border border-border bg-input px-1.5 py-1 text-xs text-surface"- :value="node.fontWeight"- @change="selectWeight(+($event.target as HTMLSelectElement).value)"- >- <option v-for="w in WEIGHTS" :key="w.value" :value="w.value">{{ w.label }}</option>- </select>+ <AppSelect+ :model-value="node.fontWeight"+ :options="WEIGHTS"+ @update:model-value="selectWeight(+$event)"+ /><ScrubInputclass="flex-1":model-value="node.fontSize"