]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blob - client/src/sass/include/_mixins.scss
9a8d0073a85959fb2e6074c3307c6740e07c0143
[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
17 @mixin ellipsis {
18 white-space: nowrap;
19 overflow: hidden;
20 text-overflow: ellipsis;
21 }
22
23 @mixin ellipsis-multiline($font-size: 16px, $number-of-lines: 2) {
24 display: block;
25 /* Fallback for non-webkit */
26 display: -webkit-box;
27 max-height: $font-size * $number-of-lines;
28 /* Fallback for non-webkit */
29 font-size: $font-size;
30 line-height: $font-size;
31 overflow: hidden;
32 text-overflow: ellipsis;
33 }
34
35 @mixin prefix($property, $parameters...) {
36 @each $prefix in -webkit-, -moz-, -ms-, -o-, "" {
37 #{$prefix}#{$property}: $parameters;
38 }
39 }
40
41 @mixin peertube-word-wrap {
42 word-break: break-word;
43 word-wrap: break-word;
44 overflow-wrap: break-word;
45 -webkit-hyphens: auto;
46 -ms-hyphens: auto;
47 -moz-hyphens: auto;
48 hyphens: auto;
49 }
50
51 @mixin apply-svg-color ($color) {
52 ::ng-deep svg {
53 path[fill="#000000"],
54 g[fill="#000000"],
55 rect[fill="#000000"],
56 circle[fill="#000000"],
57 polygon[fill="#000000"] {
58 fill: $color;
59 }
60
61 path[stroke="#000000"],
62 g[stroke="#000000"],
63 rect[stroke="#000000"],
64 circle[stroke="#000000"],
65 polygon[stroke="#000000"] {
66 stroke: $color;
67 }
68
69 stop[stop-color="#000000"] {
70 stop-color: $color;
71 }
72 }
73 }
74
75 @mixin fill-svg-color ($color) {
76 ::ng-deep svg {
77 path {
78 fill: $color;
79 }
80 }
81 }
82
83 @mixin button-focus-visible-shadow($color) {
84 &.focus-visible {
85 box-shadow: inset 0 1px 1px rgba(0, 0, 0, 0.075), 0 0 4px $color;
86 }
87 }
88
89 @mixin peertube-input-text($width) {
90 display: inline-block;
91 height: $button-height;
92 width: $width;
93 background: var(--inputBackgroundColor);
94 border: 1px solid #C6C6C6;
95 border-radius: 3px;
96 padding-left: 15px;
97 padding-right: 15px;
98 font-size: 15px;
99
100 &::placeholder {
101 color: var(--inputPlaceholderColor);
102 }
103
104 @media screen and (max-width: $width) {
105 width: 100%;
106 }
107 }
108
109 @mixin peertube-input-group($width) {
110 width: $width;
111 min-height: $button-height;
112 padding-top: 0;
113 padding-bottom: 0;
114
115 .input-group-text{
116 font-size: 14px;
117 color: gray;
118 }
119 }
120
121 @mixin peertube-textarea ($width, $height) {
122 @include peertube-input-text($width);
123
124 height: $height;
125 padding: 5px 15px;
126 font-size: 15px;
127 }
128
129 @mixin orange-button {
130 @include button-focus-visible-shadow(var(--mainHoverColor));
131
132 &, &:active, &:focus {
133 color: #fff;
134 background-color: var(--mainColor);
135 }
136
137 &:hover {
138 color: #fff;
139 background-color: var(--mainHoverColor);
140 }
141
142 &[disabled], &.disabled {
143 cursor: default;
144 color: #fff;
145 background-color: #C6C6C6;
146 }
147
148 my-global-icon {
149 @include apply-svg-color(#fff)
150 }
151 }
152
153 @mixin tertiary-button {
154 color: $grey-foreground-color;
155 background-color: transparent;
156
157 &[disabled], &.disabled {
158 cursor: default;
159 }
160
161 my-global-icon {
162 @include apply-svg-color(transparent)
163 }
164 }
165
166 @mixin grey-button {
167 &, &:active, &:focus {
168 background-color: $grey-background-color;
169 color: $grey-foreground-color;
170 }
171
172 &:hover, &:active, &:focus, &[disabled], &.disabled {
173 color: $grey-foreground-color;
174 background-color: $grey-background-hover-color;
175 }
176
177 &[disabled], &.disabled {
178 cursor: default;
179 }
180
181 my-global-icon {
182 @include apply-svg-color($grey-foreground-color)
183 }
184 }
185
186 @mixin peertube-button {
187 border: none;
188 font-weight: $font-semibold;
189 font-size: 15px;
190 height: $button-height;
191 line-height: $button-height;
192 border-radius: 3px;
193 text-align: center;
194 padding: 0 17px 0 13px;
195 cursor: pointer;
196 }
197
198 @mixin peertube-button-link {
199 display: inline-block;
200
201 @include disable-default-a-behaviour;
202 @include peertube-button;
203 }
204
205 @mixin peertube-button-outline {
206 display: inline-block;
207
208 @include disable-default-a-behaviour;
209 @include peertube-button;
210
211 border: 1px solid;
212 }
213
214 @mixin button-with-icon($width: 20px, $margin-right: 3px, $top: -1px) {
215 my-global-icon {
216 position: relative;
217 width: $width;
218 margin-right: $margin-right;
219 top: $top;
220 }
221 }
222
223 @mixin peertube-button-file ($width) {
224 position: relative;
225 overflow: hidden;
226 display: inline-block;
227 width: $width;
228
229 @include peertube-button;
230 @include orange-button;
231
232 input[type=file] {
233 position: absolute;
234 top: 0;
235 right: 0;
236 min-width: 100%;
237 min-height: 100%;
238 font-size: 100px;
239 text-align: right;
240 filter: alpha(opacity=0);
241 opacity: 0;
242 outline: none;
243 background: white;
244 cursor: inherit;
245 display: block;
246 }
247 }
248
249 @mixin icon ($size) {
250 display: inline-block;
251 background-repeat: no-repeat;
252 background-size: contain;
253 width: $size;
254 height: $size;
255 vertical-align: middle;
256 cursor: pointer;
257 }
258
259 @mixin select-arrow-down {
260 top: 50%;
261 right: calc(0% + 15px);
262 content: " ";
263 height: 0;
264 width: 0;
265 position: absolute;
266 pointer-events: none;
267 border: 5px solid rgba(0, 0, 0, 0);
268 border-top-color: #000;
269 margin-top: -2px;
270 z-index: 100;
271 }
272
273 @mixin peertube-select-container ($width) {
274 padding: 0;
275 margin: 0;
276 border: 1px solid #C6C6C6;
277 width: $width;
278 border-radius: 3px;
279 overflow: hidden;
280 background: var(--inputBackgroundColor);
281 position: relative;
282 font-size: 15px;
283
284 &.disabled {
285 background-color: #E5E5E5;
286
287 select {
288 cursor: default;
289 }
290 }
291
292 @media screen and (max-width: $width) {
293 width: 100%;
294 }
295
296 &:after {
297 @include select-arrow-down;
298 }
299
300 select {
301 padding: 0 35px 0 12px;
302 width: calc(100% + 2px);
303 position: relative;
304 left: 1px;
305 border: none;
306 box-shadow: none;
307 background: transparent none;
308 appearance: none;
309 cursor: pointer;
310 height: $button-height;
311 text-overflow: ellipsis;
312 color: var(--mainForegroundColor);
313
314 &:focus {
315 outline: none;
316 }
317
318 &:-moz-focusring {
319 color: transparent;
320 text-shadow: 0 0 0 #000;
321 }
322
323 option {
324 color: #000;
325 }
326 }
327 }
328
329 // Thanks: https://codepen.io/triss90/pen/XNEdRe/
330 @mixin peertube-radio-container {
331 input[type="radio"] {
332 display: none;
333
334 & + label {
335 font-weight: $font-regular;
336 cursor: pointer;
337
338 &:before {
339 position: relative;
340 top: -2px;
341 content: '';
342 background: #fff;
343 border-radius: 100%;
344 border: 1px solid #000;
345 display: inline-block;
346 width: 15px;
347 height: 15px;
348 vertical-align: middle;
349 cursor: pointer;
350 text-align: center;
351 margin-right: 10px;
352 }
353 }
354
355 &:checked + label:before {
356 background-color: #000;
357 box-shadow: inset 0 0 0 4px #fff;
358 }
359
360 &:focus + label:before {
361 outline: none;
362 border-color: #000;
363 }
364 }
365 }
366
367 @mixin peertube-checkbox ($border-width) {
368 opacity: 0;
369 position: absolute;
370
371 &:focus + span {
372 box-shadow: 0 0 0 .1rem rgba(87, 85, 217, .2);
373 }
374
375 & + span {
376 position: relative;
377 width: 18px;
378 min-width: 18px;
379 height: 18px;
380 border: $border-width solid $fg-color;
381 border-radius: 3px;
382 vertical-align: middle;
383 cursor: pointer;
384
385 &:after {
386 content: '';
387 position: absolute;
388 top: calc(2px - #{$border-width});
389 left: 5px;
390 width: 5px;
391 height: 12px;
392 opacity: 0;
393 transform: rotate(45deg) scale(0);
394 border-right: 2px solid $bg-color;
395 border-bottom: 2px solid $bg-color;
396 }
397 }
398
399 &:checked + span {
400 border-color: transparent;
401 background: $orange-color;
402 animation: jelly 0.6s ease;
403
404 &:after {
405 opacity: 1;
406 transform: rotate(45deg) scale(1);
407 }
408 }
409
410 & + span + span {
411 font-size: 15px;
412 font-weight: $font-regular;
413 margin-left: 5px;
414 cursor: pointer;
415 display: inline;
416 }
417
418 &[disabled] + span,
419 &[disabled] + span + span{
420 opacity: 0.5;
421 cursor: default;
422 }
423 }
424
425
426 @mixin avatar ($size) {
427 object-fit: cover;
428 border-radius: 50%;
429 width: $size;
430 height: $size;
431 min-width: $size;
432 min-height: $size;
433 }
434
435 @mixin chevron ($size, $border-width) {
436 border-style: solid;
437 border-width: $border-width $border-width 0 0;
438 content: '';
439 display: inline-block;
440 transform: rotate(-45deg);
441 height: $size;
442 width: $size;
443 }
444
445 @mixin chevron-right ($size, $border-width) {
446 @include chevron($size, $border-width);
447
448 left: 0;
449 transform: rotate(45deg);
450 }
451
452 @mixin chevron-left ($size, $border-width) {
453 @include chevron($size, $border-width);
454
455 left: 0.25em;
456 transform: rotate(-135deg);
457 }
458
459 @mixin in-content-small-title {
460 text-transform: uppercase;
461 color: var(--mainColor);
462 font-weight: $font-bold;
463 font-size: 13px;
464 }
465
466 @mixin actor-owner {
467 @include disable-default-a-behaviour;
468
469 font-size: 13px;
470 margin-top: 4px;
471 color: var(--mainForegroundColor);
472
473 span:hover {
474 opacity: 0.8;
475 }
476
477 img {
478 @include avatar(18px);
479
480 margin-left: 7px;
481 position: relative;
482 top: -2px;
483 }
484 }
485
486 @mixin sub-menu-with-actor {
487 height: max-content;
488 display: flex;
489 flex-direction: column;
490 align-items: flex-start;
491
492 .actor {
493 display: flex;
494 margin-top: 20px;
495 margin-bottom: 20px;
496
497 img {
498 @include avatar(80px);
499
500 margin-right: 20px;
501 }
502
503 .actor-info {
504 display: flex;
505 flex-direction: column;
506 justify-content: center;
507
508 .actor-names {
509 display: flex;
510 align-items: center;
511 flex-wrap: wrap;
512
513 .actor-display-name {
514 font-size: 23px;
515 font-weight: $font-bold;
516 margin-right: 7px;
517 }
518
519 .actor-name {
520 position: relative;
521 top: 3px;
522 font-size: 14px;
523 color: $grey-actor-name;
524 }
525 }
526
527 .actor-lower {
528 grid-area: lower;
529 }
530
531 .actor-followers {
532 font-size: 15px;
533 }
534
535 .actor-owner {
536 @include actor-owner;
537 }
538 }
539 }
540
541 .links {
542 margin-top: 0;
543 margin-bottom: 15px;
544
545 a {
546 margin-top: 0;
547 margin-bottom: 0;
548 text-transform: uppercase;
549 font-weight: 600;
550 font-size: 110%;
551
552 @media screen and (max-width: $mobile-view) {
553 font-size: 130%;
554 }
555 }
556 }
557 }
558
559 @mixin create-button {
560 @include peertube-button-link;
561 @include orange-button;
562 @include button-with-icon(20px, 5px, -1px);
563 }
564
565 @mixin row-blocks {
566 display: flex;
567 min-height: 130px;
568 padding-bottom: 20px;
569 margin-bottom: 20px;
570 border-bottom: 1px solid #C6C6C6;
571
572 @media screen and (max-width: 800px) {
573 flex-direction: column;
574 height: auto;
575 align-items: center;
576 }
577 }
578
579 @mixin dropdown-with-icon-item {
580 padding: 6px 15px;
581
582 my-global-icon {
583 width: 22px;
584 opacity: .7;
585
586 margin-right: 10px;
587 position: relative;
588 top: -2px;
589 }
590 }