Skip to content

Commit f305156

Browse files
committed
fix: make sure button/link icons always have correct size
1 parent 98c68f5 commit f305156

4 files changed

Lines changed: 6 additions & 26 deletions

File tree

app/components/Button/Base.vue

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -53,11 +53,7 @@ defineExpose({
5353
"
5454
:aria-keyshortcuts="keyshortcut"
5555
>
56-
<span
57-
v-if="classicon"
58-
:class="[size === 'small' ? 'size-3' : 'size-4', classicon]"
59-
aria-hidden="true"
60-
/>
56+
<span v-if="classicon" class="size-[1em]" :class="classicon" aria-hidden="true" />
6157
<slot />
6258
<kbd
6359
v-if="keyshortcut"

app/components/Link/Base.vue

Lines changed: 4 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@ const props = withDefaults(
1212
'type'?: never
1313
'variant'?: 'button-primary' | 'button-secondary' | 'link'
1414
'size'?: 'small' | 'medium'
15-
'iconSize'?: 'sm' | 'md' | 'lg'
1615
1716
'keyshortcut'?: string
1817
@@ -52,21 +51,11 @@ const isLinkAnchor = computed(
5251
() => !!props.to && typeof props.to === 'string' && props.to.startsWith('#'),
5352
)
5453
55-
const ICON_SIZE_MAP = {
56-
sm: 'size-3 min-w-3',
57-
md: 'size-4 min-w-4',
58-
lg: 'size-5 min-w-5',
59-
}
60-
6154
/** size is only applicable for button like links */
6255
const isLink = computed(() => props.variant === 'link')
6356
const isButton = computed(() => props.variant !== 'link')
6457
const isButtonSmall = computed(() => props.size === 'small' && props.variant !== 'link')
6558
const isButtonMedium = computed(() => props.size === 'medium' && props.variant !== 'link')
66-
67-
const iconSizeClass = computed(
68-
() => ICON_SIZE_MAP[props.iconSize || (isButtonSmall.value && 'sm') || 'md'],
69-
)
7059
</script>
7160

7261
<template>
@@ -100,22 +89,22 @@ const iconSizeClass = computed(
10089
:aria-keyshortcuts="keyshortcut"
10190
:target="isLinkExternal ? '_blank' : undefined"
10291
>
103-
<span v-if="classicon" class="me-1" :class="[iconSizeClass, classicon]" aria-hidden="true" />
92+
<span v-if="classicon" class="me-1 size-[1em]" :class="classicon" aria-hidden="true" />
10493
<slot />
10594
<!-- automatically show icon indicating external link -->
10695
<span
10796
v-if="isLinkExternal && !classicon"
108-
class="i-carbon:launch rtl-flip w-3 h-3 opacity-50"
97+
class="i-carbon:launch rtl-flip size-[1em] opacity-50"
10998
aria-hidden="true"
11099
/>
111100
<span
112101
v-else-if="isLinkAnchor && isLink"
113-
class="i-carbon:link w-3 h-3 opacity-0 group-hover/link:opacity-100 transition-opacity duration-200"
102+
class="i-carbon:link size-[1em] opacity-0 group-hover/link:opacity-100 transition-opacity duration-200"
114103
aria-hidden="true"
115104
/>
116105
<kbd
117106
v-if="keyshortcut"
118-
class="ms-2 inline-flex items-center justify-center w-4 h-4 text-xs text-fg bg-bg-muted border border-border rounded no-underline"
107+
class="ms-2 inline-flex items-center justify-center size-4 text-xs text-fg bg-bg-muted border border-border rounded no-underline"
119108
aria-hidden="true"
120109
>
121110
{{ keyshortcut }}

app/components/Package/Versions.vue

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -369,7 +369,6 @@ function getTagVersions(tag: string): VersionDisplay[] {
369369
: row.primaryVersion.version
370370
"
371371
:classicon="row.primaryVersion.deprecated ? 'i-carbon-warning-hex' : undefined"
372-
icon-size="sm"
373372
>
374373
<span dir="ltr">
375374
{{ row.primaryVersion.version }}
@@ -423,7 +422,6 @@ function getTagVersions(tag: string): VersionDisplay[] {
423422
: v.version
424423
"
425424
:classicon="v.deprecated ? 'i-carbon-warning-hex' : undefined"
426-
icon-size="sm"
427425
>
428426
<span dir="ltr">
429427
{{ v.version }}
@@ -525,7 +523,6 @@ function getTagVersions(tag: string): VersionDisplay[] {
525523
: row.primaryVersion.version
526524
"
527525
:classicon="row.primaryVersion.deprecated ? 'i-carbon-warning-hex' : undefined"
528-
icon-size="sm"
529526
>
530527
<span dir="ltr">
531528
{{ row.primaryVersion.version }}
@@ -602,7 +599,6 @@ function getTagVersions(tag: string): VersionDisplay[] {
602599
:classicon="
603600
group.versions[0]?.deprecated ? 'i-carbon-warning-hex' : undefined
604601
"
605-
icon-size="sm"
606602
>
607603
<span dir="ltr">
608604
{{ group.versions[0]?.version }}
@@ -664,7 +660,6 @@ function getTagVersions(tag: string): VersionDisplay[] {
664660
:classicon="
665661
group.versions[0]?.deprecated ? 'i-carbon-warning-hex' : undefined
666662
"
667-
icon-size="sm"
668663
>
669664
<span dir="ltr">
670665
{{ group.versions[0]?.version }}

app/components/Tag/Static.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ const props = withDefaults(
1616
class="bg-bg-muted text-fg-muted inline-flex gap-x-1 items-center justify-center font-mono border border-transparent rounded-md text-xs px-2 py-0.5"
1717
:class="{ 'opacity-40': variant === 'ghost' }"
1818
>
19-
<span v-if="classicon" :class="['size-3', classicon]" aria-hidden="true" />
19+
<span v-if="classicon" class="size-[1em]" :class="classicon" aria-hidden="true" />
2020
<slot />
2121
</component>
2222
</template>

0 commit comments

Comments
 (0)