]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blob - client/src/sass/include/_mixins.scss
Use random port for mock servers in tests
[github/Chocobozzz/PeerTube.git] / client / src / sass / include / _mixins.scss
1 @import '_variables';
2
3 @mixin disable-default-a-behaviour {
4 &:hover,
5 &:focus,
6 &:active {
7 text-decoration: none !important;
8 outline: none !important;
9 }
10 }
11
12 @mixin disable-outline {
13 &:focus:not(.focus-visible) {
14 outline: none;
15 }
16 }
17
18 @mixin ellipsis {
19 white-space: nowrap;
20 overflow: hidden;
21 text-overflow: ellipsis;
22 }
23
24 @mixin ellipsis-multiline($font-size: 16px, $number-of-lines: 2) {
25 display: block;
26 /* Fallback for non-webkit */
27 display: -webkit-box; /* stylelint-disable-line value-no-vendor-prefix */
28 -webkit-line-clamp: $number-of-lines;
29 /* Fallback for non-webkit */
30 font-size: $font-size;
31 line-height: $font-size;
32 overflow: hidden;
33 text-overflow: ellipsis;
34 max-height: $font-size * $number-of-lines;
35 }
36
37 @mixin fade-text ($fade-after, $background-color) {
38 position: relative;
39 overflow: hidden;
40
41 &::after {
42 content: '';
43 pointer-events: none;
44 width: 100%;
45 height: 100%;
46 position: absolute;
47 left: 0;
48 top: 0;
49 background: linear-gradient(transparent $fade-after, $background-color);
50 }
51 }
52
53 @mixin peertube-word-wrap ($with-hyphen: true) {
54 word-break: break-word;
55 word-wrap: break-word;
56 overflow-wrap: break-word;
57
58 @if $with-hyphen {
59 hyphens: auto;
60 }
61 }
62
63 @mixin apply-svg-color ($color) {
64 ::ng-deep .feather,
65 ::ng-deep .material,
66 ::ng-deep .misc {
67 color: $color;
68 }
69 }
70
71 @mixin fill-svg-color ($color) {
72 ::ng-deep svg {
73 path {
74 fill: $color;
75 }
76 }
77 }
78
79 @mixin button-focus($color) {
80 &:focus,
81 &.focus-visible {
82 box-shadow: #{$focus-box-shadow-form} $color;
83 }
84 }
85
86 @mixin peertube-input-text($width) {
87 display: inline-block;
88 height: $button-height;
89 width: $width;
90 color: pvar(--inputForegroundColor);
91 background-color: pvar(--inputBackgroundColor);
92 border: 1px solid #C6C6C6;
93 border-radius: 3px;
94 padding-left: 15px;
95 padding-right: 15px;
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: $width) {
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 border: 0;
261 font-weight: $font-semibold;
262 font-size: 15px;
263 height: $button-height;
264 line-height: $button-height;
265 // FIXME: because of primeng that redefines border-radius of all input[type="..."]
266 border-radius: 3px !important;
267 text-align: center;
268 padding: 0 17px 0 13px;
269 cursor: pointer;
270 }
271
272 @mixin peertube-button-link {
273 @include disable-default-a-behaviour;
274 @include peertube-button;
275
276 display: inline-block;
277 }
278
279 @mixin peertube-button-outline {
280 @include disable-default-a-behaviour;
281 @include peertube-button;
282
283 display: inline-block;
284 border: 1px solid;
285 }
286
287 @mixin button-with-icon($width: 20px, $margin-right: 3px, $top: -1px) {
288 display: inline-flex;
289 align-items: center;
290 line-height: normal !important;
291
292 my-global-icon {
293 position: relative;
294 width: $width;
295 margin-right: $margin-right;
296 top: $top;
297 }
298 }
299
300 @mixin peertube-file {
301 position: relative;
302 overflow: hidden;
303 display: inline-block;
304 min-height: 30px;
305
306 input[type=file] {
307 position: absolute;
308 top: 0;
309 right: 0;
310 width: 100%;
311 height: 100%;
312 font-size: 100px;
313 text-align: right;
314 filter: alpha(opacity=0);
315 opacity: 0;
316 outline: none;
317 background: #fff;
318 cursor: inherit;
319 display: block;
320 }
321 }
322
323 @mixin peertube-button-file ($width) {
324 @include peertube-file;
325 @include peertube-button;
326
327 width: $width;
328 }
329
330 @mixin icon ($size) {
331 display: inline-block;
332 background-repeat: no-repeat;
333 background-size: contain;
334 width: $size;
335 height: $size;
336 vertical-align: middle;
337 cursor: pointer;
338 }
339
340 @mixin responsive-width ($width) {
341 width: $width;
342
343 @media screen and (max-width: $width) {
344 width: 100%;
345 }
346 }
347
348 @mixin peertube-select-container ($width) {
349 padding: 0;
350 margin: 0;
351 width: $width;
352 border-radius: 3px;
353 color: pvar(--inputForegroundColor);
354 background: pvar(--inputBackgroundColor);
355 position: relative;
356 font-size: 15px;
357
358 &.disabled {
359 background-color: #E5E5E5;
360
361 select {
362 cursor: default;
363 }
364 }
365
366 @media screen and (max-width: $width) {
367 width: 100%;
368 }
369
370 &::after {
371 top: 50%;
372 right: calc(0% + 15px);
373 content: ' ';
374 height: 0;
375 width: 0;
376 position: absolute;
377 pointer-events: none;
378 border: 5px solid rgba(0, 0, 0, 0);
379 border-top-color: #000;
380 margin-top: -2px;
381 z-index: 100;
382 }
383
384 select {
385 padding: 0 35px 0 12px;
386 position: relative;
387 border: 1px solid #C6C6C6;
388 background: transparent none;
389 appearance: none;
390 cursor: pointer;
391 height: $button-height;
392 text-overflow: ellipsis;
393 color: pvar(--mainForegroundColor);
394
395 &:focus {
396 outline: none;
397 }
398
399 &:-moz-focusring {
400 color: transparent;
401 text-shadow: 0 0 0 #000;
402 }
403
404 option {
405 color: #000;
406 }
407 }
408
409 &.peertube-select-button {
410 @include grey-button;
411
412 select,
413 option {
414 font-weight: $font-semibold;
415 color: pvar(--greyForegroundColor);
416 border: 0;
417 }
418 }
419 }
420
421 // Thanks: https://codepen.io/triss90/pen/XNEdRe/
422 @mixin peertube-radio-container {
423 input[type=radio] {
424 display: none;
425
426 + label {
427 font-weight: $font-regular;
428 cursor: pointer;
429
430 &::before {
431 position: relative;
432 top: -2px;
433 content: '';
434 background: #fff;
435 border-radius: 100%;
436 border: 1px solid #000;
437 display: inline-block;
438 width: 15px;
439 height: 15px;
440 vertical-align: middle;
441 cursor: pointer;
442 text-align: center;
443 margin-right: 10px;
444 }
445 }
446
447 &:checked + label::before {
448 background-color: #000;
449 box-shadow: inset 0 0 0 4px #fff;
450 }
451
452 &:focus + label::before {
453 outline: none;
454 border-color: #000;
455 }
456 }
457 }
458
459 @mixin peertube-checkbox ($border-width) {
460 opacity: 0;
461 position: absolute;
462
463 &:focus + span {
464 box-shadow: #{$focus-box-shadow-form} pvar(--mainColorLightest);
465 }
466
467 + span {
468 position: relative;
469 width: 18px;
470 min-width: 18px;
471 height: 18px;
472 border: $border-width solid #C6C6C6;
473 border-radius: 3px;
474 vertical-align: middle;
475 cursor: pointer;
476
477 &::after {
478 content: '';
479 position: absolute;
480 top: calc(2px - #{$border-width});
481 left: 5px;
482 width: 5px;
483 height: 12px;
484 opacity: 0;
485 transform: rotate(45deg) scale(0);
486 border-right: 2px solid $bg-color;
487 border-bottom: 2px solid $bg-color;
488 }
489 }
490
491 &:checked + span {
492 border-color: transparent;
493 background: pvar(--mainColor);
494 animation: jelly 0.6s ease;
495
496 &::after {
497 opacity: 1;
498 transform: rotate(45deg) scale(1);
499 }
500 }
501
502 + span + span {
503 font-size: 15px;
504 font-weight: $font-regular;
505 margin-left: 5px;
506 cursor: pointer;
507 display: inline;
508 }
509
510 &[disabled] + span,
511 &[disabled] + span + span {
512 opacity: 0.5;
513 cursor: default;
514 }
515 }
516
517 @mixin table-badge {
518 border-radius: 2px;
519 padding: 1/4em 1/2em;
520 text-transform: uppercase;
521 font-weight: $font-bold;
522 font-size: 12px;
523 letter-spacing: 1/3px;
524
525 &.badge-banned,
526 &.badge-red {
527 background-color: #ffcdd2;
528 color: #c63737;
529 }
530
531 &.badge-banned {
532 text-decoration: line-through;
533 }
534
535 &.badge-yellow {
536 background-color: #feedaf;
537 color: #8a5340;
538 }
539
540 &.badge-brown {
541 background-color: #ffd8b2;
542 color: #805b36;
543 }
544
545 &.badge-green {
546 background-color: #c8e6c9;
547 color: #256029;
548 }
549
550 &.badge-blue {
551 background-color: #b3e5fc;
552 color: #23547b;
553 }
554
555 &.badge-purple {
556 background-color: #eccfff;
557 color: #694382;
558 }
559 }
560
561 @mixin actor-avatar-size ($size) {
562 display: inline-block;
563 width: $size;
564 height: $size;
565 min-width: $size;
566 min-height: $size;
567 }
568
569 @mixin chevron ($size, $border-width) {
570 border-style: solid;
571 border-width: $border-width $border-width 0 0;
572 content: '';
573 display: inline-block;
574 transform: rotate(-45deg);
575 height: $size;
576 width: $size;
577 }
578
579 @mixin chevron-right ($size, $border-width) {
580 @include chevron($size, $border-width);
581
582 left: 0;
583 transform: rotate(45deg);
584 }
585
586 @mixin chevron-left ($size, $border-width) {
587 @include chevron($size, $border-width);
588
589 left: 0.25em;
590 transform: rotate(-135deg);
591 }
592
593 @mixin in-content-small-title {
594 text-transform: uppercase;
595 color: pvar(--mainColor);
596 font-weight: $font-bold;
597 font-size: 13px;
598 }
599
600 @mixin settings-big-title {
601 text-transform: uppercase;
602 color: pvar(--mainColor);
603 font-weight: $font-bold;
604 font-size: 110%;
605 margin-bottom: 10px;
606 }
607
608 @mixin create-button {
609 @include peertube-button-link;
610 @include orange-button;
611 @include button-with-icon(20px, 5px, -1px);
612 }
613
614 @mixin row-blocks ($column-responsive: true) {
615 display: flex;
616 min-height: 130px;
617 padding-bottom: 20px;
618 margin-bottom: 20px;
619 border-bottom: 1px solid #C6C6C6;
620
621 @media screen and (max-width: $small-view) {
622 @if $column-responsive {
623 flex-direction: column;
624 height: auto;
625 align-items: center;
626 } @else {
627 min-height: initial;
628 padding-bottom: 10px;
629 margin-bottom: 10px;
630 }
631 }
632 }
633
634 @mixin dropdown-with-icon-item {
635 padding: 6px 15px;
636
637 my-global-icon {
638 width: 22px;
639 opacity: .7;
640
641 margin-right: 10px;
642 position: relative;
643 top: -2px;
644 }
645 }
646
647 @mixin progressbar($small: false) {
648 background-color: $grey-background-color;
649 display: flex;
650 height: 1rem;
651 overflow: hidden;
652 font-size: 0.75rem;
653 border-radius: 0.25rem;
654 position: relative;
655
656 span {
657 position: absolute;
658 color: $grey-foreground-color;
659 @if $small {
660 top: -1px;
661 }
662
663 &:nth-of-type(1) {
664 left: .2rem;
665 }
666 &:nth-of-type(2) {
667 right: .2rem;
668 }
669 }
670
671 .progress-bar {
672 color: pvar(--mainBackgroundColor);
673 background-color: pvar(--mainColor);
674 display: flex;
675 flex-direction: column;
676 justify-content: center;
677 text-align: center;
678 white-space: nowrap;
679 transition: width 0.6s ease;
680
681 &.secondary {
682 background-color: pvar(--secondaryColor);
683 }
684
685 &.red {
686 background-color: lighten($color: #c54130, $amount: 10);
687 }
688 }
689 }
690
691 @mixin breadcrumb {
692 display: flex;
693 flex-wrap: wrap;
694 padding: 0.75rem 1rem;
695 margin-bottom: 1rem;
696 list-style: none;
697 background-color: pvar(--submenuBackgroundColor);
698 border-radius: 0.25rem;
699
700 .breadcrumb-item {
701 display: flex;
702
703 a {
704 color: pvar(--mainColor);
705 }
706
707 + .breadcrumb-item {
708 padding-left: 0.5rem;
709 &::before {
710 display: inline-block;
711 padding-right: 0.5rem;
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(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 margin-left: -.4rem;
826 margin-right: .2rem;
827 }
828
829 &.two-lines {
830 $avatar-height: 2rem;
831
832 height: $avatar-height;
833
834 my-actor-avatar {
835 @include actor-avatar-size($avatar-height);
836 }
837
838 div {
839 display: flex;
840 flex-direction: column;
841 height: $avatar-height;
842 margin-left: .1rem;
843 margin-right: .1rem;
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: 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 @content;
866 }
867 }
868
869 @mixin sub-menu-h1 {
870 ::ng-deep h1 {
871 font-size: 1.3rem;
872 border-bottom: 2px solid $grey-background-color;
873 padding-bottom: 15px;
874 margin-bottom: $sub-menu-margin-bottom;
875
876 > span > my-global-icon,
877 > my-global-icon {
878 margin-right: 10px;
879 width: 24px;
880 height: 24px;
881 vertical-align: top;
882 }
883
884 .badge {
885 margin-left: 7px;
886 vertical-align: top;
887 }
888 }
889 }
890
891 @mixin play-icon ($width, $height) {
892 width: 0;
893 height: 0;
894
895 position: absolute;
896 left: 50%;
897 top: 50%;
898 transform: translate(-50%, -50%) scale(0.5);
899
900 border-top: ($height / 2) solid transparent;
901 border-bottom: ($height / 2) solid transparent;
902
903 border-left: $width solid rgba(255, 255, 255, 0.95);
904 }
905
906 @mixin on-small-main-col () {
907 :host-context(.main-col:not(.expanded)) {
908 @media screen and (max-width: $small-view + $menu-width) {
909 @content;
910 }
911 }
912
913 :host-context(.main-col.expanded) {
914 @media screen and (max-width: $small-view) {
915 @content;
916 }
917 }
918 }
919
920 @mixin on-mobile-main-col () {
921 :host-context(.main-col:not(.expanded)) {
922 @media screen and (max-width: $mobile-view + $menu-width) {
923 @content;
924 }
925 }
926
927 :host-context(.main-col.expanded) {
928 @media screen and (max-width: $mobile-view) {
929 @content;
930 }
931 }
932 }