Skip to content

Commit 49c2c0d

Browse files
yannbfsacrosanctic
andcommitted
feat: add storybook playground link
Co-Authored-By: Scott Wu <sw@scottwu.ca>
1 parent d4e1ae9 commit 49c2c0d

File tree

3 files changed

+24
-4
lines changed

3 files changed

+24
-4
lines changed

app/components/Package/Playgrounds.vue

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ const providerIcons: Record<string, string> = {
2020
'solid-playground': 'i-simple-icons:solid',
2121
'svelte-playground': 'i-simple-icons:svelte',
2222
'tailwind-playground': 'i-simple-icons:tailwindcss',
23+
'storybook': 'i-simple-icons:storybook',
2324
}
2425
2526
// Map provider id to color class
@@ -37,6 +38,7 @@ const providerColors: Record<string, string> = {
3738
'solid-playground': 'text-provider-solid',
3839
'svelte-playground': 'text-provider-svelte',
3940
'tailwind-playground': 'text-provider-tailwind',
41+
'storybook': 'text-provider-storybook',
4042
}
4143
4244
function getIcon(provider: string): string {

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

Lines changed: 21 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,26 @@ const { data: readmeData } = useLazyFetch<ReadmeResponse>(
109109
{ default: () => ({ html: '', mdExists: false, playgroundLinks: [], toc: [] }) },
110110
)
111111
112+
const { data: packageJson } = useLazyFetch<{ storybook?: { title: string; url: string } }>(() => {
113+
const version = requestedVersion.value ?? 'latest'
114+
return `https://cdn.jsdelivr.net/npm/${packageName.value}@${version}/package.json`
115+
})
116+
117+
const playgroundLinks = computed(() => [
118+
...readmeData.value.playgroundLinks,
119+
// Libraries with a storybook field in package.json contain a link to their deployed playground
120+
...(packageJson.value?.storybook
121+
? [
122+
{
123+
url: packageJson.value.storybook.url,
124+
provider: 'storybook',
125+
providerName: 'Storybook',
126+
label: 'Storybook',
127+
},
128+
]
129+
: []),
130+
])
131+
112132
const {
113133
data: readmeMarkdownData,
114134
status: readmeMarkdownStatus,
@@ -1387,10 +1407,7 @@ const showSkeleton = shallowRef(false)
13871407
/>
13881408

13891409
<!-- Playground links -->
1390-
<PackagePlaygrounds
1391-
v-if="readmeData?.playgroundLinks?.length"
1392-
:links="readmeData.playgroundLinks"
1393-
/>
1410+
<PackagePlaygrounds v-if="playgroundLinks.length" :links="playgroundLinks" />
13941411

13951412
<PackageCompatibility :engines="displayVersion?.engines" />
13961413

uno.config.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,7 @@ export default defineConfig({
104104
solid: '#2C4F7C',
105105
svelte: '#FF3E00',
106106
tailwind: '#06B6D4',
107+
storybook: '#FF4785',
107108
},
108109
},
109110
animation: {

0 commit comments

Comments
 (0)