Skip to content

Commit fb5bd17

Browse files
authored
Initialize sky nav JS for all prototypes that use the sky nav (#1503)
1 parent a1cbf85 commit fb5bd17

File tree

5 files changed

+36
-10
lines changed

5 files changed

+36
-10
lines changed

package-lock.json

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import singleArticlePrototype from './example/example.twig';
2+
import { useSkyNav } from '../use-sky-nav.ts';
23

34
export default {
45
title: 'Prototypes/Single Article',
@@ -7,4 +8,7 @@ export default {
78
},
89
};
910

10-
export const Example = () => singleArticlePrototype({});
11+
export const Example = () => {
12+
useSkyNav();
13+
return singleArticlePrototype({});
14+
};
Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import singlePagePrototype from './example/example.twig';
22
import './example/example.scss';
33
import devices from './data/devices.json';
4+
import { useSkyNav } from '../use-sky-nav.ts';
45

56
export default {
67
title: 'Prototypes/Single Page',
@@ -9,7 +10,9 @@ export default {
910
},
1011
};
1112

12-
export const Example = () =>
13-
singlePagePrototype({
13+
export const Example = () => {
14+
useSkyNav();
15+
return singlePagePrototype({
1416
devices,
1517
});
18+
};

src/prototypes/team/team.stories.js

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import teamIndividualPrototype from './example/team-individual.twig';
33
import teamArticlePage2 from './example/team-articles-page2.twig';
44
import avatars from './data/avatars.json';
55
import './example/team-individual.scss';
6+
import { useSkyNav } from '../use-sky-nav.ts';
67

78
export default {
89
title: 'Prototypes/Team Page',
@@ -12,14 +13,21 @@ export default {
1213
},
1314
};
1415

15-
export const List = () =>
16-
teamListPrototype({
16+
export const List = () => {
17+
useSkyNav();
18+
return teamListPrototype({
1719
avatars,
1820
});
21+
};
1922

20-
export const IndividualBio = () =>
21-
teamIndividualPrototype({
23+
export const IndividualBio = () => {
24+
useSkyNav();
25+
return teamIndividualPrototype({
2226
avatars,
2327
});
28+
};
2429

25-
export const ArticlesPage2 = () => teamArticlePage2({});
30+
export const ArticlesPage2 = () => {
31+
useSkyNav();
32+
return teamArticlePage2({});
33+
};

src/prototypes/use-sky-nav.ts

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
import { useEffect } from '@storybook/client-api';
2+
import { initSkyNav } from '../components/sky-nav/sky-nav';
3+
4+
export const useSkyNav = () => {
5+
useEffect(() => {
6+
const { destroy } = initSkyNav(
7+
document.querySelector('.js-sky-nav-menu-toggle')
8+
);
9+
return destroy;
10+
}, []);
11+
}

0 commit comments

Comments
 (0)