Skip to content

Commit bad256b

Browse files
committed
✨(frontend) add right panel
Add a right panel, it will in a first time be used to display the comment side panel, but it will be used in the future for other features as well.
1 parent 0bfc697 commit bad256b

7 files changed

Lines changed: 136 additions & 34 deletions

File tree

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,2 @@
11
export * from './useEditorStore';
22
export * from './useHeadingStore';
3-
export * from './usePanelEditorStore';

src/frontend/apps/impress/src/features/docs/doc-editor/stores/usePanelEditorStore.tsx

Lines changed: 0 additions & 19 deletions
This file was deleted.

src/frontend/apps/impress/src/features/docs/doc-header/components/FloatingBar.tsx

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import { css } from 'styled-components';
44
import { Box } from '@/components';
55
import { useCunninghamTheme } from '@/cunningham/useCunninghamTheme';
66
import { LeftPanelCollapseButton } from '@/features/left-panel';
7+
import { RightPanelCollapseButton } from '@/features/right-panel/components/RightPanelCollapseButton';
78
import { useResponsiveStore } from '@/stores';
89

910
/**
@@ -22,19 +23,15 @@ export const FloatingBar = () => {
2223
const sm = spacingsTokens['sm'];
2324
return css`
2425
position: sticky;
25-
top: calc(-${base});
26+
top: 0;
2627
left: 0;
2728
right: 0;
28-
width: calc(100% + ${base} + ${base});
29+
width: 100%;
2930
min-height: 64px;
3031
padding: ${sm};
31-
margin-left: calc(-${base});
32-
margin-right: calc(-${base});
3332
margin-top: calc(-${base});
3433
z-index: 21; // Under editor select box but above other elements (e.g., doc title, suggestion menu)
35-
display: flex;
3634
align-items: flex-start;
37-
justify-content: flex-start;
3835
isolation: isolate;
3936
4037
&::before {
@@ -73,8 +70,11 @@ export const FloatingBar = () => {
7370
className="--docs--floating-bar"
7471
data-testid="floating-bar"
7572
$css={FLOATING_STYLES}
73+
$direction="row"
74+
$justify="space-between"
7675
>
7776
<LeftPanelCollapseButton />
77+
<RightPanelCollapseButton />
7878
</Box>
7979
);
8080
};
Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
import { useTranslation } from 'react-i18next';
2+
import { css } from 'styled-components';
3+
4+
import { Box } from '@/components';
5+
import { useDocStore, useProviderStore } from '@/features/docs/doc-management';
6+
import { HEADER_HEIGHT } from '@/features/header';
7+
8+
import { useRightPanelStore } from './useRightPanelStore';
9+
10+
export const RightPanel = () => {
11+
const { t } = useTranslation();
12+
const { currentDoc: doc } = useDocStore();
13+
const { _, isPanelOpen } = useRightPanelStore();
14+
const { provider, isReady } = useProviderStore();
15+
const isProviderReady =
16+
isReady && provider && provider?.configuration.name === doc?.id;
17+
18+
if (!doc || !isProviderReady) {
19+
return null;
20+
}
21+
22+
return (
23+
<Box
24+
className="--docs--right-panel"
25+
aria-label={t('Right panel')}
26+
aria-hidden={!isPanelOpen}
27+
$width="300px"
28+
$height={`calc(100dvh - ${HEADER_HEIGHT}px)`}
29+
$position="sticky"
30+
$hasTransition
31+
$background="var(--c--contextuals--background--surface--secondary)"
32+
$css={css`
33+
flex-shrink: 0;
34+
border-left: 1px solid var(--c--contextuals--border--surface--primary);
35+
transform: translateX(0%);
36+
top: 0;
37+
align-self: flex-start;
38+
opacity: 1;
39+
${!isPanelOpen &&
40+
css`
41+
transform: translateX(200%);
42+
opacity: 0;
43+
margin-left: 0rem;
44+
width: 0;
45+
`}
46+
`}
47+
></Box>
48+
);
49+
};
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
import { Button } from '@gouvfr-lasuite/cunningham-react';
2+
import { useTranslation } from 'react-i18next';
3+
import { css } from 'styled-components';
4+
5+
import CommentsIcon from '@/assets/icons/ui-kit/bubble-text.svg';
6+
import { Card } from '@/components';
7+
8+
import { useRightPanelStore } from './useRightPanelStore';
9+
10+
export const RightPanelCollapseButton = () => {
11+
const { t } = useTranslation();
12+
const { isPanelOpen, togglePanel } = useRightPanelStore();
13+
14+
const ariaLabel = isPanelOpen
15+
? t('Hide the right side panel')
16+
: t('Show the right side panel');
17+
18+
return (
19+
<Card
20+
className="--docs--right-panel-collapse-button"
21+
$direction="row"
22+
$css={css`
23+
padding: var(--c--globals--spacings--xxxs);
24+
align-items: center;
25+
gap: var(--c--globals--spacings--xxxs);
26+
border-radius: var(--c--globals--spacings--xs);
27+
box-shadow: 0 2px 4px 0 rgba(0, 0, 0, 0.05);
28+
`}
29+
>
30+
<Button
31+
size="small"
32+
onClick={togglePanel}
33+
aria-label={ariaLabel}
34+
aria-expanded={isPanelOpen}
35+
color="neutral"
36+
variant={isPanelOpen ? 'secondary' : 'tertiary'}
37+
icon={<CommentsIcon width={24} height={24} aria-hidden="true" />}
38+
data-testid="floating-bar-toggle-right-panel"
39+
></Button>
40+
</Card>
41+
);
42+
};
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
import { create } from 'zustand';
2+
3+
export interface UseRightPanelStore {
4+
isPanelOpen: boolean;
5+
setIsPanelOpen: (isOpen: boolean) => void;
6+
togglePanel: () => void;
7+
}
8+
9+
export const useRightPanelStore = create<UseRightPanelStore>((set) => ({
10+
isPanelOpen: false,
11+
setIsPanelOpen: (isPanelOpen) => {
12+
set(() => ({ isPanelOpen }));
13+
},
14+
togglePanel: () => {
15+
set((state) => ({ isPanelOpen: !state.isPanelOpen }));
16+
},
17+
}));

src/frontend/apps/impress/src/layouts/MainLayout.tsx

Lines changed: 22 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,11 @@ import { PropsWithChildren } from 'react';
22
import { useTranslation } from 'react-i18next';
33
import { css } from 'styled-components';
44

5-
import { Box } from '@/components';
5+
import { Box, BoxProps } from '@/components';
66
import { Header } from '@/features/header';
77
import { HEADER_HEIGHT } from '@/features/header/conf';
88
import { LeftPanel, ResizableLeftPanel } from '@/features/left-panel';
9+
import { RightPanel } from '@/features/right-panel/components/RightPanel';
910
import { DocEditorSkeleton, Skeleton } from '@/features/skeletons';
1011
import { useResponsiveStore } from '@/stores';
1112

@@ -43,20 +44,29 @@ export function MainLayout({
4344

4445
export interface MainLayoutContentProps {
4546
backgroundColor: 'white' | 'grey';
46-
enableResizablePanel?: boolean;
47+
enableResizablePanel: boolean;
4748
}
4849

4950
export function MainLayoutContent({
5051
children,
5152
backgroundColor,
52-
enableResizablePanel = false,
53+
enableResizablePanel,
5354
}: PropsWithChildren<MainLayoutContentProps>) {
5455
const { isDesktop } = useResponsiveStore();
5556

5657
if (enableResizablePanel) {
5758
return (
5859
<ResizableLeftPanel leftPanel={<LeftPanel />}>
59-
<MainContent backgroundColor={backgroundColor}>{children}</MainContent>
60+
<Box $direction="row" $width="100%">
61+
<MainContent
62+
backgroundColor={backgroundColor}
63+
$flex="auto"
64+
$padding="0"
65+
>
66+
{children}
67+
</MainContent>
68+
<RightPanel />
69+
</Box>
6070
</ResizableLeftPanel>
6171
);
6272
}
@@ -86,10 +96,15 @@ export function MainLayoutContent({
8696
);
8797
}
8898

99+
type MainContentProps = BoxProps & {
100+
backgroundColor: 'white' | 'grey';
101+
};
102+
89103
const MainContent = ({
90104
children,
91105
backgroundColor,
92-
}: PropsWithChildren<MainLayoutContentProps>) => {
106+
...props
107+
}: PropsWithChildren<MainContentProps>) => {
93108
const { isDesktop } = useResponsiveStore();
94109

95110
const { t } = useTranslation();
@@ -106,9 +121,7 @@ const MainContent = ({
106121
$width="100%"
107122
$height={`calc(100dvh - ${HEADER_HEIGHT}px)`}
108123
$position="relative"
109-
$padding={{
110-
all: isDesktop ? 'base' : '0',
111-
}}
124+
$padding={isDesktop ? 'base' : '0'}
112125
$background={
113126
currentBackgroundColor === 'white'
114127
? 'var(--c--contextuals--background--surface--primary)'
@@ -118,6 +131,7 @@ const MainContent = ({
118131
overflow-y: auto;
119132
overflow-x: clip;
120133
`}
134+
{...props}
121135
>
122136
<Skeleton>
123137
<DocEditorSkeleton />

0 commit comments

Comments
 (0)