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