Skip to content

Commit a1448ad

Browse files
Reduce global css (#2468)
Co-authored-by: Connor Bär <[email protected]>
1 parent a4b5d2c commit a1448ad

File tree

7 files changed

+47
-47
lines changed

7 files changed

+47
-47
lines changed

packages/circuit-ui/components/Body/Body.module.css

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -88,12 +88,14 @@
8888
/* Variants */
8989

9090
.highlight,
91-
strong {
91+
strong.base,
92+
.base strong {
9293
font-weight: var(--cui-font-weight-bold);
9394
}
9495

9596
.quote,
96-
blockquote {
97+
blockquote.base,
98+
.base blockquote {
9799
padding-left: var(--cui-spacings-kilo);
98100
font-style: italic;
99101
border-left: var(--cui-border-width-mega) solid var(--cui-border-accent);

packages/circuit-ui/components/ModalContext/Modal.css renamed to packages/circuit-ui/components/ModalContext/ModalContext.module.css

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
/* Remove scroll on the body when react-modal is open */
2-
.cui-modal-open {
2+
.open {
33
height: 100%;
44
overflow-y: hidden;
55
-webkit-overflow-scrolling: auto;
66
}
77

88
/* Enable keyboard navigation inside the modal, see https://github.com/reactjs/react-modal/issues/782 */
9-
.cui-modal-portal {
9+
.portal {
1010
position: absolute;
1111
width: 100%;
1212
height: 100%;

packages/circuit-ui/components/ModalContext/ModalContext.tsx

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -29,11 +29,10 @@ import { last } from '../../util/helpers.js';
2929
import { warn } from '../../util/logger.js';
3030

3131
import type { BaseModalProps, ModalComponent } from './types.js';
32+
import classes from './ModalContext.module.css';
3233

33-
import './Modal.css';
34-
35-
const PORTAL_CLASS_NAME = 'cui-modal-portal';
36-
const HTML_OPEN_CLASS_NAME = 'cui-modal-open';
34+
const PORTAL_CLASS_NAME = classes.portal;
35+
const HTML_OPEN_CLASS_NAME = classes.open;
3736
// These are the default app element ids in Next.js, Docusaurus, CRA and Storybook.
3837
const APP_ELEMENT_IDS = ['root', '__next', '__docusaurus', 'storybook-root'];
3938

packages/circuit-ui/components/SidePanel/SidePanel.tsx

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -109,8 +109,6 @@ export const SidePanel = ({
109109
labelledby: headerAriaId,
110110
},
111111
onRequestClose: onBack || onClose,
112-
portalClassName: 'cui-side-panel-portal',
113-
htmlOpenClassName: 'cui-side-panel-open',
114112
bodyOpenClassName: '',
115113
/**
116114
* react-modal relies on document.activeElement to return focus after the modal is closed.

packages/circuit-ui/components/SidePanel/SidePanelContext.css

Lines changed: 0 additions & 35 deletions
This file was deleted.

packages/circuit-ui/components/SidePanel/SidePanelContext.module.css

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,39 @@
1+
:root {
2+
--side-panel-width: 400px;
3+
}
4+
5+
/* Enable keyboard navigation inside the modal, see https://github.com/reactjs/react-modal/issues/782 */
6+
.portal {
7+
position: fixed;
8+
right: 0;
9+
bottom: 0;
10+
}
11+
12+
@media (max-width: 767px) {
13+
/* Remove scroll on the body when react-modal is open */
14+
.open {
15+
height: 100%;
16+
overflow-y: hidden;
17+
-webkit-overflow-scrolling: auto;
18+
}
19+
20+
/* Enable keyboard navigation inside the modal, see https://github.com/reactjs/react-modal/issues/782 */
21+
.portal {
22+
top: 0;
23+
left: 0;
24+
z-index: var(--cui-z-index-modal);
25+
}
26+
}
27+
28+
/* Enable keyboard navigation inside the modal, see https://github.com/reactjs/react-modal/issues/782 */
29+
@media (min-width: 768px) {
30+
.portal {
31+
top: var(--top-navigation-height, 0);
32+
z-index: var(--cui-z-index-absolute);
33+
width: var(--side-panel-width);
34+
}
35+
}
36+
137
.base {
238
width: 100%;
339
min-height: calc(100vh - var(--top-navigation-height));

packages/circuit-ui/components/SidePanel/SidePanelContext.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,6 @@ import { TRANSITION_DURATION } from './constants.js';
3838
import type { SidePanelHookProps } from './useSidePanel.js';
3939
import classes from './SidePanelContext.module.css';
4040

41-
import './SidePanelContext.css';
42-
4341
// It is important for users of screen readers that other page content be hidden
4442
// (via the `aria-hidden` attribute) while the side panel is open on mobile.
4543
// To allow react-modal to do this, Circuit UI calls `ReactModal.setAppElement`
@@ -287,6 +285,8 @@ export function SidePanelProvider({
287285
isStacked={isStacked}
288286
onBack={handleBack}
289287
onClose={handleClose}
288+
portalClassName={classes.portal}
289+
htmlOpenClassName={classes.open}
290290
/>
291291
);
292292
})}

0 commit comments

Comments
 (0)