Skip to content

Commit e70f094

Browse files
authored
Merge branch 'main' into feat/changelog-1
2 parents 78ba6f7 + f0ada7e commit e70f094

File tree

17 files changed

+464
-72
lines changed

17 files changed

+464
-72
lines changed

.storybook/main.ts

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

33
const config = {
4-
stories: ['../app/**/*.stories.@(js|ts)'],
4+
stories: ['../.storybook/*.mdx', '../app/**/*.stories.@(js|ts)'],
55
addons: ['@storybook/addon-a11y', '@storybook/addon-docs', '@storybook/addon-themes'],
66
framework: '@storybook-vue/nuxt',
77
staticDirs: ['./.public'],

.storybook/manager.ts

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,19 @@
11
import { addons } from 'storybook/manager-api'
2-
import { create } from 'storybook/theming'
32

4-
const npmxTheme = create({
5-
brandTitle: 'npmx Storybook',
6-
brandImage: '/npmx-storybook.svg',
7-
})
3+
import npmxDark from './theme'
84

95
addons.setConfig({
10-
theme: npmxTheme,
6+
theme: npmxDark,
7+
layoutCustomisations: {
8+
showToolbar: (state, defaultValue) => {
9+
if (state.viewMode === 'docs' && state.storyId) {
10+
const story = state.index?.[state.storyId]
11+
const tags = story?.tags || []
12+
if (tags.includes('hide-toolbar')) {
13+
return false
14+
}
15+
}
16+
return defaultValue
17+
},
18+
},
1119
})

.storybook/preview-head.html

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
<style>
2+
/* Override docs story canvas background to match npmx theme */
3+
.docs-story {
4+
background-color: var(--bg, oklch(0.171 0 0)) !important;
5+
}
6+
</style>

.storybook/preview.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@ import { currentLocales } from '../config/i18n'
44
import { fn } from 'storybook/test'
55
import { ACCENT_COLORS } from '../shared/utils/constants'
66

7+
import npmxDark from './theme'
8+
79
// related: https://github.com/npmx-dev/npmx.dev/blob/1431d24be555bca5e1ae6264434d49ca15173c43/test/nuxt/setup.ts#L12-L26
810
// Stub Nuxt specific globals
911
// @ts-expect-error - dynamic global name
@@ -25,6 +27,9 @@ const preview: Preview = {
2527
date: /Date$/i,
2628
},
2729
},
30+
docs: {
31+
theme: npmxDark,
32+
},
2833
},
2934
// Provides toolbars to switch things like theming and language
3035
globalTypes: {

.storybook/storybook-welcome.mdx

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
import { Meta } from '@storybook/addon-docs/blocks';
2+
3+
<Meta title="Welcome" tags={['hide-toolbar']}/>
4+
5+
# Welcome
6+
7+
Welcome to the npmx Storybook.

.storybook/theme.ts

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
import { create } from 'storybook/theming'
2+
3+
const npmxDark = create({
4+
base: 'dark',
5+
6+
brandTitle: 'npmx Storybook',
7+
brandImage: '/npmx-storybook.svg',
8+
9+
// UI
10+
appContentBg: '#101010', // oklch(0.171 0 0)
11+
})
12+
13+
export default npmxDark

.vscode/settings.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
"editor.formatOnSave": true,
44
"i18n-ally.keystyle": "nested",
55
"i18n-ally.localesPaths": ["./i18n/locales"],
6-
"typescript.tsdk": "node_modules/typescript/lib",
6+
"js/ts.tsdk.path": "node_modules/typescript/lib",
77
"explorer.fileNesting.enabled": true,
88
"explorer.fileNesting.patterns": {
99
"*.vue": "${capture}.stories.ts"

app/components/Package/TableRow.vue

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -22,13 +22,6 @@ const isSelected = computed<boolean>(() => {
2222
return isPackageSelected(props.result.package.name)
2323
})
2424
25-
function formatDownloads(count?: number): string {
26-
if (count === undefined) return '-'
27-
if (count >= 1_000_000) return `${(count / 1_000_000).toFixed(1)}M`
28-
if (count >= 1_000) return `${(count / 1_000).toFixed(1)}K`
29-
return count.toString()
30-
}
31-
3225
function formatScore(value?: number): string {
3326
if (value === undefined || value === 0) return '-'
3427
return Math.round(value * 100).toString()
@@ -44,6 +37,8 @@ const allMaintainersText = computed(() => {
4437
if (!pkg.value.maintainers?.length) return ''
4538
return pkg.value.maintainers.map(m => m.name || m.email).join(', ')
4639
})
40+
41+
const compactNumberFormatter = useCompactNumberFormatter()
4742
</script>
4843

4944
<template>
@@ -89,7 +84,11 @@ const allMaintainersText = computed(() => {
8984
v-if="isColumnVisible('downloads')"
9085
class="py-2 px-3 font-mono text-xs text-fg-muted text-end tabular-nums"
9186
>
92-
{{ formatDownloads(result.downloads?.weekly) }}
87+
{{
88+
result.downloads?.weekly !== undefined
89+
? compactNumberFormatter.format(result.downloads.weekly)
90+
: '-'
91+
}}
9392
</td>
9493

9594
<!-- Updated -->

app/components/PaginationControls.vue

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -155,7 +155,7 @@ function handlePageSizeChange(event: Event) {
155155
@change="handlePageSizeChange"
156156
:items="
157157
PAGE_SIZE_OPTIONS.map(size => ({
158-
label: $t('filters.pagination.per_page', { count: size }),
158+
label: $t('filters.pagination.per_page', { count: $n(size) }),
159159
value: String(size),
160160
}))
161161
"
@@ -207,7 +207,7 @@ function handlePageSizeChange(event: Event) {
207207
:aria-current="page === currentPage ? 'page' : undefined"
208208
@click="goToPage(page)"
209209
>
210-
{{ page }}
210+
{{ $n(page) }}
211211
</button>
212212
</template>
213213

app/pages/about.stories.ts

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
import About from './about.vue'
2+
import type { Meta, StoryObj } from '@storybook-vue/nuxt'
3+
import AppHeader from '~/components/AppHeader.vue'
4+
import AppFooter from '~/components/AppFooter.vue'
5+
6+
const meta = {
7+
component: About,
8+
parameters: {
9+
layout: 'fullscreen',
10+
},
11+
decorators: [
12+
() => ({
13+
components: { AppHeader, AppFooter },
14+
template: `
15+
<div class="min-h-screen flex flex-col bg-bg text-fg">
16+
<AppHeader :show-logo="true" />
17+
<div id="main-content" class="flex-1 flex flex-col" tabindex="-1">
18+
<story />
19+
</div>
20+
<AppFooter />
21+
</div>
22+
`,
23+
}),
24+
],
25+
} satisfies Meta<typeof About>
26+
27+
export default meta
28+
type Story = StoryObj<typeof meta>
29+
30+
export const Default: Story = {}

0 commit comments

Comments
 (0)