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