Skip to content

Commit

Permalink
feat: update based on review
Browse files Browse the repository at this point in the history
  • Loading branch information
lukicenturi committed Jul 11, 2023
1 parent e5c8323 commit 7c7ccf1
Show file tree
Hide file tree
Showing 4 changed files with 51 additions and 32 deletions.
54 changes: 42 additions & 12 deletions example/src/views/HomeView.vue
Original file line number Diff line number Diff line change
Expand Up @@ -143,25 +143,55 @@ const buttons = ref([
{ clicks: 0, color: 'info', disabled: true, rounded: true },
{ clicks: 0, color: 'success', disabled: true, rounded: true },
{ clicks: 0, color: 'primary', fab: true },
{ clicks: 0, color: 'secondary', fab: true },
{ clicks: 0, color: 'error', fab: true },
{ clicks: 0, color: 'warning', fab: true },
{ clicks: 0, color: 'info', fab: true },
{ clicks: 0, color: 'success', fab: true },
{ clicks: 0, color: 'primary', variant: 'fab' },
{ clicks: 0, color: 'secondary', variant: 'fab' },
{ clicks: 0, color: 'error', variant: 'fab' },
{ clicks: 0, color: 'warning', variant: 'fab' },
{ clicks: 0, color: 'info', variant: 'fab' },
{ clicks: 0, color: 'success', variant: 'fab' },
{ clicks: 0, color: 'primary', fab: true, icon: true, iconName: 'add-fill' },
{
clicks: 0,
color: 'primary',
variant: 'fab',
icon: true,
iconName: 'add-fill',
},
{
clicks: 0,
color: 'secondary',
fab: true,
variant: 'fab',
icon: true,
iconName: 'add-fill',
},
{
clicks: 0,
color: 'error',
variant: 'fab',
icon: true,
iconName: 'add-fill',
},
{
clicks: 0,
color: 'warning',
variant: 'fab',
icon: true,
iconName: 'add-fill',
},
{
clicks: 0,
color: 'info',
variant: 'fab',
icon: true,
iconName: 'add-fill',
},
{
clicks: 0,
color: 'success',
variant: 'fab',
icon: true,
iconName: 'add-fill',
},
{ clicks: 0, color: 'error', fab: true, icon: true, iconName: 'add-fill' },
{ clicks: 0, color: 'warning', fab: true, icon: true, iconName: 'add-fill' },
{ clicks: 0, color: 'info', fab: true, icon: true, iconName: 'add-fill' },
{ clicks: 0, color: 'success', fab: true, icon: true, iconName: 'add-fill' },
{
clicks: 0,
Expand Down
13 changes: 3 additions & 10 deletions src/components/buttons/Button.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,13 +44,15 @@ describe('Button', () => {
expect(wrapper.find('button').classes()).toMatch(/_success_/);
});

it('passes outlined props', async () => {
it('passes variant props', async () => {
const wrapper = createWrapper();
expect(wrapper.find('button').classes()).not.toMatch(/_outlined_/);
await wrapper.setProps({ variant: 'outlined' });
expect(wrapper.find('button').classes()).toMatch(/_outlined_/);
await wrapper.setProps({ variant: 'text' });
expect(wrapper.find('button').classes()).toMatch(/_text_/);
await wrapper.setProps({ variant: 'fab' });
expect(wrapper.find('button').classes()).toMatch(/_fab_/);
});

it('passes rounded props', async () => {
Expand All @@ -62,15 +64,6 @@ describe('Button', () => {
expect(wrapper.find('button').classes()).not.toMatch(/_rounded_/);
});

it('passes fab props', async () => {
const wrapper = createWrapper();
expect(wrapper.find('button').classes()).not.toMatch(/_fab_/);
await wrapper.setProps({ fab: true });
expect(wrapper.find('button').classes()).toMatch(/_fab_/);
await wrapper.setProps({ fab: false });
expect(wrapper.find('button').classes()).not.toMatch(/_fab_/);
});

it('passes icon props', async () => {
const wrapper = createWrapper();
expect(wrapper.find('button').classes()).not.toMatch(/_icon_/);
Expand Down
7 changes: 3 additions & 4 deletions src/components/buttons/Button.stories.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,11 @@ const meta: Meta<typeof Button> = {
color: { control: 'select', options: contextColors },
variant: {
control: 'select',
options: ['default', 'outlined', 'text'],
options: ['default', 'outlined', 'text', 'fab'],
table: { category: 'Shape' },
},
rounded: { control: 'boolean', table: { category: 'Shape' } },
elevation: { control: 'number', table: { category: 'Shape' } },
fab: { control: 'boolean', table: { category: 'Shape' } },
icon: { control: 'boolean', table: { category: 'Shape' } },
sm: { control: 'boolean', table: { category: 'Size' } },
lg: { control: 'boolean', table: { category: 'Size' } },
Expand Down Expand Up @@ -180,9 +179,9 @@ export const ErrorOutlinedDisabled = {

export const FloatingActionButton = {
args: {
label: 'Error Button',
label: 'Floating Action Button',
color: 'primary',
fab: true,
variant: 'fab',
},
};

Expand Down
9 changes: 3 additions & 6 deletions src/components/buttons/Button.vue
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,7 @@ const props = withDefaults(
color?: ContextColorsType;
rounded?: boolean;
elevation?: number | string | null;
variant?: 'default' | 'outlined' | 'text';
fab?: boolean;
variant?: 'default' | 'outlined' | 'text' | 'fab';
icon?: boolean;
size?: 'sm' | 'lg';
sm?: boolean;
Expand All @@ -22,13 +21,12 @@ const props = withDefaults(
rounded: false,
elevation: null,
variant: 'default',
fab: false,
icon: false,
size: undefined,
}
);
const { disabled, elevation, fab } = toRefs(props);
const { disabled, elevation, variant } = toRefs(props);
const attrs = useAttrs();
const css = useCssModule();
Expand All @@ -43,7 +41,7 @@ const usedElevation: ComputedRef<number | string> = computed(() => {
return elevationProp;
}
if (get(fab)) {
if (get(variant) === 'fab') {
return 6;
}
Expand All @@ -63,7 +61,6 @@ const usedElevation: ComputedRef<number | string> = computed(() => {
[css.disabled]: disabled,
[css.loading]: loading,
[css._rounded]: rounded,
[css.fab]: fab,
[css.icon]: icon,
},
]"
Expand Down

0 comments on commit 7c7ccf1

Please sign in to comment.