Skip to content

Commit

Permalink
Add required (#7)
Browse files Browse the repository at this point in the history
  • Loading branch information
NonSpicyBurrito authored Oct 22, 2024
1 parent aca32b4 commit 4d1cc73
Show file tree
Hide file tree
Showing 6 changed files with 11 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/App.vue
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,7 @@ const onClose = () => {
:min="0"
:max="100"
:step="1"
required
/>

<VFileField v-model="cover" label="Cover" accept="image/*" />
Expand Down
2 changes: 2 additions & 0 deletions src/components/fields/VFileField.vue
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import VField from './VField.vue'
defineProps<{
label: string
accept?: string
required?: boolean
}>()
const modelValue = defineModel<File | undefined>({ required: true })
Expand All @@ -20,6 +21,7 @@ const onChange = (e: Event) => {
:class="modelValue ? 'text-text-normal' : 'italic text-text-disabled'"
type="file"
:accept
:required
@change="onChange"
/>
</VField>
Expand Down
2 changes: 2 additions & 0 deletions src/components/fields/VNumberField.vue
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ defineProps<{
min?: number
max?: number
step?: number
required?: boolean
}>()
const modelValue = defineModel<number>({ required: true })
Expand All @@ -22,6 +23,7 @@ const modelValue = defineModel<number>({ required: true })
:min
:max
:step
:required
/>
</VField>
</template>
2 changes: 2 additions & 0 deletions src/components/fields/VSelectField.vue
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import VField from './VField.vue'
defineProps<{
label: string
options: Record<string, T>
required?: boolean
}>()
const modelValue = defineModel<T>({ required: true })
Expand All @@ -14,6 +15,7 @@ const modelValue = defineModel<T>({ required: true })
<select
v-model="modelValue"
class="w-full appearance-none bg-button-normal px-2 py-1 transition-colors hover:bg-button-highlighted focus:outline-none focus:ring-1 focus:ring-text-normal active:bg-button-pressed"
:required
>
<option v-for="(value, key) in options" :key :value class="bg-surface">
{{ key }}
Expand Down
2 changes: 2 additions & 0 deletions src/components/fields/VTextAreaField.vue
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ defineProps<{
label: string
placeholder: string
maxlength?: number
required?: boolean
}>()
const modelValue = defineModel<string>({ required: true })
Expand All @@ -18,6 +19,7 @@ const modelValue = defineModel<string>({ required: true })
type="text"
:placeholder
:maxlength
:required
/>
</VField>
</template>
2 changes: 2 additions & 0 deletions src/components/fields/VTextField.vue
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ defineProps<{
label: string
placeholder: string
maxlength?: number
required?: boolean
}>()
const modelValue = defineModel<string>({ required: true })
Expand All @@ -18,6 +19,7 @@ const modelValue = defineModel<string>({ required: true })
type="text"
:placeholder
:maxlength
:required
/>
</VField>
</template>

0 comments on commit 4d1cc73

Please sign in to comment.