Skip to content

Commit

Permalink
feat(VRadio): implement disabled state
Browse files Browse the repository at this point in the history
fix #13
  • Loading branch information
gravitano committed Sep 23, 2022
1 parent 534da1b commit e948e6c
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 1 deletion.
12 changes: 12 additions & 0 deletions packages/forms/src/radio/VRadio.stories.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,18 @@ Radio.parameters = {
},
};

export const Disabled = Template.bind({});
Disabled.args = {
disabled: true,
};
Disabled.parameters = {
docs: {
source: {
code: '<v-radio disabled />',
},
},
};

export const Validation: Story<{}> = () => ({
components: {VRadio, VBtn},
setup() {
Expand Down
13 changes: 12 additions & 1 deletion packages/forms/src/radio/VRadio.vue
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,14 @@ const props = defineProps({
type: Boolean,
default: false,
},
disabled: {
type: Boolean,
default: false,
},
disabledClass: {
type: String,
default: 'disabled:text-gray-200 disabled:cursor-not-allowed',
},
});
const {modelValue, rules, label, inputClass, color, name, id} = toRefs(props);
Expand Down Expand Up @@ -114,7 +122,10 @@ watch(
:name="name"
:value="value"
class="transition duration-300"
:class="[inputClass, colorClass]"
:class="[inputClass, colorClass, disabled && disabledClass]"
:aria-disabled="disabled"
:disabled="disabled"
v-bind="$attrs"
/>
<label v-if="label" :for="id || name" :class="labelClass">
{{ label }}
Expand Down

0 comments on commit e948e6c

Please sign in to comment.