summaryrefslogtreecommitdiffstats
path: root/toolkit/content/widgets/message-bar.css
blob: db08e2dde8efc9ae43b12a4d5975ac0052892b3e (plain)
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
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
/* This Source Code Form is subject to the terms of the Mozilla Public
 * License, v. 2.0. If a copy of the MPL was not distributed with this
 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */

:host {
  --info-icon-url: url("chrome://global/skin/icons/info-filled.svg");
  --warn-icon-url: url("chrome://global/skin/icons/warning.svg");
  --success-icon-url: url("chrome://global/skin/icons/check.svg");
  --error-icon-url: url("chrome://global/skin/icons/error.svg");
  --close-icon-url: url("chrome://global/skin/icons/close-12.svg");
  --close-fill-color: var(--in-content-icon-color);
  --icon-size: 16px;
  --close-icon-size: 24px;
}

:host([message-bar-type=infobar]) {
  --close-icon-size: 24px;
}

/* MessageBar colors by message type */
/* Colors from: https://design.firefox.com/photon/components/message-bars.html#type-specific-style */

:host {
  --message-bar-background-color: var(--in-content-box-info-background);
  --message-bar-text-color: var(--in-content-text-color);
  --message-bar-icon-url: var(--info-icon-url);
  /* The default values of --in-content-button* are sufficient, even for dark themes */
}

:host([type=warning]:not([message-bar-type=infobar])) {
  --message-bar-background-color: var(--yellow-50);
  --message-bar-text-color: var(--yellow-90);

  --in-content-button-background: var(--yellow-60);
  --in-content-button-background-hover: var(--yellow-70);
  --in-content-button-background-active: var(--yellow-80);

  --close-fill-color: var(--message-bar-text-color);
}
:host([type=warning]) {
  --message-bar-icon-url: var(--warn-icon-url);
}

:host([type=success]:not([message-bar-type=infobar])) {
  --message-bar-background-color: var(--green-50);
  --message-bar-text-color: var(--green-90);

  --message-bar-icon-url: var(--success-icon-url);
  --in-content-button-background: var(--green-60);
  --in-content-button-background-hover: var(--green-70);
  --in-content-button-background-active: var(--green-80);
}

:host([type=error]:not([message-bar-type=infobar])) {
  --message-bar-background-color: var(--red-60);
  --message-bar-text-color: #ffffff;

  --in-content-button-background: var(--red-70);
  --in-content-button-background-hover: var(--red-80);
  --in-content-button-background-active: var(--red-90);
}
:host([type=error]),
:host([type=critical]) {
  --message-bar-icon-url: var(--error-icon-url);
}

:host {
  border-radius: 4px;
}

/* Make the host to behave as a block by default, but allow hidden to hide it. */
:host(:not([hidden])) {
  display: block;
}

::slotted(button) {
  /* Enforce micro-button width. */
  min-width: -moz-fit-content !important;
}

/* MessageBar Grid Layout */

.container {
  background: var(--message-bar-background-color);
  color: var(--message-bar-text-color);

  padding: 4px 8px;
  position: relative;

  border-radius: 4px;

  display: flex;
  /* Ensure that the message bar shadow dom elements are vertically aligned. */
  align-items: center;
}

:host([align="center"]) .container {
  justify-content: center;
}

.content {
  margin: 0 4px;
  display: inline-block;
  /* Ensure that the message bar content is vertically aligned. */
  align-items: center;
  /* Ensure that the message bar content is wrapped. */
  word-break: break-word;
}

/* MessageBar icon style */

.icon {
  padding: 4px;
  width: var(--icon-size);
  height: var(--icon-size);
  flex-shrink: 0;
}

.icon::after {
  appearance: none;
  -moz-context-properties: fill, stroke;
  fill: currentColor;
  stroke: currentColor;
  content: var(--message-bar-icon-url);
}

/* Use a spacer to position the close button at the end, but also support
 * centering if required. */
.spacer {
  flex-grow: 1;
}

/* Close icon styles */

:host(:not([dismissable])) .close {
  display: none;
}

.close {
  background-image: var(--close-icon-url);
  background-repeat: no-repeat;
  background-position: center center;
  -moz-context-properties: fill;
  fill: currentColor;
  min-width: auto;
  min-height: auto;
  width: var(--close-icon-size);
  height: var(--close-icon-size);
  margin: 0;
  padding: 0;
  flex-shrink: 0;
}

@media not (prefers-contrast) {
  .container.infobar {
    box-shadow: 0 1px 2px rgba(58, 57, 68, 0.1);
    background: var(--in-content-page-background);
  }

  .close {
    fill: var(--close-fill-color);
  }

  @media (prefers-color-scheme: dark) {
    /* Don't set the background in prefers-contrast mode or macOS can end up
     * with black on black text. */
    .container.infobar {
      background: rgb(66,65,77);
    }
  }
}

:host([message-bar-type=infobar]:first-of-type) {
  margin-top: 4px;
}

:host([message-bar-type=infobar]) {
  margin: 0 4px 4px;
}

.container.infobar {
  /* Don't let lwthemes set a text-shadow. */
  text-shadow: none;
  padding: 0;
}

.container.infobar::before {
  content: "";
  display: block;
  width: 2px;
  position: absolute;
  background-image: linear-gradient(0deg, #9059ff 0%, #ff4aa2 52.08%, #ffbd4f 100%);
  top: 0;
  inset-inline-start: 0;
  height: 100%;
  border-start-start-radius: 4px;
  border-end-start-radius: 4px;
}

.container.infobar {
  align-items: flex-start;
}

/* Infobars styling. */
.notification-content {
  margin: 0;
  margin-inline-start: 8px;
}

.notification-message {
  min-height: 16px; /* min-height: 32px with block padding */
  padding-block: 8px;
  margin-inline-end: 20px;
}

.notification-button-container,
.notification-message {
  display: inline-block;
  vertical-align: middle;
}

.container.infobar > .notification-content > .notification-message img.inline-icon {
  /* Align inline icon images in the message content */
  vertical-align: bottom;
  /* Ensure they get the right fill color. */
  -moz-context-properties: fill;
  fill: currentColor;
}

.close {
  margin: 4px 8px;
  background-size: 12px;
}

.notification-button {
  margin: 4px;
  /* This is supposed to be 6px but then the buttons are 26px tall by default
   * on Windows. Drop it down to 4px (with the 1px border) */
  padding-block: 3px;
}

.notification-button:first-of-type {
  /* When the buttons wrap to their own line we want to match the 8px on the message. */
  margin-inline-start: 0;
}

strong {
  font-weight: 600;
}

.text-link:hover {
  cursor: pointer;
}

.infobar > .icon {
  padding: 0;
  margin: 8px 0;
}

.infobar > .icon,
:host([type=system]) .notification-content {
  margin-inline-start: 16px;
}

:host([type=system]) .icon {
  display: none;
}
:host([type=info]) .icon {
  color: rgb(0,144,237);
}
:host([type=warning]) .icon {
  color: rgb(255,164,54);
}
:host([type=critical]) .icon {
  color: rgb(226,40,80);
}

@media (prefers-color-scheme: dark) {
  :host([type=info]) .icon {
    color: rgb(128,235,255);
  }
  :host([type=warning]) .icon {
    color: rgb(255,189,79);
  }
  :host([type=critical]) .icon {
    color: rgb(255,154,162);
  }
}