]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blame - client/src/sass/include/_mixins.scss
use focus-visible polyfill to improve keyboard navigation
[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 &::-moz-focus-inner {
16 border: 0;
17 padding: 0
18 }
19}
20
769ac6c1
RK
21/**
22 * This mixin will crop text in block for needed amount of lines and put ellipsis at the end
23 *
24 * @param $font-size font-size property
25 * @param $line-height line-height property
26 * @param $lines-to-show amount of lines to show
27 */
74d63469 28@mixin ellipsis-multiline($font-size: 1rem, $line-height: 1, $lines-to-show: 2) {
769ac6c1
RK
29 display: block;
30 /* Fallback for non-webkit */
31 display: -webkit-box;
32 max-height: $font-size*$line-height*$lines-to-show;
33 /* Fallback for non-webkit */
34 font-size: $font-size;
35 line-height: $line-height;
36 -webkit-line-clamp: $lines-to-show;
37 -webkit-box-orient: vertical;
38 overflow: hidden;
39 text-overflow: ellipsis;
40}
41
42@mixin prefix($property, $parameters...) {
43 @each $prefix in -webkit-, -moz-, -ms-, -o-, "" {
44 #{$prefix}#{$property}: $parameters;
45 }
46}
47
7a14004b
C
48@mixin peertube-word-wrap {
49 word-break: normal;
50 word-wrap: break-word;
51 overflow-wrap: break-word;
52 -webkit-hyphens: auto;
53 -ms-hyphens: auto;
54 -moz-hyphens: auto;
55 hyphens: auto;
56 text-align: justify;
57}
58
c30745f3
C
59@mixin peertube-input-text($width) {
60 display: inline-block;
61 height: $button-height;
62 width: $width;
9a0fc840 63 background: var(--inputColor);
c30745f3
C
64 border: 1px solid #C6C6C6;
65 border-radius: 3px;
66 padding-left: 15px;
15ca2e87 67 padding-right: 15px;
9a0fc840
RK
68
69 &::placeholder {
70 color: var(--inputPlaceholderColor);
71 }
8a19bee1 72}
c30745f3 73
8a19bee1
C
74@mixin peertube-input-group($width) {
75 width: $width;
76 height: $button-height;
77 padding-top: 0;
78 padding-bottom: 0;
79
80 .input-group-text{
81 font-size: 14px;
9a0fc840 82 color: gray;
c30745f3
C
83 }
84}
85
5f0805d3
C
86@mixin peertube-textarea ($width, $height) {
87 @include peertube-input-text($width);
88
89 height: $height;
90 padding: 5px 15px;
91 font-size: 15px;
92}
93
7b272fd7 94@mixin orange-button {
15a7387d
C
95 &, &:active, &:focus {
96 color: #fff;
9a0fc840 97 background-color: var(--mainColor);
15a7387d 98 }
7b272fd7 99
15a7387d 100 &:hover {
0727cab0 101 color: #fff;
9a0fc840 102 background-color: var(--mainHoverColor);
7b272fd7 103 }
4cc66133
C
104
105 &[disabled], &.disabled {
106 cursor: default;
cadb46d8
C
107 color: #fff;
108 background-color: #C6C6C6;
4cc66133 109 }
7b272fd7
C
110}
111
112@mixin grey-button {
15a7387d
C
113 &, &:active, &:focus {
114 background-color: $grey-color;
115 color: #585858;
116 }
7b272fd7 117
4cc66133 118 &:hover, &:active, &:focus, &[disabled], &.disabled {
0727cab0 119 color: #585858;
7b272fd7
C
120 background-color: $grey-hoover-color;
121 }
4cc66133
C
122
123 &[disabled], &.disabled {
124 cursor: default;
125 }
7b272fd7
C
126}
127
c30745f3
C
128@mixin peertube-button {
129 border: none;
c30745f3
C
130 font-weight: $font-semibold;
131 font-size: 15px;
132 height: $button-height;
133 line-height: $button-height;
134 border-radius: 3px;
135 text-align: center;
c30745f3
C
136 padding: 0 17px 0 13px;
137 cursor: pointer;
e600e1fe 138 outline: 0;
c30745f3
C
139}
140
141@mixin peertube-button-link {
142 display: inline-block;
143
c30745f3 144 @include disable-default-a-behaviour;
ce0e281d 145 @include peertube-button;
c30745f3 146}
2295ce6c 147
c5911fd3
C
148@mixin peertube-button-file ($width) {
149 position: relative;
150 overflow: hidden;
151 display: inline-block;
152 width: $width;
153
154 @include peertube-button;
155 @include orange-button;
156
157 input[type=file] {
158 position: absolute;
159 top: 0;
160 right: 0;
161 min-width: 100%;
162 min-height: 100%;
163 font-size: 100px;
164 text-align: right;
165 filter: alpha(opacity=0);
166 opacity: 0;
167 outline: none;
168 background: white;
169 cursor: inherit;
170 display: block;
171 }
172}
173
0727cab0
C
174@mixin icon ($size) {
175 display: inline-block;
176 background-repeat: no-repeat;
177 background-size: contain;
178 width: $size;
179 height: $size;
180 vertical-align: middle;
181 cursor: pointer;
182}
4cc66133 183
15a7387d
C
184@mixin peertube-select-container ($width) {
185 padding: 0;
186 margin: 0;
4cc66133 187 border: 1px solid #C6C6C6;
4cc66133
C
188 width: $width;
189 border-radius: 3px;
15a7387d 190 overflow: hidden;
9a0fc840 191 background: var(--inputColor);
15a7387d 192 position: relative;
5f0805d3 193 font-size: 15px;
15a7387d
C
194
195 &:after {
196 top: 50%;
197 right: calc(0% + 15px);
198 content: " ";
199 height: 0;
200 width: 0;
201 position: absolute;
202 pointer-events: none;
203 border: 5px solid rgba(0, 0, 0, 0);
a4f99a76 204 border-top-color: #000;
15a7387d
C
205 margin-top: -2px;
206 z-index: 100;
207 }
208
209 select {
108af661 210 padding: 0 35px 0 12px;
15a7387d
C
211 width: calc(100% + 2px);
212 position: relative;
213 left: 1px;
214 border: none;
215 box-shadow: none;
216 background: transparent none;
217 appearance: none;
218 cursor: pointer;
219 height: $button-height;
108af661 220 text-overflow: ellipsis;
15a7387d
C
221
222 &:focus {
223 outline: none;
224 }
225
226 &:-moz-focusring {
227 color: transparent;
228 text-shadow: 0 0 0 #000;
229 }
230 }
231}
232
233@mixin peertube-select-disabled-container ($width) {
234 @include peertube-select-container($width);
235
236 background-color: #E5E5E5;
237
238 select {
239 cursor: default;
240 }
4cc66133 241}
a0d69908 242
5f0805d3
C
243// Thanks: https://codepen.io/triss90/pen/XNEdRe/
244@mixin peertube-radio-container {
245 input[type="radio"] {
246 display: none;
247
248 & + label {
249 font-weight: $font-regular;
250 cursor: pointer;
251
252 &:before {
253 position: relative;
254 top: -2px;
255 content: '';
256 background: #fff;
257 border-radius: 100%;
258 border: 1px solid #000;
259 display: inline-block;
260 width: 15px;
261 height: 15px;
262 vertical-align: middle;
263 cursor: pointer;
264 text-align: center;
265 margin-right: 10px;
266 }
267 }
268
269 &:checked + label:before {
270 background-color: #000;
271 box-shadow: inset 0 0 0 4px #fff;
272 }
273
274 &:focus + label:before {
275 outline: none;
276 border-color: #000;
277 }
278 }
279}
280
a0d69908
C
281@mixin peertube-checkbox ($border-width) {
282 display: none;
283
0f7fedc3 284 & + span {
a0d69908
C
285 position: relative;
286 width: 18px;
287 height: 18px;
9a0fc840 288 border: $border-width solid var(--mainForegroundColor);
a0d69908
C
289 border-radius: 3px;
290 vertical-align: middle;
291 cursor: pointer;
292
293 &:after {
294 content: '';
295 position: absolute;
296 top: calc(2px - #{$border-width});
297 left: 5px;
298 width: 5px;
299 height: 12px;
300 opacity: 0;
301 transform: rotate(45deg) scale(0);
dcbc29d5
C
302 border-right: 2px solid var(--mainBackgroundColor);
303 border-bottom: 2px solid var(--mainBackgroundColor);
a0d69908
C
304 }
305 }
306
0f7fedc3 307 &:checked + span {
a0d69908 308 border-color: transparent;
9a0fc840 309 background: var(--mainColor);
a0d69908
C
310 animation: jelly 0.6s ease;
311
312 &:after {
313 opacity: 1;
314 transform: rotate(45deg) scale(1);
315 }
316 }
317
0f7fedc3 318 & + span + span {
a0d69908
C
319 font-size: 15px;
320 font-weight: $font-regular;
321 margin-left: 5px;
322 cursor: pointer;
6693df9d 323 display: inline;
a0d69908 324 }
bbe0f064 325
0f7fedc3
C
326 &[disabled] + span,
327 &[disabled] + span + span{
bbe0f064
C
328 opacity: 0.5;
329 cursor: default;
330 }
a0d69908
C
331}
332
4e8c8728
C
333
334@mixin avatar ($size) {
335 object-fit: cover;
a4f99a76 336 border-radius: 50%;
4e8c8728
C
337 width: $size;
338 height: $size;
339}
c6352f2c
C
340
341@mixin chevron ($size, $border-width) {
342 border-style: solid;
343 border-width: $border-width $border-width 0 0;
344 content: '';
345 display: inline-block;
346 transform: rotate(-45deg);
347 height: $size;
348 width: $size;
349}
350
351@mixin chevron-right ($size, $border-width) {
352 @include chevron($size, $border-width);
353
354 left: 0;
355 transform: rotate(45deg);
356}
357
358@mixin chevron-left ($size, $border-width) {
359 @include chevron($size, $border-width);
360
361 left: 0.25em;
362 transform: rotate(-135deg);
363}
0626e7af
C
364
365@mixin in-content-small-title {
366 text-transform: uppercase;
9a0fc840 367 color: var(--mainColor);
0626e7af
C
368 font-weight: $font-bold;
369 font-size: 13px;
170726f5
C
370}
371
22a16e36
C
372@mixin actor-owner {
373 @include disable-default-a-behaviour;
374
9a0fc840 375 display: inline-table;
22a16e36
C
376 font-size: 13px;
377 margin-top: 4px;
9a0fc840 378 color: var(--mainForegroundColor);
22a16e36
C
379
380 span:hover {
381 opacity: 0.8;
382 }
383
384 img {
385 @include avatar(18px);
386
387 margin-left: 7px;
388 position: relative;
389 top: -2px;
390 }
391}
392
170726f5
C
393@mixin sub-menu-with-actor {
394 height: 160px;
395 display: flex;
396 flex-direction: column;
397 align-items: start;
398
399 .actor {
400 display: flex;
401 margin-top: 20px;
402 margin-bottom: 20px;
403
404 img {
405 @include avatar(80px);
406
407 margin-right: 20px;
408 }
409
410 .actor-info {
411 display: flex;
412 flex-direction: column;
413 justify-content: center;
414
7de6afdf
C
415 .actor-names {
416 display: flex;
417 align-items: center;
418
419 .actor-display-name {
420 font-size: 23px;
421 font-weight: $font-bold;
422 }
423
424 .actor-name {
425 margin-left: 7px;
426 position: relative;
427 top: 3px;
428 font-size: 14px;
22a16e36 429 color: $grey-actor-name;
7de6afdf 430 }
170726f5
C
431 }
432
433 .actor-followers {
434 font-size: 15px;
435 }
a4f99a76
C
436
437 .actor-owner {
22a16e36 438 @include actor-owner;
a4f99a76 439 }
170726f5
C
440 }
441 }
442
443 .links {
444 margin-top: 0;
445 margin-bottom: 10px;
446
447 a {
448 margin-top: 0;
449 margin-bottom: 0;
450 }
451 }
08c1efbe
C
452}
453
695237b2 454@mixin create-button ($imageUrl) {
08c1efbe
C
455 @include peertube-button-link;
456 @include orange-button;
457
458 .icon.icon-add {
f2bbd1e1 459 @include icon(20px);
08c1efbe 460
f2bbd1e1
C
461 position: relative;
462 top: -1px;
463 margin-right: 5px;
695237b2 464 background-image: url($imageUrl);
08c1efbe 465 }
a4f99a76 466}
22a16e36
C
467
468@mixin row-blocks {
469 display: flex;
470 min-height: 130px;
471 padding-bottom: 20px;
472 margin-bottom: 20px;
473 border-bottom: 1px solid #C6C6C6;
474
475 @media screen and (max-width: 800px) {
476 flex-direction: column;
477 height: auto;
478 text-align: center;
479 align-items: center;
480 }
6aff854c
C
481}
482
483@mixin video-miniature-small-screen {
484 text-align: center;
485
486 /deep/ .video-miniature {
487 padding-right: 0;
488 height: auto;
489 width: 100%;
490 margin-bottom: 20px;
491
492 .video-miniature-information {
493 width: 100% !important;
494
495 span {
496 width: 100%;
497 }
498 }
499
500 .video-thumbnail {
501 width: 100%;
502 height: auto;
503
504 img {
505 width: 100%;
506 height: auto;
507 }
508 }
509 }
22a16e36 510}