Skip to content

Commit b9f1dfa

Browse files
committed
fix(components): ensure consistent drawer title styling
1 parent 35f3b49 commit b9f1dfa

File tree

1 file changed

+20
-0
lines changed

1 file changed

+20
-0
lines changed

packages/compass-components/src/components/drawer-portal.tsx

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ import {
1616
import { css, cx } from '@leafygreen-ui/emotion';
1717
import { isEqual } from 'lodash';
1818
import { rafraf } from '../utils/rafraf';
19+
import { BaseFontSize, fontWeights } from '@leafygreen-ui/tokens';
1920

2021
type ToolbarData = Required<DrawerLayoutProps>['toolbarData'];
2122

@@ -175,6 +176,14 @@ const drawerLayoutFixesStyles = css({
175176
borderTop: 'none',
176177
borderBottom: 'none',
177178
},
179+
180+
// drawer content > title content
181+
'& > div:nth-child(2) > div:nth-child(2) > div:first-child > div:first-child > div:first-child > div:first-child':
182+
{
183+
// fix for the flex parent not allowing flex children to collapse if they
184+
// are overflowing the container
185+
minWidth: 0,
186+
},
178187
});
179188

180189
const emptyDrawerLayoutFixesStyles = css({
@@ -205,6 +214,16 @@ const drawerSectionPortalStyles = css({
205214
height: '100%',
206215
});
207216

217+
// Leafygreen dynamically changes styles of the title group based on whether or
218+
// not title is a `string` or a `ReactNode`, we want it to consistently have
219+
// bold title styles no matter what title you provided, so we wrap it in our own
220+
// container
221+
const drawerTitleGroupStyles = css({
222+
width: '100%',
223+
fontSize: BaseFontSize.Body2,
224+
fontWeight: fontWeights.bold,
225+
});
226+
208227
/**
209228
* DrawerAnchor component will render the drawer in any place it is rendered.
210229
* This component has to wrap any content that Drawer will be shown near
@@ -235,6 +254,7 @@ export const DrawerAnchor: React.FunctionComponent<{
235254
.map((data) => {
236255
return {
237256
...data,
257+
title: <div className={drawerTitleGroupStyles}>{data.title}</div>,
238258
content: (
239259
<div
240260
key={data.id}

0 commit comments

Comments
 (0)