Skip to content

Commit 180d055

Browse files
authored
Merge pull request #653 from dnum-mi/develop
Develop
2 parents 7588987 + 28f1346 commit 180d055

File tree

165 files changed

+9155
-3985
lines changed

Some content is hidden

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

165 files changed

+9155
-3985
lines changed

.gitignore

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -322,3 +322,8 @@ $RECYCLE.BIN/
322322
# End of https://www.toptal.com/developers/gitignore/api/node,visualstudiocode,intellij,windows,macos,linux
323323
stats.html
324324
types/
325+
326+
327+
# Vitepress
328+
.vitepress/dist
329+
.vitepress/cache

.storybook/main.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ const config: StorybookConfig = {
1010
'@storybook/addon-a11y',
1111
'@storybook/addon-styling',
1212
],
13-
staticsDir: ['../public'],
1413
framework: {
1514
name: '@storybook/vue3-vite',
1615
options: {},

.storybook/preview.ts

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
11
import type { Preview } from "@storybook/vue3"
2+
import { setup } from "@storybook/vue3"
23
import { themes } from '@storybook/theming'
34
import { withThemeByDataAttribute } from "@storybook/addon-styling"
5+
import { FocusTrap } from 'focus-trap-vue'
6+
import { defineComponent } from 'vue'
7+
import { OhVueIcon as VIcon} from 'oh-vue-icons'
48

59
import VueDsfrTheme from './vue-dsfr-theme.js'
610
import '../src/assets/variables-fdr.css'
@@ -89,4 +93,20 @@ const preview: Preview = {
8993
},
9094
}
9195

96+
const RouterLink = defineComponent({
97+
name: 'RouterLink',
98+
props: {
99+
to: String,
100+
},
101+
template: `
102+
<a :href="to" v-bind="$attrs"><slot /></a>
103+
`,
104+
})
105+
106+
setup(app => {
107+
app.component('RouterLink', RouterLink);
108+
app.component('VIcon', VIcon)
109+
app.component('FocusTrap', FocusTrap)
110+
})
111+
92112
export default preview;

.vitepress/config.ts

Lines changed: 128 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,128 @@
1+
import { fileURLToPath, URL } from 'url'
2+
3+
import { defineConfig } from 'vitepress'
4+
import { whyframe } from '@whyframe/core'
5+
import { whyframeVue } from '@whyframe/vue'
6+
import { hmrFix } from './plugins/hmrFix.js'
7+
8+
// https://vitepress.dev/reference/site-config
9+
export default defineConfig({
10+
title: "VueDsfr",
11+
description: "Une documentation pour les utilisateurs de VueDsfr",
12+
13+
cleanUrls: true,
14+
appearance: { listenToStorageChanges: false }, // handling this in Story.vue itself to avoid flickering
15+
16+
rewrites: {
17+
'src/components/:comp/:comp.md': 'composants/:comp.md',
18+
'docs/:splat*': ':splat*',
19+
},
20+
21+
themeConfig: {
22+
search: {
23+
provider: 'local',
24+
options: {
25+
translations: {
26+
button: {
27+
buttonText: 'Rechercher...',
28+
buttonAriaLabel: 'Rechercher'
29+
},
30+
modal: {
31+
backButtonTitle: 'effacer la recherche',
32+
displayDetails: 'afficher les détails',
33+
noResultsText: 'Aucun résultat pour ',
34+
resetButtonTitle: 'resetButtonTitle',
35+
footer: {
36+
selectText: 'aller à ce texte',
37+
navigateText: 'naviguer dans les résultats',
38+
closeText: 'fermer'
39+
}
40+
}
41+
},
42+
}
43+
},
44+
outline:{
45+
level: [2, 3],
46+
label: 'Sur cette page :',
47+
},
48+
logo: '/nouveau-logo-marianne-gouvernement.png',
49+
// https://vitepress.dev/reference/default-theme-config
50+
nav: [
51+
{ text: 'Home', link: '/' },
52+
],
53+
54+
sidebar: [
55+
{
56+
text: 'Pour commencer',
57+
collapsed: false,
58+
items: [
59+
{
60+
text: 'Commencer',
61+
link: '/pour-commencer',
62+
},
63+
{
64+
text: 'L’écosystème',
65+
link: '/ecosysteme',
66+
},
67+
{
68+
text: 'Les icônes',
69+
link: '/icones',
70+
},
71+
{
72+
text: 'Guide du développeur',
73+
link: '/guide-developpeur',
74+
},
75+
]
76+
},
77+
{
78+
text: 'Tous les types',
79+
link: '/types',
80+
items: []
81+
},
82+
{
83+
text: 'Tous les composants',
84+
link: '/composants',
85+
collapsed: false,
86+
items: [
87+
{
88+
text: 'DsfrAlert',
89+
link: '/composants/DsfrAlert.md',
90+
},
91+
{
92+
text: 'DsfrBadge',
93+
link: '/composants/DsfrBadge.md',
94+
},
95+
]
96+
},
97+
{
98+
text: 'Recettes nuxt',
99+
link: '/nuxt/',
100+
},
101+
],
102+
103+
socialLinks: [
104+
{ icon: 'github', link: 'https://github.com/dnum-mi/vue-dsfr' }
105+
]
106+
},
107+
108+
vite: {
109+
plugins: [
110+
whyframe({ defaultSrc: '/_frame', components: [{ name: 'Story' }] }),
111+
whyframeVue({ include: /\.(vue|md)$/ }),
112+
hmrFix()
113+
],
114+
115+
resolve: {
116+
alias: {
117+
'@': fileURLToPath(new URL('../src', import.meta.url)),
118+
}
119+
},
120+
121+
// not needed, just there to prevent reload on cold start
122+
optimizeDeps: {
123+
include: [
124+
'@vueuse/core',
125+
]
126+
}
127+
},
128+
})

