Skip to content

Commit

Permalink
feat: add disabled state to icon
Browse files Browse the repository at this point in the history
  • Loading branch information
Mike Lebeau committed Jan 16, 2024
1 parent adbf7e9 commit 8a6fee8
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 1 deletion.
5 changes: 5 additions & 0 deletions packages/components/icon/src/icon.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,11 @@ export const iconProps = buildProps({
default: '#00000',
required: false,
},
isDisabled: {
type: Boolean,
default: false,
required: false,
},
} as const)

export type IconProps = ExtractPropTypes<typeof iconProps>
Expand Down
2 changes: 1 addition & 1 deletion packages/components/icon/src/icon.vue
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ const fontSize = computed(() => {
const style = computed(() => {
return {
fontSize: fontSize.value,
color: props.color,
color: props.isDisabled ? '#BBBBBB' : props.color,
}
})
</script>
10 changes: 10 additions & 0 deletions packages/components/icon/test/icon.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,16 @@ describe('Icon tests', () => {
expect(findIcon().text()).toBe('check')
})

it('should set the icon disabled', async () => {
factory({
icon: 'check',
color: 'red',
isDisabled: true,
})

expect(findIcon().element.style.color).toBe('rgb(187, 187, 187)')
})

it('should set the color', async () => {
factory({
icon: 'check',
Expand Down

0 comments on commit 8a6fee8

Please sign in to comment.