Skip to content

Commit 0f514e0

Browse files
committed
📱(frontend) reduce breakpoint mobile view
Most of the application was switching to mobile view at the medium breakpoint. Medium breakpoint let enough place to display most of the application features and it is more user friendly to switch to mobile view at the small breakpoint. We are switching to mobile view at the small breakpoint to give more place to the application features and to be more user friendly.
1 parent 39c8532 commit 0f514e0

12 files changed

Lines changed: 61 additions & 49 deletions

File tree

src/frontend/apps/e2e/__tests__/app-impress/left-panel.spec.ts

Lines changed: 20 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -84,16 +84,13 @@ test.describe('Left panel desktop', () => {
8484
});
8585
});
8686

87-
test.describe('Left panel mobile', () => {
88-
test.use({ viewport: { width: 500, height: 1200 } });
89-
90-
test.beforeEach(async ({ page }) => {
91-
await page.goto('/');
92-
});
93-
94-
test('checks all the desktop elements are hidden and all mobile elements are visible', async ({
87+
test.describe('Left panel responsive', () => {
88+
test('checks elements visibility on different screen sizes', async ({
9589
page,
9690
}) => {
91+
await page.setViewportSize({ width: 500, height: 1200 });
92+
await page.goto('/');
93+
9794
await expect(page.getByTestId('left-panel-desktop')).toBeHidden();
9895
await expect(page.getByTestId('left-panel-mobile')).not.toBeInViewport();
9996

@@ -120,12 +117,27 @@ test.describe('Left panel mobile', () => {
120117
await expect(newDocButton).toBeInViewport();
121118
await expect(languageButton).toBeInViewport();
122119
await expect(logoutButton).toBeInViewport();
120+
121+
await header.getByLabel('Close the header menu').click();
122+
123+
// Tablet size - like in desktop, left panel should be visible
124+
await page.setViewportSize({ width: 900, height: 1200 });
125+
await page.goto('/');
126+
127+
await expect(page.getByRole('link', { name: 'All docs' })).toBeInViewport();
128+
await expect(newDocButton).toBeInViewport();
129+
await expect(languageButton).toBeInViewport();
130+
await expect(logoutButton).toBeInViewport();
131+
await expect(header.getByLabel('Open the header menu')).toBeHidden();
123132
});
124133

125134
test('checks panel closes when clicking on a subdoc', async ({
126135
page,
127136
browserName,
128137
}) => {
138+
await page.setViewportSize({ width: 500, height: 1200 });
139+
await page.goto('/');
140+
129141
const [docTitle] = await createDoc(
130142
page,
131143
'mobile-doc-test',
@@ -162,12 +174,4 @@ test.describe('Left panel mobile', () => {
162174
await verifyDocName(page, docChild);
163175
await expect(page.getByTestId('left-panel-mobile')).not.toBeInViewport();
164176
});
165-
166-
test('checks resize handle is not present on mobile', async ({ page }) => {
167-
await page.goto('/');
168-
169-
// Verify the resize handle is NOT present on mobile
170-
const resizeHandle = page.locator('[data-panel-resize-handle-id]');
171-
await expect(resizeHandle).toBeHidden();
172-
});
173177
});

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

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ const DocTitleEmojiPicker = ({ doc }: DocTitleProps) => {
110110
};
111111

112112
const DocTitleInput = ({ doc }: DocTitleProps) => {
113-
const { isDesktop } = useResponsiveStore();
113+
const { isLargeScreen } = useResponsiveStore();
114114
const { t } = useTranslation();
115115
const { isTopRoot } = useDocUtils(doc);
116116
const { untitledDocument } = useTrans();
@@ -227,9 +227,9 @@ const DocTitleInput = ({ doc }: DocTitleProps) => {
227227
pointer-events: none;
228228
font-style: italic;
229229
}
230-
font-size: ${isDesktop
231-
? css`var(--c--globals--font--sizes--h2)`
232-
: css`var(--c--globals--font--sizes--sm)`};
230+
font-size: ${isLargeScreen
231+
? 'var(--c--globals--font--sizes--h2)'
232+
: 'var(--c--globals--font--sizes--sm)'};
233233
font-weight: 700;
234234
outline: none;
235235
`}

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ import { useResponsiveStore } from '@/stores';
1616
*/
1717
export const FloatingBar = () => {
1818
const { spacingsTokens } = useCunninghamTheme();
19-
const { isDesktop } = useResponsiveStore();
19+
const { isLargeScreen } = useResponsiveStore();
2020

2121
const FLOATING_STYLES = useMemo(() => {
2222
const base = spacingsTokens['base'];
@@ -69,7 +69,7 @@ export const FloatingBar = () => {
6969
$direction="row"
7070
$justify="space-between"
7171
>
72-
{isDesktop ? <LeftPanelCollapseButton /> : <Box />}
72+
{isLargeScreen ? <LeftPanelCollapseButton /> : <Box />}
7373
<RightPanelCollapseButton />
7474
</Box>
7575
);

src/frontend/apps/impress/src/features/docs/doc-search/components/DocSearchModal.tsx

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import Image from 'next/image';
44
import { useRouter } from 'next/router';
55
import { useState } from 'react';
66
import { useTranslation } from 'react-i18next';
7+
import { createGlobalStyle } from 'styled-components';
78
import { useDebouncedCallback } from 'use-debounce';
89

910
import { Box, ButtonCloseModal, Text } from '@/components';
@@ -20,6 +21,12 @@ import EmptySearchIcon from '../assets/illustration-docs-empty.png';
2021

2122
import { DocSearchContent } from './DocSearchContent';
2223

24+
const ModalStyle = createGlobalStyle`
25+
.c__modal__scroller {
26+
overflow: inherit ;
27+
}
28+
`;
29+
2330
type DocSearchModalGlobalProps = {
2431
onClose: () => void;
2532
isOpen: boolean;
@@ -43,7 +50,7 @@ const DocSearchModalGlobal = ({
4350
const [filters, setFilters] = useState<DocSearchFiltersValues>(
4451
defaultFilters ?? {},
4552
);
46-
const { isDesktop } = useResponsiveStore();
53+
const { isLargeScreen } = useResponsiveStore();
4754
const handleInputSearch = useDebouncedCallback(setSearch, 300);
4855

4956
const handleSelect = (doc: Doc) => {
@@ -60,10 +67,11 @@ const DocSearchModalGlobal = ({
6067
<Modal
6168
{...modalProps}
6269
closeOnClickOutside
63-
size={isDesktop ? ModalSize.LARGE : ModalSize.FULL}
70+
size={isLargeScreen ? ModalSize.LARGE : ModalSize.FULL}
6471
hideCloseButton
6572
aria-describedby="doc-search-modal-title"
6673
>
74+
<ModalStyle />
6775
<Box
6876
aria-label={t('Search modal')}
6977
$direction="column"
@@ -107,7 +115,7 @@ const DocSearchModalGlobal = ({
107115
>
108116
<Box
109117
$padding={{ horizontal: '10px', vertical: 'base' }}
110-
$height={isDesktop ? '500px' : 'calc(100vh - 68px - 1rem)'}
118+
$height={isLargeScreen ? '500px' : 'calc(100vh - 68px - 1rem)'}
111119
>
112120
{search.length === 0 && (
113121
<Box

src/frontend/apps/impress/src/features/docs/docs-grid/components/DocsGrid.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ export const DocsGrid = ({
9797
$position="relative"
9898
$width="100%"
9999
$maxWidth="960px"
100-
$maxHeight="calc(100vh - 52px - 2rem)"
100+
$maxHeight={`calc(100vh - 52px - ${isDesktop ? '2rem' : '0rem'})`}
101101
$align="center"
102102
className="--docs--doc-grid"
103103
>

src/frontend/apps/impress/src/features/header/components/Header.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ export const Header = () => {
1919
const { t } = useTranslation();
2020
const { data: config } = useConfig();
2121
const { spacingsTokens } = useCunninghamTheme();
22-
const { isDesktop } = useResponsiveStore();
22+
const { isLargeScreen } = useResponsiveStore();
2323

2424
const icon = config?.theme_customization?.header?.icon;
2525

@@ -46,7 +46,7 @@ export const Header = () => {
4646
var(--c--contextuals--border--surface--primary);
4747
`}
4848
>
49-
{!isDesktop && <LeftPanelToggleMobile />}
49+
{!isLargeScreen && <LeftPanelToggleMobile />}
5050
<StyledLink
5151
href="/"
5252
data-testid="header-logo-link"
@@ -82,7 +82,7 @@ export const Header = () => {
8282
/>
8383
</Box>
8484
</StyledLink>
85-
{!isDesktop ? (
85+
{!isLargeScreen ? (
8686
<Box $direction="row" $gap={spacingsTokens['sm']}>
8787
<Waffle />
8888
</Box>

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,8 @@ const MobileLeftPanelStyle = createGlobalStyle`
2424
`;
2525

2626
export const LeftPanel = () => {
27-
const { isDesktop } = useResponsiveStore();
28-
if (isDesktop) {
27+
const { isLargeScreen } = useResponsiveStore();
28+
if (isLargeScreen) {
2929
return <LeftPanelDesktop />;
3030
}
3131

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ type LeftPanelFavoriteItemProps = {
1414

1515
export const LeftPanelFavoriteItem = ({ doc }: LeftPanelFavoriteItemProps) => {
1616
const { colorsTokens, spacingsTokens } = useCunninghamTheme();
17-
const { isDesktop } = useResponsiveStore();
17+
const { isLargeScreen } = useResponsiveStore();
1818

1919
return (
2020
<Box
@@ -26,7 +26,7 @@ export const LeftPanelFavoriteItem = ({ doc }: LeftPanelFavoriteItemProps) => {
2626
padding: ${spacingsTokens['2xs']};
2727
border-radius: 4px;
2828
.pinned-actions {
29-
opacity: ${isDesktop ? 0 : 1};
29+
opacity: ${isLargeScreen ? 0 : 1};
3030
}
3131
&:hover {
3232
background-color: var(

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

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ export const ResizableLeftPanel = ({
5151
maxPanelSizePx = 450,
5252
}: ResizableLeftPanelProps) => {
5353
const { t } = useTranslation();
54-
const { isDesktop } = useResponsiveStore();
54+
const { isLargeScreen } = useResponsiveStore();
5555
const { isPanelOpen } = useLeftPanelStore();
5656
const ref = useRef<ImperativePanelHandle>(null);
5757
const savedWidthPxRef = useRef<number>(minPanelSizePx);
@@ -89,19 +89,19 @@ export const ResizableLeftPanel = ({
8989
* to either expand/collapse
9090
*/
9191
useEffect(() => {
92-
if (!ref.current || !isDesktop) {
92+
if (!ref.current || !isLargeScreen) {
9393
return;
9494
}
9595
if (isPanelOpen) {
9696
ref.current.expand();
9797
} else {
9898
ref.current.collapse();
9999
}
100-
}, [isPanelOpen, isDesktop]);
100+
}, [isPanelOpen, isLargeScreen]);
101101

102102
// Keep pixel width constant on window resize
103103
useEffect(() => {
104-
if (!isDesktop) {
104+
if (!isLargeScreen) {
105105
return;
106106
}
107107

@@ -117,7 +117,7 @@ export const ResizableLeftPanel = ({
117117
return () => {
118118
window.removeEventListener('resize', handleResize);
119119
};
120-
}, [isDesktop]);
120+
}, [isLargeScreen]);
121121

122122
/**
123123
* Workaround: NVDA does not enter focus mode for role="separator"
@@ -158,15 +158,15 @@ export const ResizableLeftPanel = ({
158158
}}
159159
order={0}
160160
defaultSize={
161-
isDesktop
161+
isLargeScreen
162162
? Math.max(
163163
minPanelSizePercent,
164164
Math.min(panelSizePercent, maxPanelSizePercent),
165165
)
166166
: 0
167167
}
168-
minSize={isDesktop ? minPanelSizePercent : 0}
169-
maxSize={isDesktop ? maxPanelSizePercent : 0}
168+
minSize={isLargeScreen ? minPanelSizePercent : 0}
169+
maxSize={isLargeScreen ? maxPanelSizePercent : 0}
170170
onResize={handleResize}
171171
>
172172
{leftPanel}
@@ -193,7 +193,7 @@ export const ResizableLeftPanel = ({
193193
cursor: 'col-resize',
194194
}}
195195
onDragging={setIsDragging}
196-
disabled={!isDesktop}
196+
disabled={!isLargeScreen}
197197
/>
198198
)}
199199
<Panel order={1}>{children}</Panel>

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ export function MainLayoutContent({
5252
backgroundColor,
5353
enableResizablePanel,
5454
}: PropsWithChildren<MainLayoutContentProps>) {
55-
const { isDesktop } = useResponsiveStore();
55+
const { isLargeScreen } = useResponsiveStore();
5656

5757
if (enableResizablePanel) {
5858
return (
@@ -71,7 +71,7 @@ export function MainLayoutContent({
7171
);
7272
}
7373

74-
if (!isDesktop) {
74+
if (!isLargeScreen) {
7575
return (
7676
<>
7777
<LeftPanel />

0 commit comments

Comments
 (0)