Skip to content

Commit 1099966

Browse files
committed
merge main
2 parents 6ad2bc5 + f18d64e commit 1099966

File tree

101 files changed

+6706
-747
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

101 files changed

+6706
-747
lines changed

.storybook/main.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import type { StorybookConfig } from '@storybook-vue/nuxt'
22

33
const config = {
44
stories: ['../app/**/*.stories.@(js|ts)'],
5-
addons: ['@storybook/addon-a11y', '@storybook/addon-docs'],
5+
addons: ['@storybook/addon-a11y', '@storybook/addon-docs', '@storybook/addon-themes'],
66
framework: '@storybook-vue/nuxt',
77
features: {
88
backgrounds: false,

.storybook/preview.ts

Lines changed: 10 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import type { Preview } from '@storybook-vue/nuxt'
2+
import { withThemeByDataAttribute } from '@storybook/addon-themes'
23
import { currentLocales } from '../config/i18n'
34
import { fn } from 'storybook/test'
45
import { ACCENT_COLORS } from '../shared/utils/constants'
@@ -58,31 +59,22 @@ const preview: Preview = {
5859
],
5960
},
6061
},
61-
theme: {
62-
name: 'Theme',
63-
description: 'Color mode',
64-
defaultValue: 'dark',
65-
toolbar: {
66-
icon: 'moon',
67-
dynamicTitle: true,
68-
items: [
69-
{ value: 'light', icon: 'sun', title: 'Light' },
70-
{ value: 'dark', icon: 'moon', title: 'Dark' },
71-
],
72-
},
73-
},
7462
},
7563
decorators: [
64+
withThemeByDataAttribute({
65+
themes: {
66+
Light: 'light',
67+
Dark: 'dark',
68+
},
69+
defaultTheme: 'Dark',
70+
attributeName: 'data-theme',
71+
}),
7672
(story, context) => {
77-
const { locale, theme, accentColor } = context.globals as {
73+
const { locale, accentColor } = context.globals as {
7874
locale: string
79-
theme: string
8075
accentColor?: string
8176
}
8277

83-
// Set theme from globals
84-
document.documentElement.setAttribute('data-theme', theme)
85-
8678
// Set accent color from globals
8779
if (accentColor) {
8880
document.documentElement.style.setProperty('--accent-color', `var(--swatch-${accentColor})`)

app/app.vue

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -47,10 +47,12 @@ if (import.meta.server) {
4747
setJsonLd(createWebSiteSchema())
4848
}
4949
50+
const keyboardShortcuts = useKeyboardShortcuts()
51+
5052
onKeyDown(
5153
'/',
5254
e => {
53-
if (isEditableElement(e.target)) return
55+
if (!keyboardShortcuts.value || isEditableElement(e.target)) return
5456
e.preventDefault()
5557
5658
const searchInput = document.querySelector<HTMLInputElement>(
@@ -70,7 +72,7 @@ onKeyDown(
7072
onKeyDown(
7173
'?',
7274
e => {
73-
if (isEditableElement(e.target)) return
75+
if (!keyboardShortcuts.value || isEditableElement(e.target)) return
7476
e.preventDefault()
7577
showKbdHints.value = true
7678
},
@@ -80,7 +82,7 @@ onKeyDown(
8082
onKeyUp(
8183
'?',
8284
e => {
83-
if (isEditableElement(e.target)) return
85+
if (!keyboardShortcuts.value || isEditableElement(e.target)) return
8486
e.preventDefault()
8587
showKbdHints.value = false
8688
},

app/assets/main.css

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -336,6 +336,11 @@ input[type='search']::-webkit-search-results-decoration {
336336
animation-timing-function: cubic-bezier(0.22, 1, 0.36, 1);
337337
}
338338

339+
/* Hide keyboard shortcut hints before hydration when user disabled them */
340+
:root[data-kbd-shortcuts='false'] [data-kbd-hint] {
341+
display: none;
342+
}
343+
339344
/* Locking the scroll whenever any of the modals are open */
340345
html:has(dialog:modal) {
341346
overflow: hidden;

app/components/AppFooter.vue

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ const isHome = computed(() => route.name === 'index')
66
77
const modalRef = useTemplateRef('modalRef')
88
const showModal = () => modalRef.value?.showModal?.()
9+
const closeModal = () => modalRef.value?.close?.()
910
</script>
1011

1112
<template>
@@ -84,7 +85,7 @@ const showModal = () => modalRef.value?.showModal?.()
8485
<p class="mb-2 font-mono text-fg-subtle">
8586
{{ $t('shortcuts.section.package') }}
8687
</p>
87-
<ul class="mb-6 flex flex-col gap-2">
88+
<ul class="mb-8 flex flex-col gap-2">
8889
<li class="flex gap-2 items-center">
8990
<kbd class="kbd">.</kbd>
9091
<span>{{ $t('shortcuts.open_code_view') }}</span>
@@ -98,6 +99,19 @@ const showModal = () => modalRef.value?.showModal?.()
9899
<span>{{ $t('shortcuts.compare_from_package') }}</span>
99100
</li>
100101
</ul>
102+
<p class="text-fg-muted leading-relaxed">
103+
<i18n-t keypath="shortcuts.disable_shortcuts" tag="span" scope="global">
104+
<template #settings>
105+
<NuxtLink
106+
:to="{ name: 'settings' }"
107+
class="hover:text-fg underline decoration-fg-subtle/50 hover:decoration-fg"
108+
@click="closeModal"
109+
>
110+
{{ $t('settings.title') }}
111+
</NuxtLink>
112+
</template>
113+
</i18n-t>
114+
</p>
101115
</Modal>
102116
<LinkBase :to="NPMX_DOCS_SITE">
103117
{{ $t('footer.docs') }}

app/components/AppHeader.vue

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@ import type { NavigationConfig, NavigationConfigWithGroups } from '~/types'
44
import { isEditableElement } from '~/utils/input'
55
import { NPMX_DOCS_SITE } from '#shared/utils/constants'
66
7+
const keyboardShortcuts = useKeyboardShortcuts()
8+
79
withDefaults(
810
defineProps<{
911
showLogo?: boolean
@@ -133,7 +135,7 @@ const mobileLinks = computed<NavigationConfigWithGroups>(() => [
133135
134136
const showFullSearch = shallowRef(false)
135137
const showMobileMenu = shallowRef(false)
136-
const { env } = useAppConfig().buildInfo
138+
const { env, prNumber } = useAppConfig().buildInfo
137139
138140
// On mobile, clicking logo+search button expands search
139141
const route = useRoute()
@@ -183,7 +185,7 @@ function handleSearchFocus() {
183185
184186
onKeyStroke(
185187
e => {
186-
if (isEditableElement(e.target)) {
188+
if (!keyboardShortcuts.value || isEditableElement(e.target)) {
187189
return
188190
}
189191
@@ -233,6 +235,15 @@ onKeyStroke(
233235
{{ env === 'release' ? 'alpha' : env }}
234236
</span>
235237
</NuxtLink>
238+
<NuxtLink
239+
v-if="prNumber"
240+
:to="`https://github.com/npmx-dev/npmx.dev/pull/${prNumber}`"
241+
:aria-label="`Open GitHub pull request ${prNumber}`"
242+
>
243+
<span class="text-xs px-1.5 py-0.5 rounded badge-green font-sans font-medium ms-2">
244+
PR #{{ prNumber }}
245+
</span>
246+
</NuxtLink>
236247
</div>
237248
<!-- Spacer when logo is hidden on desktop -->
238249
<span v-else class="hidden sm:block w-1" />

app/components/Button/Base.vue

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,8 @@ const props = withDefaults(
2626
2727
const el = useTemplateRef('el')
2828
29+
const keyboardShortcutsEnabled = useKeyboardShortcuts()
30+
2931
defineExpose({
3032
focus: () => el.value?.focus(),
3133
getBoundingClientRect: () => el.value?.getBoundingClientRect(),
@@ -56,12 +58,13 @@ defineExpose({
5658
*/
5759
disabled ? true : undefined
5860
"
59-
:aria-keyshortcuts="ariaKeyshortcuts"
61+
:aria-keyshortcuts="keyboardShortcutsEnabled ? ariaKeyshortcuts : undefined"
6062
>
6163
<span v-if="classicon" class="size-[1em]" :class="classicon" aria-hidden="true" />
6264
<slot />
6365
<kbd
64-
v-if="ariaKeyshortcuts"
66+
v-if="keyboardShortcutsEnabled && ariaKeyshortcuts"
67+
data-kbd-hint
6568
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"
6669
aria-hidden="true"
6770
>

app/components/Code/FileTree.vue

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -94,12 +94,7 @@ watch(
9494
block
9595
:style="{ paddingLeft: `${depth * 12 + 32}px` }"
9696
>
97-
<svg
98-
class="size-[1em] me-1 shrink-0"
99-
viewBox="0 0 16 16"
100-
fill="currentColor"
101-
aria-hidden="true"
102-
>
97+
<svg class="size-[1em] me-1 shrink-0" viewBox="0 0 16 16" aria-hidden="true">
10398
<use :href="`/file-tree-sprite.svg#${getFileIcon(node.name)}`" />
10499
</svg>
105100
<span class="truncate">{{ node.name }}</span>

app/components/CollapsibleSection.vue

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import { LinkBase } from '#components'
44
55
interface Props {
66
title: string
7+
subtitle?: string
78
isLoading?: boolean
89
headingLevel?: `h${number}`
910
id: string
@@ -81,7 +82,8 @@ useHead({
8182
<div class="flex items-center justify-between mb-3 px-1">
8283
<component
8384
:is="headingLevel"
84-
class="group text-xs text-fg-subtle uppercase tracking-wider flex items-center gap-2"
85+
class="group text-xs text-fg-subtle uppercase tracking-wider flex gap-2"
86+
:class="subtitle ? 'items-start' : 'items-center'"
8587
>
8688
<button
8789
:id="buttonId"
@@ -101,9 +103,14 @@ useHead({
101103
/>
102104
</button>
103105

104-
<LinkBase :to="`#${id}`">
105-
{{ title }}
106-
</LinkBase>
106+
<span>
107+
<LinkBase :to="`#${id}`">
108+
{{ title }}
109+
</LinkBase>
110+
<span v-if="subtitle" class="block text-2xs normal-case tracking-normal">{{
111+
subtitle
112+
}}</span>
113+
</span>
107114
</component>
108115

109116
<!-- Actions slot for buttons or other elements -->

app/components/Compare/PackageSelector.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -301,7 +301,7 @@ onClickOutside(containerRef, () => {
301301
v-if="result.description"
302302
class="text-xs text-fg-muted truncate mt-0.5 w-full block"
303303
>
304-
{{ decodeHtmlEntities(result.description) }}
304+
{{ stripHtmlTags(decodeHtmlEntities(result.description)) }}
305305
</span>
306306
</ButtonBase>
307307
</div>

0 commit comments

Comments
 (0)