Skip to content

Commit 798aeb9

Browse files
chore: update drawer elements (#619)
* chore(drawer): update header font-size * chore(drawer): update close icon - use the same as modals * chore(drawer): ensure all drawers show close icon * test(drawer): update drawer snapshot * chore(drawer): remove control for close button in storybook * chore(drawer): update close button margin * test(drawer): update drawer snapshot
1 parent 38e18f9 commit 798aeb9

File tree

4 files changed

+67
-28
lines changed

4 files changed

+67
-28
lines changed

src/components/Drawer/Drawer.stories.tsx

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,6 @@ export const Default: StoryFn<DrawerArgs> = (args) => {
6666
};
6767

6868
Default.args = {
69-
headerCloseBtn: true,
7069
placement: "left",
7170
showMask: true,
7271
};
@@ -128,7 +127,6 @@ export const MultipleDrawers: StoryFn<DrawerArgs> = (args) => {
128127
};
129128

130129
MultipleDrawers.args = {
131-
headerCloseBtn: true,
132130
placement: "left",
133131
showMask: true,
134132
};

src/components/Drawer/__snapshots__/Drawer.test.tsx.snap

Lines changed: 50 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -27,25 +27,25 @@ exports[`<Drawer/> matches snapshot with close button 1`] = `
2727
style="opacity: 0; transform: none;"
2828
>
2929
<header
30-
class="css-zc36g1-drawerHeader-drawerHeader"
30+
class="css-13we4q5-drawerHeader-drawerHeader"
3131
data-testid="drawer-header"
3232
id="drawer-title"
3333
>
3434
<h2
35-
class="css-1ibrhk6-headingContainer-headingContainer"
35+
class="css-3lqpyc-headingContainer-headingContainer"
3636
>
3737
Title
3838
</h2>
3939
<button
4040
aria-label="Close drawer"
41-
class="linkButton css-5ruphf-baseButton-baseButton-solidButton-solidButton-outlineButton-outlineButton-ghostButton-ghostButton-linkButton-linkButton-iconBeforeButton-iconBeforeButton-iconAfterButton-iconAfterButton-btnContainer-btnContainer"
41+
class="close-button linkButton css-5ruphf-baseButton-baseButton-solidButton-solidButton-outlineButton-outlineButton-ghostButton-ghostButton-linkButton-linkButton-iconBeforeButton-iconBeforeButton-iconAfterButton-iconAfterButton-btnContainer-btnContainer"
4242
type="button"
4343
>
4444
<span
4545
class="btn-text"
4646
>
4747
<svg-file-stub
48-
height="24"
48+
height="32"
4949
/>
5050
</span>
5151
</button>
@@ -88,23 +88,36 @@ exports[`<Drawer/> matches snapshot with header, body and footer 1`] = `
8888
style="opacity: 0; transform: none;"
8989
>
9090
<header
91-
class="css-zc36g1-drawerHeader-drawerHeader"
91+
class="css-13we4q5-drawerHeader-drawerHeader"
9292
data-testid="drawer-header"
9393
id="drawer-title"
9494
>
9595
<h2
96-
class="css-1ibrhk6-headingContainer-headingContainer"
96+
class="css-3lqpyc-headingContainer-headingContainer"
9797
>
9898
Test header
9999
</h2>
100+
<button
101+
aria-label="Close drawer"
102+
class="close-button linkButton css-5ruphf-baseButton-baseButton-solidButton-solidButton-outlineButton-outlineButton-ghostButton-ghostButton-linkButton-linkButton-iconBeforeButton-iconBeforeButton-iconAfterButton-iconAfterButton-btnContainer-btnContainer"
103+
type="button"
104+
>
105+
<span
106+
class="btn-text"
107+
>
108+
<svg-file-stub
109+
height="32"
110+
/>
111+
</span>
112+
</button>
100113
</header>
101114
<div
102115
class="css-1vbxgux-drawerBody"
103116
>
104117
Test body
105118
</div>
106119
<footer
107-
class="css-123pp4v-footerContainer-footerContainer"
120+
class="css-ss7yvy-footerContainer-footerContainer"
108121
data-testid="drawer-footer"
109122
>
110123
Test footer
@@ -146,15 +159,28 @@ exports[`<Drawer/> matches snapshot with noGutters Header 1`] = `
146159
style="opacity: 0; transform: none;"
147160
>
148161
<header
149-
class="css-wmpb2t-drawerHeader-drawerHeader"
162+
class="css-glijxi-drawerHeader-drawerHeader"
150163
data-testid="drawer-header"
151164
id="drawer-title"
152165
>
153166
<h2
154-
class="css-1ibrhk6-headingContainer-headingContainer"
167+
class="css-3lqpyc-headingContainer-headingContainer"
155168
>
156169
Title
157170
</h2>
171+
<button
172+
aria-label="Close drawer"
173+
class="close-button linkButton css-5ruphf-baseButton-baseButton-solidButton-solidButton-outlineButton-outlineButton-ghostButton-ghostButton-linkButton-linkButton-iconBeforeButton-iconBeforeButton-iconAfterButton-iconAfterButton-btnContainer-btnContainer"
174+
type="button"
175+
>
176+
<span
177+
class="btn-text"
178+
>
179+
<svg-file-stub
180+
height="32"
181+
/>
182+
</span>
183+
</button>
158184
</header>
159185
</dialog>
160186
</div>
@@ -193,15 +219,28 @@ exports[`<Drawer/> matches snapshot with right placement 1`] = `
193219
style="opacity: 0; transform: translateX(100%) translateZ(0);"
194220
>
195221
<header
196-
class="css-zc36g1-drawerHeader-drawerHeader"
222+
class="css-13we4q5-drawerHeader-drawerHeader"
197223
data-testid="drawer-header"
198224
id="drawer-title"
199225
>
200226
<h2
201-
class="css-1ibrhk6-headingContainer-headingContainer"
227+
class="css-3lqpyc-headingContainer-headingContainer"
202228
>
203229
Title
204230
</h2>
231+
<button
232+
aria-label="Close drawer"
233+
class="close-button linkButton css-5ruphf-baseButton-baseButton-solidButton-solidButton-outlineButton-outlineButton-ghostButton-ghostButton-linkButton-linkButton-iconBeforeButton-iconBeforeButton-iconAfterButton-iconAfterButton-btnContainer-btnContainer"
234+
type="button"
235+
>
236+
<span
237+
class="btn-text"
238+
>
239+
<svg-file-stub
240+
height="32"
241+
/>
242+
</span>
243+
</button>
205244
</header>
206245
</dialog>
207246
</div>

src/components/Drawer/components/Header.tsx

Lines changed: 13 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import React from "react";
22
import { SerializedStyles } from "@emotion/react";
33
import Heading from "../../Heading/Heading";
44
import Button from "../../Button/Button";
5-
import { CloseSVG } from "../../../icons/";
5+
import { CloseModalSVG } from "../../../icons/";
66
import { drawerHeader } from "./styles";
77
import { FCWithChildren } from "types/common";
88

@@ -12,8 +12,7 @@ export type HeaderProps = {
1212
};
1313

1414
const Header: FCWithChildren<HeaderProps> = ({ onClose, noGutters = false, children }) => {
15-
const title = typeof children === "string" ? <Heading>{children}</Heading> : children;
16-
const showCloseButton = Boolean(onClose);
15+
const title = typeof children === "string" ? <Heading size="md">{children}</Heading> : children;
1716

1817
return (
1918
<header
@@ -22,18 +21,17 @@ const Header: FCWithChildren<HeaderProps> = ({ onClose, noGutters = false, child
2221
css={(): SerializedStyles => drawerHeader({ noGutters })}
2322
>
2423
{title}
25-
{showCloseButton && (
26-
<Button
27-
type="button"
28-
variant="link"
29-
color="secondary"
30-
noGutters
31-
aria-label="Close drawer"
32-
onClick={onClose}
33-
>
34-
<CloseSVG height={24} />
35-
</Button>
36-
)}
24+
<Button
25+
type="button"
26+
variant="link"
27+
color="secondary"
28+
className="close-button"
29+
noGutters
30+
aria-label="Close drawer"
31+
onClick={onClose}
32+
>
33+
<CloseModalSVG height={32} />
34+
</Button>
3735
</header>
3836
);
3937
};

src/components/Drawer/components/styles.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,10 @@ export const drawerHeader = ({ noGutters }: { noGutters: boolean }): SerializedS
1414
${mq["sm"]} {
1515
padding: ${noGutters ? 0 : "1rem 2rem"};
1616
}
17+
18+
.close-button {
19+
margin-inline-end: -0.8rem;
20+
}
1721
`;
1822
};
1923

0 commit comments

Comments
 (0)