File size: 9,461 Bytes
1e92f2d |
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 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 |
@import "@wordpress/base-styles/breakpoints";
$bar-chart-border-radius: 2px;
$year-bar-chart-border-radius: 4px;
// Chart
// Life is a statistical anomaly
.chart {
position: relative;
box-sizing: border-box;
padding: 0 0 0 20px;
}
// Y-axis
// Y-axis markers (lines)
.chart .chart__y-axis-markers {
position: absolute;
left: 0;
right: 0;
height: 200px;
}
.chart .chart__y-axis-marker {
position: absolute;
top: 0;
width: 100%;
height: 1px;
border-top: 1px solid var(--color-neutral-0);
}
// Y-axis marker lines inside each chart__bar
// (This is needed so that bars overlap correctly)
.chart__bar-marker {
z-index: z-index("root", ".chart__bar-marker");
position: absolute;
top: 0;
width: 100%;
height: 1px;
border-top: 1px solid color-mix(in srgb, var(--color-neutral-0) 10%, transparent);
}
.chart__bar-marker,
.chart__y-axis-label,
.chart .chart__y-axis-marker {
&.is-fifty {
top: 50%;
}
&.is-zero {
top: 100%;
}
}
// Y-axis labels
// 1: matches Y-axis padding
$y-axis-padding: 0 20px;
.chart__y-axis {
position: relative;
float: right;
height: 200px;
padding: $y-axis-padding;
font-size: $font-body-extra-small;
color: var(--color-neutral-40);
margin-bottom: 30px;
}
.chart__y-axis-label {
position: absolute;
top: 0;
right: 20px; // 1
text-align: right;
}
// For forcing the width of y-axis to the width of the label
// Uses invisible text to establish consistent width while maintaining layout flow
.chart__y-axis-width-spacer {
color: color-mix(in srgb, transparent 100%, var(--color-surface));
}
// X-axis
// 1: hides spaces between elements
.chart__x-axis {
position: relative;
font-size: 0; // 1
padding: 5px 0;
min-height: 18px;
color: var(--color-neutral-60);
}
.chart__x-axis-label {
position: absolute;
display: inline-block;
vertical-align: top;
font-size: $font-body-extra-small;
text-align: center;
font-weight: 400;
line-height: 24px;
color: var(--color-neutral-40);
}
// X-axis label indicator
// (vertical thin grey bar)
.chart__x-axis-label::before {
content: "";
display: block;
position: absolute;
top: -4px;
left: 50%;
margin-left: -0.5px;
width: 1px;
height: 5px;
background: var(--color-neutral-60);
}
// X-axis width spacer
// Similar to y-axis, creates consistent width spacing using invisible text
.chart__x-axis-width-spacer {
color: color-mix(in srgb, transparent 100%, var(--color-surface));
padding: $y-axis-padding;
right: 0;
&::before {
display: none;
}
}
// Bar wrapper
// 1: hides spaces between elements
.chart__bars {
position: relative;
font-size: 0; // 1
height: 200px;
text-align: center;
overflow: hidden;
display: flex;
}
// Individual bar
// 1: Needs to be relative so that the contained graphic bar has boundaries
// 2: Animate the bar on mounting to make it consistent with the transitions later when values change
.chart__bar {
text-align: center;
display: inline-block;
position: relative; // 1
height: 200px;
-ms-flex-grow: 1;
flex-grow: 1;
-ms-flex-shrink: 1;
flex-shrink: 1;
transform: scaleY(0);
transform-origin: 0% 100%;
animation: growUpOnMounting 0.2s ease-in forwards; // 2
@keyframes growUpOnMounting {
100% {
transform: scaleY(1);
}
}
&:hover {
cursor: pointer;
background-color: color-mix(in srgb, var(--color-neutral) 10%, transparent);
}
&.is-selected {
cursor: default;
background-color: color-mix(in srgb, var(--color-primary) 10%, transparent);
}
}
// Individual bar wrapper & misc
// 1: Positions the bar in the space as defined by .bar
// 2: use `transform` (as opposed to top or height) for better transition performance
// 3: add a transition to make switching between periods nicer
// 4: set `transform-origin` to the bottom so scalling takes the bar up ↑
// Wider bars for period `Year`
.is-period-year {
.chart__bar-section {
border-top-left-radius: $year-bar-chart-border-radius;
border-top-right-radius: $year-bar-chart-border-radius;
}
.chart__bar-section-inner {
border-top-left-radius: $year-bar-chart-border-radius;
border-top-right-radius: $year-bar-chart-border-radius;
}
}
.chart__bar-section {
display: inline-block;
background-color: var(--color-primary);
position: absolute;
right: 16%; // 1
bottom: 0; // 1
left: 16%; // 1
height: 100%;
transform: scaleY(0); // 2
transition: transform 0.3s ease-in-out; // 3
transform-origin: 0% 100%; // 4
z-index: z-index("root", ".chart__bar-section");
border-top-left-radius: $bar-chart-border-radius;
border-top-right-radius: $bar-chart-border-radius;
}
.chart__bar-section-inner {
background-color: var(--color-primary-dark);
position: absolute;
right: 23.33%;
bottom: 0;
left: 23.33%;
border-top-left-radius: $bar-chart-border-radius;
border-top-right-radius: $bar-chart-border-radius;
}
// Chart legend (wrapper)
// 1: L/R matches padding of y-axis labels in chart
.chart__legend {
margin-bottom: 16px;
display: flex;
align-items: center;
justify-content: flex-end;
@media (max-width: $break-medium) {
padding: 0 16px;
}
}
// Chart legend options (list)
.chart__legend-options {
color: var(--color-neutral);
list-style-type: none;
margin: 0;
font-size: $font-body-extra-small;
@media (max-width: $break-mobile) {
display: none;
}
@container (inline-size < #{$break-mobile}) {
display: none;
}
}
// Chart legend option (list item)
.chart__legend-option {
display: inline;
text-align: left;
// Expand labels to create bigger touch targets
@media (max-width: $break-mobile) {
width: 50%;
display: inline-block;
&:first-child {
.chart__legend-color {
margin-left: 2px; // 2
}
}
}
&:not(:first-child) {
margin-left: 24px;
}
// Chart legend color
// 1: Needed to overvwrite form styles in main stylesheets
// 2: Make leftmost legend fit snugly up against the leftmost bars
.chart__legend-color {
width: 20px;
height: 20px;
background: var(--color-primary);
display: inline-block;
border-radius: 4px;
vertical-align: top;
margin: 0 8px 0 0;
&.is-dark-blue {
background: var(--color-primary-dark);
}
}
// Chart legend checkbox
.chart__legend-checkbox {
margin: 0;
float: none;
vertical-align: top;
width: 20px;
height: 20px;
background-color: var(--color-surface);
border: 1px solid var(--color-neutral-10);
border-radius: 2px;
margin-right: 8px;
&:checked::before {
margin: 3px auto;
}
}
}
// Chart legend label
// 1: 19/10px instead of 20/12px because it aligns better optically
.chart__legend-label {
display: inline-block;
padding: 0;
color: var(--studio-black);
font-size: $font-body-small;
font-weight: 400;
line-height: 18px;
&.form-label {
display: inline-block;
margin-bottom: 0;
font-weight: 400;
}
&.is-selectable {
cursor: pointer;
&:focus,
&:hover {
color: var(--studio-black);
}
}
@media (max-width: $break-mobile) {
display: block;
}
}
// Chart empty (message)
// A message displayed when there's absolutely no data to chart
.chart__empty {
align-items: center;
display: flex;
justify-content: center;
position: absolute;
top: 0;
right: 0;
bottom: 0;
left: 0;
z-index: z-index("root", ".chart__empty");
padding: 0 50px;
}
// Chart tooltip
.chart__tooltip {
// The tooltip doesn't trigger pointer events to prevent causing a premature
// mouseleave event when the tooltip is hovered over
pointer-events: none;
.popover__inner {
width: 230px;
text-align: left;
ul {
@include clear-fix;
list-style: none;
margin: 0;
padding: 0;
li {
font-size: $font-body-extra-small;
text-transform: uppercase;
font-weight: 400;
height: 24px;
letter-spacing: 0.1em;
border: 0;
.wrapper {
display: block;
line-height: 24px;
clear: both;
}
.value {
text-align: right;
float: right;
min-width: 22px;
color: var(--color-neutral-10);
}
.label {
display: block;
overflow: hidden;
word-break: break-all;
vertical-align: baseline;
}
.gridicon {
vertical-align: middle;
margin-right: 6px;
margin-top: -3px;
}
}
}
}
// @TODO Integrate styles with Stats
&.is-streak {
.popover__inner {
width: 160px;
li {
height: 14px;
.label {
width: 100%;
float: left;
text-align: center;
.rtl & {
font-size: $font-body-extra-small;
}
.post-count {
font-weight: 600;
}
}
.value {
float: none;
}
}
}
}
}
.chart__tooltip .module-content-list-item {
// @TODO Integrate styles with Stats
&.is-date-label {
font-size: $font-body-extra-small;
margin-bottom: 2px;
text-transform: uppercase;
font-weight: 600;
border-bottom: 1px solid var(--color-neutral-60);
padding-bottom: 2px;
}
// @TODO Integrate styles with Stats
&.is-published-item {
height: 19px;
.label {
text-transform: none;
color: var(--color-neutral-10);
overflow: hidden;
letter-spacing: 0;
height: 19px;
}
.value {
width: 0;
min-width: 0;
&::before {
@include long-content-fade($color: var(--color-neutral-60));
position: relative;
left: -30px;
width: 30px;
height: 24px;
}
}
}
}
.chart.is-placeholder {
padding: 8px 20px;
.chart__bar,
.chart__bar:hover {
cursor: default;
background-color: transparent;
.chart__bar-section {
background-color: color-mix(in srgb, var(--color-neutral-0) 50%, transparent);
}
}
}
|