Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

icon button component #24

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 6 additions & 4 deletions src/stories/Button.stories.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,14 @@ const meta = {
size: { control: 'select', options: ['small', 'medium', 'large'] },
variant: { options: ['contained', 'outlined', 'subtle'] },
type: { options: ['primary', 'destructive'] },
shape: { options: ['rounded','squared'] },
label: {
options: ['Sans icone', 'Icone droite', 'Icone gauche'],
options: ['Sans icône', 'Icône droite', 'Icône gauche', 'Icône seule'],
mapping: {
'Sans icone': { text: 'Button' },
'Icone droite': { text: 'Button', icon: { name: 'fa fa-smile', position: 'right' } },
'Icone gauche': { text: 'Button', icon: { name: 'fa fa-smile', position: 'left' } },
'Sans icône': { text: 'Button' },
'Icône droite': { text: 'Button', icon: { name: 'fa fa-smile', position: 'right' } },
'Icône gauche': { text: 'Button', icon: { name: 'fa fa-smile', position: 'left' } },
'Icône seule': { icon: { name: 'fa fa-smile', position: 'left' } },
},
}
},
Expand Down
14 changes: 11 additions & 3 deletions src/stories/Button.vue
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ type ButtonProps = {
* The label of the button
*/
label: {
text: string,
text?: string,
icon?: Icon
},
/**
Expand All @@ -40,6 +40,11 @@ type ButtonProps = {
*/
size?: 'small' | 'medium' | 'large',

/**
* shape of the button
*/
shape?: 'rounded' | 'squared',

/**
* Button disabled state
*/
Expand All @@ -50,6 +55,7 @@ const props = withDefaults(defineProps<ButtonProps>(), {
type:'primary',
variant:'contained',
size:'medium',
shape: 'rounded'
});

const emit = defineEmits<{
Expand All @@ -58,8 +64,10 @@ const emit = defineEmits<{

const classes = computed(() => ({
'storybook-button': true,
[`storybook-button--${props.type || 'primary'}-${props.variant || 'contained'}`]: true,
[`storybook-button--${props.size || 'medium'}`]: true,
[`storybook-button--${props.type}-${props.variant}`]: true,
[`storybook-button--${props.size}`]: true,
[`storybook-button--${props.shape}`]: true,
[`storybook-button--icon-button`]: (props.label.icon && !props.label.text) ,
[`storybook-button-icon--${props.label.icon?.position}`]: props.label.icon,

}));
Expand Down
24 changes: 23 additions & 1 deletion src/stories/button.css
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ button {
cursor: pointer;
transition:box-shadow 200ms ease-in-out;
padding: 12px 24px;
border-radius: 24px;
font-size: 16px;
}

Expand Down Expand Up @@ -170,19 +169,42 @@ button {
box-shadow: none;
}

/* BUTTON SHAPE */

.storybook-button--rounded{
border-radius: 2rem;
}

.storybook-button--squared{
border-radius: .5rem;
}

/* BUTTON SIZES*/

.storybook-button--small {
font-size: 12px;
padding: 10px 16px;

&.storybook-button--icon-button{
padding: .75rem;
}

}
.storybook-button--medium {
font-size: 14px;
padding: 11px 20px;

&.storybook-button--icon-button{
padding: 1rem;
}
}
.storybook-button--large {
font-size: 16px;
padding: 12px 24px;

&.storybook-button--icon-button{
padding: 1.25rem;
}
}

.storybook-button-icon--left{
Expand Down