Skip to content

Commit 97a17d3

Browse files
committed
.
1 parent 646c3df commit 97a17d3

7 files changed

Lines changed: 35 additions & 58 deletions

File tree

app/components/Package/Playgrounds.vue

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ const providerIcons: Record<string, string> = {
1717
'nuxt-new': 'i-simple-icons:nuxtdotjs',
1818
'vite-new': 'i-simple-icons:vite',
1919
'jsfiddle': 'i-carbon:code',
20+
'storybook': 'i-simple-icons:storybook',
2021
}
2122
2223
// Map provider id to color class
@@ -30,6 +31,7 @@ const providerColors: Record<string, string> = {
3031
'nuxt-new': 'text-provider-nuxt',
3132
'vite-new': 'text-provider-vite',
3233
'jsfiddle': 'text-provider-jsfiddle',
34+
'storybook': 'text-provider-storybook',
3335
}
3436
3537
function getIcon(provider: string): string {

app/components/VersionSelector.vue

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -74,15 +74,7 @@ const versionToTags = computed(() => buildVersionToTagsMap(props.distTags))
7474
7575
/** Get URL for a specific version */
7676
function getVersionUrl(version: string): string {
77-
let url = props.urlPattern.replace('{version}', version)
78-
// Replace storyid placeholder if it exists
79-
if (url.includes('{storyid}')) {
80-
// Get current storyid from route query
81-
const route = useRoute()
82-
const currentStoryId = route.query.storyid as string
83-
url = url.replace('{storyid}', currentStoryId || '')
84-
}
85-
return url
77+
return props.urlPattern.replace('{version}', version)
8678
}
8779
8880
/** Safe semver comparison with fallback */

app/pages/package-stories/[...path].vue

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -52,8 +52,8 @@ const { data: pkg } = usePackage(packageName)
5252
// URL pattern for version selector - maintain current story if available
5353
const versionUrlPattern = computed(() => {
5454
const base = `/package-stories/${packageName.value}/v/{version}`
55-
// Use placeholder for storyid that will be handled by version switch watcher
56-
return currentStoryId.value ? `${base}?storyid={storyid}` : base
55+
// Directly include the current storyid if available
56+
return currentStoryId.value ? `${base}?storyid=${currentStoryId.value}` : base
5757
})
5858
5959
// Fetch package.json to get Storybook URL
@@ -383,7 +383,7 @@ defineOgImageComponent('Default', {
383383
</div>
384384
<div class="flex items-center gap-2">
385385
<a
386-
:href="packageJson.storybook.url"
386+
:href="packageJson.storybook.url + '?path=/story/' + currentStoryId"
387387
target="_blank"
388388
rel="noopener noreferrer"
389389
class="px-2 py-1 font-mono text-xs text-fg-muted bg-bg-subtle border border-border rounded hover:text-fg hover:border-border-hover transition-colors inline-flex items-center gap-1"

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

Lines changed: 25 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,20 @@ const { data: readmeData } = useLazyFetch<ReadmeResponse>(
7070
{ default: () => ({ html: '', md: '', playgroundLinks: [], toc: [] }) },
7171
)
7272
73+
const playgroundLinks = computed(() => [
74+
...readmeData.value.playgroundLinks,
75+
...(packageJson.value?.storybook
76+
? [
77+
{
78+
url: packageJson.value.storybook.url,
79+
provider: 'storybook',
80+
providerName: 'Storybook',
81+
label: 'Storybook',
82+
},
83+
]
84+
: []),
85+
])
86+
7387
//copy README file as Markdown
7488
const { copied: copiedReadme, copy: copyReadme } = useClipboard({
7589
source: () => readmeData.value?.md ?? '',
@@ -110,9 +124,7 @@ const {
110124
immediate: false,
111125
},
112126
)
113-
onMounted(() => {
114-
fetchInstallSize()
115-
})
127+
onMounted(() => fetchInstallSize())
116128
117129
const { data: skillsData } = useLazyFetch<SkillsListResponse>(
118130
() => {
@@ -639,6 +651,15 @@ onKeyStroke(
639651
>
640652
{{ $t('package.links.code') }}
641653
</LinkBase>
654+
<LinkBase
655+
v-if="packageJson?.storybook"
656+
variant="button-secondary"
657+
:to="{ name: 'stories', params: { path: [pkg.name, 'v', resolvedVersion] } }"
658+
aria-keyshortcuts="."
659+
classicon="i-carbon:code"
660+
>
661+
stories
662+
</LinkBase>
642663
<LinkBase
643664
variant="button-secondary"
644665
:to="{ name: 'compare', query: { packages: pkg.name } }"
@@ -1160,23 +1181,7 @@ onKeyStroke(
11601181
<PackageWeeklyDownloadStats :packageName :createdIso="pkg?.time?.created ?? null" />
11611182

11621183
<!-- Playground links -->
1163-
<PackagePlaygrounds
1164-
v-if="readmeData?.playgroundLinks?.length"
1165-
:links="readmeData.playgroundLinks"
1166-
/>
1167-
1168-
<!-- <StorybookPlaygrounds
1169-
v-if="readmeData?.storybookPlaygrounds?.length"
1170-
:links="readmeData.storybookPlaygroundLinks"
1171-
/> -->
1172-
1173-
<a v-if="packageJson?.storybook" :href="packageJson.storybook.url">storybook</a>
1174-
<a
1175-
v-if="packageJson?.storybook"
1176-
:href="`/package-stories/${pkg.name}/v/${resolvedVersion}`"
1177-
>sb internal</a
1178-
>
1179-
<!-- :to="{ name: 'code', params: { path: [pkg.name, 'v', resolvedVersion] } }" -->
1184+
<PackagePlaygrounds v-if="playgroundLinks.length" :links="playgroundLinks" />
11801185

11811186
<PackageCompatibility :engines="displayVersion?.engines" />
11821187

app/utils/storybook-tree.ts

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -9,17 +9,13 @@ export function transformStorybookEntries(
99
const tree: StorybookFileTree[] = []
1010
const dirMap = new Map<string, StorybookFileTree>()
1111

12-
// Sort entries by title for consistent ordering
13-
const sortedEntries = Object.values(entries).sort((a, b) =>
14-
(a.title || '').localeCompare(b.title || ''),
15-
)
16-
17-
for (const entry of sortedEntries) {
12+
// Use entries in original order to preserve object key ordering
13+
for (const [_id, entry] of Object.entries(entries)) {
1814
// Parse title into path parts
1915
// "Example/Button/Primary" -> ["Example", "Button", "Primary"]
2016
if (!entry.title) continue
2117
const parts = entry.title.split('/')
22-
const storyName = parts.pop()! // Last part is the story name
18+
const storyName = entry.name
2319
const storyPath = parts.join('/') || '' || ''
2420

2521
// Create directories as needed

lunaria/files/en-GB.json

Lines changed: 0 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -630,25 +630,6 @@
630630
},
631631
"file_path": "File path"
632632
},
633-
"stories": {
634-
"stories_label": "Stories",
635-
"story_path": "Story path",
636-
"root": "Stories",
637-
"version_required": "Version is required to browse stories",
638-
"go_to_package": "Go to package",
639-
"loading_stories": "Loading Storybook stories...",
640-
"no_storybook_found": "No Storybook found",
641-
"check_package_json": "Check if this package has Storybook configuration in package.json",
642-
"back_to_package": "Back to package",
643-
"failed_to_load_stories": "Failed to load Storybook stories",
644-
"storybook_unavailable": "The Storybook instance may be unavailable or misconfigured",
645-
"open_storybook": "Open Storybook",
646-
"story": "Story",
647-
"open_in_storybook": "Open in Storybook",
648-
"select_story": "Select a story from the tree to view it here",
649-
"toggle_tree": "Toggle story tree",
650-
"close_tree": "Close story tree"
651-
},
652633
"badges": {
653634
"provenance": {
654635
"verified": "verified",

uno.config.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,7 @@ export default defineConfig({
9898
nuxt: '#00DC82',
9999
vite: '#646CFF',
100100
jsfiddle: '#0084FF',
101+
storybook: '#FF4785',
101102
},
102103
},
103104
animation: {

0 commit comments

Comments
 (0)