Skip to content

Commit 35c7668

Browse files
authored
Merge pull request #654 from dnum-mi/fix/issue#621
Fix/issue#621
2 parents 1bd0ded + 50a019e commit 35c7668

File tree

8 files changed

+28
-68
lines changed

8 files changed

+28
-68
lines changed

.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;

src/components/DsfrHeader/DsfrHeader.types.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
11
import type { HTMLAttributes, StyleValue } from 'vue'
22
import type { RouteLocationRaw } from 'vue-router'
3+
import { OhVueIcon } from 'oh-vue-icons'
34

45
export type DsfrHeaderMenuLinkProps = {
56
button?: boolean
67
icon?: string
7-
iconAttrs?: HTMLAttributes
8+
iconAttrs?: InstanceType<typeof OhVueIcon>['$props'] & HTMLAttributes
89
iconRight?: boolean
910
label?: string
1011
target?: string

src/components/DsfrHeader/DsfrHeaderMenuLink.vue

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ const linkData = computed(() => {
5858
@click.stop="onClick"
5959
>
6060
<template
61-
v-if="(icon || iconAttrs) && !iconRight"
61+
v-if="(icon || iconAttrs?.name) && !iconRight"
6262
>
6363
<VIcon
6464
:name="icon"
@@ -70,7 +70,7 @@ const linkData = computed(() => {
7070
{{ label }}
7171

7272
<template
73-
v-if="(icon || iconAttrs) && iconRight"
73+
v-if="(icon || iconAttrs?.name) && iconRight"
7474
>
7575
<VIcon
7676
:name="icon"

src/components/DsfrNavigation/DsfrNavigation.stories.ts

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,5 @@
1-
import { setup } from '@storybook/vue3'
2-
31
import DsfrNavigation from './DsfrNavigation.vue'
42

5-
const RouterLink = {
6-
name: 'RouterLink',
7-
props: {
8-
to: String,
9-
},
10-
template: `
11-
<a :href="to" v-bind="$attrs"><slot /></a>
12-
`,
13-
}
14-
15-
setup(app => {
16-
app.component('RouterLink', RouterLink)
17-
})
18-
193
/**
204
* [Voir quand l’utiliser sur la documentation du DSFR](https://www.systeme-de-design.gouv.fr/elements-d-interface/composants/navigation-principale)
215
*/

src/components/DsfrNavigation/DsfrNavigationMegaMenuCategory.stories.ts

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -3,22 +3,6 @@ import DsfrNavigationItem from './DsfrNavigationItem.vue'
33
import DsfrNavigationMegaMenu from './DsfrNavigationMegaMenu.vue'
44
import DsfrNavigationMegaMenuCategory from './DsfrNavigationMegaMenuCategory.vue'
55

6-
import { setup } from '@storybook/vue3'
7-
8-
const RouterLink = {
9-
name: 'RouterLink',
10-
props: {
11-
to: String,
12-
},
13-
template: `
14-
<a :href="to" v-bind="$attrs"><slot /></a>
15-
`,
16-
}
17-
18-
setup(app => {
19-
app.component('RouterLink', RouterLink)
20-
})
21-
226
export default {
237
component: DsfrNavigationMegaMenuCategory,
248
title: 'Composants/DsfrNavigationMegaMenuCategory',

src/components/DsfrNavigation/DsfrNavigationMenuItem.stories.ts

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -4,22 +4,6 @@ import DsfrNavigationMenu from './DsfrNavigationMenu.vue'
44
import DsfrNavigationMenuItem from './DsfrNavigationMenuItem.vue'
55
import DsfrNavigationMenuLink from './DsfrNavigationMenuLink.vue'
66

7-
import { setup } from '@storybook/vue3'
8-
9-
const RouterLink = {
10-
name: 'RouterLink',
11-
props: {
12-
to: String,
13-
},
14-
template: `
15-
<a :href="to" v-bind="$attrs"><slot /></a>
16-
`,
17-
}
18-
19-
setup(app => {
20-
app.component('RouterLink', RouterLink)
21-
})
22-
237
export default {
248
component: DsfrNavigationMenuItem,
259
title: 'Composants/DsfrNavigationMenuItem',

src/components/DsfrNavigation/DsfrNavigationMenuLink.stories.ts

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,11 @@
11
import DsfrNavigationMenuLink from './DsfrNavigationMenuLink.vue'
22
import DsfrNavigation from './DsfrNavigation.vue'
33

4-
import { setup } from '@storybook/vue3'
5-
64
import { addIcons } from 'oh-vue-icons'
75
import { RiHome2Line } from 'oh-vue-icons/icons/ri/index.js'
86

97
addIcons(RiHome2Line)
108

11-
const RouterLink = {
12-
name: 'RouterLink',
13-
props: {
14-
to: String,
15-
},
16-
template: `
17-
<a :href="to" v-bind="$attrs"><slot /></a>
18-
`,
19-
}
20-
21-
setup(app => {
22-
app.component('RouterLink', RouterLink)
23-
})
24-
259
export default {
2610
component: DsfrNavigationMenuLink,
2711
title: 'Composants/DsfrNavigationMenuLink',

vite.config.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,10 @@ const projectDir = dirname(new URL(import.meta.url).pathname)
1010
const isVitepress = process.env.VITEPRESS === 'true'
1111

1212
const config: UserConfig = {
13-
plugins: [vue(), vueJsx()],
13+
plugins: [
14+
vue(),
15+
vueJsx(),
16+
],
1417
resolve: {
1518
alias: {
1619
'@': fileURLToPath(new URL('./src', import.meta.url)),

0 commit comments

Comments
 (0)