diff options
Diffstat (limited to 'src/sass/lib')
-rw-r--r-- | src/sass/lib/animation.scss | 34 | ||||
-rw-r--r-- | src/sass/lib/css-vars.scss | 100 | ||||
-rw-r--r-- | src/sass/lib/functions.scss | 2 | ||||
-rw-r--r-- | src/sass/lib/mixins.scss | 117 |
4 files changed, 175 insertions, 78 deletions
diff --git a/src/sass/lib/animation.scss b/src/sass/lib/animation.scss index b6c22d42..b0443798 100644 --- a/src/sass/lib/animation.scss +++ b/src/sass/lib/animation.scss @@ -3,29 +3,29 @@ // -------------------------------------------------------------- @keyframes plyr-progress { - to { - background-position: $plyr-progress-loading-size 0; - } + to { + background-position: $plyr-progress-loading-size 0; + } } @keyframes plyr-popup { - 0% { - opacity: 0.5; - transform: translateY(10px); - } + 0% { + opacity: 0.5; + transform: translateY(10px); + } - to { - opacity: 1; - transform: translateY(0); - } + to { + opacity: 1; + transform: translateY(0); + } } @keyframes plyr-fade-in { - from { - opacity: 0; - } + from { + opacity: 0; + } - to { - opacity: 1; - } + to { + opacity: 1; + } } diff --git a/src/sass/lib/css-vars.scss b/src/sass/lib/css-vars.scss new file mode 100644 index 00000000..fb30f3a7 --- /dev/null +++ b/src/sass/lib/css-vars.scss @@ -0,0 +1,100 @@ +// Downloaded from https://github.com/malyw/css-vars (and modified) + +// global map to be filled via variables +$css-vars: (); + +// the variable may be set to "true" anywhere in the code, +// so native CSS custom properties will be used instead of the Sass global map +$css-vars-use-native: false !default; + +/// +// Assigns a variable to the global map +/// +@function css-var-assign($varName: null, $varValue: null) { + @return map-merge( + $css-vars, + ( + $varName: $varValue, + ) + ); +} + +/// +// Emulates var() CSS native function behavior +// +// $args[0] {String} "--" + variable name +// [$args[1]] Optional default value if variable is not assigned yet +// +// E.G.: +// color: var(--main-color); +// background: var(--main-background, green); +/// +@function var($args...) { + // CHECK PARAMS + @if (length($args) ==0) { + @error 'Variable name is expected to be passed to the var() function'; + } + @if (str-length(nth($args, 1)) < 2 or str-slice(nth($args, 1), 0, 2) != '--') { + @error "Variable name is expected to start from '--'"; + } + + // PROCESS + $var-name: nth($args, 1); + $var-value: map-get($css-vars, $var-name); + + @if ($css-vars-use-native) { + // CSS variables + // Native CSS: don't process function in case of native + @return unquote('var(' + $args + ')'); + } @else { + @if ($var-value == null) { + // variable is not provided so far + @if (length($args) == 2) { + $var-value: nth($args, 2); + } + } + + // Sass: return value from the map + @return $var-value; + } +} + +/// +// SASS mixin to provide variables +// E.G.: +// @include css-vars(( +// --color: rebeccapurple, +// --height: 68px, +// --margin-top: calc(2vh + 20px) +// )); +/// +@mixin css-vars($var-map: null) { + // CHECK PARAMS + @if ($var-map == null) { + @error 'Map of variables is expected, instead got: null'; + } + @if (type_of($var-map) != map) { + @error 'Map of variables is expected, instead got another type passed: #{type_of($var, ap)}'; + } + + // PROCESS + @if ($css-vars-use-native) { + // CSS variables + // Native CSS: assign CSS custom properties to the global scope + @at-root :root { + @each $var-name, $var-value in $var-map { + @if (type_of($var-value) == string) { + #{$var-name}: $var-value; // to prevent quotes interpolation + } @else { + #{$var-name}: #{$var-value}; + } + } + } + } @else { + // Sass or debug + // merge variables and values to the global map (provides no output) + @each $var-name, $var-value in $var-map { + $css-vars: css-var-assign($varName, $varValue) !global; // store in global variable + } + } +} diff --git a/src/sass/lib/functions.scss b/src/sass/lib/functions.scss index a99a1b80..e991e2d8 100644 --- a/src/sass/lib/functions.scss +++ b/src/sass/lib/functions.scss @@ -3,5 +3,5 @@ // ========================================================================== @function to-percentage($input) { - @return $input * 1%; + @return $input * 1%; } diff --git a/src/sass/lib/mixins.scss b/src/sass/lib/mixins.scss index 5a1ca753..cbb8cc78 100644 --- a/src/sass/lib/mixins.scss +++ b/src/sass/lib/mixins.scss @@ -4,93 +4,90 @@ // Nicer focus styles // --------------------------------------- -@mixin plyr-tab-focus($color: $plyr-tab-focus-default-color) { - box-shadow: 0 0 0 5px rgba($color, 0.5); - outline: 0; +@mixin plyr-tab-focus($color: $plyr-tab-focus-color) { + outline-color: $color; + outline-offset: 2px; + outline-style: dotted; + outline-width: 3px; } // Font smoothing // --------------------------------------- @mixin plyr-font-smoothing($mode: true) { - @if $mode { - -moz-osx-font-smoothing: grayscale; - -webkit-font-smoothing: antialiased; - } @else { - -moz-osx-font-smoothing: auto; - -webkit-font-smoothing: subpixel-antialiased; - } + @if $mode { + -moz-osx-font-smoothing: grayscale; + -webkit-font-smoothing: antialiased; + } } // <input type="range"> styling // --------------------------------------- @mixin plyr-range-track() { - background: transparent; - border: 0; - border-radius: ($plyr-range-track-height / 2); - height: $plyr-range-track-height; - transition: box-shadow 0.3s ease; - user-select: none; + background: transparent; + border: 0; + border-radius: calc(#{$plyr-range-track-height} / 2); + height: $plyr-range-track-height; + transition: box-shadow 0.3s ease; + user-select: none; } @mixin plyr-range-thumb() { - background: $plyr-range-thumb-bg; - border: 0; - border-radius: 100%; - box-shadow: $plyr-range-thumb-shadow; - height: $plyr-range-thumb-height; - position: relative; - transition: all 0.2s ease; - width: $plyr-range-thumb-height; + background: $plyr-range-thumb-background; + border: 0; + border-radius: 100%; + box-shadow: $plyr-range-thumb-shadow; + height: $plyr-range-thumb-height; + position: relative; + transition: all 0.2s ease; + width: $plyr-range-thumb-height; } -@mixin plyr-range-thumb-active($color: rgba($plyr-range-thumb-bg, 0.5)) { - box-shadow: $plyr-range-thumb-shadow, 0 0 0 $plyr-range-thumb-active-shadow-width $color; +@mixin plyr-range-thumb-active($color) { + box-shadow: $plyr-range-thumb-shadow, 0 0 0 $plyr-range-thumb-active-shadow-width $color; } // Fullscreen styles // --------------------------------------- @mixin plyr-fullscreen-active() { - background: #000; - border-radius: 0 !important; - height: 100%; - margin: 0; - width: 100%; + background: #000; + border-radius: 0 !important; + height: 100%; + margin: 0; + width: 100%; - video { - height: 100%; - } + video { + height: 100%; + } - .plyr__video-wrapper { - height: 100%; - position: static; - } + .plyr__video-wrapper { + height: 100%; + position: static; + } - // Vimeo requires some different styling - &.plyr--vimeo .plyr__video-wrapper { - height: 0; - position: relative; - top: 50%; - transform: translateY(-50%); - } + // Vimeo requires some different styling + &.plyr--vimeo .plyr__video-wrapper { + height: 0; + position: relative; + } - // Display correct icon - .plyr__control .icon--exit-fullscreen { - display: block; + // Display correct icon + .plyr__control .icon--exit-fullscreen { + display: block; - + svg { - display: none; - } + + svg { + display: none; } + } - // Hide cursor in fullscreen when controls hidden - &.plyr--hide-controls { - cursor: none; - } + // Hide cursor in fullscreen when controls hidden + &.plyr--hide-controls { + cursor: none; + } - // Large captions in full screen on larger screens - @media (min-width: $plyr-bp-lg) { - .plyr__captions { - font-size: $plyr-font-size-captions-large; - } + // Large captions in full screen on larger screens + @media (min-width: $plyr-bp-lg) { + .plyr__captions { + font-size: $plyr-font-size-captions-large; } + } } |