]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blob - client/src/sass/include/_mixins.scss
Merge branch 'release/4.2.0' into develop
[github/Chocobozzz/PeerTube.git] / client / src / sass / include / _mixins.scss
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 $input-border-color;
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: $input-border-color;
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: $input-border-color;
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-outline {
288 @include disable-default-a-behaviour;
289 @include peertube-button;
290
291 display: inline-block;
292 border: 1px solid;
293 }
294
295 @mixin button-with-icon($width: 20px, $margin-right: 3px, $top: -1px) {
296 my-global-icon {
297 @include margin-right($margin-right);
298
299 position: relative;
300 width: $width;
301 top: $top;
302 }
303 }
304
305 @mixin peertube-file {
306 position: relative;
307 overflow: hidden;
308 display: inline-block;
309 min-height: 30px;
310
311 input[type=file] {
312 position: absolute;
313 top: 0;
314 right: 0;
315 width: 100%;
316 height: 100%;
317 font-size: 100px;
318 text-align: end;
319 filter: alpha(opacity=0);
320 opacity: 0;
321 outline: none;
322 background: #fff;
323 cursor: inherit;
324 display: block;
325 }
326 }
327
328 @mixin peertube-button-file ($width) {
329 @include peertube-file;
330 @include peertube-button;
331
332 width: $width;
333 }
334
335 @mixin icon ($size) {
336 display: inline-block;
337 background-repeat: no-repeat;
338 background-size: contain;
339 width: $size;
340 height: $size;
341 vertical-align: middle;
342 cursor: pointer;
343 }
344
345 @mixin responsive-width ($width) {
346 width: $width;
347
348 @media screen and (max-width: $width) {
349 width: 100%;
350 }
351 }
352
353 @mixin peertube-select-container ($width) {
354 padding: 0;
355 margin: 0;
356 width: $width;
357 border-radius: 3px;
358 color: pvar(--inputForegroundColor);
359 background: pvar(--inputBackgroundColor);
360 position: relative;
361 height: min-content;
362
363 &.disabled {
364 background-color: #E5E5E5;
365
366 select {
367 cursor: default;
368 }
369 }
370
371 select[disabled] {
372 background-color: #f9f9f9;
373 }
374
375 @media screen and (max-width: $width) {
376 width: 100%;
377 }
378
379 &::after {
380 top: 50%;
381 right: calc(0% + 15px);
382 content: ' ';
383 height: 0;
384 width: 0;
385 position: absolute;
386 pointer-events: none;
387 border: 5px solid rgba(0, 0, 0, 0);
388 border-top-color: #000;
389 margin-top: -2px;
390 z-index: 100;
391 }
392
393 select {
394 padding: 0 35px 0 12px;
395 position: relative;
396 border: 1px solid $input-border-color;
397 background: transparent none;
398 appearance: none;
399 height: $button-height;
400 text-overflow: ellipsis;
401 color: pvar(--mainForegroundColor);
402 font-size: $form-input-font-size;
403 line-height: $form-input-line-height;
404
405 &:focus {
406 outline: none;
407 }
408
409 &:-moz-focusring {
410 color: transparent;
411 text-shadow: 0 0 0 #000;
412 }
413
414 option {
415 color: #000;
416
417 &[value=undefined] {
418 font-weight: $font-semibold;
419 }
420 }
421 }
422
423 &.peertube-select-button {
424 @include grey-button;
425
426 select {
427 font-weight: $font-semibold;
428 color: pvar(--greyForegroundColor);
429 border: 0;
430 }
431 }
432 }
433
434 // Thanks: https://codepen.io/manabox/pen/raQmpL
435 @mixin peertube-radio-container {
436 label {
437 font-size: $form-input-font-size;
438 }
439
440 [type=radio]:checked,
441 [type=radio]:not(:checked) {
442 position: absolute;
443 left: -9999px;
444 }
445
446 [type=radio]:checked + label,
447 [type=radio]:not(:checked) + label {
448 position: relative;
449 padding-left: 28px;
450 cursor: pointer;
451 line-height: 20px;
452 display: inline-block;
453 font-weight: $font-regular;
454 }
455
456 [type=radio]:checked + label::before,
457 [type=radio]:not(:checked) + label::before {
458 content: '';
459 position: absolute;
460 left: 0;
461 top: 0;
462 width: 18px;
463 height: 18px;
464 border: 1px solid $input-border-color;
465 border-radius: 100%;
466 background: #fff;
467 }
468
469 [type=radio]:checked + label::after,
470 [type=radio]:not(:checked) + label::after {
471 content: '';
472 width: 10px;
473 height: 10px;
474 background: pvar(--mainColor);
475 position: absolute;
476 top: 4px;
477 left: 4px;
478 border-radius: 100%;
479 transition: all 0.2s ease;
480 }
481 [type=radio]:not(:checked) + label::after {
482 opacity: 0;
483 transform: scale(0);
484 }
485 [type=radio]:checked + label::after {
486 opacity: 1;
487 transform: scale(1);
488 }
489
490 .form-group-description {
491 display: block;
492 margin-top: -7px;
493 margin-bottom: 10px;
494 margin-left: 29px;
495 }
496 }
497
498 @mixin peertube-checkbox ($border-width) {
499 opacity: 0;
500 position: absolute;
501
502 &:focus + span {
503 box-shadow: #{$focus-box-shadow-form} pvar(--mainColorLightest);
504 }
505
506 + span {
507 position: relative;
508 width: 18px;
509 min-width: 18px;
510 height: 18px;
511 border: $border-width solid $input-border-color;
512 border-radius: 3px;
513 vertical-align: middle;
514 cursor: pointer;
515
516 &::after {
517 content: '';
518 position: absolute;
519 top: calc(2px - #{$border-width});
520 left: 5px;
521 width: 5px;
522 height: 12px;
523 opacity: 0;
524 transform: rotate(45deg) scale(0);
525 border-right: 2px solid $bg-color;
526 border-bottom: 2px solid $bg-color;
527 }
528 }
529
530 &:checked + span {
531 border-color: transparent;
532 background: pvar(--mainColor);
533 animation: jelly 0.6s ease;
534
535 &::after {
536 opacity: 1;
537 transform: rotate(45deg) scale(1);
538 }
539 }
540
541 + span + span {
542 @include margin-left(5px);
543
544 font-weight: $font-regular;
545 cursor: pointer;
546 display: inline;
547 }
548
549 &[disabled] + span,
550 &[disabled] + span + span {
551 opacity: 0.5;
552 cursor: default;
553 }
554 }
555
556 @mixin actor-avatar-size ($size) {
557 display: inline-block;
558 width: $size;
559 height: $size;
560 min-width: $size;
561 min-height: $size;
562 }
563
564 @mixin actor-counters ($separator-margin: 10px) {
565 color: pvar(--greyForegroundColor);
566 display: flex;
567 align-items: center;
568
569 > *:not(:last-child)::after {
570 content: '•';
571 margin: 0 $separator-margin;
572 color: pvar(--mainColor);
573 }
574 }
575
576 @mixin in-content-small-title {
577 text-transform: uppercase;
578 color: pvar(--mainColor);
579 font-weight: $font-bold;
580 font-size: 13px;
581 }
582
583 @mixin settings-big-title {
584 text-transform: uppercase;
585 color: pvar(--mainColor);
586 font-weight: $font-bold;
587 font-size: 1rem;
588 margin-bottom: 10px;
589 }
590
591 @mixin create-button {
592 @include peertube-button-link;
593 @include orange-button;
594 @include button-with-icon(20px, 5px, -1px);
595 }
596
597 @mixin row-blocks ($column-responsive: true, $min-height: 130px, $separator: true) {
598 display: flex;
599 min-height: $min-height;
600 padding-bottom: 20px;
601 margin-bottom: 20px;
602
603 @if $separator {
604 border-bottom: 1px solid $input-border-color;
605 }
606
607 @media screen and (max-width: $small-view) {
608 @if $column-responsive {
609 flex-direction: column;
610 height: auto;
611 align-items: center;
612 } @else {
613 min-height: initial;
614 padding-bottom: 10px;
615 margin-bottom: 10px;
616 }
617 }
618 }
619
620 @mixin dropdown-with-icon-item {
621 padding: 6px 15px;
622
623 my-global-icon {
624 @include margin-right(10px);
625
626 width: 22px;
627 opacity: .7;
628 position: relative;
629 top: -2px;
630 }
631 }
632
633 @mixin progressbar($small: false) {
634 background-color: $grey-background-color;
635 display: flex;
636 height: 1rem;
637 overflow: hidden;
638 font-size: 0.75rem;
639 border-radius: 0.25rem;
640 position: relative;
641
642 span {
643 position: absolute;
644 color: $grey-foreground-color;
645
646 @if $small {
647 top: -1px;
648 }
649
650 &:nth-of-type(1) {
651 left: .2rem;
652 }
653 &:nth-of-type(2) {
654 right: .2rem;
655 }
656 }
657
658 .progress-bar {
659 color: pvar(--mainBackgroundColor);
660 background-color: pvar(--mainColor);
661 display: flex;
662 flex-direction: column;
663 justify-content: center;
664 text-align: center;
665 white-space: nowrap;
666 transition: width 0.6s ease;
667
668 &.red {
669 background-color: lighten($color: #c54130, $amount: 10);
670 }
671 }
672 }
673
674 @mixin breadcrumb {
675 display: flex;
676 flex-wrap: wrap;
677 padding: 0;
678 margin-bottom: 1rem;
679 list-style: none;
680 font-weight: $font-semibold;
681
682 .breadcrumb-item {
683 display: flex;
684
685 a {
686 color: pvar(--mainColor);
687 }
688
689 + .breadcrumb-item {
690 @include padding-left(0.5rem);
691
692 &::before {
693 @include padding-right(0.5rem);
694
695 display: inline-block;
696 color: #6c757d;
697 content: '/';
698 }
699 }
700
701 &.active {
702 color: #6c757d;
703 }
704 }
705 }
706
707 @mixin dashboard {
708 display: flex;
709 flex-wrap: wrap;
710 margin: 0 -5px;
711
712 > div {
713 box-sizing: border-box;
714 flex: 0 0 percentage(math.div(1, 3));
715 padding: 0 5px;
716 margin-bottom: 10px;
717
718 > a {
719 @include disable-default-a-behaviour;
720
721 text-decoration: none;
722 color: inherit;
723 display: block;
724 font-size: 18px;
725
726 &:active,
727 &:focus,
728 &:hover {
729 opacity: .8;
730 }
731 }
732
733 > a,
734 > div {
735 padding: 20px;
736 background: pvar(--submenuBackgroundColor);
737 border-radius: 4px;
738 box-sizing: border-box;
739 height: 100%;
740 }
741 }
742
743 .dashboard-num,
744 .dashboard-text {
745 text-align: center;
746 font-size: 130%;
747 color: pvar(--mainForegroundColor);
748 line-height: 30px;
749 margin-bottom: 20px;
750 }
751
752 .dashboard-label {
753 font-size: 90%;
754 color: pvar(--inputPlaceholderColor);
755 text-align: center;
756 }
757 }
758
759 @mixin divider($color: pvar(--submenuBackgroundColor), $background: pvar(--mainBackgroundColor)) {
760 width: 95%;
761 border-top: .05rem solid $color;
762 height: .05rem;
763 text-align: center;
764 display: block;
765 position: relative;
766
767 &[data-content] {
768 margin: .8rem 0;
769
770 &::after {
771 background: $background;
772 color: $color;
773 content: attr(data-content);
774 display: inline-block;
775 font-size: .7rem;
776 padding: 0 .4rem;
777 transform: translateY(-.65rem);
778 }
779 }
780 }
781
782 @mixin chip {
783 --chip-radius: 5rem;
784 --chip-padding: .2rem .4rem;
785 $avatar-height: 1.2rem;
786
787 align-items: center;
788 border-radius: var(--chip-radius);
789 display: inline-flex;
790 font-size: 90%;
791 color: pvar(--mainForegroundColor);
792 height: $avatar-height;
793 line-height: 1rem;
794 margin: .1rem;
795 max-width: 320px;
796 overflow: hidden;
797 padding: var(--chip-padding);
798 text-decoration: none;
799 text-overflow: ellipsis;
800 vertical-align: middle;
801 white-space: nowrap;
802
803 &.rectangular {
804 --chip-radius: .2rem;
805 --chip-padding: .2rem .3rem;
806 }
807
808 my-actor-avatar {
809 @include margin-left(-.4rem);
810 @include margin-right(.2rem);
811 }
812
813 &.two-lines {
814 $avatar-height: 2rem;
815
816 height: $avatar-height;
817
818 my-actor-avatar {
819 display: inline-block;
820 }
821
822 div {
823 margin: 0 .1rem;
824
825 display: flex;
826 flex-direction: column;
827 height: $avatar-height;
828 justify-content: center;
829 }
830 }
831 }
832
833 // applies ratio (default to 16:9) to a child element (using $selector) only using
834 // an immediate's parent size. This allows to set a ratio without explicit
835 // dimensions, as width/height cannot be computed from each other.
836 @mixin block-ratio ($selector: 'div', $inverted-ratio: math.div(9, 16)) {
837 $padding-percent: percentage($inverted-ratio);
838
839 position: relative;
840 height: 0;
841 width: 100%;
842 padding-top: $padding-percent;
843
844 #{$selector} {
845 position: absolute;
846 width: 100%;
847 height: 100%;
848 top: 0;
849
850 @content;
851 }
852 }
853
854 @mixin sub-menu-h1 {
855 ::ng-deep h1 {
856 font-size: 1.3rem;
857 border-bottom: 2px solid $grey-background-color;
858 padding-bottom: 15px;
859 margin-bottom: $sub-menu-margin-bottom;
860
861 > span > my-global-icon,
862 > my-global-icon {
863 @include margin-right(10px);
864 width: 24px;
865 height: 24px;
866 vertical-align: top;
867 }
868
869 .pt-badge {
870 @include margin-left(7px);
871
872 vertical-align: top;
873 }
874 }
875 }
876
877 @mixin play-icon ($width, $height) {
878 width: 0;
879 height: 0;
880
881 position: absolute;
882 left: 50%;
883 top: 50%;
884 transform: translate(-50%, -50%) scale(0.5);
885
886 border-top: #{math.div($height, 2)} solid transparent;
887 border-bottom: #{math.div($height, 2)} solid transparent;
888
889 border-left: $width solid rgba(255, 255, 255, 0.95);
890 }
891
892 @mixin on-small-main-col () {
893 :host-context(.main-col:not(.expanded)) {
894 @media screen and (max-width: $small-view + $menu-width) {
895 @content;
896 }
897 }
898
899 :host-context(.main-col.expanded) {
900 @media screen and (max-width: $small-view) {
901 @content;
902 }
903 }
904 }
905
906 @mixin on-mobile-main-col () {
907 :host-context(.main-col:not(.expanded)) {
908 @media screen and (max-width: $mobile-view + $menu-width) {
909 @content;
910 }
911 }
912
913 :host-context(.main-col.expanded) {
914 @media screen and (max-width: $mobile-view) {
915 @content;
916 }
917 }
918 }
919
920 @mixin margin ($block-start, $inline-end, $block-end, $inline-start) {
921 @include margin-left($inline-start);
922 @include margin-right($inline-end);
923
924 margin-top: $block-start;
925 margin-bottom: $block-end;
926 }
927
928 @mixin padding ($block-start, $inline-end, $block-end, $inline-start) {
929 @include padding-left($inline-start);
930 @include padding-right($inline-end);
931
932 padding-top: $block-start;
933 padding-bottom: $block-end;
934 }
935
936 @mixin margin-left ($value) {
937 @supports (margin-inline-start: $value) {
938 margin-inline-start: $value;
939 }
940
941 @supports not (margin-inline-start: $value) {
942 margin-left: $value;
943 }
944 }
945
946 @mixin margin-right ($value) {
947 @supports (margin-inline-end: $value) {
948 margin-inline-end: $value;
949 }
950
951 @supports not (margin-inline-end: $value) {
952 margin-right: $value;
953 }
954 }
955
956 @mixin padding-left ($value) {
957 @supports (padding-inline-start: $value) {
958 padding-inline-start: $value;
959 }
960
961 @supports not (padding-inline-start: $value) {
962 padding-left: $value;
963 }
964 }
965
966 @mixin padding-right ($value) {
967 @supports (padding-inline-end: $value) {
968 padding-inline-end: $value;
969 }
970
971 @supports not (padding-inline-end: $value) {
972 padding-right: $value;
973 }
974 }