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