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