@stackoverflow/stacks 1.5.0 → 1.6.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,223 +1,223 @@
1
- //
2
- // STACK OVERFLOW
3
- // NOTICES
4
- //
5
- // This CSS comes from Stacks, our CSS & Pattern library for rapidly building
6
- // Stack Overflow. For documentation of all these classes and how to contribute,
7
- // visit https://stackoverflow.design/
8
- //
9
- .construct-notice-component() {
10
- background: var(--_no-bg, var(--black-050));
11
- border-color: var(--_no-bc, var(--bc-medium));
12
- border-style: solid;
13
- color: var(--_no-fc, var(--fc-medium));
14
- font-size: var(--fs-body1);
15
-
16
- code {
17
- background: var(--_no-code-bg, transparent);
18
- }
19
-
20
- & &--btn {
21
- color: inherit;
22
- padding: var(--su8);
23
-
24
- &:focus,
25
- &:hover {
26
- background: var(--_no-btn-focus-bg, var(--black-100));
27
- }
28
-
29
- &:active {
30
- background: var(--_no-btn-active-bg, var(--black-150));
31
- }
32
- }
1
+ .construct-notice-component(@baseClass) {
2
+ // BASE COMPONENT-SPECIFIC CUSTOM PROPERTIES
3
+ --_no-bc: var(--bc-medium);
4
+ --_no-bg: var(--black-050);
5
+ --_no-fc: var(--fc-medium);
6
+ --_no-btn-bg-focus: var(--black-100);
7
+ --_no-btn-bg-active: var(--black-150);
33
8
 
9
+ // MODIFIERS
34
10
  &:not(&__important) {
35
- .dark-mode({ --_no-bc: var(--_no-bg); });
36
- .highcontrast-mode({ --_no-bc: currentColor; });
37
- .highcontrast-dark-mode({ --_no-bc: currentColor; });
11
+ .dark-mode({
12
+ --_no-bc: var(--_no-bg);
13
+ });
14
+ .highcontrast-mode({
15
+ --_no-bc: currentColor;
16
+ });
17
+ .highcontrast-dark-mode({
18
+ --_no-bc: currentColor;
19
+ });
38
20
  }
39
-
40
21
  &__important {
41
22
  --_no-bc: var(--_no-bg);
42
23
  --_no-bg: var(--black-700);
43
24
  --_no-fc: var(--white);
44
- --_no-btn-focus-bg: var(--black-800);
45
- --_no-btn-active-bg: var(--black-900);
25
+ --_no-btn-bg-focus: var(--black-800);
26
+ --_no-btn-bg-active: var(--black-900);
46
27
 
47
- .highcontrast-mode({ --_no-bc: var(--_no-bg); });
28
+ .highcontrast-mode({
29
+ --_no-bc: var(--_no-bg);
30
+ });
48
31
  }
49
32
 
33
+ // VARIANTS
50
34
  &__danger {
51
35
  --_no-bc: var(--red-200);
52
36
  --_no-bg: var(--red-050);
53
- --_no-btn-focus-bg: var(--red-100);
54
- --_no-btn-active-bg: var(--red-200);
55
- }
56
- &__danger:not(&__important) {
57
- .highcontrast-mode({
58
- --_no-bg: var(--red-200);
59
- });
60
- }
61
- &__danger&__important {
62
- --_no-bc: var(--_no-bg);
63
- --_no-bg: var(--red-500);
64
- --_no-btn-focus-bg: var(--red-600);
65
- --_no-btn-active-bg: var(--red-700);
37
+ --_no-btn-bg-active: var(--red-200);
38
+ --_no-btn-bg-focus: var(--red-100);
66
39
 
67
- .dark-mode({
68
- --_no-bg: var(--red-400);
69
- --_no-fc: var(--black-900);
70
- });
71
- .highcontrast-dark-mode({
40
+ &:not(.@{baseClass}__important) {
41
+ .highcontrast-mode({
42
+ --_no-bg: var(--red-200);
43
+ });
44
+ }
45
+ &.@{baseClass}__important {
46
+ --_no-bc: var(--_no-bg);
72
47
  --_no-bg: var(--red-500);
73
- --_no-fc: var(--white);
74
- });
75
- }
48
+ --_no-btn-bg-active: var(--red-700);
49
+ --_no-btn-bg-focus: var(--red-600);
76
50
 
51
+ .dark-mode({
52
+ --_no-bg: var(--red-400);
53
+ --_no-fc: var(--black-900);
54
+ });
55
+ .highcontrast-dark-mode({
56
+ --_no-bg: var(--red-500);
57
+ --_no-fc: var(--white);
58
+ });
59
+ }
60
+ }
77
61
  &__info {
78
62
  --_no-bc: var(--theme-secondary-150);
79
63
  --_no-bg: var(--theme-secondary-050);
80
- --_no-btn-focus-bg: var(--theme-secondary-100);
81
- --_no-btn-active-bg: var(--theme-secondary-150);
64
+ --_no-btn-bg-focus: var(--theme-secondary-100);
65
+ --_no-btn-bg-active: var(--theme-secondary-150);
82
66
  --_no-code-bg: var(--theme-secondary-150);
83
- }
84
- &__info:not(&__important) {
85
- .highcontrast-mode({
86
- --_no-bg: var(--theme-secondary-100);
87
- });
88
- .highcontrast-dark-mode({
89
- --_no-bg: var(--theme-secondary-100);
90
- });
91
- }
92
- &__info&__important {
93
- --_no-bc: var(--_no-bg);
94
- --_no-bg: var(--theme-secondary-400);
95
- --_no-btn-focus-bg: var(--theme-secondary-500);
96
- --_no-btn-active-bg: var(--theme-secondary-600);
97
67
 
98
- .dark-mode({
99
- --_no-bg: var(--theme-secondary-300);
100
- --_no-fc: var(--black-900);
101
- });
102
- .highcontrast-dark-mode({
68
+ &:not(.@{baseClass}__important) {
69
+ .highcontrast-mode({
70
+ --_no-bg: var(--theme-secondary-100);
71
+ });
72
+ .highcontrast-dark-mode({
73
+ --_no-bg: var(--theme-secondary-100);
74
+ });
75
+ }
76
+ &.@{baseClass}__important {
77
+ --_no-bc: var(--_no-bg);
103
78
  --_no-bg: var(--theme-secondary-400);
104
- --_no-fc: var(--white);
105
- });
106
- }
79
+ --_no-btn-bg-active: var(--theme-secondary-600);
80
+ --_no-btn-bg-focus: var(--theme-secondary-500);
107
81
 
82
+ .dark-mode({
83
+ --_no-bg: var(--theme-secondary-300);
84
+ --_no-fc: var(--black-900);
85
+ });
86
+ .highcontrast-dark-mode({
87
+ --_no-bg: var(--theme-secondary-400);
88
+ --_no-fc: var(--white);
89
+ });
90
+ }
91
+ }
108
92
  &__success {
109
93
  --_no-bc: var(--green-200);
110
94
  --_no-bg: var(--green-050);
111
- --_no-btn-focus-bg: var(--green-100);
112
- --_no-btn-active-bg: var(--green-200);
113
- }
114
- &__success:not(&__important) {
115
- .highcontrast-mode({
116
- --_no-bg: var(--green-200);
117
- });
118
- }
119
- &__success&__important {
120
- --_no-bc: var(--_no-bg);
121
- --_no-bg: var(--green-400);
122
- --_no-fc: var(--black-900);
123
- --_no-btn-focus-bg: var(--green-500);
124
- --_no-btn-active-bg: var(--green-600);
95
+ --_no-btn-bg-active: var(--green-200);
96
+ --_no-btn-bg-focus: var(--green-100);
125
97
 
126
- .dark-mode({
127
- --_no-bg: var(--green-500);
128
- --_no-fc: var(--white);
129
- });
130
- .highcontrast-mode({
131
- --_no-bg: var(--green-500);
132
- --_no-fc: var(--white);
133
- });
134
- }
98
+ &:not(.@{baseClass}__important) {
99
+ .highcontrast-mode({
100
+ --_no-bg: var(--green-200);
101
+ });
102
+ }
103
+ &.@{baseClass}__important {
104
+ --_no-bc: var(--_no-bg);
105
+ --_no-bg: var(--green-400);
106
+ --_no-fc: var(--black-900);
107
+ --_no-btn-bg-active: var(--green-600);
108
+ --_no-btn-bg-focus: var(--green-500);
135
109
 
110
+ .dark-mode({
111
+ --_no-bg: var(--green-500);
112
+ --_no-fc: var(--white);
113
+ });
114
+ .highcontrast-mode({
115
+ --_no-bg: var(--green-500);
116
+ --_no-fc: var(--white);
117
+ });
118
+ }
119
+ }
136
120
  &__warning {
137
121
  --_no-bc: var(--yellow-300);
138
122
  --_no-bg: var(--yellow-050);
139
- --_no-btn-focus-bg: var(--yellow-200);
140
- --_no-btn-active-bg: var(--yellow-300);
123
+ --_no-btn-bg-active: var(--yellow-300);
124
+ --_no-btn-bg-focus: var(--yellow-200);
141
125
  --_no-code-bg: var(--yellow-200);
126
+
127
+ &:not(.@{baseClass}__important) {
128
+ .highcontrast-mode({
129
+ --_no-bg: var(--yellow-200);
130
+ });
131
+ }
132
+ &.@{baseClass}__important {
133
+ --_no-bc: var(--_no-bg);
134
+ --_no-bg: var(--yellow-400);
135
+ --_no-fc: var(--black-900);
136
+ --_no-btn-bg-active: var(--yellow-600);
137
+ --_no-btn-bg-focus: var(--yellow-500);
138
+
139
+ .dark-mode({
140
+ --_no-bg: var(--yellow-600);
141
+ --_no-fc: var(--white);
142
+ });
143
+ .highcontrast-mode({
144
+ --_no-bg: var(--yellow-700);
145
+ --_no-fc: var(--white);
146
+ });
147
+ }
142
148
  }