.vitepress/plugins/hmrFix.ts

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
import { fileURLToPath } from 'node:url'
2+
import fullReload from 'vite-plugin-full-reload'
3+
import type { Plugin } from 'vitepress'
4+
5+
const styles = fileURLToPath(
6+
new URL('../../src/styles/index.css', import.meta.url)
7+
)
8+
9+
export const hmrFix = () => {
10+
return [
11+
{
12+
name: 'tw:hmr-fix',
13+
async handleHotUpdate({ file, modules, server }) {
14+
if (/[\\/]src[\\/].*\.vue$/.test(file)) {
15+
return [
16+
...modules,
17+
...(server.moduleGraph.getModulesByFile(styles) || [])
18+
]
19+
}
20+
}
21+
} satisfies Plugin,
22+
fullReload(['./docs/_frame.md'])
23+
]
24+
}

.vitepress/theme/Story.vue

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
<script setup lang="ts">
2+
import { ref, watchEffect, onMounted } from 'vue'
3+
import { useData } from 'vitepress'
4+
5+
const iframe = ref<HTMLIFrameElement>()
6+
const { isDark } = useData()
7+
8+
withDefaults(defineProps<{
9+
minH?: string
10+
dark?: boolean
11+
storyTitle?: string
12+
}>(), {
13+
minH: '100px',
14+
storyTitle: 'Story',
15+
})
16+
17+
watchEffect(() => {
18+
const { contentDocument: doc, contentWindow: win } = iframe.value || {}
19+
if (!doc || !win) return
20+
21+
const css = doc.createElement('style')
22+
css.appendChild(doc.createTextNode(`*{transition:none!important}`))
23+
doc.head.appendChild(css)
24+
25+
doc.documentElement.setAttribute('data-fr-theme', isDark.value ? 'dark' : 'light')
26+
27+
const _ = win.getComputedStyle(css).opacity
28+
doc.head.removeChild(css)
29+
})
30+
31+
onMounted(() => {
32+
setTimeout(() => {
33+
const { contentDocument: doc, contentWindow: win } = iframe.value || {}
34+
if (!doc || !win) return
35+
36+
doc.documentElement.setAttribute('data-fr-theme', isDark.value ? 'dark' : 'light')
37+
}, 1000)
38+
})
39+
</script>
40+
41+
<template>
42+
<div class="vp-block active" >
43+
<iframe data-why :title="storyTitle" ref="iframe">
44+
<slot />
45+
</iframe>
46+
</div>
47+
</template>
48+
49+
<style scoped>
50+
iframe[data-why] {
51+
border: 0;
52+
width: 100%;
53+
min-height: v-bind(minH);
54+
visibility: hidden;
55+
}
56+
</style>

.vitepress/theme/VIconLink.vue

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
<script setup lang="ts">
2+
import { type OhVueIcon as VIcon } from 'oh-vue-icons'
3+
4+
withDefaults(defineProps<{
5+
href: string
6+
rel?: string
7+
target?: string
8+
icon?: string | InstanceType<typeof VIcon>['$props']
9+
iconLeft: string | InstanceType<typeof VIcon>['$props']
10+
}>(), {
11+
rel: 'noreferrer',
12+
target: '_blank',
13+
})
14+
</script>
15+
16+
<template>
17+
<a :href="href" :target="target" :rel="rel">
18+
<VIcon v-if="iconLeft" style="margin-right: 0.125rem;" v-bind="typeof iconLeft == 'object' ? iconLeft : { name: iconLeft }" />
19+
<slot />
20+
<VIcon v-if="icon" style="margin-left: 0.125rem;" v-bind="typeof icon == 'object' ? icon : { name: icon }" />
21+
</a>
22+
</template>

.vitepress/theme/icons.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
export {
2+
RiCloseLine,
3+
RiArrowDropDownLine,
4+
RiArrowDropUpLine,
5+
SiDiscord,
6+
SiGithub,
7+
SiNpm,
8+
SiVisualstudiocode,
9+
} from 'oh-vue-icons/icons'

.vitepress/theme/index.ts

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
import type { Theme } from 'vitepress'
2+
import DefaultTheme from 'vitepress/theme'
3+
import { OhVueIcon as VIcon, addIcons } from 'oh-vue-icons'
4+
5+
import Story from './Story.vue'
6+
import VIconLink from './VIconLink.vue'
7+
import * as vpIcons from './icons'
8+
9+
import './style.css'
10+
11+
addIcons(...Object.values(vpIcons))
12+
13+
export default {
14+
extends: DefaultTheme,
15+
enhanceApp({ app }) {
16+
app.component('VIcon', VIcon)
17+
app.component('VIconLink', VIconLink)
18+
app.component('Story', Story)
19+
}
20+
} satisfies Theme

0 commit comments

Comments
 (0)