Skip to content

Commit 904f9cb

Browse files
committed
added new accordion with updated styles
1 parent 89d3463 commit 904f9cb

File tree

2 files changed

+130
-21
lines changed

2 files changed

+130
-21
lines changed

packages/compass-indexes/src/components/create-index-form/create-index-form.tsx

Lines changed: 46 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ import { usePreference } from 'compass-preferences-model/provider';
2121
import IndexFlowSection from './index-flow-section';
2222
import QueryFlowSection from './query-flow-section';
2323
import toNS from 'mongodb-ns';
24+
import CreateIndexOptionsAccordion from './create-index-options-accordion';
2425

2526
const createIndexModalFieldsStyles = css({
2627
margin: `${spacing[600]}px 0 ${spacing[800]}px 0`,
@@ -165,28 +166,52 @@ function CreateIndexForm({
165166
collectionName={collectionName}
166167
/>
167168
)}
168-
169-
{/* TODO in CLOUDP-314036: update the accordion design */}
170-
<Accordion data-testid="create-index-modal-toggle-options" text="Options">
171-
<div
172-
data-testid="create-index-modal-options"
173-
className={createIndexModalOptionStyles}
169+
{showIndexesGuidanceVariant ? (
170+
<CreateIndexOptionsAccordion>
171+
<div
172+
data-testid="create-index-modal-options"
173+
className={createIndexModalOptionStyles}
174+
>
175+
<CheckboxInput name="unique"></CheckboxInput>
176+
<CollapsibleInput name="name"></CollapsibleInput>
177+
<CollapsibleInput name="expireAfterSeconds"></CollapsibleInput>
178+
<CollapsibleInput name="partialFilterExpression"></CollapsibleInput>
179+
<CollapsibleInput name="wildcardProjection"></CollapsibleInput>
180+
<CollapsibleInput name="collation"></CollapsibleInput>
181+
{hasColumnstoreIndexesSupport(serverVersion) && (
182+
<CollapsibleInput name="columnstoreProjection"></CollapsibleInput>
183+
)}
184+
<CheckboxInput name="sparse"></CheckboxInput>
185+
{showRollingIndexOption && (
186+
<CheckboxInput name="buildInRollingProcess"></CheckboxInput>
187+
)}
188+
</div>
189+
</CreateIndexOptionsAccordion>
190+
) : (
191+
<Accordion
192+
data-testid="create-index-modal-toggle-options"
193+
text="Options"
174194
>
175-
<CheckboxInput name="unique"></CheckboxInput>
176-
<CollapsibleInput name="name"></CollapsibleInput>
177-
<CollapsibleInput name="expireAfterSeconds"></CollapsibleInput>
178-
<CollapsibleInput name="partialFilterExpression"></CollapsibleInput>
179-
<CollapsibleInput name="wildcardProjection"></CollapsibleInput>
180-
<CollapsibleInput name="collation"></CollapsibleInput>
181-
{hasColumnstoreIndexesSupport(serverVersion) && (
182-
<CollapsibleInput name="columnstoreProjection"></CollapsibleInput>
183-
)}
184-
<CheckboxInput name="sparse"></CheckboxInput>
185-
{showRollingIndexOption && (
186-
<CheckboxInput name="buildInRollingProcess"></CheckboxInput>
187-
)}
188-
</div>
189-
</Accordion>
195+
<div
196+
data-testid="create-index-modal-options"
197+
className={createIndexModalOptionStyles}
198+
>
199+
<CheckboxInput name="unique"></CheckboxInput>
200+
<CollapsibleInput name="name"></CollapsibleInput>
201+
<CollapsibleInput name="expireAfterSeconds"></CollapsibleInput>
202+
<CollapsibleInput name="partialFilterExpression"></CollapsibleInput>
203+
<CollapsibleInput name="wildcardProjection"></CollapsibleInput>
204+
<CollapsibleInput name="collation"></CollapsibleInput>
205+
{hasColumnstoreIndexesSupport(serverVersion) && (
206+
<CollapsibleInput name="columnstoreProjection"></CollapsibleInput>
207+
)}
208+
<CheckboxInput name="sparse"></CheckboxInput>
209+
{showRollingIndexOption && (
210+
<CheckboxInput name="buildInRollingProcess"></CheckboxInput>
211+
)}
212+
</div>
213+
</Accordion>
214+
)}
190215
</>
191216
);
192217
}
Lines changed: 84 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,84 @@
1+
import {
2+
Body,
3+
css,
4+
cx,
5+
Icon,
6+
palette,
7+
useDarkMode,
8+
} from '@mongodb-js/compass-components';
9+
import React, { useState } from 'react';
10+
11+
const buttonLightThemeStyles = css({
12+
color: palette.gray.dark2,
13+
});
14+
const buttonDarkThemeStyles = css({
15+
color: palette.white,
16+
});
17+
18+
const buttonStyles = css({
19+
fontWeight: 'bold',
20+
display: 'flex',
21+
alignItems: 'center',
22+
paddingLeft: 0,
23+
paddingRight: 0,
24+
border: 'none',
25+
background: 'none',
26+
boxShadow: 'none',
27+
'&:hover': {
28+
cursor: 'pointer',
29+
},
30+
});
31+
32+
const buttonIconContainerStyles = css({
33+
marginLeft: '4px',
34+
});
35+
36+
const iconDarkThemeStyles = css({
37+
color: palette.gray.base,
38+
});
39+
40+
const iconLightThemeStyles = css({
41+
color: palette.gray.dark1,
42+
});
43+
44+
const CreateIndexOptionsAccordion = ({
45+
children,
46+
}: {
47+
children: React.ReactNode;
48+
}) => {
49+
const [open, setOpen] = useState(false);
50+
const darkMode = useDarkMode();
51+
52+
const onOpenChange = () => {
53+
setOpen(!open);
54+
};
55+
56+
return (
57+
<>
58+
<button
59+
className={cx(
60+
darkMode ? buttonDarkThemeStyles : buttonLightThemeStyles,
61+
buttonStyles
62+
)}
63+
type="button"
64+
aria-expanded={open ? 'true' : 'false'}
65+
onClick={onOpenChange}
66+
>
67+
<Body baseFontSize={16} weight="medium">
68+
Options
69+
</Body>
70+
<Icon
71+
className={
72+
(cx(darkMode ? iconDarkThemeStyles : iconLightThemeStyles),
73+
buttonIconContainerStyles)
74+
}
75+
glyph={open ? 'ChevronDown' : 'ChevronRight'}
76+
/>
77+
</button>
78+
79+
{open && <>{children}</>}
80+
</>
81+
);
82+
};
83+
84+
export default CreateIndexOptionsAccordion;

0 commit comments

Comments
 (0)