Skip to content

Commit 7068f1e

Browse files
PanchoutNathanlunika
authored andcommitted
✨(frontend) enhance dropdown menu and quick search components
- Added a horizontal separator to the dropdown menu for better visual distinction between options. - Updated padding in the quick search input for improved layout consistency. - Adjusted margin in the quick search group for better spacing. - Increased vertical padding in quick search item content for enhanced readability. - Modified the horizontal separator to accept custom padding for more flexible styling. - Improved left panel styling to manage overflow behavior effectively. - Removed unused skeleton loading styles from globals.css to clean up the codebase.
1 parent 900e205 commit 7068f1e

File tree

8 files changed

+81
-91
lines changed

8 files changed

+81
-91
lines changed

src/frontend/apps/impress/src/components/DropdownMenu.tsx

Lines changed: 67 additions & 60 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
import { PropsWithChildren, useRef, useState } from 'react';
1+
import { HorizontalSeparator } from '@gouvfr-lasuite/ui-kit';
2+
import { Fragment, PropsWithChildren, useRef, useState } from 'react';
23
import { css } from 'styled-components';
34

45
import { Box, BoxButton, BoxProps, DropButton, Icon, Text } from '@/components';
@@ -14,6 +15,7 @@ export type DropdownMenuOption = {
1415
isSelected?: boolean;
1516
disabled?: boolean;
1617
show?: boolean;
18+
showSeparator?: boolean;
1719
};
1820

