@@ -6,50 +6,17 @@ export type Variant = (typeof variants)[number];
66<script setup lang="ts" generic =" UNUSED " >
77import { type Component , computed } from " vue" ;
88
9- import type { IconName } from " @knime/kds-styles/img/icons/def" ;
10-
119import Icon from " ../Icon/Icon.vue" ;
12- import type { Size } from " ../types" ;
13-
14- export type BaseButtonProps =
15- // button with label
16- | {
17- // common
18- variant? : Variant ;
19- size? : Size ;
20- destructive? : boolean ;
21- disabled? : boolean ;
22-
23- // specific
24- label: string ;
25- leadingIcon? : IconName | null ;
26- trailingIcon? : IconName | null ;
27-
28- // not allowed
29- icon? : never ;
30- }
31- // button only with icon
32- | {
33- // common
34- variant? : Variant ;
35- size? : Size ;
36- destructive? : boolean ;
37- disabled? : boolean ;
38-
39- // specific
40- icon: IconName ;
41-
42- // not allowed
43- label? : never ;
44- leadingIcon? : never ;
45- trailingIcon? : never ;
46- };
10+
11+ import type { BaseButtonProps } from " ./types" ;
4712
4813type BaseButtonPropsWithComponent = BaseButtonProps & {
4914 component? : string | Component ;
5015};
5116
5217const props = withDefaults (defineProps <BaseButtonPropsWithComponent >(), {
18+ label: undefined ,
19+ leadingIcon: undefined ,
5320 component: " button" ,
5421 size: " medium" ,
5522 variant: " filled" ,
@@ -91,20 +58,13 @@ function onClick(e: MouseEvent) {
9158 :disabled =" props.disabled"
9259 @click =" onClick($event)"
9360 >
94- <template v-if =" props .label " >
95- <Icon
96- v-if =" props.leadingIcon"
97- :name =" props.leadingIcon"
98- :size =" iconSize"
99- />
100- <span class =" label" >{{ props.label }}</span >
101- <Icon
102- v-if =" props.trailingIcon"
103- :name =" props.trailingIcon"
104- :size =" iconSize"
105- />
106- </template >
107- <Icon v-else-if =" props.icon" :name =" props.icon" :size =" iconSize" />
61+ <Icon v-if =" props.leadingIcon" :name =" props.leadingIcon" :size =" iconSize" />
62+ <span v-if =" props.label" class =" label" >{{ props.label }}</span >
63+ <Icon
64+ v-if =" props.trailingIcon && props.label"
65+ :name =" props.trailingIcon"
66+ :size =" iconSize"
67+ />
10868 </Component >
10969</template >
11070
0 commit comments