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