Skip to content

Commit 4b26d6d

Browse files
authored
feat: adjust breakpoint for icons in documents tab CLOUDP-328862 (#7084)
* adjust breakpoint for icons in documents tab * lowered the breakpoint and updated comment format
1 parent 69a472d commit 4b26d6d

File tree

6 files changed

+28
-9
lines changed

6 files changed

+28
-9
lines changed

packages/compass-components/src/components/actions/dropdown-menu-button.tsx

Lines changed: 16 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -11,12 +11,13 @@ import { actionTestId } from './utils';
1111
import { ActionGlyph } from './action-glyph';
1212
import { isSeparatorMenuAction, type MenuAction } from './item-action-menu';
1313

14-
const hiddenOnNarrowStyles = css({
15-
[`@container ${WorkspaceContainer.toolbarContainerQueryName} (width < 900px)`]:
16-
{
17-
display: 'none',
18-
},
19-
});
14+
const getHiddenOnNarrowStyles = (narrowBreakpoint: string) =>
15+
css({
16+
[`@container ${WorkspaceContainer.toolbarContainerQueryName} (width < ${narrowBreakpoint})`]:
17+
{
18+
display: 'none',
19+
},
20+
});
2021

2122
export type DropdownMenuButtonProps<Action extends string> = {
2223
actions: MenuAction<Action>[];
@@ -29,6 +30,7 @@ export type DropdownMenuButtonProps<Action extends string> = {
2930
buttonText: string;
3031
buttonProps: ButtonProps & React.ButtonHTMLAttributes<HTMLButtonElement>;
3132
hideOnNarrow?: boolean;
33+
narrowBreakpoint?: string;
3234
};
3335

3436
export function DropdownMenuButton<Action extends string>({
@@ -42,6 +44,7 @@ export function DropdownMenuButton<Action extends string>({
4244
iconSize = ItemActionButtonSize.Default,
4345
'data-testid': dataTestId,
4446
hideOnNarrow = true,
47+
narrowBreakpoint = '900px',
4548
}: DropdownMenuButtonProps<Action>) {
4649
// This ref is used by the Menu component to calculate the height and position
4750
// of the menu.
@@ -97,7 +100,13 @@ export function DropdownMenuButton<Action extends string>({
97100
{...buttonProps}
98101
>
99102
{buttonText && (
100-
<span className={hideOnNarrow ? hiddenOnNarrowStyles : undefined}>
103+
<span
104+
className={
105+
hideOnNarrow
106+
? getHiddenOnNarrowStyles(narrowBreakpoint)
107+
: undefined
108+
}
109+
>
101110
{buttonText}
102111
</span>
103112
)}

packages/compass-crud/src/components/add-data-menu.tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import {
77
} from '@mongodb-js/compass-components';
88
import type { MenuAction } from '@mongodb-js/compass-components';
99
import { usePreference } from 'compass-preferences-model/provider';
10+
import { DOCUMENT_NARROW_ICON_BREAKPOINT } from '../constants/document-narrow-icon-breakpoint';
1011

1112
const tooltipContainerStyles = css({
1213
display: 'flex',
@@ -55,6 +56,7 @@ function AddDataMenuButton({
5556
leftGlyph: <Icon glyph="PlusWithCircle" />,
5657
disabled: isDisabled,
5758
}}
59+
narrowBreakpoint={DOCUMENT_NARROW_ICON_BREAKPOINT}
5860
></DropdownMenuButton>
5961
);
6062
}

packages/compass-crud/src/components/crud-toolbar.tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ import UpdateMenu from './update-data-menu';
2323
import DeleteMenu from './delete-data-menu';
2424
import { QueryBar } from '@mongodb-js/compass-query-bar';
2525
import { useConnectionInfoRef } from '@mongodb-js/compass-connections/provider';
26+
import { DOCUMENT_NARROW_ICON_BREAKPOINT } from '../constants/document-narrow-icon-breakpoint';
2627

2728
const crudQueryBarStyles = css({
2829
width: '100%',
@@ -234,6 +235,7 @@ const CrudToolbar: React.FunctionComponent<CrudToolbarProps> = ({
234235
size: 'xsmall',
235236
leftGlyph: <Icon glyph="Export" />,
236237
}}
238+
narrowBreakpoint={DOCUMENT_NARROW_ICON_BREAKPOINT}
237239
/>
238240
)}
239241
{!readonly && (

packages/compass-crud/src/components/delete-data-menu.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,15 @@ import {
66
WorkspaceContainer,
77
css,
88
} from '@mongodb-js/compass-components';
9+
import { DOCUMENT_NARROW_ICON_BREAKPOINT } from '../constants/document-narrow-icon-breakpoint';
910

1011
type DeleteMenuButtonProps = {
1112
isWritable: boolean;
1213
onClick: () => void;
1314
};
1415

1516
const hiddenOnNarrowStyles = css({
16-
[`@container ${WorkspaceContainer.toolbarContainerQueryName} (width < 900px)`]:
17+
[`@container ${WorkspaceContainer.toolbarContainerQueryName} (width < ${DOCUMENT_NARROW_ICON_BREAKPOINT})`]:
1718
{
1819
display: 'none',
1920
},

packages/compass-crud/src/components/update-data-menu.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,15 @@ import {
66
css,
77
WorkspaceContainer,
88
} from '@mongodb-js/compass-components';
9+
import { DOCUMENT_NARROW_ICON_BREAKPOINT } from '../constants/document-narrow-icon-breakpoint';
910

1011
type UpdateMenuButtonProps = {
1112
isWritable: boolean;
1213
onClick: () => void;
1314
};
1415

1516
const hiddenOnNarrowStyles = css({
16-
[`@container ${WorkspaceContainer.toolbarContainerQueryName} (width < 900px)`]:
17+
[`@container ${WorkspaceContainer.toolbarContainerQueryName} (width < ${DOCUMENT_NARROW_ICON_BREAKPOINT})`]:
1718
{
1819
display: 'none',
1920
},
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
/**
2+
* This is the width at which the icons switch to narrow mode in the Documents tab.
3+
*/
4+
export const DOCUMENT_NARROW_ICON_BREAKPOINT = '960px';

0 commit comments

Comments
 (0)