diff --git a/apps/tailwind-components/components/Button.vue b/apps/tailwind-components/components/Button.vue index a00ad0146f..2ade2fb506 100644 --- a/apps/tailwind-components/components/Button.vue +++ b/apps/tailwind-components/components/Button.vue @@ -13,6 +13,8 @@ const props = withDefaults( icon?: string; iconPosition?: ButtonIconPosition; disabled?: boolean; + iconOnly?: boolean; + tooltip?: string; }>(), { type: "primary", @@ -20,9 +22,16 @@ const props = withDefaults( label: "", iconPosition: "left", disabled: false, + iconOnly: false, } ); +watchEffect(() => { + if (props.iconOnly && (props.label === "" || props.label === undefined)) { + console.error("Icon only buttons must have a label"); + } +}); + const COLOR_MAPPING = { primary: "tracking-widest uppercase font-display bg-button-primary text-button-primary border-button-primary hover:bg-button-primary-hover hover:text-button-primary-hover hover:border-button-primary-hover", @@ -55,22 +64,26 @@ const colorClasses = computed(() => { }); const sizeClasses = computed(() => { - return SIZE_MAPPING[props.size]; + return props.iconOnly ? "p-[8px]" : SIZE_MAPPING[props.size]; }); const iconPositionClass = computed(() => { return ICON_POSITION_MAPPING[props.iconPosition]; }); + +const tooltipText = computed(() => { + return props.tooltip || props.iconOnly ? props.label : ""; +}); diff --git a/apps/tailwind-components/pages/Button.story.vue b/apps/tailwind-components/pages/Button.story.vue index ebbaf28a4a..f0520337bd 100644 --- a/apps/tailwind-components/pages/Button.story.vue +++ b/apps/tailwind-components/pages/Button.story.vue @@ -60,5 +60,54 @@ CaretDown + +

Icon only

+
+
+
+ +
+
+ +
+
+ +
+
+ + +
+ + +
+
+ + diff --git a/apps/tailwind-components/pages/ButtonBar.story.vue b/apps/tailwind-components/pages/ButtonBar.story.vue index 1b58b9a88c..832b4389d1 100644 --- a/apps/tailwind-components/pages/ButtonBar.story.vue +++ b/apps/tailwind-components/pages/ButtonBar.story.vue @@ -14,4 +14,9 @@ + + +