1921
export type DropdownMenuProps = {
@@ -112,71 +114,76 @@ export const DropdownMenu = ({
112114
}
113115
const isDisabled = option.disabled !== undefined && option.disabled;
114116
return (
115-
<BoxButton
116-
role="menuitem"
117-
aria-label={option.label}
118-
data-testid={option.testId}
119-
$direction="row"
120-
disabled={isDisabled}
121-
onClick={(event) => {
122-
event.preventDefault();
123-
event.stopPropagation();
124-
onOpenChange?.(false);
125-
void option.callback?.();
126-
}}
127-
key={option.label}
128-
$align="center"
129-
$justify="space-between"
130-
$background={colorsTokens['greyscale-000']}
131-
$color={colorsTokens['primary-600']}
132-
$padding={{ vertical: 'xs', horizontal: 'base' }}
133-
$width="100%"
134-
$gap={spacingsTokens['base']}
135-
$css={css`
136-
border: none;
137-
${index === 0 &&
138-
css`
139-
border-top-left-radius: 4px;
140-
border-top-right-radius: 4px;
141-
`}
142-
${index === options.length - 1 &&
143-
css`
144-
border-bottom-left-radius: 4px;
145-
border-bottom-right-radius: 4px;
146-
`}
147-
font-size: var(--c--theme--font--sizes--sm);
148-
color: var(--c--theme--colors--greyscale-1000);
149-
font-weight: 500;
150-
cursor: ${isDisabled ? 'not-allowed' : 'pointer'};
151-
user-select: none;
152-
153-
&:hover {
154-
background-color: var(--c--theme--colors--greyscale-050);
155-
}
156-
`}
157-
>
158-
<Box
117+
<Fragment key={option.label}>
118+
<BoxButton
119+
role="menuitem"
120+
aria-label={option.label}
121+
data-testid={option.testId}
159122
$direction="row"
123+
disabled={isDisabled}
124+
onClick={(event) => {
125+
event.preventDefault();
126+
event.stopPropagation();
127+
onOpenChange?.(false);
128+
void option.callback?.();
129+
}}
130+
key={option.label}
160131
$align="center"
132+
$justify="space-between"
133+
$background={colorsTokens['greyscale-000']}
134+
$color={colorsTokens['primary-600']}
135+
$padding={{ vertical: 'xs', horizontal: 'base' }}
136+
$width="100%"
161137
$gap={spacingsTokens['base']}
138+
$css={css`
139+
border: none;
140+
${index === 0 &&
141+
css`
142+
border-top-left-radius: 4px;
143+
border-top-right-radius: 4px;
144+
`}
145+
${index === options.length - 1 &&
146+
css`
147+
border-bottom-left-radius: 4px;
148+
border-bottom-right-radius: 4px;
149+
`}
150+
font-size: var(--c--theme--font--sizes--sm);
151+
color: var(--c--theme--colors--greyscale-1000);
152+
font-weight: 500;
153+
cursor: ${isDisabled ? 'not-allowed' : 'pointer'};
154+
user-select: none;
155+
156+
&:hover {
157+
background-color: var(--c--theme--colors--greyscale-050);
158+
}
159+
`}
162160
>
163-
{option.icon && (
164-
<Icon
165-
$size="20px"
166-
$theme="greyscale"
167-
$variation={isDisabled ? '400' : '1000'}
168-
iconName={option.icon}
169-
/>
161+
<Box
162+
$direction="row"
163+
$align="center"
164+
$gap={spacingsTokens['base']}
165+
>
166+
{option.icon && (
167+
<Icon
168+
$size="20px"
169+
$theme="greyscale"
170+
$variation={isDisabled ? '400' : '1000'}
171+
iconName={option.icon}
172+
/>
173+
)}
174+
<Text $variation={isDisabled ? '400' : '1000'}>
175+
{option.label}
176+
</Text>
177+
</Box>
178+
{(option.isSelected ||
179+
selectedValues?.includes(option.value ?? '')) && (
180+
<Icon iconName="check" $size="20px" $theme="greyscale" />
170181
)}
171-
<Text $variation={isDisabled ? '400' : '1000'}>
172-
{option.label}
173-
</Text>
174-
</Box>
175-
{(option.isSelected ||
176-
selectedValues?.includes(option.value ?? '')) && (
177-
<Icon iconName="check" $size="20px" $theme="greyscale" />
182+
</BoxButton>
183+
{option.showSeparator && (
184+
<HorizontalSeparator withPadding={false} />
178185
)}
179-
</BoxButton>
186+
</Fragment>
180187
);
181188
})}
182189
</Box>

src/frontend/apps/impress/src/components/quick-search/QuickSearchGroup.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ export const QuickSearchGroup = <T,>({
1818
renderElement,
1919
}: Props<T>) => {
2020
return (
21-
<Box $margin={{ top: 'base' }}>
21+
<Box $margin={{ top: 'sm' }}>
2222
<Command.Group
2323
key={group.groupName}
2424
heading={group.groupName}

src/frontend/apps/impress/src/components/quick-search/QuickSearchInput.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ export const QuickSearchInput = ({
4444
$align="center"
4545
className="quick-search-input"
4646
$gap={spacingsTokens['2xs']}
47-
$padding={{ all: 'base' }}
47+
$padding={{ horizontal: 'base', vertical: 'sm' }}
4848
>
4949
{!loading && <Icon iconName="search" $variation="600" />}
5050
{loading && (

src/frontend/apps/impress/src/components/quick-search/QuickSearchItemContent.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,9 @@ export const QuickSearchItemContent = ({
2424
<Box
2525
$direction="row"
2626
$align="center"
27-
$padding={{ horizontal: '2xs', vertical: '3xs' }}
27+
$padding={{ horizontal: '2xs', vertical: '4xs' }}
2828
$justify="space-between"
29+
$minHeight="34px"
2930
$width="100%"
3031
>
3132
<Box

src/frontend/apps/impress/src/components/separators/HorizontalSeparator.tsx

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import { useCunninghamTheme } from '@/cunningham';
2+
import { Spacings } from '@/utils';
23

34
import { Box } from '../Box';
45

@@ -10,19 +11,25 @@ export enum SeparatorVariant {
1011
type Props = {
1112
variant?: SeparatorVariant;
1213
$withPadding?: boolean;
14+
customPadding?: Spacings;
1315
};
1416

1517
export const HorizontalSeparator = ({
1618
variant = SeparatorVariant.LIGHT,
1719
$withPadding = true,
20+
customPadding,
1821
}: Props) => {
1922
const { colorsTokens } = useCunninghamTheme();
2023

24+
const padding = $withPadding
25+
? (customPadding ?? 'base')
26+
: ('none' as Spacings);
27+
2128
return (
2229
<Box
2330
$height="1px"
2431
$width="100%"
25-
$margin={{ vertical: $withPadding ? 'base' : 'none' }}
32+
$margin={{ vertical: padding }}
2633
$background={
2734
variant === SeparatorVariant.DARK
2835
? '#e5e5e533'

src/frontend/apps/impress/src/features/docs/doc-management/utils.ts

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -38,11 +38,6 @@ export const getDocLinkRole = (doc: Doc) => {
3838
};
3939

4040
export const docLinkIsDesync = (doc: Doc) => {
41-
// If the document has no ancestors
42-
if (!doc.ancestors_link_reach) {
43-
return false;
44-
}
45-
4641
return (
4742
doc.computed_link_reach !== doc.ancestors_link_reach ||
4843
doc.computed_link_role !== doc.ancestors_link_role

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,8 @@ export const LeftPanel = () => {
7070
position: fixed;
7171
transform: translateX(${isPanelOpen ? '0' : '-100dvw'});
7272
background-color: var(--c--theme--colors--greyscale-000);
73+
overflow-y: auto;
74+
overflow-x: hidden;
7375
`}
7476
className="--docs--left-panel-mobile"
7577
>

src/frontend/apps/impress/src/pages/globals.css

Lines changed: 0 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -76,25 +76,3 @@ main ::-webkit-scrollbar-thumb:hover,
7676
nextjs-portal {
7777
display: none;
7878
}
79-
80-
.skeleton {
81-
background: linear-gradient(
82-
100deg,
83-
var(--c--theme--colors--greyscale-050) 30%,
84-
var(--c--theme--colors--greyscale-100) 50%,
85-
var(--c--theme--colors--greyscale-050) 70%
86-
);
87-
background-size: 200% 100%;
88-
animation: shimmer 2.5s infinite;
89-
border-radius: 4px;
90-
}
91-
92-
@keyframes shimmer {
93-
0% {
94-
background-position: -200% 0;
95-
}
96-
97-
100% {
98-
background-position: 200% 0;
99-
}
100-
}

0 commit comments

Comments
 (0)