]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blame_incremental - client/src/sass/include/_mixins.scss
Try to fix tests
[github/Chocobozzz/PeerTube.git] / client / src / sass / include / _mixins.scss
... / ...
CommitLineData
1@use 'sass:math';
2@use '_variables' as *;
3
4@mixin disable-default-a-behaviour {
5 &:hover,
6 &:focus,
7 &:active {
8 text-decoration: none !important;
9 outline: none !important;
10 }
11}
12
13@mixin disable-outline {
14 &:focus:not(.focus-visible) {
15 outline: none;
16 }
17}
18
19@mixin ellipsis {
20 white-space: nowrap;
21 overflow: hidden;
22 text-overflow: ellipsis;
23}
24
25@mixin ellipsis-multiline($font-size: 16px, $number-of-lines: 2) {
26 display: block;
27 /* Fallback for non-webkit */
28 display: -webkit-box; /* stylelint-disable-line value-no-vendor-prefix */
29 -webkit-line-clamp: $number-of-lines;
30 /* Fallback for non-webkit */
31 font-size: $font-size;
32 line-height: $font-size;
33 overflow: hidden;
34 text-overflow: ellipsis;
35 max-height: $font-size * $number-of-lines;
36}
37
38@mixin fade-text ($fade-after, $background-color) {
39 position: relative;
40 overflow: hidden;
41
42 &::after {
43 content: '';
44 pointer-events: none;
45 width: 100%;
46 height: 100%;
47 position: absolute;
48 left: 0;
49 top: 0;
50 background: linear-gradient(transparent $fade-after, $background-color);
51 }
52}
53
54@mixin peertube-word-wrap ($with-hyphen: true) {
55 word-break: break-word;
56 word-wrap: break-word;
57 overflow-wrap: break-word;
58
59 @if $with-hyphen {
60 hyphens: auto;
61 }
62}
63
64@mixin apply-svg-color ($color) {
65 ::ng-deep .feather,
66 ::ng-deep .material,
67 ::ng-deep .misc {
68 color: $color;
69 }
70}
71
72@mixin fill-svg-color ($color) {
73 ::ng-deep svg {
74 path {
75 fill: $color;
76 }
77 }
78}
79
80@mixin button-focus($color) {
81 &:focus,
82 &.focus-visible {
83 box-shadow: #{$focus-box-shadow-form} $color;
84 }
85}
86
87@mixin peertube-input-text($width) {
88 padding: 0 15px;
89 display: inline-block;
90 height: $button-height;
91 width: $width;
92 max-width: $width;
93 color: pvar(--inputForegroundColor);
94 background-color: pvar(--inputBackgroundColor);
95 border: 1px solid pvar(--inputBorderColor);
96 border-radius: 3px;
97 font-size: $form-input-font-size;
98 line-height: $form-input-line-height;
99
100 &::placeholder {
101 color: pvar(--inputPlaceholderColor);
102 }
103
104 &[readonly] {
105 opacity: 0.7;
106 }
107
108 @media screen and (max-width: calc(#{$width} + 40px)) {
109 width: 100%;
110 }
111}
112
113@mixin peertube-textarea ($width, $height) {
114 @include peertube-input-text($width);
115
116 color: pvar(--textareaForegroundColor) !important;
117 background-color: pvar(--textareaBackgroundColor) !important;
118 height: $height;
119 padding: 5px 15px;
120}
121
122@mixin orange-button {
123 @include button-focus(pvar(--mainColorLightest));
124
125 &,
126 &:active,
127 &:focus {
128 color: #fff;
129 background-color: pvar(--mainColor);
130 }
131
132 &:hover {
133 color: #fff;
134 background-color: pvar(--mainHoverColor);
135 }
136
137 &[disabled],
138 &.disabled {
139 cursor: default;
140 color: #fff;
141 background-color: pvar(--inputBorderColor);
142 }
143
144 my-global-icon {
145 @include apply-svg-color(#fff);
146 }
147}
148
149@mixin orange-button-inverted {
150 @include button-focus(pvar(--mainColorLightest));
151
152 border: 2px solid pvar(--mainColor);
153 font-weight: $font-semibold;
154
155 &,
156 &:active,
157 &:focus {
158 color: pvar(--mainColor);
159 background-color: pvar(--mainBackgroundColor);
160 }
161
162 &:hover {
163 color: pvar(--mainColor);
164 background-color: pvar(--mainColorLightest);
165 }
166
167 &[disabled],
168 &.disabled {
169 cursor: default;
170 color: pvar(--mainColor);
171 background-color: pvar(--inputBorderColor);
172 }
173
174 my-global-icon {
175 @include apply-svg-color(pvar(--mainColor));
176 }
177}
178
179@mixin tertiary-button {
180 @include button-focus($grey-button-outline-color);
181
182 color: pvar(--greyForegroundColor);
183 background-color: transparent;
184
185 &[disabled],
186 .disabled {
187 cursor: default;
188 }
189
190 my-global-icon {
191 @include apply-svg-color(transparent);
192 }
193}
194
195@mixin grey-button {
196 @include button-focus($grey-button-outline-color);
197
198 background-color: pvar(--greyBackgroundColor);
199 color: pvar(--greyForegroundColor);
200
201 &:hover,
202 &:active,
203 &:focus,
204 &[disabled],
205 &.disabled {
206 color: pvar(--greyForegroundColor);
207 background-color: pvar(--greySecondaryBackgroundColor);
208 }
209
210 &[disabled],
211 &.disabled {
212 cursor: default;
213 }
214
215 my-global-icon {
216 @include apply-svg-color(pvar(--greyForegroundColor));
217 }
218}
219
220@mixin danger-button {
221 $color: lighten($color: #c54130, $amount: 10);
222 $text: #fff6f5;
223
224 @include button-focus(scale-color($color, $alpha: -95%));
225
226 background-color: $color;
227 color: $text;
228
229 &:hover,
230 &:active,
231 &:focus,
232 &[disabled],
233 &.disabled {
234 background-color: lighten($color: $color, $amount: 10);
235 }
236
237 &[disabled],
238 &.disabled {
239 cursor: default;
240 }
241
242 my-global-icon {
243 @include apply-svg-color($text);
244 }
245}
246
247@mixin peertube-button {
248 padding: 0 13px;
249
250 border: 0;
251 font-weight: $font-semibold;
252 height: $button-height;
253 line-height: $button-height;
254
255 // Because of primeng that redefines border-radius of all input[type="..."]
256 border-radius: 3px !important;
257
258 text-align: center;
259 cursor: pointer;
260
261 font-size: $button-font-size;
262
263 my-global-icon + * {
264 @include margin-right(4px);
265 }
266}
267
268@mixin peertube-button-big {
269 height: auto;
270 padding: 10px 25px;
271 font-size: 18px;
272 line-height: 1.2;
273 border: 0;
274 font-weight: $font-semibold;
275
276 // Because of primeng that redefines border-radius of all input[type="..."]
277 border-radius: 3px !important;
278}
279
280@mixin peertube-button-link {
281 @include disable-default-a-behaviour;
282 @include peertube-button;
283
284 display: inline-block;
285}
286
287@mixin peertube-button-big-link {
288 @include disable-default-a-behaviour;
289 @include peertube-button-big;
290
291 display: inline-block;
292}
293
294@mixin peertube-button-outline {
295 @include disable-default-a-behaviour;
296 @include peertube-button;
297
298 display: inline-block;
299 border: 1px solid;
300}
301
302@mixin button-with-icon($width: 20px, $margin-right: 3px, $top: -1px) {
303 my-global-icon {
304 @include margin-right($margin-right);
305
306 position: relative;
307 width: $width;
308 top: $top;
309 }
310}
311
312@mixin peertube-file {
313 position: relative;
314 overflow: hidden;
315 display: inline-block;
316 min-height: 30px;
317
318 input[type=file] {
319 position: absolute;
320 top: 0;
321 right: 0;
322 width: 100%;
323 height: 100%;
324 font-size: 100px;
325 text-align: end;
326 filter: alpha(opacity=0);
327 opacity: 0;
328 outline: none;
329 background: #fff;
330 cursor: inherit;
331 display: block;
332 }
333}
334
335@mixin peertube-button-file ($width) {
336 @include peertube-file;
337 @include peertube-button;
338
339 width: $width;
340}
341
342@mixin icon ($size) {
343 display: inline-block;
344 background-repeat: no-repeat;
345 background-size: contain;
346 width: $size;
347 height: $size;
348 vertical-align: middle;
349 cursor: pointer;
350}
351
352@mixin responsive-width ($width) {
353 width: $width;
354
355 @media screen and (max-width: $width) {
356 width: 100%;
357 }
358}
359
360@mixin peertube-select-container ($width) {
361 padding: 0;
362 margin: 0;
363 width: $width;
364 border-radius: 3px;
365 color: pvar(--inputForegroundColor);
366 background: pvar(--inputBackgroundColor);
367 position: relative;
368 height: min-content;
369
370 &.disabled {
371 background-color: #E5E5E5;
372
373 select {
374 cursor: default;
375 }
376 }
377
378 select[disabled] {
379 background-color: #f9f9f9;
380 }
381
382 @media screen and (max-width: $width) {
383 width: 100%;
384 }
385
386 &::after {
387 top: 50%;
388 right: calc(0% + 15px);
389 content: ' ';
390 height: 0;
391 width: 0;
392 position: absolute;
393 pointer-events: none;
394 border: 5px solid rgba(0, 0, 0, 0);
395 border-top-color: #000;
396 margin-top: -2px;
397 z-index: 100;
398 }
399
400 select {
401 padding: 0 35px 0 12px;
402 position: relative;
403 border: 1px solid pvar(--inputBorderColor);
404 background: transparent none;
405 appearance: none;
406 height: $button-height;
407 text-overflow: ellipsis;
408 color: pvar(--mainForegroundColor);
409 font-size: $form-input-font-size;
410 line-height: $form-input-line-height;
411
412 &:focus {
413 outline: none;
414 }
415
416 &:-moz-focusring {
417 color: transparent;
418 text-shadow: 0 0 0 #000;
419 }
420
421 option {
422 color: #000;
423
424 &[value=undefined] {
425 font-weight: $font-semibold;
426 }
427 }
428 }
429
430 &.peertube-select-button {
431 @include grey-button;
432
433 select {
434 font-weight: $font-semibold;
435 color: pvar(--greyForegroundColor);
436 border: 0;
437 }
438 }
439}
440
441// Thanks: https://codepen.io/manabox/pen/raQmpL
442@mixin peertube-radio-container {
443 label {
444 font-size: $form-input-font-size;
445 }
446
447 [type=radio]:checked,
448 [type=radio]:not(:checked) {
449 position: absolute;
450 left: -9999px;
451 }
452
453 [type=radio]:checked + label,
454 [type=radio]:not(:checked) + label {
455 position: relative;
456 padding-left: 28px;
457 cursor: pointer;
458 line-height: 20px;
459 display: inline-block;
460 font-weight: $font-regular;
461 }
462
463 [type=radio]:checked + label::before,
464 [type=radio]:not(:checked) + label::before {
465 content: '';
466 position: absolute;
467 left: 0;
468 top: 0;
469 width: 18px;
470 height: 18px;
471 border: 1px solid pvar(--inputBorderColor);
472 border-radius: 100%;
473 background: #fff;
474 }
475
476 [type=radio]:checked + label::after,
477 [type=radio]:not(:checked) + label::after {
478 content: '';
479 width: 10px;
480 height: 10px;
481 background: pvar(--mainColor);
482 position: absolute;
483 top: 4px;
484 left: 4px;
485 border-radius: 100%;
486 transition: all 0.2s ease;
487 }
488 [type=radio]:not(:checked) + label::after {
489 opacity: 0;
490 transform: scale(0);
491 }
492 [type=radio]:checked + label::after {
493 opacity: 1;
494 transform: scale(1);
495 }
496
497 .form-group-description {
498 display: block;
499 margin-top: -7px;
500 margin-bottom: 10px;
501 margin-left: 29px;
502 }
503}
504
505@mixin peertube-checkbox ($border-width) {
506 opacity: 0;
507 position: absolute;
508
509 &:focus + span {
510 box-shadow: #{$focus-box-shadow-form} pvar(--mainColorLightest);
511 }
512
513 + span {
514 position: relative;
515 width: 18px;
516 min-width: 18px;
517 height: 18px;
518 border: $border-width solid pvar(--inputBorderColor);
519 border-radius: 3px;
520 vertical-align: middle;
521 cursor: pointer;
522
523 &::after {
524 content: '';
525 position: absolute;
526 top: calc(2px - #{$border-width});
527 left: 5px;
528 width: 5px;
529 height: 12px;
530 opacity: 0;
531 transform: rotate(45deg) scale(0);
532 border-right: 2px solid $bg-color;
533 border-bottom: 2px solid $bg-color;
534 }
535 }
536
537 &:checked + span {
538 border-color: transparent;
539 background: pvar(--mainColor);
540 animation: jelly 0.6s ease;
541
542 &::after {
543 opacity: 1;
544 transform: rotate(45deg) scale(1);
545 }
546 }
547
548 + span + span {
549 @include margin-left(5px);
550
551 font-weight: $font-regular;
552 cursor: pointer;
553 display: inline;
554 }
555
556 &[disabled] + span,
557 &[disabled] + span + span {
558 opacity: 0.5;
559 cursor: default;
560 }
561}
562
563@mixin actor-avatar-size ($size) {
564 display: inline-block;
565 width: $size;
566 height: $size;
567 min-width: $size;
568 min-height: $size;
569}
570
571@mixin actor-counters ($separator-margin: 10px) {
572 color: pvar(--greyForegroundColor);
573 display: flex;
574 align-items: center;
575
576 > *:not(:last-child)::after {
577 content: '•';
578 margin: 0 $separator-margin;
579 color: pvar(--mainColor);
580 }
581}
582
583@mixin in-content-small-title {
584 text-transform: uppercase;
585 color: pvar(--mainColor);
586 font-weight: $font-bold;
587 font-size: 13px;
588}
589
590@mixin settings-big-title {
591 text-transform: uppercase;
592 color: pvar(--mainColor);
593 font-weight: $font-bold;
594 font-size: 1rem;
595 margin-bottom: 10px;
596}
597
598@mixin create-button {
599 @include peertube-button-link;
600 @include orange-button;
601 @include button-with-icon(20px, 5px, -1px);
602}
603
604@mixin row-blocks ($column-responsive: true, $min-height: 130px, $separator: true) {
605 display: flex;
606 min-height: $min-height;
607 padding-bottom: 20px;
608 margin-bottom: 20px;
609
610 @if $separator {
611 border-bottom: 1px solid pvar(--inputBorderColor);
612 }
613
614 @media screen and (max-width: $small-view) {
615 @if $column-responsive {
616 flex-direction: column;
617 height: auto;
618 align-items: center;
619 } @else {
620 min-height: initial;
621 padding-bottom: 10px;
622 margin-bottom: 10px;
623 }
624 }
625}
626
627@mixin dropdown-with-icon-item {
628 padding: 6px 15px;
629
630 my-global-icon {
631 @include margin-right(10px);
632
633 width: 22px;
634 opacity: .7;
635 position: relative;
636 top: -2px;
637 }
638}
639
640@mixin progressbar($small: false) {
641 background-color: $grey-background-color;
642 display: flex;
643 height: 1rem;
644 overflow: hidden;
645 font-size: 0.75rem;
646 border-radius: 0.25rem;
647 position: relative;
648
649 span {
650 position: absolute;
651 color: $grey-foreground-color;
652
653 @if $small {
654 top: -1px;
655 }
656
657 &:nth-of-type(1) {
658 left: .2rem;
659 }
660 &:nth-of-type(2) {
661 right: .2rem;
662 }
663 }
664
665 .progress-bar {
666 color: pvar(--mainBackgroundColor);
667 background-color: pvar(--mainColor);
668 display: flex;
669 flex-direction: column;
670 justify-content: center;
671 text-align: center;
672 white-space: nowrap;
673 transition: width 0.6s ease;
674
675 &.red {
676 background-color: lighten($color: #c54130, $amount: 10);
677 }
678 }
679}
680
681@mixin breadcrumb {
682 display: flex;
683 flex-wrap: wrap;
684 padding: 0;
685 margin-bottom: 1rem;
686 list-style: none;
687 font-weight: $font-semibold;
688
689 .breadcrumb-item {
690 display: flex;
691
692 a {
693 color: pvar(--mainColor);
694 }
695
696 + .breadcrumb-item {
697 @include padding-left(0.5rem);
698
699 &::before {
700 @include padding-right(0.5rem);
701
702 display: inline-block;
703 color: #6c757d;
704 content: '/';
705 }
706 }
707
708 &.active {
709 color: #6c757d;
710 }
711 }
712}
713
714@mixin dashboard {
715 display: flex;
716 flex-wrap: wrap;
717 margin: 0 -5px;
718
719 > div {
720 box-sizing: border-box;
721 flex: 0 0 percentage(math.div(1, 3));
722 padding: 0 5px;
723 margin-bottom: 10px;
724
725 > a {
726 @include disable-default-a-behaviour;
727
728 text-decoration: none;
729 color: inherit;
730 display: block;
731 font-size: 18px;
732
733 &:active,
734 &:focus,
735 &:hover {
736 opacity: .8;
737 }
738 }
739
740 > a,
741 > div {
742 padding: 20px;
743 background: pvar(--submenuBackgroundColor);
744 border-radius: 4px;
745 box-sizing: border-box;
746 height: 100%;
747 }
748 }
749
750 .dashboard-num,
751 .dashboard-text {
752 text-align: center;
753 font-size: 130%;
754 color: pvar(--mainForegroundColor);
755 line-height: 30px;
756 margin-bottom: 20px;
757 }
758
759 .dashboard-label {
760 font-size: 90%;
761 color: pvar(--inputPlaceholderColor);
762 text-align: center;
763 }
764}
765
766@mixin divider($color: pvar(--submenuBackgroundColor), $background: pvar(--mainBackgroundColor)) {
767 width: 95%;
768 border-top: .05rem solid $color;
769 height: .05rem;
770 text-align: center;
771 display: block;
772 position: relative;
773
774 &[data-content] {
775 margin: .8rem 0;
776
777 &::after {
778 background: $background;
779 color: $color;
780 content: attr(data-content);
781 display: inline-block;
782 font-size: .7rem;
783 padding: 0 .4rem;
784 transform: translateY(-.65rem);
785 }
786 }
787}
788
789@mixin chip {
790 --chip-radius: 5rem;
791 --chip-padding: .2rem .4rem;
792 $avatar-height: 1.2rem;
793
794 align-items: center;
795 border-radius: var(--chip-radius);
796 display: inline-flex;
797 font-size: 90%;
798 color: pvar(--mainForegroundColor);
799 height: $avatar-height;
800 line-height: 1rem;
801 margin: .1rem;
802 max-width: 320px;
803 overflow: hidden;
804 padding: var(--chip-padding);
805 text-decoration: none;
806 text-overflow: ellipsis;
807 vertical-align: middle;
808 white-space: nowrap;
809
810 &.rectangular {
811 --chip-radius: .2rem;
812 --chip-padding: .2rem .3rem;
813 }
814
815 my-actor-avatar {
816 @include margin-left(-.4rem);
817 @include margin-right(.2rem);
818 }
819
820 &.two-lines {
821 $avatar-height: 2rem;
822
823 height: $avatar-height;
824
825 my-actor-avatar {
826 display: inline-block;
827 }
828
829 div {
830 margin: 0 .1rem;
831
832 display: flex;
833 flex-direction: column;
834 height: $avatar-height;
835 justify-content: center;
836 }
837 }
838}
839
840// applies ratio (default to 16:9) to a child element (using $selector) only using
841// an immediate's parent size. This allows to set a ratio without explicit
842// dimensions, as width/height cannot be computed from each other.
843@mixin block-ratio ($selector: 'div', $inverted-ratio: math.div(9, 16)) {
844 $padding-percent: percentage($inverted-ratio);
845
846 position: relative;
847 height: 0;
848 width: 100%;
849 padding-top: $padding-percent;
850
851 #{$selector} {
852 position: absolute;
853 width: 100%;
854 height: 100%;
855 top: 0;
856
857 @content;
858 }
859}
860
861@mixin sub-menu-h1 {
862 ::ng-deep h1 {
863 font-size: 1.3rem;
864 border-bottom: 2px solid $grey-background-color;
865 padding-bottom: 15px;
866 margin-bottom: $sub-menu-margin-bottom;
867
868 > span > my-global-icon,
869 > my-global-icon {
870 @include margin-right(10px);
871 width: 24px;
872 height: 24px;
873 vertical-align: top;
874 }
875
876 .pt-badge {
877 @include margin-left(7px);
878
879 vertical-align: top;
880 }
881 }
882}
883
884@mixin play-icon ($width, $height) {
885 width: 0;
886 height: 0;
887
888 position: absolute;
889 left: 50%;
890 top: 50%;
891 transform: translate(-50%, -50%) scale(0.5);
892
893 border-top: #{math.div($height, 2)} solid transparent;
894 border-bottom: #{math.div($height, 2)} solid transparent;
895
896 border-left: $width solid rgba(255, 255, 255, 0.95);
897}
898
899@mixin on-small-main-col () {
900 :host-context(.main-col:not(.expanded)) {
901 @media screen and (max-width: $small-view + $menu-width) {
902 @content;
903 }
904 }
905
906 :host-context(.main-col.expanded) {
907 @media screen and (max-width: $small-view) {
908 @content;
909 }
910 }
911}
912
913@mixin on-mobile-main-col () {
914 :host-context(.main-col:not(.expanded)) {
915 @media screen and (max-width: $mobile-view + $menu-width) {
916 @content;
917 }
918 }
919
920 :host-context(.main-col.expanded) {
921 @media screen and (max-width: $mobile-view) {
922 @content;
923 }
924 }
925}
926
927@mixin margin ($block-start, $inline-end, $block-end, $inline-start) {
928 @include margin-left($inline-start);
929 @include margin-right($inline-end);
930
931 margin-top: $block-start;
932 margin-bottom: $block-end;
933}
934
935@mixin padding ($block-start, $inline-end, $block-end, $inline-start) {
936 @include padding-left($inline-start);
937 @include padding-right($inline-end);
938
939 padding-top: $block-start;
940 padding-bottom: $block-end;
941}
942
943@mixin margin-left ($value) {
944 @supports (margin-inline-start: $value) {
945 margin-inline-start: $value;
946 }
947
948 @supports not (margin-inline-start: $value) {
949 margin-left: $value;
950 }
951}
952
953@mixin margin-right ($value) {
954 @supports (margin-inline-end: $value) {
955 margin-inline-end: $value;
956 }
957
958 @supports not (margin-inline-end: $value) {
959 margin-right: $value;
960 }
961}
962
963@mixin padding-left ($value) {
964 @supports (padding-inline-start: $value) {
965 padding-inline-start: $value;
966 }
967
968 @supports not (padding-inline-start: $value) {
969 padding-left: $value;
970 }
971}
972
973@mixin padding-right ($value) {
974 @supports (padding-inline-end: $value) {
975 padding-inline-end: $value;
976 }
977
978 @supports not (padding-inline-end: $value) {
979 padding-right: $value;
980 }
981}