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