143
- &__warning:not(&__important) {
144
- .highcontrast-mode({
145
- --_no-bg: var(--yellow-200);
146
- });
149
+
150
+ // CHILD ELEMENTS
151
+ code {
152
+ background: var(--_no-code-bg, transparent);
147
153
  }
148
- &__warning&__important {
149
- --_no-bc: var(--_no-bg);
150
- --_no-bg: var(--yellow-400);
151
- --_no-btn-focus-bg: var(--yellow-500);
152
- --_no-btn-active-bg: var(--yellow-600);
153
- --_no-fc: var(--black-900);
154
+ & &--btn {
155
+ &:focus,
156
+ &:hover {
157
+ background: var(--_no-btn-bg-focus);
158
+ }
159
+ &:active {
160
+ background: var(--_no-btn-bg-active);
161
+ }
154
162
 
155
- .dark-mode({
156
- --_no-bg: var(--yellow-600);
157
- --_no-fc: var(--white);
158
- });
159
- .highcontrast-mode({
160
- --_no-bg: var(--yellow-700);
161
- --_no-fc: var(--white);
162
- });
163
+ color: inherit;
164
+ padding: var(--su8);
163
165
  }
166
+
167
+ // STYLES MODIFIED BY COMPONENT-SPECIFIC CUSTOM PROPERTIES
168
+ background: var(--_no-bg);
169
+ border-color: var(--_no-bc);
170
+ color: var(--_no-fc);
171
+
172
+ border-style: solid;
173
+ font-size: var(--fs-body1);
164
174
  }
165
175
 
166
176
  // Banner
167
177
  // TODO deprecate .s-banner (by turning it into a modifier on .s-notice)
168
178
  // This would reduce the amount of CSS we ship to the client and simplify our codebase
169
179
  .s-banner {
170
- .construct-notice-component();
171
- --_no-x-offset: 0;
172
- // When we use .s-banner, we need to adjust the padding-top on
173
- // the body tag. This class correctly adjusts the body padding ONLY if
174
- // the notice is one line. If it wraps to multiple lines, more classes or
175
- // (ideally) JS will need to be used to determine the notice's height
176
- // at the time of render. The padding value is determined like so:
177
- //
178
- // 50px (top bar) + 44px (notice height) - 1px (bottom border)
179
- //
180
- // The borders subtraction are necessary to neatly tuck everything together.
181
- // ----------------------------------------------------------------------------
182
- &__body-pt {
183
- padding-top: 93px;
184
- }
185
- // If you want to put the banner above the topbar
186
- &.is-pinned {
187
- z-index: calc(var(--zi-navigation-fixed) + 1);
188
- }
189
- // If you want to hide and reveal the banner
190
- &[aria-hidden="true"] {
191
- --_no-x-offset: -50px; // TODO convert to su vars
192
- visibility: hidden;
180
+ --_no-x-offset: 0; // [1]
181
+ .construct-notice-component(s-banner);
182
+
183
+ &[aria-hidden="true"] { // If you want to hide and reveal the banner
184
+ --_no-x-offset: calc(var(--su48) + var(--su2) * -1); // -50px
193
185
  opacity: 0;
186
+ visibility: hidden;
194
187
  }
195
188
  &[aria-hidden="false"] {
196
- --_no-x-offset: 49px; // TODO convert to su vars
197
- visibility: visible;
189
+ --_no-x-offset: calc(var(--su48) + var(--su1)); // 49px
198
190
  opacity: 1;
191
+ visibility: visible;
192
+ }
193
+ &.is-pinned { // If you want to put the banner above the topbar
194
+ z-index: calc(var(--zi-navigation-fixed) + 1);
195
+ }
196
+ &__body-pt {
197
+ padding-top: 93px;
199
198
  }
200
- // When we want to keep hero content capped
201
- .s-banner--container {
199
+ & &--container { // When we want to keep hero content capped
200
+ margin: 0 auto;
201
+ max-width: calc(var(--s-step) * 10);
202
202
  position: relative;
203
203
  width: 100%;
204
- max-width: calc(var(--s-step) * 10);
205
- margin: 0 auto;
206
204
  }
207
205
 
206
+ -webkit-transform: translate3d(0, var(--_no-x-offset), 0);
207
+ transform: translate3d(0, var(--_no-x-offset), 0);
208
+
208
209
  border-width: var(--su-static1) 0;
209
210
  inset: 0 0 auto 0;
210
211
  padding: var(--su12);
211
212
  position: fixed;
212
213
  width: 100%;
213
214
  z-index: calc(var(--zi-navigation-fixed) - 1); // Tuck below topbar
214
- -webkit-transform: translate3d(0, var(--_no-x-offset), 0);
215
- transform: translate3d(0, var(--_no-x-offset), 0);
216
215
  }
217
216
 
218
217
  // Notice
219
218
  .s-notice {
220
- .construct-notice-component();
219
+ .construct-notice-component(s-notice);
220
+
221
221
  border-radius: var(--br-sm);
222
222
  border-width: var(--su-static1);
223
223
  padding: var(--su16);
@@ -225,36 +225,43 @@
225
225
 
226
226
  // Toast
227
227
  .s-toast {
228
- visibility: hidden;
229
- position: fixed;
230
- display: flex;
231
- justify-content: center;
232
- top: var(--su16);
233
- left: var(--su8);
234
- right: var(--su8);
235
- opacity: 0;
236
- z-index: calc(var(--zi-modals) + 1); // Toasts should appear above modals
237
- transform: translate3d(0, -66px, 0);
238
- transition: transform 100ms var(--te-smooth-slow) 0s, opacity 60ms var(--te-smooth-slow) 0ms, visibility 0s 150ms;
239
- pointer-events: none;
240
-
228
+ @media (prefers-reduced-motion) {
229
+ transform: none !important;
230
+ }
241
231
  &[aria-hidden="false"] {
242
- visibility: visible;
243
232
  opacity: 1;
244
233
  transform: translate3d(0, 0, 0);
245
234
  transition: visibility 0s 0s, opacity 100ms var(--te-smooth) 0s, transform 100ms var(--te-smooth) 0s;
246
- }
247
-
248
- @media (prefers-reduced-motion) {
249
- transform: none;
235
+ visibility: visible;
250
236
  }
251
237
 
252
238
  .s-notice {
239
+ box-shadow: var(--bs-sm);
253
240
  max-width: 44rem;
254
- width: 100%;
255
- padding-top: var(--su8);
256
241
  padding-bottom: var(--su8);
257
- box-shadow: var(--bs-sm);
242
+ padding-top: var(--su8);
258
243
  pointer-events: all;
244
+ width: 100%;
259
245
  }
246
+
247
+ display: flex;
248
+ justify-content: center;
249
+ left: var(--su8);
250
+ opacity: 0;
251
+ pointer-events: none;
252
+ position: fixed;
253
+ right: var(--su8);
254
+ top: var(--su16);
255
+ transform: translate3d(0, -66px, 0);
256
+ transition: transform 100ms var(--te-smooth-slow) 0s, opacity 60ms var(--te-smooth-slow) 0ms, visibility 0s 150ms;
257
+ visibility: hidden;
258
+ z-index: calc(var(--zi-modals) + 1); // Toasts should appear above modals
260
259
  }
260
+
261
+ // [1] When we use .s-banner, we need to adjust the padding-top on
262
+ // the body tag. This class correctly adjusts the body padding ONLY if
263
+ // the notice is one line. If it wraps to multiple lines, more classes or
264
+ // (ideally) JS will need to be used to determine the notice's height
265
+ // at the time of render. The padding value is determined like so:
266
+ // 50px (top bar) + 44px (notice height) - 1px (bottom border)
267
+ // The borders subtraction are necessary to neatly tuck everything together.
@@ -1,12 +1,3 @@
1
- //
2
- // STACK OVERFLOW
3
- // POST SUMMARY
4
- //
5
- // This CSS comes from Stacks, our CSS & Pattern library for rapidly building
6
- // Stack Overflow. For documentation of all these classes and how to contribute,
7
- // visit https://stackoverflow.design/
8
- //
9
-
10
1
  .s-post-summary {
11
2
  position: relative;
12
3
  display: flex;