/
_alerts.scss
150 lines (121 loc) · 3.32 KB
/
_alerts.scss
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
// ------------------------------
// edX Pattern Library: Utilities - Alerts
//
// About: Contains base styling for alerts.
// ----------------------------
// #CONFIG
// #UTILITIES
// #GENERAL
// #INDIVIDUAL CASES
// ----------------------------
// #CONFIG
// ----------------------------
$alert-background-color: palette(grayscale, white) !default;
$alert-icon-color: palette(grayscale, white) !default;
$alert-border-radius: spacing-vertical(xx-small) !default;
// border around the sides and bottom
$alert-border: rem(1) solid palette(grayscale-cool, light) !default;
// alert colors
$alert-information-color: palette(information, base) !default;
$alert-warning-color: palette(warning, base) !default;
$alert-error-color: palette(error, base) !default;
$alert-success-color: palette(success, base) !default;
// ----------------------------
// #UTILITIES
// ----------------------------
@mixin alert($alert-color) {
border-top: rem(2) solid $alert-color;
.alert-icon {
color: $alert-icon-color;
background-color: $alert-color;
}
}
@mixin alert-message($width) {
@include susy-media($bp-screen-md) {
@include float(left);
width: $width;
padding: spacing-vertical(small);
padding-top: 0;
padding-bottom: 0;
}
:last-child {
// keeps the message compact
margin-bottom: 0;
}
}
// ----------------------------
// #GENERAL
// ----------------------------
.alert {
background-color: $alert-background-color;
border: $alert-border;
border-radius: $alert-border-radius;
border-top-left-radius: 0;
border-top-right-radius: 0;
padding: spacing-vertical(small) spacing-horizontal(base);
overflow: auto;
box-shadow: 0 rem(2) rem(2) 0 palette(grayscale-cool, xx-light);
}
.alert-icon {
// hide icons on small screens
display: none;
@include susy-media($bp-screen-md) {
@include float(left);
display: block;
// create a circle around the icon
border-radius: 50%;
// create room around the icon for the circle
padding: spacing-vertical(x-small);
}
}
.alert-message-with-action {
// provide room for the action to be displayed next to the alert message
@include alert-message(70%);
}
.alert-message {
@include alert-message(90%);
}
.alert-title {
@extend %hd-5;
@extend %headings-emphasized;
@include susy-media($bp-screen-md) {
// shift the section up to make the alert more compact
margin-top: - spacing-vertical(x-small);
}
}
.alert-copy {
@extend %copy-base;
@include susy-media($bp-screen-md) {
// shift the message down to be in line with the icon
margin-top: spacing-vertical(xx-small);
}
}
.alert-copy-with-title {
@extend %copy-base;
}
.alert-action {
width: 100%;
@include susy-media($bp-screen-md) {
@include float(right);
width: inherit;
}
}
// ----------------------------
// #INDIVIDUAL CASES
// ----------------------------
// information-based alert
.alert-information {
@include alert($alert-information-color);
}
// warning-based alert
.alert-warning {
@include alert($alert-warning-color);
}
// error-based alert
.alert-error {
@include alert($alert-error-color);
}
// success-based alert
.alert-success {
@include alert($alert-success-color);
}