@stackoverflow/stacks 1.3.0 → 1.3.3

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.
Files changed (39) hide show
  1. package/dist/controllers/s-expandable-control.d.ts +1 -1
  2. package/dist/controllers/s-tooltip.d.ts +16 -1
  3. package/dist/css/stacks.css +848 -559
  4. package/dist/css/stacks.min.css +1 -1
  5. package/dist/js/stacks.js +153 -84
  6. package/dist/js/stacks.min.js +1 -1
  7. package/lib/css/atomic/borders.less +1 -0
  8. package/lib/css/atomic/colors.less +1 -0
  9. package/lib/css/atomic/misc.less +1 -1
  10. package/lib/css/atomic/typography.less +0 -6
  11. package/lib/css/components/activity-indicator.less +18 -17
  12. package/lib/css/components/avatars.less +50 -131
  13. package/lib/css/components/breadcrumbs.less +4 -4
  14. package/lib/css/components/buttons.less +8 -48
  15. package/lib/css/components/empty-states.less +15 -0
  16. package/lib/css/components/{collapsible.less → expandable.less} +0 -0
  17. package/lib/css/components/inputs.less +37 -101
  18. package/lib/css/components/labels.less +98 -0
  19. package/lib/css/components/links.less +15 -3
  20. package/lib/css/components/notices.less +190 -163
  21. package/lib/css/components/post-summary.less +98 -35
  22. package/lib/css/components/progress-bars.less +1 -1
  23. package/lib/css/components/prose.less +4 -4
  24. package/lib/css/components/spinner.less +39 -1
  25. package/lib/css/components/tables.less +1 -5
  26. package/lib/css/components/uploader.less +70 -84
  27. package/lib/css/exports/constants-colors.less +19 -0
  28. package/lib/css/stacks-dynamic.less +0 -1
  29. package/lib/css/stacks-static.less +3 -2
  30. package/lib/ts/controllers/s-expandable-control.ts +23 -19
  31. package/lib/ts/controllers/s-modal.ts +16 -16
  32. package/lib/ts/controllers/s-navigation-tablist.ts +13 -13
  33. package/lib/ts/controllers/s-popover.ts +26 -18
  34. package/lib/ts/controllers/s-table.ts +31 -29
  35. package/lib/ts/controllers/s-tooltip.ts +62 -23
  36. package/lib/ts/stacks.ts +8 -4
  37. package/package.json +17 -17
  38. package/lib/css/components/banners.less +0 -80
  39. package/lib/css/components/blank-states.less +0 -26
