@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,274 +0,0 @@
1
- //
2
- // STACK OVERFLOW
3
- // SIDEBAR WIDGET -- STATIC PARTS
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
- // This file contains almost all the CSS for the sidebar widget. The only exception
10
- // is the "current color" highlight when the widget is used for navigation. That
11
- // part is configurable and is in the dynamic part of Stacks as
12
- // widget-dynamic.less.
13
-
14
- .s-sidebarwidget {
15
- --s-sidebarwidget-content-padding: calc(var(--su16) - var(--su1)); // subtract 1px for border
16
- --s-sidebarwidget-content-inner-spacing: var(--su12); // the spacing between two adjacent simple items
17
- --s-sidebarwidget-content-outer-spacing: var(--su16); // the spacing at the start/end of a group of simple items, as well as between a complex item and its separator line
18
-
19
- --s-sidebarwidget-outer-border-color: var(--bc-medium);
20
- --s-sidebarwidget-content-separator-color: var(--bc-light);
21
- --s-sidebarwidget-header-background-color: var(--black-025);
22
-
23
- position: relative; // so that it's the positioning parent for the :after
24
- border: 1px solid var(--s-sidebarwidget-outer-border-color);
25
- border-radius: var(--br-sm);
26
- box-shadow: var(--bs-sm);
27
- font-size: var(--fs-body1);
28
- background-color: var(--white);
29
-
30
- &:not(.s-anchors) a:not(.button):not(.s-btn):not(.post-tag):not(.s-sidebarwidget--action):not(.s-user-card--link) {
31
- &,
32
- &:visited {
33
- color: var(--black-500);
34
- }
35
- }
36
-
37
- // We must support things like collapsible (in particular invisble) elements, wrapper elements,
38
- // etc. Therefore every .-content and .-header must stand on its own; we cannot rely on things
39
- // like :first-child, because the *first* child may not be the first *visible* child, and it may
40
- // also be the :first-child of some wrapper. This is why every .-header and .-content has a
41
- // border-top. But because you shouldn't see the first visible item's or header's top border
42
- // (the widget itself provides for that border), we shift everything up by one pixel with the following pseudo-element.
43
- &:before {
44
- content: '';
45
- display: block;
46
- margin-top: -1px;
47
- }
48
-
49
- // However, because of the above, the top item's divider line now sits above the .s-sidebarwidget's top
50
- // border. We could fix this by using overflow: hidden, but that would constrain users of
51
- // .s-sidebarwidget to never have things like tooltips, autocompletes or the like that reach outside
52
- // the widget boundaries.
53
- // What we do instead is re-create the widget's top border in an absolutely positioned :after,
54
- // which sits above our item's top border. Technically, a tiny corner of the item's border will
55
- // still be visible, but at its highest point, this corner has a height of 0.27 pixels. And for
56
- // this sub-pixel issues, we're talking about different shades of gray. So we can live with that.
57
- &:after {
58
- content: '';
59
- position: absolute;
60
- top: -1px;
61
- right: -1px;
62
- left: -1px;
63
- // TODO: this makes no sense. revisit.
64
- height: calc(2px + var(--br-sm)); // we need 2px border + 2px border radius to have the correct corner shape
65
- border-top: 1px solid var(--s-sidebarwidget-outer-border-color);
66
- border-radius: var(--br-sm);
67
- pointer-events: none; // if the top item is clickable, then we don't want to prevent clicking the top 2 pixels
68
-
69
- // In order to also perfectly recreate the inner corner shape, our pseudo-element needs
70
- // the border on all sides. But we can only do that if we're able to hide the bottom part,
71
- // so this only works in browsers that support clip-path.
72
- @supports ((-webkit-clip-path: polygon(0% 0%, 100% 0%, 100% 100%, 0% 100%)) or (clip-path: polygon(0% 0%, 100% 0%, 100% 100%, 0% 100%))) or (-webkit-clip-path: polygon(0% 0%, 100% 0%, 100% 100%, 0% 100%)) {
73
- -webkit-clip-path: polygon(0% 0%, 100% 0%, 100% 50%, 0% 50%);
74
- clip-path: polygon(0% 0%, 100% 0%, 100% 50%, 0% 50%);
75
- border: 1px solid var(--s-sidebarwidget-outer-border-color);
76
- }
77
- }
78
- }
79
-
80
- .s-sidebarwidget--header,
81
- .s-sidebarwidget--content {
82
- border-top: 1px solid var(--s-sidebarwidget-content-separator-color);
83
-
84
- &:active {
85
- outline: none;
86
- }
87
- }
88
-
89
-
90
- .s-sidebarwidget--header {
91
- padding: var(--s-sidebarwidget-content-inner-spacing) var(--s-sidebarwidget-content-padding);
92
- background: var(--s-sidebarwidget-header-background-color);
93
- color: var(--black-600);
94
- font-size: var(--fs-body2);
95
- font-weight: normal;
96
- margin: 0;
97
-
98
- &:first-child {
99
- border-top-left-radius: var(--br-sm);
100
- border-top-right-radius: var(--br-sm);
101
- }
102
-
103
- &.s-sidebarwidget__small-bold-text {
104
- font-size: var(--fs-caption);
105
- font-weight: bold;
106
- .-action {
107
- font-weight: normal;
108
- line-height: calc(1.3 * var(--fs-caption)); // line-height should be the same as in the outside element, so the header and action baselines line up
109
- }
110
- }
111
-
112
- &.s-sidebarwidget__expanding-control {
113
- cursor: pointer;
114
- &:before {
115
- content: '';
116
- float: left;
117
- margin-top: ~"calc(1.3em / 2 - 5px)"; // 1.3 is our standard line height
118
- margin-right: var(--su12);
119
- border: 5px solid transparent;
120
- border-left-color: var(--bc-darker);
121
- border-right-width: 0;
122
- transition: -webkit-transform 0.3s cubic-bezier(0.4, 0.4, 0.6, 1);
123
- transition: transform 0.3s cubic-bezier(0.4, 0.4, 0.6, 1);
124
- transition: transform 0.3s cubic-bezier(0.4, 0.4, 0.6, 1), -webkit-transform 0.3s cubic-bezier(0.4, 0.4, 0.6, 1);
125
- }
126
- &[aria-expanded='true']:before {
127
- -webkit-transform: rotate(90deg);
128
- transform: rotate(90deg);
129
- }
130
- }
131
- }
132
-
133
- .s-sidebarwidget--action {
134
- float: right;
135
- margin: 0 0 var(--su4) var(--su8);
136
- color: var(--blue);
137
- font-size: var(--fs-fine);
138
- line-height: 1.3 * 15px; // line-height should be the same as in the outside element, so the header and action baselines line up
139
- }
140
-
141
- table.s-sidebarwidget--content.s-sidebarwidget__items {
142
- padding: calc(var(--s-sidebarwidget-content-outer-spacing) - var(--s-sidebarwidget-content-inner-spacing)) calc(var(--s-sidebarwidget-content-padding) - var(--s-sidebarwidget-content-inner-spacing));
143
- border-collapse: separate;
144
- border-spacing: var(--s-sidebarwidget-content-inner-spacing);
145
-
146
- tr.-item {
147
- display: table-row;
148
- td {
149
- padding: 0;
150
- }
151
- }
152
- }
153
-
154
- .s-sidebarwidget--content:not(table) {
155
- &:not(.s-sidebarwidget__items) {
156
- display: flex;
157
- }
158
- &:not(.s-sidebarwidget__block-items) .s-sidebarwidget--item {
159
- display: flex;
160
- }
161
- }
162
-
163
- .s-sidebarwidget--content {
164
- margin: 0;
165
- padding: var(--s-sidebarwidget-content-outer-spacing) var(--s-sidebarwidget-content-padding);
166
-
167
- &.s-sidebarwidget__items {
168
- display: block;
169
- // the items themselves provide part of the spacing, so the content padding needs to account for that
170
- padding: calc(var(--s-sidebarwidget-content-outer-spacing) - var(--s-sidebarwidget-content-inner-spacing)) var(--s-sidebarwidget-content-padding);
171
- &.s-sidebarwidget__block-items .s-sidebarwidget--item {
172
- .d-block;
173
- }
174
- }
175
- }
176
-
177
- .s-sidebarwidget--item {
178
- margin: var(--s-sidebarwidget-content-inner-spacing) 0;
179
-
180
- &,
181
- & > :first-child {
182
- &[aria-current="true"],
183
- &[aria-current="page"] {
184
- position: relative;
185
- color: var(--black);
186
- font-weight: bold;
187
-
188
- &:before {
189
- content: '';
190
- position: absolute;
191
- left: 0;
192
- height: calc(100% + var(--s-sidebarwidget-content-inner-spacing));
193
- margin-top: calc(var(--s-sidebarwidget-content-inner-spacing) / 2 * -1);
194
- margin-left: calc(var(--s-sidebarwidget-content-padding) * -1 - 1px); // the orange selection indicator overlaps with the widget border
195
- border-left-width: 3px;
196
- border-left-style: solid;
197
- // border-left-color is set in widget-dynamic.less
198
- }
199
-
200
- a,
201
- a:visited { // TODO: this isn't the best way to go about this. There should be a "is current" highlight without font modification for more complex cases
202
- color: inherit;
203
- }
204
- }
205
- }
206
- }
207
-
208
- .s-sidebarwidget--subnav {
209
- list-style-type: none;
210
- padding-left: 0;
211
- margin-left: var(--su8);
212
-
213
- li {
214
- margin-top: 12px;
215
- padding-left: 16px;
216
- background-position: 0 calc((1.2em - 10px) / 2);
217
- background-repeat: no-repeat;
218
- background-size: auto 10px;
219
-
220
- #stacks-internals #bullet-arrow(var(--black-100));
221
-
222
- &[aria-current="true"],
223
- &[aria-current="page"] {
224
- // this is given a bullet-arrow in the primary color in widget-dynamic.less
225
- color: var(--black);
226
- font-weight: bold;
227
-
228
- a,
229
- a:visited { // TODO: see above
230
- color: inherit;
231
- }
232
- }
233
- }
234
- }
235
-
236
- // COLOR ALTERNATIVES
237
- // todo: use CSS custom properties for this once we don't care about IE anymore
238
-
239
- .alternate-color(blue);
240
- .alternate-color(yellow);
241
- .alternate-color(green);
242
-
243
- .alternate-color(@name) {
244
- &.s-sidebarwidget__@{name} {
245
- border-color: var(~"--@{name}-200");
246
- background-color: var(~"--@{name}-050");
247
-
248
- .highcontrast-mode({
249
- border-color: var(~"--@{name}-700");
250
- });
251
-
252
- .s-sidebarwidget--header {
253
- background-color: var(~"--@{name}-100");
254
- color: var(--fc-medium);
255
- }
256
-
257
- .s-sidebarwidget--header,
258
- .s-sidebarwidget--content {
259
- border-color: var(~"--@{name}-200");
260
-
261
- .highcontrast-mode({
262
- border-color: var(~"--@{name}-700");
263
- });
264
- }
265
-
266
- &:after {
267
- border-color: var(~"--@{name}-200");
268
-
269
- .highcontrast-mode({
270
- border-color: var(~"--@{name}-700");
271
- });
272
- }
273
- }
274
- }