From 401f13f7e305d60097db2334642e423c41d8897d Mon Sep 17 00:00:00 2001 From: Corentin Thomasset Date: Sun, 7 May 2023 23:29:55 +0200 Subject: [PATCH] ui-lib(button): size variants --- src/ui/c-button/c-button.demo.vue | 41 ++++++++++++++++++++----------- src/ui/c-button/c-button.theme.ts | 15 +++++++++++ src/ui/c-button/c-button.vue | 15 +++++++---- 3 files changed, 51 insertions(+), 20 deletions(-) diff --git a/src/ui/c-button/c-button.demo.vue b/src/ui/c-button/c-button.demo.vue index 988659f5..4e9aa1ab 100644 --- a/src/ui/c-button/c-button.demo.vue +++ b/src/ui/c-button/c-button.demo.vue @@ -2,28 +2,39 @@

{{ _.capitalize(buttonVariant) }}

- - Button - +
+ + Button + - - A - + + A + +
diff --git a/src/ui/c-button/c-button.theme.ts b/src/ui/c-button/c-button.theme.ts index 87ad89f3..e96ac56b 100644 --- a/src/ui/c-button/c-button.theme.ts +++ b/src/ui/c-button/c-button.theme.ts @@ -27,6 +27,21 @@ const createTheme = ({ style }: { style: 'light' | 'dark' }) => { const theme = appThemes[style]; return { + size: { + small: { + width: '28px', + fontSize: '12px', + }, + medium: { + width: '34px', + fontSize: '14px', + }, + large: { + width: '40px', + fontSize: '16px', + }, + }, + basic: { default: createState({ textColor: theme.text.baseColor, diff --git a/src/ui/c-button/c-button.vue b/src/ui/c-button/c-button.vue index 2cbc4fd4..c17b0781 100644 --- a/src/ui/c-button/c-button.vue +++ b/src/ui/c-button/c-button.vue @@ -25,6 +25,7 @@ const props = withDefaults( circle?: boolean; href?: string; to?: RouteLocationRaw; + size?: 'small' | 'medium' | 'large'; }>(), { type: 'default', @@ -34,9 +35,10 @@ const props = withDefaults( circle: false, href: undefined, to: undefined, + size: 'medium', }, ); -const { variant, disabled, round, circle, href, type, to } = toRefs(props); +const { variant, disabled, round, circle, href, type, to, size: sizeName } = toRefs(props); const emits = defineEmits(['click']); @@ -58,18 +60,20 @@ const tag = computed(() => { return 'button'; }); const appTheme = useAppTheme(); + +const size = computed(() => theme.value.size[sizeName.value]);