]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blob - client/src/sass/include/_mixins.scss
Fix avatar size in moderation tables
[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 {
54 word-break: break-word;
55 word-wrap: break-word;
56 overflow-wrap: break-word;
57 hyphens: auto;
58 }
59
60 @mixin apply-svg-color ($color) {
61 ::ng-deep .feather,
62 ::ng-deep .material {
63 color: $color;
64 }
65 }
66
67 @mixin fill-svg-color ($color) {
68 ::ng-deep svg {
69 path {
70 fill: $color;
71 }
72 }
73 }
74
75 @mixin button-focus($color) {
76 &:focus,
77 &.focus-visible {
78 box-shadow: #{$focus-box-shadow-form} $color;
79 }
80 }
81
82 @mixin peertube-input-text($width) {
83 display: inline-block;
84 height: $button-height;
85 width: $width;
86 color: pvar(--inputForegroundColor);
87 background-color: pvar(--inputBackgroundColor);
88 border: 1px solid #C6C6C6;
89 border-radius: 3px;
90 padding-left: 15px;
91 padding-right: 15px;
92 font-size: 15px;
93
94 &::placeholder {
95 color: pvar(--inputPlaceholderColor);
96 }
97
98 &[readonly] {
99 opacity: 0.7;
100 }
101
102 @media screen and (max-width: $width) {
103 width: 100%;
104 }
105 }
106
107 @mixin peertube-input-group($width) {
108 width: $width;
109 min-height: $button-height;
110 padding-top: 0;
111 padding-bottom: 0;
112 flex-wrap: nowrap;
113
114 .input-group-text {
115 font-size: 14px;
116 color: #808080;
117 }
118 }
119
120 @mixin peertube-textarea ($width, $height) {
121 @include peertube-input-text($width);
122
123 color: pvar(--textareaForegroundColor);
124 background-color: pvar(--textareaBackgroundColor);
125 height: $height;
126 padding: 5px 15px;
127 font-size: 15px;
128 }
129
130 @mixin orange-button {
131 @include button-focus(pvar(--mainColorLightest));
132
133 &,
134 &:active,
135 &:focus {
136 color: #fff;
137 background-color: pvar(--mainColor);
138 }
139
140 &:hover {
141 color: #fff;
142 background-color: pvar(--mainHoverColor);
143 }
144
145 &[disabled],
146 &.disabled {
147 cursor: default;
148 color: #fff;
149 background-color: #C6C6C6;
150 }
151
152 my-global-icon {
153 @include apply-svg-color(#fff);
154 }
155 }
156
157 @mixin orange-button-inverted {
158 @include button-focus(pvar(--mainColorLightest));
159
160 border: 2px solid pvar(--mainColor);
161 font-weight: $font-semibold;
162
163 &,
164 &:active,
165 &:focus {
166 color: pvar(--mainColor);
167 background-color: pvar(--mainBackgroundColor);
168 }
169
170 &:hover {
171 color: pvar(--mainColor);
172 background-color: pvar(--mainColorLightest);
173 }
174
175 &[disabled],
176 &.disabled {
177 cursor: default;
178 color: pvar(--mainColor);
179 background-color: #C6C6C6;
180 }
181
182 my-global-icon {
183 @include apply-svg-color(pvar(--mainColor));
184 }
185 }
186
187 @mixin tertiary-button {
188 @include button-focus($grey-button-outline-color);
189
190 color: pvar(--greyForegroundColor);
191 background-color: transparent;
192
193 &[disabled],
194 .disabled {
195 cursor: default;
196 }
197
198 my-global-icon {
199 @include apply-svg-color(transparent);
200 }
201 }
202
203 @mixin grey-button {
204 @include button-focus($grey-button-outline-color);
205
206 background-color: $grey-background-color;
207 color: pvar(--greyForegroundColor);
208
209 &:hover,
210 &:active,
211 &:focus,
212 &[disabled],
213 &.disabled {
214 color: pvar(--greyForegroundColor);
215 background-color: $grey-background-hover-color;
216 }
217
218 &[disabled],
219 &.disabled {
220 cursor: default;
221 }
222
223 my-global-icon {
224 @include apply-svg-color(pvar(--greyForegroundColor));
225 }
226 }
227
228 @mixin danger-button {
229 $color: lighten($color: #c54130, $amount: 10);
230 $text: #fff6f5;
231
232 @include button-focus(scale-color($color, $alpha: -95%));
233
234 background-color: $color;
235 color: $text;
236
237 &:hover,
238 &:active,
239 &:focus,
240 &[disabled],
241 &.disabled {
242 background-color: lighten($color: $color, $amount: 10);
243 }
244
245 &[disabled],
246 &.disabled {
247 cursor: default;
248 }
249
250 my-global-icon {
251 @include apply-svg-color($text);
252 }
253 }
254
255 @mixin peertube-button {
256 border: 0;
257 font-weight: $font-semibold;
258 font-size: 15px;
259 height: $button-height;
260 line-height: $button-height;
261 // FIXME: because of primeng that redefines border-radius of all input[type="..."]
262 border-radius: 3px !important;
263 text-align: center;
264 padding: 0 17px 0 13px;
265 cursor: pointer;
266 }
267
268 @mixin peertube-button-link {
269 @include disable-default-a-behaviour;
270 @include peertube-button;
271
272 display: inline-block;
273 }
274
275 @mixin peertube-button-outline {
276 @include disable-default-a-behaviour;
277 @include peertube-button;
278
279 display: inline-block;
280 border: 1px solid;
281 }
282
283 @mixin button-with-icon($width: 20px, $margin-right: 3px, $top: -1px) {
284 display: inline-flex;
285 align-items: center;
286 line-height: normal !important;
287
288 my-global-icon {
289 position: relative;
290 width: $width;
291 margin-right: $margin-right;
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: right;
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 select-arrow-down {
337 top: 50%;
338 right: calc(0% + 15px);
339 content: ' ';
340 height: 0;
341 width: 0;
342 position: absolute;
343 pointer-events: none;
344 border: 5px solid rgba(0, 0, 0, 0);
345 border-top-color: #000;
346 margin-top: -2px;
347 z-index: 100;
348 }
349
350 @mixin responsive-width ($width) {
351 width: $width;
352
353 @media screen and (max-width: $width) {
354 width: 100%;
355 }
356 }
357
358 @mixin peertube-select-container ($width) {
359 padding: 0;
360 margin: 0;
361 width: $width;
362 border-radius: 3px;
363 color: pvar(--inputForegroundColor);
364 background: pvar(--inputBackgroundColor);
365 position: relative;
366 font-size: 15px;
367
368 &.disabled {
369 background-color: #E5E5E5;
370
371 select {
372 cursor: default;
373 }
374 }
375
376 @media screen and (max-width: $width) {
377 width: 100%;
378 }
379
380 &::after {
381 @include select-arrow-down;
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 @mixin admin-sub-header-responsive {
850 flex-direction: column;
851
852 .form-sub-title {
853 margin-right: 0 !important;
854 margin-bottom: 10px;
855 text-align: center;
856 }
857
858 .admin-sub-nav {
859 display: block;
860 overflow-x: auto;
861 white-space: nowrap;
862 height: 50px;
863 padding: 10px 0;
864 width: 100%;
865
866 a {
867 margin-left: 5px;
868 }
869 }
870 }
871
872 // applies ratio (default to 16:9) to a child element (using $selector) only using
873 // an immediate's parent size. This allows to set a ratio without explicit
874 // dimensions, as width/height cannot be computed from each other.
875 @mixin block-ratio ($selector: 'div', $inverted-ratio: 9/16) {
876 $padding-percent: percentage($inverted-ratio);
877
878 position: relative;
879 height: 0;
880 width: 100%;
881 padding-top: $padding-percent;
882
883 #{$selector} {
884 position: absolute;
885 width: 100%;
886 height: 100%;
887 top: 0;
888 @content;
889 }
890 }
891
892 @mixin sub-menu-h1 {
893 ::ng-deep h1 {
894 font-size: 1.3rem;
895 border-bottom: 2px solid $grey-background-color;
896 padding-bottom: 15px;
897 margin-bottom: $sub-menu-margin-bottom;
898
899 > span > my-global-icon,
900 > my-global-icon {
901 margin-right: 10px;
902 width: 24px;
903 height: 24px;
904 vertical-align: top;
905 }
906
907 .badge {
908 margin-left: 7px;
909 vertical-align: top;
910 }
911 }
912 }
913
914 @mixin play-icon ($width, $height) {
915 width: 0;
916 height: 0;
917
918 position: absolute;
919 left: 50%;
920 top: 50%;
921 transform: translate(-50%, -50%) scale(0.5);
922
923 border-top: ($height / 2) solid transparent;
924 border-bottom: ($height / 2) solid transparent;
925
926 border-left: $width solid rgba(255, 255, 255, 0.95);
927 }
928
929 @mixin on-small-main-col () {
930 :host-context(.main-col:not(.expanded)) {
931 @media screen and (max-width: $small-view + $menu-width) {
932 @content;
933 }
934 }
935
936 :host-context(.main-col.expanded) {
937 @media screen and (max-width: $small-view) {
938 @content;
939 }
940 }
941 }
942
943 @mixin on-mobile-main-col () {
944 :host-context(.main-col:not(.expanded)) {
945 @media screen and (max-width: $mobile-view + $menu-width) {
946 @content;
947 }
948 }
949
950 :host-context(.main-col.expanded) {
951 @media screen and (max-width: $mobile-view) {
952 @content;
953 }
954 }
955 }