Skip to content

AI-native design editor. Open-source Figma alternative.

feat: give selects and comboboxes the control size scale inputs and buttons use (#1492)

Danila Poyarkov73a65349466e
diff --git a/changes/1492/fixed.md b/changes/1492/fixed.md
new file mode 100644
index 000000000..8ab4e5940
--- /dev/null
+++ b/changes/1492/fixed.md
@@ -0,0 +1 @@
+- Selects in Settings and in the share, workspace members, and statuses dialogs are as tall as the fields and buttons beside them.
diff --git a/src/components/cloud/share/CloudShareDialog.vue b/src/components/cloud/share/CloudShareDialog.vue
index 79905f6c4..577d713fc 100644
--- a/src/components/cloud/share/CloudShareDialog.vue
+++ b/src/components/cloud/share/CloudShareDialog.vue
@@ -118,15 +118,10 @@ function submitInvite() {
v-model="invitePermission"
:label="t.shareNewPeoplePermission"
:options="permissionOptions"
- :ui="{ trigger: 'h-8 w-28' }"
+ size="sm"
+ :ui="{ trigger: 'w-28' }"
/>
- <AppButton
- type="submit"
- color="primary"
- variant="solid"
- :loading="inviting"
- :ui="{ base: 'h-8 px-3' }"
- >
+ <AppButton type="submit" color="primary" variant="solid" :loading="inviting">
{{ t.shareInvite }}
</AppButton>
</form>
diff --git a/src/components/cloud/workspace/CloudWorkspaceMembersDialog.vue b/src/components/cloud/workspace/CloudWorkspaceMembersDialog.vue
index 75385d6fb..0f03bf9fd 100644
--- a/src/components/cloud/workspace/CloudWorkspaceMembersDialog.vue
+++ b/src/components/cloud/workspace/CloudWorkspaceMembersDialog.vue
@@ -251,6 +251,7 @@ function invite() {
v-model="role"
:label="t.inviteRole"
:options="roleOptions"
+ size="sm"
:ui="{ trigger: ui.roleSelect(), item: ui.roleItem() }"
>
<template #option="{ option }">
diff --git a/src/components/home/search/HomeSearchActions.vue b/src/components/home/search/HomeSearchActions.vue
index 07fa8b78b..dbbd50d5d 100644
--- a/src/components/home/search/HomeSearchActions.vue
+++ b/src/components/home/search/HomeSearchActions.vue
@@ -52,6 +52,7 @@ watch(
name="file-search"
autocomplete="off"
class="md:flex-1"
+ size="md"
:density="isMobile ? 'comfortable' : 'compact'"
:placeholder="isMobile ? files.searchFiles : files.searchRecentAndStorageFiles"
:aria-label="files.searchFiles"
diff --git a/src/components/settings/models/ProfileEditor.vue b/src/components/settings/models/ProfileEditor.vue
index 44e406c40..f2df85d49 100644
--- a/src/components/settings/models/ProfileEditor.vue
+++ b/src/components/settings/models/ProfileEditor.vue
@@ -151,8 +151,9 @@ async function remove() {
<SettingsSection>
<template #title>{{ ai.modelConfiguration }}</template>
- <ProviderSettingsField :label="ai.provider">
+ <ProviderSettingsField v-slot="{ control }" :label="ai.provider">
<ProviderSelect
+ v-bind="control"
:model-value="draft.providerID"
:aria-label="ai.provider"
data-test-id="settings-model-provider"
@@ -205,9 +206,11 @@ async function remove() {
v-if="isCloud && cloudWorkspaceOptions.length"
:label="ai.cloudWorkspace"
:hint="ai.cloudWorkspaceHint"
+ v-slot="{ control }"
:error="fieldErrors.cloudWorkspace"
>
<AppSelect
+ v-bind="control"
:model-value="draft.cloudWorkspaceId ?? ''"
:label="ai.cloudWorkspace"
:options="cloudWorkspaceOptions"
@@ -277,9 +280,11 @@ async function remove() {
<ProviderSettingsField
v-if="draft.providerID === 'openai-compatible'"
+ v-slot="{ control }"
:label="ai.apiType"
>
<AppSelect
+ v-bind="control"
v-model="draft.customAPIType"
:label="ai.apiType"
:options="[
diff --git a/src/components/settings/provider/ProviderSettingsField.vue b/src/components/settings/provider/ProviderSettingsField.vue
index 0fb9c6433..1a4b7c8e5 100644
--- a/src/components/settings/provider/ProviderSettingsField.vue
+++ b/src/components/settings/provider/ProviderSettingsField.vue
@@ -23,7 +23,9 @@ const control = computed(() => ({
'aria-describedby':
compact([error && `${inputID.value}-error`, hint && `${inputID.value}-hint`]).join(' ') ||
undefined,
- state: error ? ('invalid' as const) : ('idle' as const)
+ state: error ? ('invalid' as const) : ('idle' as const),
+ // Inputs, selects, and comboboxes in a Settings form share one height.
+ size: 'sm' as const
}))
const emit = defineEmits<{ clear: []; blur: [] }>()
diff --git a/src/components/statuses/StatusesDialog.vue b/src/components/statuses/StatusesDialog.vue
index 8eb59b0e8..858f69d32 100644
--- a/src/components/statuses/StatusesDialog.vue
+++ b/src/components/statuses/StatusesDialog.vue
@@ -236,6 +236,7 @@ function discard() {
:model-value="preset ?? CUSTOM"
:options="presetOptions"
:label="messages.preset"
+ size="sm"
:ui="{ trigger: 'w-40' }"
class="mr-auto"
@update:model-value="choosePreset(String($event))"
diff --git a/src/components/ui/input/AppInput.vue b/src/components/ui/input/AppInput.vue
index bf5247b27..afc0a3fee 100644
--- a/src/components/ui/input/AppInput.vue
+++ b/src/components/ui/input/AppInput.vue
@@ -40,7 +40,7 @@ const {
max,
step,
tone = 'default',
- size = 'md',
+ size = 'sm',
state = 'idle'
} = defineProps<AppInputProps>()
diff --git a/src/components/ui/input/PresetNumberField.vue b/src/components/ui/input/PresetNumberField.vue
index d28a3885b..21a267b02 100644
--- a/src/components/ui/input/PresetNumberField.vue
+++ b/src/components/ui/input/PresetNumberField.vue
@@ -123,6 +123,7 @@ function commitDraft(): void {
ref="field"
v-model="draft"
type="number"
+ size="xs"
:min="min"
:max="max"
:step="1"
diff --git a/src/components/ui/select/AppCombobox.vue b/src/components/ui/select/AppCombobox.vue
index 952a50cff..1e5c391b7 100644
--- a/src/components/ui/select/AppCombobox.vue
+++ b/src/components/ui/select/AppCombobox.vue
@@ -21,6 +21,7 @@ import { useRetainedPopup } from '@open-pencil/vue/lifecycle/retention'
import { fuzzySearch } from '@open-pencil/vue/shared/search'
import type { ComponentUI } from '@/components/ui/types'
+import type { ControlSize } from '@/theme/control'
import theme from '@/theme/select/combobox'
import type { AppComboboxTheme } from '@/theme/select/combobox'
@@ -43,6 +44,8 @@ interface AppComboboxProps {
resultLimit?: number
/** How the open list lines up with the trigger; `end` for a trigger at the end of a field. */
align?: 'start' | 'center' | 'end'
+ /** The height on the control scale; the design panel's dense `xs` unless a form asks. */
+ size?: ControlSize
ui?: ComponentUI<AppComboboxTheme>
}
@@ -57,6 +60,7 @@ const {
disabled = false,
resultLimit = 100,
align = 'start',
+ size,
ui
} = defineProps<AppComboboxProps>()
@@ -110,10 +114,10 @@ function updateOpen(value: boolean): void {
<ComboboxTrigger
v-bind="$attrs"
:aria-label="label"
- :class="styles.trigger({ class: ui?.trigger })"
+ :class="styles.trigger({ size, class: ui?.trigger })"
>
<slot name="value" :option="selectedOption">
- <span :class="styles.value({ class: ui?.value })">
+ <span :class="styles.value({ size, class: ui?.value })">
{{ selectedOption?.label ?? (modelValue || placeholder) }}
</span>
</slot>
diff --git a/src/components/ui/select/AppSelect.stories.ts b/src/components/ui/select/AppSelect.stories.ts
index f4df3519e..15be5753a 100644
--- a/src/components/ui/select/AppSelect.stories.ts
+++ b/src/components/ui/select/AppSelect.stories.ts
@@ -2,7 +2,9 @@ import type { Meta, StoryObj } from '@storybook/vue3-vite'
import { computed, ref } from 'vue'
import AppButton from '@/components/ui/button/AppButton.vue'
+import AppInput from '@/components/ui/input/AppInput.vue'
+import AppCombobox from './AppCombobox.vue'
import AppSelect from './AppSelect.vue'
const meta = {
@@ -60,3 +62,34 @@ export const Grouped: Story = {
</div>`
})
}
+
+/** Each row is one step of the control scale: the input, select, combobox, and button line up. */
+export const ControlSizes: Story = {
+ render: () => ({
+ components: { AppSelect, AppButton, AppCombobox, AppInput },
+ setup() {
+ const sizes = ['xs', 'sm', 'md', 'lg'] as const
+ const text = ref('Name')
+ const value = ref('dark')
+ const model = ref('gpt')
+ const options = [
+ { value: 'dark', label: 'Dark' },
+ { value: 'light', label: 'Light' }
+ ]
+ const models = [
+ { value: 'gpt', label: 'GPT' },
+ { value: 'claude', label: 'Claude' }
+ ]
+ return { sizes, text, value, model, options, models }
+ },
+ template: `
+ <div class="flex w-[36rem] flex-col gap-3">
+ <div v-for="size in sizes" :key="size" class="flex items-center gap-2" :data-size="size">
+ <AppInput v-model="text" :size="size" aria-label="Name" class="flex-1" />
+ <AppSelect v-model="value" :size="size" :options="options" label="Theme" :ui="{ trigger: 'w-28' }" />
+ <AppCombobox v-model="model" :size="size" :options="models" label="Model" :ui="{ trigger: 'w-28' }" />
+ <AppButton :size="size" variant="outline">Save</AppButton>
+ </div>
+ </div>`
+ })
+}
diff --git a/src/components/ui/select/AppSelect.vue b/src/components/ui/select/AppSelect.vue
index 4f1cedbf4..474a787f5 100644
--- a/src/components/ui/select/AppSelect.vue
+++ b/src/components/ui/select/AppSelect.vue
@@ -20,6 +20,7 @@ import type {
SelectPlacement
} from '@/components/ui/select/select'
import type { ComponentUI } from '@/components/ui/types'
+import type { ControlSize } from '@/theme/control'
import theme from '@/theme/select/app'
import type { AppSelectTheme } from '@/theme/select/app'
@@ -37,12 +38,14 @@ interface AppSelectProps<TValue extends string | number> {
* `trigger` slot or a value outside the options: there is no row to line up with the trigger.
*/
placement?: SelectPlacement
+ /** The height on the control scale; the design panel's dense `xs` unless a form asks. */
+ size?: ControlSize
ui?: ComponentUI<AppSelectTheme>
}
defineOptions({ inheritAttrs: false })
-const { options, groups, label, placeholder, displayLabel, placement, ui } =
+const { options, groups, label, placeholder, displayLabel, placement, size, ui } =
defineProps<AppSelectProps<T>>()
const modelValue = defineModel<T>({ required: true })
const slots = useSlots()
@@ -88,7 +91,7 @@ const itemUI = computed(() => ({ item: ui?.item, indicator: ui?.indicator }))
v-else
:aria-label="label"
v-bind="$attrs"
- :class="styles.trigger({ class: ui?.trigger })"
+ :class="styles.trigger({ size, class: ui?.trigger })"
>
<!-- An icon before the chosen option, such as the glyph its menu row shows. -->
<slot name="leading" />
diff --git a/src/theme/select/app.ts b/src/theme/select/app.ts
index 45429e34c..2e751de8a 100644
--- a/src/theme/select/app.ts
+++ b/src/theme/select/app.ts
@@ -3,10 +3,19 @@ import selectTheme from './select'
const appSelectTheme = {
slots: {
...selectTheme.slots,
- trigger: [selectTheme.slots.trigger, 'w-full min-w-0 px-1.5']
+ trigger: [selectTheme.slots.trigger, 'w-full min-w-0']
},
- variants: selectTheme.variants,
- defaultVariants: selectTheme.defaultVariants
+ variants: {
+ ...selectTheme.variants,
+ /** The control scale in `theme/control.ts`, with the padding and text of an input that size. */
+ size: {
+ xs: { trigger: 'h-6 px-1.5 text-[11px]' },
+ sm: { trigger: 'h-7 px-2.5 text-xs' },
+ md: { trigger: 'h-8 px-3 text-xs' },
+ lg: { trigger: 'h-9 px-3 text-sm' }
+ }
+ },
+ defaultVariants: { ...selectTheme.defaultVariants, size: 'xs' as const }
}
export type AppSelectTheme = typeof appSelectTheme
diff --git a/src/theme/select/combobox.ts b/src/theme/select/combobox.ts
index 75785e702..9ee96663a 100644
--- a/src/theme/select/combobox.ts
+++ b/src/theme/select/combobox.ts
@@ -6,9 +6,9 @@ const appComboboxTheme = {
slots: {
trigger: [
panelFieldBase,
- 'flex w-full min-w-0 items-center justify-between px-2 aria-invalid:border-error aria-invalid:focus:ring-error/25'
+ 'flex w-full min-w-0 items-center justify-between aria-invalid:border-error aria-invalid:focus:ring-error/25'
],
- value: 'min-w-0 flex-1 truncate text-left text-[11px] text-surface',
+ value: 'min-w-0 flex-1 truncate text-left text-surface',
chevron: 'ml-1 size-3 shrink-0 text-muted',
content: [
'z-[110] max-h-72 min-w-[var(--reka-combobox-trigger-width)] overflow-hidden text-[11px]',
@@ -26,7 +26,17 @@ const appComboboxTheme = {
indicator: 'absolute left-1.5 inline-flex items-center justify-center',
description: 'truncate font-mono text-[9px] text-muted',
meta: 'shrink-0 rounded bg-accent/10 px-1 py-px text-[9px] text-primary'
- }
+ },
+ variants: {
+ /** The control scale in `theme/control.ts`, with the padding and text of an input that size. */
+ size: {
+ xs: { trigger: 'h-6 px-2', value: 'text-[11px]' },
+ sm: { trigger: 'h-7 px-2.5', value: 'text-xs' },
+ md: { trigger: 'h-8 px-3', value: 'text-xs' },
+ lg: { trigger: 'h-9 px-3', value: 'text-sm' }
+ }
+ },
+ defaultVariants: { size: 'xs' as const }
}
export type AppComboboxTheme = typeof appComboboxTheme