Skip to content

Commit

Permalink
Implement disabled text input styles
Browse files Browse the repository at this point in the history
  • Loading branch information
NoelDeMartin committed Aug 15, 2024
1 parent 0bac9a2 commit cc33442
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 0 deletions.
13 changes: 13 additions & 0 deletions src/components/forms/TextInput.story.vue
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,17 @@
/>
</AGForm>
</Variant>

<Variant title="Disabled">
<AGForm :form="disabledForm">
<TextInput
name="food"
label="What's the best food?"
placeholder="Ramen"
disabled
/>
</AGForm>
</Variant>
</Story>
</template>

Expand All @@ -43,11 +54,13 @@ import { ref, watchEffect } from 'vue';
const form = useForm({ food: requiredStringInput() });
const errorForm = useForm({ food: requiredStringInput() });
const disabledForm = useForm({ food: requiredStringInput() });
const label = ref('What\'s the best food?');
const placeholder = ref('Ramen');
const hasErrors = ref(false);
errorForm.submit();
disabledForm.food = 'Ramen';
watchEffect(() => (hasErrors.value ? form.submit() : form.reset()));
</script>
Expand Down
1 change: 1 addition & 0 deletions src/components/forms/TextInput.vue
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ const renderedInputClass = computed(() =>
? 'ring-red-300 placeholder:text-red-300 focus:ring-red-500'
: 'ring-gray-300 placeholder:text-gray-400 focus:ring-[--primary-600]',
'w-full rounded-lg border-0 text-base text-gray-900 shadow-sm ring-1 ring-inset',
'disabled:cursor-not-allowed disabled:bg-gray-50 disabled:text-gray-500 disabled:ring-gray-200',
'focus:ring-2 focus:ring-inset',
].join(' '),
props.inputClass,
Expand Down

0 comments on commit cc33442

Please sign in to comment.