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