Skip to content

Beautiful Open-Source Form Builder

Flat select input UI (#906)

Chirag Chhatrala6f74b1d8d095
diff --git a/client/components/forms/core/FlatSelectInput.vue b/client/components/forms/core/FlatSelectInput.vue
index c7fcbcd03..36007f19e 100644
--- a/client/components/forms/core/FlatSelectInput.vue
+++ b/client/components/forms/core/FlatSelectInput.vue
@@ -11,7 +11,6 @@
/>
<div
v-else
- class="relative overflow-hidden"
:class="ui.container()"
:role="multiple ? 'group' : 'radiogroup'"
:aria-label="label || `Select ${multiple ? 'options' : 'option'}`"
@@ -24,13 +23,7 @@
:key="option[optionKey]"
:role="multiple?'checkbox':'radio'"
:aria-checked="isSelected(option[optionKey])"
- :class="[
- 'relative',
- ui.option(),
- ui.hover(),
- { '!cursor-not-allowed !bg-neutral-200 dark:!bg-neutral-800': disableOptions.includes(option[optionKey]) }
- ]"
- class="focus-visible:ring-2 focus-visible:ring-form/100 focus-visible:outline-none"
+ :class="ui.option({ optionDisabled: disabled || disableOptions.includes(option[optionKey]) || isOptionDisabled(option[optionKey]) })"
:tabindex="getOptionTabIndex(index)"
@click="onSelect(option[optionKey])"
@keydown="handleKeydown($event, index)"
diff --git a/client/components/forms/heavy/components/QuillyEditor.vue b/client/components/forms/heavy/components/QuillyEditor.vue
index 4dbf82462..bb3a77396 100644
--- a/client/components/forms/heavy/components/QuillyEditor.vue
+++ b/client/components/forms/heavy/components/QuillyEditor.vue
@@ -99,6 +99,11 @@ const initializeQuill = () => {
model.value = quillInstance.getSemanticHTML()
}
+ // Apply initial disabled state
+ if (props.disabled) {
+ quillInstance.disable()
+ }
+
emit('ready', quillInstance)
}
}
@@ -133,6 +138,7 @@ watch(model, (newValue, oldValue) => {
})
watch(() => props.disabled, (newValue) => {
+ if (!quillInstance) return
if (newValue) {
quillInstance.disable()
} else {
diff --git a/client/lib/forms/themes/flat-select-input.theme.js b/client/lib/forms/themes/flat-select-input.theme.js
index a7e301cf9..d04ab2c84 100644
--- a/client/lib/forms/themes/flat-select-input.theme.js
+++ b/client/lib/forms/themes/flat-select-input.theme.js
@@ -4,68 +4,75 @@
export const flatSelectInputTheme = {
slots: {
container: [
+ 'relative overflow-hidden',
'border bg-white dark:bg-notion-dark-light',
'text-neutral-700 dark:text-neutral-300',
'focus-within:outline-hidden'
],
// Keep base minimal; theme variants add interaction + spacing
option: [
+ 'relative',
+ 'focus-visible:ring-2 focus-visible:ring-form/100 focus-visible:outline-none',
'flex items-center',
- 'border-t first:border-t-0 px-2'
+ 'border-t first:border-t-0 px-2',
+ 'transition-colors duration-150'
],
- hover: '',
help: 'text-neutral-500'
},
variants: {
theme: {
default: {
container: [
+ 'relative overflow-hidden',
'border-neutral-300 dark:border-neutral-600',
'shadow-xs'
],
option: [
- 'cursor-pointer',
+ 'relative',
+ 'focus-visible:ring-2 focus-visible:ring-form/100 focus-visible:outline-none',
'border-neutral-300 dark:border-neutral-600',
'gap-x-2'
- ],
- hover: 'hover:bg-neutral-50 dark:hover:bg-neutral-900'
+ ]
},
simple: {
container: [
+ 'relative overflow-hidden',
'border-neutral-300 dark:border-neutral-600'
],
option: [
- 'cursor-pointer',
+ 'relative',
+ 'focus-visible:ring-2 focus-visible:ring-form/100 focus-visible:outline-none',
'border-neutral-300 dark:border-neutral-600',
'gap-x-2'
- ],
- hover: 'hover:bg-neutral-50 dark:hover:bg-neutral-900'
+ ]
},
notion: {
container: [
+ 'relative overflow-hidden',
'border-notion-input-border dark:border-notion-input-borderDark',
'bg-notion-input-background dark:bg-notion-dark-light',
'text-neutral-900 dark:text-neutral-100'
],
option: [
- 'cursor-pointer',
+ 'relative',
+ 'focus-visible:ring-2 focus-visible:ring-form/100 focus-visible:outline-none',
'border-notion-input-border dark:border-notion-input-borderDark',
'space-x-2'
- ],
- hover: 'hover:backdrop-brightness-95'
+ ]
},
minimal: {
container: [
+ 'relative overflow-hidden',
'border-2 border-transparent',
'bg-neutral-100 dark:bg-notion-dark-light',
'text-neutral-700 dark:text-neutral-300'
],
option: [
- 'cursor-pointer',
+ 'relative',
+ 'focus-visible:ring-2 focus-visible:ring-form/100 focus-visible:outline-none',
'border-neutral-200 dark:border-neutral-700',
'gap-x-2'
- ],
- hover: 'hover:bg-neutral-200/50 dark:hover:bg-neutral-900'
+ ]
}
},
size: {
@@ -82,15 +89,86 @@ export const flatSelectInputTheme = {
hasError: {
true: { container: '!ring-red-500 !ring-2 !border-transparent' }
},
- disabled: {
- true: { container: '!cursor-not-allowed !bg-neutral-200 dark:!bg-neutral-800' }
+ optionDisabled: {
+ true: {
+ option: '!cursor-not-allowed opacity-50'
+ },
+ false: {
+ option: 'cursor-pointer'
+ }
}
},
+ compoundVariants: [
+ // Default theme - enabled state (hover effects)
+ {
+ theme: 'default',
+ optionDisabled: false,
+ class: {
+ option: 'hover:bg-neutral-50 dark:hover:bg-neutral-900'
+ }
+ },
+ // Default theme - disabled state (grayout)
+ {
+ theme: 'default',
+ optionDisabled: true,
+ class: {
+ option: '!bg-neutral-100 dark:!bg-neutral-800 !text-neutral-400 dark:!text-neutral-600'
+ }
+ },
+ // Simple theme - enabled state
+ {
+ theme: 'simple',
+ optionDisabled: false,
+ class: {
+ option: 'hover:bg-neutral-50 dark:hover:bg-neutral-900'
+ }
+ },
+ // Simple theme - disabled state
+ {
+ theme: 'simple',
+ optionDisabled: true,
+ class: {
+ option: '!bg-neutral-100 dark:!bg-neutral-800 !text-neutral-400 dark:!text-neutral-600'
+ }
+ },
+ // Notion theme - enabled state
+ {
+ theme: 'notion',
+ optionDisabled: false,
+ class: {
+ option: 'hover:backdrop-brightness-95'
+ }
+ },
+ // Notion theme - disabled state
+ {
+ theme: 'notion',
+ optionDisabled: true,
+ class: {
+ option: '!bg-neutral-100 dark:!bg-neutral-800 !text-neutral-400 dark:!text-neutral-600'
+ }
+ },
+ // Minimal theme - enabled state
+ {
+ theme: 'minimal',
+ optionDisabled: false,
+ class: {
+ option: 'hover:bg-neutral-200/50 dark:hover:bg-neutral-900'
+ }
+ },
+ // Minimal theme - disabled state
+ {
+ theme: 'minimal',
+ optionDisabled: true,
+ class: {
+ option: '!bg-neutral-200 dark:!bg-neutral-800 !text-neutral-400 dark:!text-neutral-600'
+ }
+ }
+ ],
defaultVariants: {
theme: 'default',
size: 'md',
borderRadius: 'small',
hasError: false,
- disabled: false
+ optionDisabled: false
}
}