Skip to content

Commit fd6b67a

Browse files
committed
Convert Notifications to CSS modules
1 parent bb3f0f5 commit fd6b67a

File tree

4 files changed

+45
-39
lines changed

4 files changed

+45
-39
lines changed

ui/frontend/Notifications.module.css

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
$buffer: 0.5em;
2+
$space: 0.25em;
3+
4+
.container {
5+
position: absolute;
6+
z-index: 10;
7+
right: $buffer;
8+
bottom: $buffer;
9+
left: $buffer;
10+
max-width: 50em;
11+
border: 2px solid #428bca;
12+
margin-right: auto;
13+
margin-left: auto;
14+
background: white;
15+
}
16+
17+
.notification {
18+
display: flex;
19+
}
20+
21+
.notificationContent {
22+
padding: $space 0 $space $space;
23+
}
24+
25+
.close {
26+
composes: -buttonReset from './shared.module.css';
27+
padding: $space;
28+
background: #e1e1db;
29+
cursor: pointer;
30+
}

ui/frontend/Notifications.tsx

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,14 @@ import { Close } from './Icon';
77
import * as actions from './actions';
88
import * as selectors from './selectors';
99

10+
import styles from './Notifications.module.css';
11+
1012
const SURVEY_URL = 'https://blog.rust-lang.org/2020/09/10/survey-launch.html';
1113

1214
const Notifications: React.SFC = () => {
1315
return (
1416
<Portal>
15-
<div className="notifications">
17+
<div className={styles.container}>
1618
<Rust2020SurveyNotification />
1719
</div>
1820
</Portal>
@@ -40,9 +42,9 @@ interface NotificationProps {
4042
}
4143

4244
const Notification: React.SFC<NotificationProps> = ({ onClose, children }) => (
43-
<div className="notifications__notification">
44-
<div className="notifications__notification-content">{children}</div>
45-
<button className="notifications__close" onClick={onClose}><Close /></button>
45+
<div className={styles.notification}>
46+
<div className={styles.notificationContent}>{children}</div>
47+
<button className={styles.close} onClick={onClose}><Close /></button>
4648
</div>
4749
);
4850

ui/frontend/index.scss

Lines changed: 0 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -647,38 +647,3 @@ $header-transition: 0.2s ease-in-out;
647647
}
648648
}
649649
}
650-
651-
.notifications {
652-
position: absolute;
653-
z-index: 10;
654-
655-
$buffer: 0.5em;
656-
657-
bottom: $buffer;
658-
left: $buffer;
659-
right: $buffer;
660-
661-
margin-left: auto;
662-
margin-right: auto;
663-
max-width: 50em;
664-
665-
background: white;
666-
border: 2px solid #428bca;
667-
668-
&__notification {
669-
display: flex;
670-
}
671-
672-
$space: 0.25em;
673-
674-
&__notification-content {
675-
padding: $space 0 $space $space;
676-
}
677-
678-
&__close {
679-
@include button-reset;
680-
padding: $space;
681-
background: #e1e1db;
682-
cursor: pointer;
683-
}
684-
}

ui/frontend/shared.module.css

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
.-buttonReset {
2+
padding: 0;
3+
border: none;
4+
background: inherit;
5+
background-color: transparent; /* IE 11 */
6+
font: inherit;
7+
line-height: inherit;
8+
text-align: inherit;
9+
}

0 commit comments

Comments
 (0)