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