Skip to content

Commit 08f85b6

Browse files
feat(docs): add Figma link support to examples
Add support for displaying Figma design links in example components. Examples can now include an example-meta block with a figma URL that will be displayed as an action button in the example toolbar. - Add exampleMeta computed property to parse meta data - Add figma icon alias to vuetify plugin - Add view-in-figma i18n translation - Add example-meta block support in vite config - Add example-meta to v-btn readonly example
1 parent 63b31e0 commit 08f85b6

File tree

5 files changed

+42
-1
lines changed

5 files changed

+42
-1
lines changed

packages/docs/src/components/examples/Example.vue

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -196,6 +196,19 @@
196196
set: val => _theme.value = val,
197197
})
198198
199+
const exampleMeta = computed<Record<string, any>>(() => {
200+
const meta = (component.value as any)?.exampleMeta
201+
202+
if (!meta) return {}
203+
204+
try {
205+
return JSON.parse(meta)
206+
} catch (e) {
207+
console.error('Invalid example meta for', props.file, e)
208+
return {}
209+
}
210+
})
211+
199212
const playgroundLink = computed(() => {
200213
if (!isLoaded.value || isError.value) return null
201214
@@ -209,6 +222,10 @@
209222
)
210223
})
211224
225+
const figmaLink = computed(() => {
226+
return exampleMeta.value.figma ?? null
227+
})
228+
212229
const actions = computed(() => [
213230
{
214231
icon: theme.value === 'dark' ? 'mdi-white-balance-sunny' : 'mdi-weather-night',
@@ -222,6 +239,13 @@
222239
target: '_blank',
223240
hide: xs.value,
224241
},
242+
{
243+
icon: '$figma',
244+
path: 'view-in-figma',
245+
href: figmaLink.value,
246+
target: '_blank',
247+
hide: xs.value || !figmaLink.value,
248+
},
225249
{
226250
icon: 'mdi-github',
227251
path: 'view-in-github',

packages/docs/src/examples/v-btn/misc-readonly.vue

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,3 +70,9 @@
7070
7171
const isSubscriber = shallowRef(false)
7272
</script>
73+
74+
<example-meta lang="json">
75+
{
76+
"figma": "https://www.figma.com/design/5f4g4pbbBsk9TTWX4Xvlx1/PRO-v3.0---Official-Vuetify-3-UI-Kit?node-id=1489-93848&t=igC9QPO7ZOgBrTij-4"
77+
}
78+
</example-meta>

packages/docs/src/i18n/messages/en.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -138,6 +138,7 @@
138138
"discord": "Discord",
139139
"done": "All done",
140140
"edit-in-playground": "Edit in Vuetify Playground",
141+
"view-in-figma": "View in Figma",
141142
"edit-this-page": "Edit this page on",
142143
"edit": "Edit",
143144
"enable-banners": "Enable banners",

packages/docs/src/plugins/vuetify.ts

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,16 @@ export function installVuetify (app: App) {
114114
},
115115
},
116116
},
117-
aliases,
117+
aliases: {
118+
...aliases,
119+
figma: [
120+
['M11.667 2H8.333a3.333 3.333 0 1 0 0 6.667h3.334z', 0.8],
121+
['M11.667 8.667H8.333a3.333 3.333 0 0 0 0 6.666h3.334z', 0.6],
122+
['M18.333 12a3.333 3.333 0 1 1-6.667 0a3.333 3.333 0 0 1 6.667 0', 1],
123+
['M8.333 15.334h3.334v3.333a3.333 3.333 0 1 1-3.334-3.334', 0.4],
124+
['M11.666 2h3.333a3.333 3.333 0 1 1 0 6.667h-3.333z', 1],
125+
],
126+
},
118127
},
119128
theme: {
120129
themes: {

packages/docs/vite.config.mts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -293,6 +293,7 @@ export default defineConfig(({ command, mode, isSsrBuild }) => {
293293
transform (code, id) {
294294
const type = id.includes('vue&type=playground-resources') ? 'playgroundResources'
295295
: id.includes('vue&type=playground-setup') ? 'playgroundSetup'
296+
: id.includes('vue&type=example-meta') ? 'exampleMeta'
296297
: null
297298
if (!type) return
298299

0 commit comments

Comments
 (0)