UNPKG

20.2 kBSCSSView Raw
1/*
2
3Copyright 2021-present Palantir Technologies, Inc. All rights reserved.
4Licensed under the Apache License, Version 2.0.
5
6*/
7
8// Import files in the same order that they are documented in the docs
9@import "~@blueprintjs/colors/lib/scss/colors";
10@import "common/variables";
11
12@import "reset";
13@import "typography";
14@import "accessibility/focus-states";
15
16// Extended color pallete
17$blue6: #99c4ff;
18$green6: #7cd7a2;
19$orange6: #f5c186;
20$red6: #ffa1a4;
21
22// Button variables and overrides
23$button-active-minimal-intent-text-modern: (
24 "primary": $blue1,
25 "success": $green1,
26 "warning": $orange1,
27 "danger": $red1
28);
29
30$dark-minimal-button-intents-modern: (
31 "primary": (rgba($blue3, 0.2), $blue5, rgba($blue3, 0.3), $blue6),
32 "success": (rgba($green3, 0.2), $green5, rgba($green3, 0.3), $green6),
33 "warning": (rgba($orange3, 0.2), $orange5, rgba($orange3, 0.3), $orange6),
34 "danger": (rgba($red3, 0.2), $red5, rgba($red3, 0.3), $red6)
35);
36$minimal-button-background-color-hover: rgba($gray3, 0.15);
37$minimal-button-background-color-active: rgba($gray3, 0.3);
38
39// Checkbox and Radio variable overrides
40$dark-control-background-color: $gray4;
41$dark-control-background-color-hover: $gray3;
42$dark-control-background-color-active: linear-gradient(0deg, rgba($white, 0.1), rgba($white, 0.1)),
43 linear-gradient(0deg, $gray2, $gray2);
44
45// Editable text variable overrides
46$input-placeholder-color: $gray1;
47$dark-input-placeholder-color: $gray4;
48
49// Input variables and overrides
50$dark-input-intent-box-shadow-colors: (
51 "primary": $blue4,
52 "success": $green4,
53 "warning": $orange4,
54 "danger" : $red4,
55);
56$dark-input-shadow-color-focus: $blue4;
57
58// Menu variables
59$menu-item-intent-colors-modern: (
60 "primary": (rgba($blue3, 0.1), $blue2, rgba($blue3, 0.2), $blue1),
61 "success": (rgba($green3, 0.1), $green2, rgba($green3, 0.2), $green1),
62 "warning": (rgba($orange3, 0.1), $orange2, rgba($orange3, 0.2), $orange1),
63 "danger" : (rgba($red3, 0.1), $red2, rgba($red3, 0.2), $red1),
64);
65
66// Slider variable overrides
67$button-box-shadow-overlay:
68 0 0 0 1px rgba($black, 0.5),
69 0 1px 1px rgba($black, 0.5);
70
71// Switch variable overrides
72$switch-indicator-background-color: rgba($gray3, 0.3);
73$switch-checked-background-color-hover: $blue2;
74$switch-checked-background-color-active: $blue1;
75
76// Tag variables
77$tag-intent-colors-modern: (
78 "primary": ($pt-intent-primary, $blue2, $blue1, $white, $white),
79 "success": ($pt-intent-success, $green2, $green1, $white, $white),
80 "warning": ($orange5, $orange4, $orange3, $pt-text-color, $pt-text-color),
81 "danger": ($pt-intent-danger, $red2, $red1, $white, $white)
82);
83
84$minimal-tag-intent-colors-modern: (
85 "primary": ($pt-intent-primary, $blue2, $blue1, $blue1),
86 "success": ($pt-intent-success, $green2, $green1, $green1),
87 "warning": ($pt-intent-warning, $orange2, $orange1, $orange1),
88 "danger": ($pt-intent-danger, $red2, $red1, $red1)
89);
90
91$minimal-dark-tag-intent-colors-modern: (
92 "primary": ($pt-intent-primary, $blue5, $blue6, $blue6),
93 "success": ($pt-intent-success, $green5, $green6, $green6),
94 "warning": ($pt-intent-warning, $orange5, $orange6, $orange6),
95 "danger": ($pt-intent-danger, $red5, $red1, $red6, $red6)
96);
97
98// Toast variables
99$toast-intent-button-colors-modern: (
100 "primary": ($pt-intent-primary, $white, $blue2, $blue1, rgba($white, 0.7)),
101 "success": ($pt-intent-success, $white, $green2, $green1, rgba($white, 0.7)),
102 "warning": ($orange5, $dark-gray1, $orange4, $orange3, rgba($dark-gray1, 0.7)),
103 "danger": ($pt-intent-danger, $white, $red2, $red1, rgba($white, 0.7))
104);
105
106// Tree variables
107$tree-intent-icon-colors-modern: (
108 "primary": $blue5,
109 "success": $green5,
110 "warning": $orange5,
111 "danger" : $red5,
112);
113
114
115@import "components/index";
116
117// Mixin helpers used across multiple components
118@mixin pt-button-minimal-dark-intent-modern(
119 $hover-color,
120 $hover-text,
121 $active-color,
122 $active-text
123) {
124 &:hover:not(:disabled) {
125 background: $hover-color;
126 color: $hover-text;
127 }
128
129 &:active:not(:disabled) {
130 background: $active-color;
131 color: $active-text;
132 }
133}
134
135// Contrast for breadcrumbs
136.#{$ns}-breadcrumbs-collapsed {
137 background: rgba($gray3, 0.15);
138
139 &:hover {
140 background: rgba($gray3, 0.3);
141 }
142}
143
144
145.#{$ns}-dark {
146 .#{$ns}-breadcrumbs {
147 > li::after {
148 background: svg-icon("16px/chevron-right.svg", (path: (fill: $pt-dark-icon-color)));
149 }
150 }
151 .#{$ns}-breadcrumbs-collapsed {
152 background: rgba($gray3, 0.2);
153
154 &::before {
155 background: svg-icon("16px/more.svg", (circle: (fill: $pt-dark-icon-color))) center no-repeat;
156 }
157
158 &:hover {
159 background: rgba($gray3, 0.3);
160 }
161 }
162}
163
164// Contrast for buttons
165.#{$ns}-button {
166 // Use dark text for warning intent
167 &.#{$ns}-intent-warning:not([class*="#{$ns}-minimal"]) {
168 &:not(:disabled) {
169 background: $orange5;
170 color: $pt-text-color;
171
172 .#{$ns}-icon>svg:not([fill]) {
173 color: rgba($dark-gray1, 0.7);
174 }
175
176 &:hover {
177 background: $orange4;
178 }
179
180 &:active {
181 background: $orange3;
182 }
183 }
184
185 &:disabled {
186 color: $pt-text-color-disabled;
187
188 .#{$ns}-dark & {
189 color: $pt-dark-text-color-disabled;
190 }
191 }
192 }
193
194
195 &.#{$ns}-minimal {
196 @mixin pt-button-minimal-intent-modern($active-text-color) {
197 &:active:not(:disabled) {
198 color: $active-text-color;
199 }
200 }
201
202 @each $intent, $colors in $button-intents {
203 &.#{$ns}-intent-#{$intent} {
204 @include pt-button-minimal-intent-modern(
205 map-get($button-active-minimal-intent-text-modern, $intent),
206 );
207 }
208 }
209
210 .#{$ns}-dark & {
211 &:not([class*="#{$ns}-intent-"]):not(:disabled) {
212 color: $white;
213 }
214
215 @each $intent, $color in $dark-minimal-button-intents-modern {
216 &.#{$ns}-intent-#{$intent} {
217 @include pt-button-minimal-dark-intent-modern($color...);
218 }
219 }
220 }
221 }
222}
223
224// Contrast for callouts
225.#{$ns}-callout {
226 background-color: rgba($gray3, 0.15);
227
228 .#{$ns}-dark & {
229 background-color: rgba($gray3, 0.2);
230
231 &.#{$ns}-callout-icon:not([class*="#{$ns}-intent-"]) > .#{$ns}-icon:first-child {
232 color: $pt-dark-icon-color;
233 }
234 }
235
236 @each $intent, $color in $pt-intent-colors {
237 &.#{$ns}-intent-#{$intent} {
238 background-color: rgba($color, 0.1);
239
240 .#{$ns}-dark & {
241 background-color: rgba($color, 0.2);
242 }
243 }
244 }
245}
246
247// Contrast for checkboxes and radio buttons
248.#{$ns}-control {
249 input:focus ~ .#{$ns}-control-indicator {
250 outline: $blue3 auto 2px;
251 }
252
253 &.#{$ns}-checkbox, &.#{$ns}-radio {
254 .#{$ns}-control-indicator {
255 box-shadow:
256 inset 0 0 0 $button-border-width rgba($black, 0.5),
257 inset 0 (-$button-border-width) 0 rgba($black, 0.1);
258 }
259 }
260
261 .#{$ns}-dark & {
262 input:focus ~ .#{$ns}-control-indicator {
263 outline: $blue5 auto 2px;
264 }
265
266 &.#{$ns}-checkbox, &.#{$ns}-radio {
267 input:not(:disabled):not(:checked) ~ .#{$ns}-control-indicator {
268 box-shadow: $dark-button-box-shadow-active;
269 }
270
271 input:not(:disabled):active:checked ~ .#{$ns}-control-indicator {
272 background: linear-gradient(180deg, rgba($white, 0.1) 0%, rgba($white, 0) 100%),
273 linear-gradient(0deg, $blue1, $blue1);
274 }
275 }
276 }
277}
278
279
280// Contrast for disabled editable text
281.#{$ns}-editable-text.#{$ns}-disabled {
282 > .#{$ns}-editable-text-content {
283 color: $pt-text-color-disabled;
284
285 .#{$ns}-dark & {
286 color: $pt-dark-text-color-disabled;
287 }
288 }
289}
290
291// Contrast for HTML tables
292table.#{$ns}-html-table {
293 &.#{$ns}-html-table-striped {
294 tbody tr:nth-child(odd) td {
295 background: rgba($gray3, 0.15);
296 }
297 }
298
299 &.#{$ns}-interactive {
300 tbody tr {
301 &:hover td {
302 background-color: rgba($gray3, 0.3);
303 cursor: pointer;
304 }
305
306 &:active td {
307 background-color: rgba($gray3, 0.35);
308 }
309 }
310 }
311}
312
313// Contrast for inputs
314.#{$ns}-input-group {
315 .#{$ns}-input {
316 // Use intent-styled box-shadows for default intent
317 box-shadow: input-transition-shadow($input-shadow-color-focus),
318 inset border-shadow(1, $gray2),
319 $pt-input-box-shadow;
320
321 &:focus {
322 box-shadow: input-transition-shadow($input-shadow-color-focus, true), $input-box-shadow-focus;
323 }
324
325 .#{$ns}-dark & {
326 box-shadow: dark-input-transition-shadow($dark-input-shadow-color-focus),
327 inset border-shadow(1, $gray3),
328 $pt-dark-input-box-shadow;
329
330 &:focus {
331 box-shadow: dark-input-transition-shadow($dark-input-shadow-color-focus, true),
332 $pt-dark-input-box-shadow;
333 }
334 }
335
336 &:disabled {
337 box-shadow: none;
338 }
339 }
340
341 @each $intent, $color in $dark-input-intent-box-shadow-colors {
342 &.#{$ns}-intent-#{$intent} {
343 .#{$ns}-input {
344 @include pt-dark-input-intent($color);
345 }
346 }
347 }
348}
349
350// Contrast for menus
351.#{$ns}-menu-item {
352 @mixin menu-item-intent-modern(
353 $hover-background-color,
354 $hover-text-color,
355 $active-background-color,
356 $active-text-color) {
357 &:hover {
358 background: $hover-background-color;
359 color: $hover-text-color;
360
361 .#{$ns}-menu-item-label {
362 color: $hover-text-color;
363 }
364 }
365
366 &:active {
367 background: $active-background-color;
368 color: $active-text-color;
369 }
370 }
371
372 &:not([class*="#{$ns}-intent-"]) {
373 &:hover {
374 background: rgba($gray3, 0.1);
375 }
376
377 &:active {
378 background: rgba($gray3, 0.2);
379
380 .#{$ns}-menu-item-label {
381 color: $pt-text-color;
382 }
383 }
384 }
385
386 @each $intent, $color in $menu-item-intent-colors-modern {
387 &.#{$ns}-intent-#{$intent} {
388 @include menu-item-intent-modern($color...);
389 }
390 }
391
392 .#{$ns}-dark & {
393 &:not([class*="#{$ns}-intent-"]) {
394 &:hover {
395 .#{$ns}-icon:first-child {
396 color: $pt-dark-icon-color;
397 }
398 }
399
400 &:active {
401 .#{$ns}-menu-item-label {
402 color: $light-gray5;
403 }
404 }
405 }
406
407 @each $intent, $color in $dark-minimal-button-intents-modern {
408 &.#{$ns}-intent-#{$intent} {
409 @include pt-button-minimal-dark-intent-modern($color...);
410
411 &:hover {
412 .#{$ns}-menu-item-label {
413 color: nth($color, 2);
414 }
415 }
416
417 &:active {
418 .#{$ns}-menu-item-label {
419 color: nth($color, 4);
420 }
421 }
422 }
423 }
424 }
425}
426
427// Contrast for sliders
428.#{$ns}-slider-handle {
429 .#{$ns}-dark & {
430 background-color: $gray4;
431
432 &:hover {
433 background-color: $gray3;
434 }
435
436 &:active,
437 &.#{$ns}-active {
438 background:
439 linear-gradient(0deg, rgba($white, 0.1), rgba($white, 0.1)),
440 linear-gradient(0deg, $gray2, $gray2);
441 }
442 }
443}
444
445// Contrast for switches
446.#{$ns}-control.#{$ns}-switch {
447
448 // Switch background styles
449 input:not(:disabled):hover ~ .#{$ns}-control-indicator {
450 background-color: rgba($gray3, 0.5);
451 }
452
453 input:not(:disabled):active ~ .#{$ns}-control-indicator {
454 background-color: rgba($gray3, 0.6);
455 }
456
457 // Checked switch background styles
458 input:checked:not(:disabled) ~ .#{$ns}-control-indicator {
459 background: $blue3;
460 }
461
462 input:checked:not(:disabled):hover ~ .#{$ns}-control-indicator {
463 background: $blue2;
464 }
465
466 input:checked:not(:disabled):active ~ .#{$ns}-control-indicator {
467 background: $blue1;
468 }
469
470 // Switch handle styles
471 .#{$ns}-control-indicator::before {
472 background: linear-gradient(180deg, rgba($white, 0.8) 0%, rgba($white, 0) 100%),
473 linear-gradient(0deg, $light-gray5, $light-gray5);
474 }
475
476 input:not(:disabled):hover ~ .#{$ns}-control-indicator::before {
477 background: linear-gradient(180deg, rgba($white, 0.5) 0%, rgba($white, 0) 100%),
478 linear-gradient(0deg, $light-gray4, $light-gray4);
479 }
480
481 input:not(:disabled):active ~ .#{$ns}-control-indicator::before {
482 background: $light-gray2;
483 }
484
485 // Dark switch styles
486 .#{$ns}-dark & {
487 // Dark switch background styles
488 input:not(:disabled) ~ .#{$ns}-control-indicator {
489 background: rgba($black, 0.5);
490 }
491
492 input:not(:disabled):hover ~ .#{$ns}-control-indicator {
493 background: rgba($black, 0.65);
494 }
495
496 input:not(:disabled):active ~ .#{$ns}-control-indicator {
497 background: rgba($black, 0.8);
498 }
499
500 // Dark checked switch background styles
501 input:checked:not(:disabled) ~ .#{$ns}-control-indicator {
502 background: $blue3;
503 }
504
505 input:checked:not(:disabled):hover ~ .#{$ns}-control-indicator {
506 background: $blue2;
507 }
508
509 input:checked:not(:disabled):active ~ .#{$ns}-control-indicator {
510 background: $blue1;
511 }
512
513 // Dark switch handle styles
514 input:not(:disabled):not(:checked) ~ .#{$ns}-control-indicator::before {
515 background: $gray4;
516 }
517
518 input:not(:disabled):not(:checked):hover ~ .#{$ns}-control-indicator::before {
519 background: $gray3;
520 }
521
522 input:not(:disabled):not(:checked):active ~ .#{$ns}-control-indicator::before {
523 background: linear-gradient(0deg, rgba($white, 0.1), rgba($white, 0.1)),
524 linear-gradient(0deg, $gray2, $gray2);
525 }
526
527 // Dark checked switch handle styles
528 input:checked:not(:disabled) ~ .#{$ns}-control-indicator::before {
529 background: linear-gradient(180deg, rgba($white, 0.8) 0%, rgba($white, 0) 100%),
530 linear-gradient(0deg, $light-gray5, $light-gray5);
531 }
532
533 input:checked:not(:disabled):hover ~ .#{$ns}-control-indicator::before {
534 background: linear-gradient(180deg, rgba($white, 0.5) 0%, rgba($white, 0) 100%),
535 linear-gradient(0deg, $light-gray4, $light-gray4);
536 }
537
538 input:checked:not(:disabled):active ~ .#{$ns}-control-indicator::before {
539 background: $light-gray2;
540 }
541 }
542}
543
544// Contrast for tags
545.#{$ns}-tag {
546 @mixin pt-tag-modern(
547 $background-color,
548 $hover-color,
549 $active-color,
550 $text-color,
551 $cross-button-color
552 ) {
553 background: $background-color;
554 color: $text-color;
555 &.#{$ns}-interactive {
556 &:hover {
557 background-color: $hover-color;
558 }
559
560 &:active {
561 background-color: $active-color;
562 }
563 }
564
565 .#{$ns}-tag-remove > .#{$ns}-icon:first-child {
566 color: rgba($cross-button-color, 0.7);
567
568 &:hover {
569 color: $cross-button-color;
570 }
571
572 &:active {
573 color: $cross-button-color;
574 }
575 }
576 }
577
578 @mixin pt-tag-minimal-intent-modern(
579 $background-color,
580 $text-color,
581 $hover-text-color,
582 $active-text-color
583 ) {
584 background-color: rgba($background-color, 0.1);
585 color: $text-color;
586
587 &.#{$ns}-interactive {
588 &:hover {
589 background-color: rgba($background-color, 0.2);
590 color: $hover-text-color;
591 }
592
593 &:active {
594 background-color: rgba($background-color, 0.3);
595 color: $active-text-color;
596 }
597 }
598
599 .#{$ns}-tag-remove > .#{$ns}-icon:first-child {
600 color: $text-color;
601
602 &:hover {
603 color: $hover-text-color;
604 }
605
606 &:active {
607 color: $active-text-color;
608 }
609 }
610 }
611
612 @mixin pt-tag-minimal-dark-intent-modern (
613 $background-color,
614 $text-color,
615 $hover-text-color,
616 $active-text-color,
617 ) {
618 .#{$ns}-dark & {
619 background-color: rgba($background-color, 0.2);
620 color: $text-color;
621
622 &.#{$ns}-interactive {
623 &:hover {
624 background-color: rgba($background-color, 0.3);
625 color: $hover-text-color;
626 }
627
628 &:active {
629 background-color: rgba($background-color, 0.35);
630 color: $active-text-color;
631 }
632 }
633
634 .#{$ns}-tag-remove > .#{$ns}-icon:first-child {
635 color: $text-color;
636
637 &:hover {
638 color: $hover-text-color;
639 }
640
641 &:active {
642 color: $active-text-color;
643 }
644 }
645 }
646 }
647
648 // Contrast for default intent
649 color: $white;
650
651 &.#{$ns}-interactive {
652 &:hover {
653 background: $dark-gray5;
654 }
655
656 &:active {
657 background: $dark-gray4;
658 }
659 }
660
661 .#{$ns}-tag-remove > .#{$ns}-icon:first-child {
662 color: rgba($white, 0.7);
663
664 &:hover {
665 color: $white;
666 }
667
668 &:active {
669 color: $white;
670 }
671 }
672
673 // Dark mode contrast for default intent
674 .#{$ns}-dark &:not([class*="#{$ns}-intent-"]) {
675 background: $gray5;
676 color: $pt-text-color;
677
678 &.#{$ns}-interactive {
679 &:hover {
680 background: $gray4;
681 }
682
683 &:active {
684 background: $gray3;
685 }
686 }
687
688 .#{$ns}-tag-remove > .#{$ns}-icon:first-child {
689 color: rgba($dark-gray1, 0.7);
690
691 &:hover {
692 color: $dark-gray1;
693 }
694
695 &:active {
696 color: $dark-gray1;
697 }
698 }
699 }
700
701 // Light mode contrast for intents
702 @each $intent, $color in $tag-intent-colors-modern {
703 &.#{$ns}-intent-#{$intent} {
704 @include pt-tag-modern($color...);
705 }
706 }
707
708 // Minimal style contrast
709 &.#{$ns}-minimal {
710 // Minimal style for default intent
711 background-color: rgba($gray3, 0.15);
712 color: $pt-text-color;
713 &.#{$ns}-interactive {
714 &:hover {
715 background-color: rgba($gray3, 0.3);
716 color: $black;
717 }
718
719 &:active {
720 background-color: rgba($gray3, 0.35);
721 color: $black;
722 }
723
724 .#{$ns}-tag-remove > .#{$ns}-icon:first-child {
725 color: $gray1;
726
727 &:hover {
728 color: $dark-gray1;
729 }
730
731 &:active {
732 color: $dark-gray1;
733 }
734 }
735 }
736
737 // Minimal dark style for default intent
738 .#{$ns}-dark & {
739 background-color: rgba($gray3, 0.15);
740 color: $light-gray1;
741
742 &.#{$ns}-interactive {
743 &:hover {
744 background-color: rgba($gray3, 0.3);
745 color: $white;
746 }
747
748 &:active {
749 background-color: rgba($gray3, 0.35);
750 color: $white;
751 }
752 }
753
754 .#{$ns}-tag-remove > .#{$ns}-icon:first-child {
755 color: $gray4;
756
757 &:hover {
758 color: $light-gray1;
759 }
760
761 &:active {
762 color: $light-gray1;
763 }
764 }
765 }
766
767 @each $intent, $color in $minimal-tag-intent-colors-modern {
768 &.#{$ns}-intent-#{$intent} {
769 @include pt-tag-minimal-intent-modern($color...);
770 }
771 }
772
773 @each $intent, $color in $minimal-dark-tag-intent-colors-modern {
774 &.#{$ns}-intent-#{$intent} {
775 @include pt-tag-minimal-dark-intent-modern($color...);
776 }
777 }
778 }
779}
780
781// Contrast for toasts
782.#{$ns}-toast {
783 // HACK needs !important to override the existing hack
784 /* stylelint-disable declaration-no-important */
785 @mixin pt-toast-intent-button-colors-modern (
786 $background-color,
787 $text-color,
788 $hover-color,
789 $active-color,
790 $icon-color,
791 ) {
792 .#{$ns}-icon:first-child {
793 color: $icon-color;
794 }
795
796 .#{$ns}-button {
797 background-color: $background-color !important;
798 color: $text-color !important;
799
800 &:hover {
801 background-color: $hover-color !important;
802 color: $text-color !important;
803 }
804
805 &:active {
806 background-color: $active-color !important;
807 color: $text-color !important;
808 }
809
810 &:last-child > .#{$ns}-icon-cross {
811 color: rgba($text-color, 0.7) !important;
812 }
813 }
814 }
815 /* stylelint-enable declaration-no-important */
816
817
818 // Contrast for default intent
819 &:not([class*="#{$ns}-intent-"]) {
820 // Contrast for default intent in dark mode
821 &.#{$ns}-dark,
822 .#{$ns}-dark & {
823 .#{$ns}-button .#{$ns}-icon {
824 color: rgba($white, 0.7);
825 }
826 }
827 }
828
829 &.#{$ns}-intent-warning {
830 background-color: $orange5;
831 color: $dark-gray1;
832 }
833
834 @each $intent, $color in $toast-intent-button-colors-modern {
835 &.#{$ns}-intent-#{$intent} {
836 @include pt-toast-intent-button-colors-modern($color...);
837 }
838 }
839}
840
841// Contrast for trees
842.#{$ns}-tree-node-content {
843 background: none;
844
845 &:hover {
846 background-color: rgba($gray3, 0.15);
847 }
848
849 &:active {
850 background-color: rgba($gray3, 0.3);
851 }
852
853 .#{$ns}-dark & .#{$ns}-icon {
854 @each $intent, $color in $tree-intent-icon-colors-modern {
855 &.#{$ns}-intent-#{$intent} {
856 color: $color;
857 }
858 }
859 }
860
861 .#{$ns}-tree-node.#{$ns}-tree-node-selected > & {
862 #{$icon-classes} {
863 color: $white;
864 }
865 }
866}