Skip to content

Commit aaecaf0

Browse files
committed
✨(frontend) add onboarding modal with help menu button
integrate onboarding feature accessible from left panel help menu
1 parent 7cf42e6 commit aaecaf0

File tree

6 files changed

+267
-6
lines changed

6 files changed

+267
-6
lines changed

src/frontend/apps/impress/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@
3636
"@fontsource/material-icons": "5.2.7",
3737
"@gouvfr-lasuite/cunningham-react": "4.1.0",
3838
"@gouvfr-lasuite/integration": "1.0.3",
39-
"@gouvfr-lasuite/ui-kit": "0.18.7",
39+
"@gouvfr-lasuite/ui-kit": "0.19.5",
4040
"@hocuspocus/provider": "3.4.3",
4141
"@mantine/core": "8.3.12",
4242
"@mantine/hooks": "8.3.12",
Lines changed: 3 additions & 0 deletions
Loading

src/frontend/apps/impress/src/features/left-panel/components/LeftPanel.tsx

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ import { useLeftPanelStore } from '../stores';
1414

1515
import { LeftPanelContent } from './LeftPanelContent';
1616
import { LeftPanelHeader } from './LeftPanelHeader';
17+
import { LeftPanelHelpMenu } from './LeftPanelHelpMenu';
1718

1819
const MobileLeftPanelStyle = createGlobalStyle`
1920
body {
@@ -57,6 +58,14 @@ export const LeftPanel = () => {
5758
<LeftPanelHeader />
5859
</Box>
5960
<LeftPanelContent />
61+
<SeparatedSection showSeparator={false}>
62+
<Box
63+
$padding={{ horizontal: 'sm', vertical: 'xs' }}
64+
$justify="flex-start"
65+
>
66+
<LeftPanelHelpMenu />
67+
</Box>
68+
</SeparatedSection>
6069
</Box>
6170
)}
6271

@@ -91,6 +100,14 @@ export const LeftPanel = () => {
91100
>
92101
<LeftPanelHeader />
93102
<LeftPanelContent />
103+
<SeparatedSection showSeparator={false}>
104+
<Box
105+
$padding={{ horizontal: 'sm', vertical: 'xs' }}
106+
$justify="flex-start"
107+
>
108+
<LeftPanelHelpMenu />
109+
</Box>
110+
</SeparatedSection>
94111
<SeparatedSection showSeparator={false}>
95112
<Box
96113
$justify="center"
Lines changed: 112 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,112 @@
1+
import { Button } from '@gouvfr-lasuite/cunningham-react';
2+
import {
3+
DropdownMenu,
4+
DropdownMenuOption,
5+
OnboardingModal,
6+
OnboardingStep,
7+
} from '@gouvfr-lasuite/ui-kit';
8+
import { type MouseEvent, useCallback, useMemo, useState } from 'react';
9+
import { useTranslation } from 'react-i18next';
10+
import { css } from 'styled-components';
11+
12+
import WandAndStarsIcon from '@/assets/icons/wand-and-stars.svg';
13+
import { Box, Icon } from '@/components';
14+
15+
export const LeftPanelHelpMenu = () => {
16+
const { t } = useTranslation();
17+
const [isMenuOpen, setIsMenuOpen] = useState(false);
18+
const [isModalOpen, setIsModalOpen] = useState(false);
19+
20+
const openModal = useCallback(() => {
21+
setIsModalOpen(true);
22+
}, []);
23+
24+
const closeModal = useCallback(() => {
25+
setIsModalOpen(false);
26+
}, []);
27+
28+
const toggleMenu = useCallback(
29+
(event: MouseEvent<HTMLButtonElement | HTMLAnchorElement>) => {
30+
event.preventDefault();
31+
event.stopPropagation();
32+
setIsMenuOpen((open) => !open);
33+
},
34+
[],
35+
);
36+
37+
const steps = useMemo<OnboardingStep[]>(
38+
() => [
39+
{
40+
icon: <Icon iconName="edit" $size="20px" aria-hidden="true" />,
41+
title: t('Onboarding step 1 title'),
42+
description: t('Onboarding step 1 description'),
43+
},
44+
{
45+
icon: <Icon iconName="account_tree" $size="20px" aria-hidden="true" />,
46+
title: t('Onboarding step 2 title'),
47+
description: t('Onboarding step 2 description'),
48+
},
49+
{
50+
icon: <Icon iconName="share" $size="20px" aria-hidden="true" />,
51+
title: t('Onboarding step 3 title'),
52+
description: t('Onboarding step 3 description'),
53+
},
54+
],
55+
[t],
56+
);
57+
58+
const options = useMemo<DropdownMenuOption[]>(
59+
() => [
60+
{
61+
label: t('Onboarding'),
62+
icon: <WandAndStarsIcon aria-hidden="true" />,
63+
callback: openModal,
64+
},
65+
],
66+
[openModal, t],
67+
);
68+
69+
return (
70+
<>
71+
<Box
72+
$css={css`
73+
.c__dropdown-menu-trigger {
74+
display: flex;
75+
justify-content: flex-start;
76+
}
77+
`}
78+
>
79+
<DropdownMenu
80+
options={options}
81+
isOpen={isMenuOpen}
82+
onOpenChange={setIsMenuOpen}
83+
>
84+
<Button
85+
aria-label={t('Open onboarding menu')}
86+
color="neutral"
87+
variant="tertiary"
88+
iconPosition="left"
89+
icon={
90+
<Icon
91+
$withThemeInherited
92+
iconName="help_outline"
93+
aria-hidden="true"
94+
/>
95+
}
96+
onClick={toggleMenu}
97+
/>
98+
</DropdownMenu>
99+
</Box>
100+
101+
<OnboardingModal
102+
isOpen={isModalOpen}
103+
appName={t('Docs')}
104+
mainTitle={t('Docs onboarding title')}
105+
steps={steps}
106+
hideContent
107+
onClose={closeModal}
108+
onComplete={closeModal}
109+
/>
110+
</>
111+
);
112+
};

0 commit comments

Comments
 (0)