@@ -0,0 +1,98 @@
1
+ .s-label {
2
+ --_fs: var(--fs-body2);
3
+
4
+ &[for] {
5
+ cursor: pointer;
6
+ }
7
+
8
+ fieldset[disabled] &,
9
+ .is-disabled & {
10
+ cursor: not-allowed;
11
+ opacity: var(--_o-disabled-static);
12
+
13
+ .s-description {
14
+ opacity: unset;
15
+ }
16
+ }
17
+
18
+ .is-readonly & {
19
+ cursor: not-allowed;
20
+ }
21
+
22
+ .s-description,
23
+ .s-input-message {
24
+ font-weight: normal;
25
+ margin-bottom: 0;
26
+ margin-top: var(--su4);
27
+ padding: 0;
28
+ }
29
+
30
+ // Sizes
31
+ &.s-label__sm {
32
+ --_fs: var(--fs-caption);
33
+ }
34
+ &.s-label__md {
35
+ --_fs: var(--fs-body3);
36
+ }
37
+ &.s-label__lg {
38
+ --_fs: var(--fs-title);
39
+ }
40
+ &.s-label__xl {
41
+ --_fs: var(--fs-headline1);
42
+ }
43
+
44
+ color: var(--fc-dark);
45
+ font-family: inherit;
46
+ font-size: var(--_fs);
47
+ font-weight: 600;
48
+ padding: 0 var(--su2); // Helps the label visually line up with inputs
49
+ }
50
+
51
+ // $$ LABEL STATUS FLAG
52
+ // ----------------------------------------------------------------------------
53
+ // Is this form item required or optional? Flag the status for users.
54
+ // Default styling is optional.
55
+ .s-label--status {
56
+ --_b: none;
57
+ --_bg: var(--black-050);
58
+ --_fc: var(--fc-medium);
59
+
60
+ .highcontrast-mode({
61
+ --_b: var(--su-static1) solid currentColor;
62
+ });
63
+
64
+ &.s-label--status__required {
65
+ --_bg: var(--red-100);
66
+ --_fc: var(--red-700);
67
+
68
+ .dark-mode({
69
+ --_bg: var(--red-050);
70
+ --_fc: var(--red-800);
71
+ });
72
+ }
73
+
74
+ &.s-label--status__new {
75
+ --_bg: var(--green-100);
76
+ --_fc: var(--green-700);
77
+
78
+ .dark-mode({
79
+ --_bg: var(--green-050);
80
+ --_fc: var(--green-800);
81
+ });
82
+ }
83
+
84
+ &.s-label--status__beta {
85
+ --_bg: var(--blue-100);
86
+ --_fc: var(--blue-700);
87
+ }
88
+
89
+ background-color: var(--_bg);
90
+ border: var(--_b);
91
+ border-radius: 1000px;
92
+ color: var(--_fc);
93
+ font-size: var(--fs-caption);
94
+ font-weight: 400;
95
+ margin-left: var(--su4);
96
+ padding: var(--su2) var(--su8);
97
+ vertical-align: text-bottom;
98
+ }
@@ -190,6 +190,8 @@ button.s-link {
190
190
  @focus-styles();
191
191
 
192
192
  &.is-selected {
193
+ --_block-bs: inset var(--_block-bs-offset-x, 3px) 0 0 var(--theme-primary-color);
194
+
193
195
  color: var(--black-800);
194
196
  font-weight: bold;
195
197
  background-color: var(--black-050);
@@ -199,11 +201,21 @@ button.s-link {
199
201
  });
200
202
 
201
203
  &.s-block-link__right {
202
- box-shadow: inset -3px 0 0 var(--theme-primary-color);
204
+ --_block-bs-offset-x: -3px;
203
205
  }
204
206
 
205
- &.s-block-link__left {
206
- box-shadow: inset 3px 0 0 var(--theme-primary-color);
207
+ &.s-block-link__left,
208
+ &.s-block-link__right {
209
+ box-shadow: var(--_block-bs);
210
+
211
+ &:focus:not(:focus-visible),
212
+ &:focus-visible {
213
+ outline: none;
214
+ }
215
+
216
+ &:focus-visible {
217
+ box-shadow: var(--_block-bs), 0 0 0 var(--su-static4) var(--focus-ring-muted);
218
+ }
207
219
  }
208
220
  }
209
221
 
@@ -6,206 +6,224 @@
6
6
  // Stack Overflow. For documentation of all these classes and how to contribute,
7
7
  // visit https://stackoverflow.design/
8
8
  //
9
- // TABLE OF CONTENTS
10
- // • BASE STYLE
11
- // • LAYOUT TRANSITIONS
12
- //
13
- // ============================================================================
14
- // $ BASE STYLES
15
- // ----------------------------------------------------------------------------
16
- // $$ FILLED, MUTED
17
- .s-notice {
18
- padding: var(--su16);
19
- border: 1px solid transparent;
20
- border-radius: var(--br-sm);
21
- color: var(--fc-medium);
9
+ .construct-notice-component() {
10
+ background: var(--_bg, var(--black-050));
11
+ border-color: var(--_bc, var(--bc-medium));
12
+ border-style: solid;
13
+ color: var(--_fc, var(--fc-medium));
22
14
  font-size: var(--fs-body1);
23
15
 
24
- .s-toast & {
25
- max-width: 44rem;
26
- width: 100%;
27
- padding-top: var(--su8);
28
- padding-bottom: var(--su8);
29
- box-shadow: var(--bs-sm);
30
- pointer-events: all;
16
+ code {
17
+ background: var(--_code-bg, transparent);
31
18
  }
32
19
 
33
- .s-notice--btn {
34
- color: var(--fc-dark);
20
+ & &--btn {
21
+ color: inherit;
35
22
  padding: var(--su8);
36
- }
37
- }
38
-
39
- // ============================================================================
40
- // $ VISUAL STYLES
41
- // ============================================================================
42
- // $$ INFO
43
- // ----------------------------------------------------------------------------
44
- .s-notice__info,
45
- .s-banner__info {
46
- border-color: var(--theme-secondary-150);
47
- background-color: var(--theme-secondary-050);
48
23
 
49
- &.s-notice__important,
50
- &.s-banner__important {
51
- background-color: var(--theme-secondary-400);
52
- }
53
-
54
- // Improve the presentation of buttons
55
- .s-notice--btn {
56
24
  &:focus,
57
25
  &:hover {
58
- background-color: var(--theme-secondary-300);
26
+ background: var(--_btn-focus-bg, var(--black-100));
59
27
  }
60
28
 
61
29
  &:active {
62
- background-color: var(--theme-secondary-400);
30
+ background: var(--_btn-active-bg, var(--black-150));
63
31
  }
64
32
  }
65
33
 
66
- code {
67
- background-color: var(--theme-secondary-150);
34
+ &:not(&__important) {
35
+ .dark-mode({ --_bc: var(--_bg); });
36
+ .highcontrast-mode({ --_bc: currentColor; });
37
+ .highcontrast-dark-mode({ --_bc: currentColor; });
68
38
  }
69
- }
70
39
 
71
- // $$ SUCCESS
72
- // ----------------------------------------------------------------------------
73
- .s-notice__success,
74
- .s-banner__success {
75
- border-color: var(--green-200);
76
- background-color: var(--green-050);
77
-
78
- // Bump up the border contrast in high contrast mode
79
- .highcontrast-mode({
80
- background-color: var(--green-200);
81
- border-color: var(--green-400);
82
- });
83
-
84
- &.s-notice__important,
85
- &.s-banner__important {
86
- background-color: var(--green-400);
87
- color: var(--black-900);
88
-
89
- // Bump up the text in high contrast
40
+ &__important {
41
+ --_bc: var(--_bg);
42
+ --_bg: var(--black-700);
43
+ --_fc: var(--white);
44
+ --_btn-focus-bg: var(--black-800);
45
+ --_btn-active-bg: var(--black-900);
46
+
47
+ .highcontrast-mode({ --_bc: var(--_bg); });
48
+ }
49
+
50
+ &__danger {
51
+ --_bc: var(--red-200);
52
+ --_bg: var(--red-050);
53
+ --_btn-focus-bg: var(--red-100);
54
+ --_btn-active-bg: var(--red-200);
55
+ }
56
+ &__danger:not(&__important) {
90
57
  .highcontrast-mode({
91
- background-color: var(--green-500);
92
- color: var(--white);
93
- border-color: transparent;
58
+ --_bg: var(--red-200);
94
59
  });
95
60
  }
96
-
97
- // Improve the presentation of buttons
98
- .s-notice--btn {
99
- &:focus,
100
- &:hover {
101
- background-color: var(--green-100);
102
- }
103
-
104
- &:active {
105
- background-color: var(--green-200);
106
- }
61
+ &__danger&__important {
62
+ --_bc: var(--_bg);
63
+ --_bg: var(--red-500);
64
+ --_btn-focus-bg: var(--red-600);
65
+ --_btn-active-bg: var(--red-700);
66
+
67
+ .dark-mode({
68
+ --_bg: var(--red-400);
69
+ --_fc: var(--black-900);
70
+ });
71
+ .highcontrast-dark-mode({
72
+ --_bg: var(--red-500);
73
+ --_fc: var(--white);
74
+ });
107
75
  }
108
- }
109
76
 
110
- // $$ WARNING
111
- // ----------------------------------------------------------------------------
112
- .s-notice__warning,
113
- .s-banner__warning {
114
- border-color: var(--yellow-300);
115
- background-color: var(--yellow-050);
116
-
117
- // Bump up the border contrast in high contrast mode
118
- .highcontrast-mode({
119
- background-color: var(--yellow-200);
120
- border-color: var(--yellow-700);
121
- });
122
-
123
- &.s-notice__important,
124
- &.s-banner__important {
125
- background-color: var(--yellow-400);
126
- color: var(--black-900);
127
-
128
- // Bump up the text in high contrast
77
+ &__info {
78
+ --_bc: var(--theme-secondary-150);
79
+ --_bg: var(--theme-secondary-050);
80
+ --_btn-focus-bg: var(--theme-secondary-100);
81
+ --_btn-active-bg: var(--theme-secondary-150);
82
+ --_code-bg: var(--theme-secondary-150);
83
+ }
84
+ &__info:not(&__important) {
129
85
  .highcontrast-mode({
130
- background-color: var(--yellow-500);
131
- color: var(--white);
132
- border-color: transparent;
86
+ --_bg: var(--theme-secondary-100);
87
+ });
88
+ .highcontrast-dark-mode({
89
+ --_bg: var(--theme-secondary-100);
90
+ });
91
+ }
92
+ &__info&__important {
93
+ --_bc: var(--_bg);
94
+ --_bg: var(--theme-secondary-400);
95
+ --_btn-focus-bg: var(--theme-secondary-500);
96
+ --_btn-active-bg: var(--theme-secondary-600);
97
+
98
+ .dark-mode({
99
+ --_bg: var(--theme-secondary-300);
100
+ --_fc: var(--black-900);
101
+ });
102
+ .highcontrast-dark-mode({
103
+ --_bg: var(--theme-secondary-400);
104
+ --_fc: var(--white);
133
105
  });
134
106
  }
135
107
 
136
- // Improve the presentation of buttons
137
- .s-notice--btn {
138
- &:focus,
139
- &:hover {
140
- background-color: var(--yellow-200);
141
- }
142
-
143
- &:active {
144
- background-color: var(--yellow-300);
145
- }
108
+ &__success {
109
+ --_bc: var(--green-200);
110
+ --_bg: var(--green-050);
111
+ --_btn-focus-bg: var(--green-100);
112
+ --_btn-active-bg: var(--green-200);
113
+ }
114
+ &__success:not(&__important) {
115
+ .highcontrast-mode({
116
+ --_bg: var(--green-200);
117
+ });
118
+ }
119
+ &__success&__important {
120
+ --_bc: var(--_bg);
121
+ --_bg: var(--green-400);
122
+ --_fc: var(--black-900);
123
+ --_btn-focus-bg: var(--green-500);
124
+ --_btn-active-bg: var(--green-600);
125
+
126
+ .dark-mode({
127
+ --_bg: var(--green-500);
128
+ --_fc: var(--white);
129
+ });
130
+ .highcontrast-mode({
131
+ --_bg: var(--green-500);
132
+ --_fc: var(--white);
133
+ });
146
134
  }
147
135
 
148
- code {
149
- background-color: var(--yellow-200);
136
+ &__warning {
137
+ --_bc: var(--yellow-300);
138
+ --_bg: var(--yellow-050);
139
+ --_btn-focus-bg: var(--yellow-200);
140
+ --_btn-active-bg: var(--yellow-300);
141
+ --_code-bg: var(--yellow-200);
142
+ }
143
+ &__warning:not(&__important) {
144
+ .highcontrast-mode({
145
+ --_bg: var(--yellow-200);
146
+ });
147
+ }
148
+ &__warning&__important {
149
+ --_bc: var(--_bg);
150
+ --_bg: var(--yellow-400);
151
+ --_btn-focus-bg: var(--yellow-500);
152
+ --_btn-active-bg: var(--yellow-600);
153
+ --_fc: var(--black-900);
154
+
155
+ .dark-mode({
156
+ --_bg: var(--yellow-600);
157
+ --_fc: var(--white);
158
+ });
159
+ .highcontrast-mode({
160
+ --_bg: var(--yellow-700);
161
+ --_fc: var(--white);
162
+ });
150
163
  }
151
164
  }
152
165
 
153
- // $$ DANGER
154
- // ----------------------------------------------------------------------------
155
- .s-notice__danger,
156
- .s-banner__danger {
157
- border-color: var(--red-200);
158
- background-color: var(--red-050);
159
-
160
- // Bump up the border contrast in high contrast mode
161
- .highcontrast-mode({
162
- background-color: var(--red-200);
163
- border-color: var(--red-500);
164
-
165
- &.s-notice__important,
166
- &.s-banner__important {
167
- background-color: var(--red-500);
168
- }
169
- });
170
-
171
- &.s-notice__important,
172
- &.s-banner__important {
173
- background-color: var(--red-400);
166
+ // Banner
167
+ // TODO deprecate .s-banner (by turning it into a modifier on .s-notice)
168
+ // This would reduce the amount of CSS we ship to the client and simplify our codebase
169
+ .s-banner {
170
+ .construct-notice-component();
171
+ --_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;
174
184
  }
175
-
176
- // Improve the presentation of buttons
177
- .s-notice--btn {
178
- &:focus,
179
- &:hover {
180
- background-color: var(--red-100);
181
- }
182
-
183
- &:active {
184
- background-color: var(--red-200);
185
- }
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
+ --_x-offset: -50px; // TODO convert to su vars
192
+ visibility: hidden;
193
+ opacity: 0;
194
+ }
195
+ &[aria-hidden="false"] {
196
+ --_x-offset: 49px; // TODO convert to su vars
197
+ visibility: visible;
198
+ opacity: 1;
199
+ }
200
+ // When we want to keep hero content capped
201
+ .s-banner--container {
202
+ position: relative;
203
+ width: 100%;
204
+ max-width: calc(var(--s-step) * 10);
205
+ margin: 0 auto;
186
206
  }
187
- }
188
207
 
189
- // $$ IMPORTANT
190
- // ----------------------------------------------------------------------------
191
- .s-notice__important {
192
- border-color: transparent;
193
- background-color: var(--black-700);
194
- color: var(--white);
208
+ border-width: var(--su-static1) 0;
209
+ inset: 0 0 auto 0;
210
+ padding: var(--su12);
211
+ position: fixed;
212
+ width: 100%;
213
+ z-index: calc(var(--zi-navigation-fixed) - 1); // Tuck below topbar
214
+ -webkit-transform: translate3d(0, var(--_x-offset), 0);
215
+ transform: translate3d(0, var(--_x-offset), 0);
195
216
  }
196
217
 
197
- .s-notice__info,
198
- .s-notice__success,
199
- .s-notice__warning,
200
- .s-notice__danger {
201
- .dark-mode({ border-color: transparent; });
202
- .highcontrast-mode({ border-color: currentColor; });
203
-
218
+ // Notice
219
+ .s-notice {
220
+ .construct-notice-component();
221
+ border-radius: var(--br-sm);
222
+ border-width: var(--su-static1);
223
+ padding: var(--su16);
204
224
  }
205
225
 
206
- // ============================================================================
207
- // $ TOASTS
208
- // ----------------------------------------------------------------------------
226
+ // Toast
209
227
  .s-toast {
210
228
  visibility: hidden;
211
229
  position: fixed;
@@ -230,4 +248,13 @@
230
248
  @media (prefers-reduced-motion) {
231
249
  transform: none;
232
250
  }
251
+
252
+ .s-notice {
253
+ max-width: 44rem;
254
+ width: 100%;
255
+ padding-top: var(--su8);
256
+ padding-bottom: var(--su8);
257
+ box-shadow: var(--bs-sm);
258
+ pointer-events: all;
259
+ }
233
260
  }