Skip to content

Commit 2c9e317

Browse files
committed
refactor: change key shortcut prop
1 parent 6e8995f commit 2c9e317

File tree

4 files changed

+27
-37
lines changed

4 files changed

+27
-37
lines changed

app/components/AppHeader.vue

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,7 @@ onKeyStroke(
157157
class="border-none"
158158
variant="button-secondary"
159159
:to="{ name: 'compare' }"
160-
keyshortcut="c"
160+
aria-keyshortcuts="c"
161161
>
162162
{{ $t('nav.compare') }}
163163
</LinkBase>
@@ -167,7 +167,7 @@ onKeyStroke(
167167
class="border-none"
168168
variant="button-secondary"
169169
:to="{ name: 'settings' }"
170-
keyshortcut=","
170+
aria-keyshortcuts=","
171171
>
172172
{{ $t('nav.settings') }}
173173
</LinkBase>

app/components/Button/Base.vue

Lines changed: 9 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,13 @@
11
<script setup lang="ts">
22
const props = withDefaults(
33
defineProps<{
4-
'disabled'?: boolean
5-
'type'?: 'button' | 'submit'
6-
'variant'?: 'primary' | 'secondary'
7-
'size'?: 'small' | 'medium'
8-
'keyshortcut'?: string
4+
disabled?: boolean
5+
type?: 'button' | 'submit'
6+
variant?: 'primary' | 'secondary'
7+
size?: 'small' | 'medium'
8+
ariaKeyshortcuts?: string
99
10-
/**
11-
* Do not use this directly. Use keyshortcut instead; it generates the correct HTML and displays the shortcut in the UI.
12-
*/
13-
'aria-keyshortcuts'?: never
14-
15-
'classicon'?: string
10+
classicon?: string
1611
}>(),
1712
{
1813
type: 'button',
@@ -51,7 +46,7 @@ defineExpose({
5146
*/
5247
disabled ? true : undefined
5348
"
54-
:aria-keyshortcuts="keyshortcut"
49+
:aria-keyshortcuts="ariaKeyshortcuts"
5550
>
5651
<span
5752
v-if="classicon"
@@ -60,11 +55,11 @@ defineExpose({
6055
/>
6156
<slot />
6257
<kbd
63-
v-if="keyshortcut"
58+
v-if="ariaKeyshortcuts"
6459
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"
6560
aria-hidden="true"
6661
>
67-
{{ keyshortcut }}
62+
{{ ariaKeyshortcuts }}
6863
</kbd>
6964
</button>
7065
</template>

app/components/Link/Base.vue

Lines changed: 13 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -5,37 +5,32 @@ const props = withDefaults(
55
defineProps<
66
{
77
/** Disabled links will be displayed as plain text */
8-
'disabled'?: boolean
8+
disabled?: boolean
99
/**
1010
* `type` should never be used, because this will always be a link.
1111
* */
12-
'type'?: never
13-
'variant'?: 'button-primary' | 'button-secondary' | 'link'
14-
'size'?: 'small' | 'medium'
12+
type?: never
13+
variant?: 'button-primary' | 'button-secondary' | 'link'
14+
size?: 'small' | 'medium'
1515
16-
'keyshortcut'?: string
17-
18-
/**
19-
* Do not use this directly. Use keyshortcut instead; it generates the correct HTML and displays the shortcut in the UI.
20-
*/
21-
'aria-keyshortcuts'?: never
16+
ariaKeyshortcuts?: string
2217
2318
/**
2419
* Don't use this directly. This will automatically be set to `_blank` for external links passed via `to`.
2520
*/
26-
'target'?: never
21+
target?: never
2722
2823
/**
2924
* Don't use this directly. This will automatically be set for external links passed via `to`.
3025
*/
31-
'rel'?: never
26+
rel?: never
3227
33-
'classicon'?: string
28+
classicon?: string
3429
35-
'to'?: NuxtLinkProps['to']
30+
to?: NuxtLinkProps['to']
3631
3732
/** always use `to` instead of `href` */
38-
'href'?: never
33+
href?: never
3934
} & NuxtLinkProps
4035
>(),
4136
{ variant: 'link', size: 'medium' },
@@ -86,7 +81,7 @@ const isButtonMedium = computed(() => props.size === 'medium' && props.variant !
8681
'text-bg bg-fg hover:(bg-fg/50) focus-visible:(bg-fg/50)': variant === 'button-primary',
8782
}"
8883
:to="to"
89-
:aria-keyshortcuts="keyshortcut"
84+
:aria-keyshortcuts="ariaKeyshortcuts"
9085
:target="isLinkExternal ? '_blank' : undefined"
9186
>
9287
<span
@@ -107,11 +102,11 @@ const isButtonMedium = computed(() => props.size === 'medium' && props.variant !
107102
aria-hidden="true"
108103
/>
109104
<kbd
110-
v-if="keyshortcut"
105+
v-if="ariaKeyshortcuts"
111106
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"
112107
aria-hidden="true"
113108
>
114-
{{ keyshortcut }}
109+
{{ ariaKeyshortcuts }}
115110
</kbd>
116111
</NuxtLink>
117112
</template>

app/pages/package/[[org]]/[name].vue

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -616,23 +616,23 @@ onKeyStroke(
616616
variant="button-secondary"
617617
v-if="docsLink"
618618
:to="docsLink"
619-
keyshortcut="d"
619+
aria-keyshortcuts="d"
620620
classicon="i-carbon:document"
621621
>
622622
{{ $t('package.links.docs') }}
623623
</LinkBase>
624624
<LinkBase
625625
variant="button-secondary"
626626
:to="{ name: 'code', params: { path: [pkg.name, 'v', resolvedVersion] } }"
627-
keyshortcut="."
627+
aria-keyshortcuts="."
628628
classicon="i-carbon:code"
629629
>
630630
{{ $t('package.links.code') }}
631631
</LinkBase>
632632
<LinkBase
633633
variant="button-secondary"
634634
:to="{ name: 'compare', query: { packages: pkg.name } }"
635-
keyshortcut="c"
635+
aria-keyshortcuts="c"
636636
classicon="i-carbon:compare"
637637
>
638638
{{ $t('package.links.compare') }}

0 commit comments

Comments
 (0)