sutty-base-jekyll-theme/_sass/helpers.scss

319 lines
8.1 KiB
SCSS
Raw Normal View History

2021-01-12 16:33:21 +00:00
// En este archivo colocamos todos las herramientas que nos hagan falta,
// de forma que podamos generar clases específicas que sean combinables
// con otras, en lugar de escribir clases específicas para cada
// elemento.
//
// Cada clase tiene su versión responsive de acuerdo a los parámetros de
// Bootstrap.
// Ocultar la barra de scroll, útil para sliders horizontales.
2020-10-28 23:47:44 +00:00
.no-scrollbar {
scrollbar-width: none;
-webkit-overflow-scrolling: touch;
&::-webkit-scrollbar { display: none; }
}
2021-01-25 19:28:49 +00:00
// Mismo alto que ancho
.square {
@extend .position-relative;
padding-bottom: 100%;
& > * {
@extend .position-absolute;
@extend .top-0;
@extend .left-0;
@extend .h-100;
}
}
2021-01-12 23:09:32 +00:00
// Eventos del cursor
@each $event in (none, auto) {
.pointer-event-#{$event} {
pointer-events: $event;
}
@each $grid-breakpoint, $_ in $grid-breakpoints {
@include media-breakpoint-up($grid-breakpoint) {
.pointer-event-#{$grid-breakpoint}-#{$event} {
pointer-events: $event;
}
}
}
2021-01-12 16:33:21 +00:00
}
// Agrega una transición a cualquier modificación de atributos
.transition {
@include transition($transition-base);
}
// Ajustes de imagen y video con respecto al contenedor
@each $keyword in (contain, cover, fill, none, scale-down) {
.fit-#{$keyword} {
object-fit: #{$keyword};
}
@each $grid-breakpoint, $_ in $grid-breakpoints {
@include media-breakpoint-up($grid-breakpoint) {
.fit-#{$grid-breakpoint}-#{$keyword} {
object-fit: #{$keyword};
}
}
}
}
// Cursores
2020-11-12 19:25:04 +00:00
@each $cursor in (pointer none) {
.cursor-#{$cursor} {
cursor: $cursor;
}
}
2021-01-12 16:33:21 +00:00
// Overflow
@each $value in (auto, hidden, scroll) {
.overflow-#{$value} {
overflow: $value !important;
}
@each $axis in (y, x) {
.overflow-#{$axis}-#{$value} {
overflow-#{$axis}: $value !important;
}
}
@each $grid-breakpoint, $_ in $grid-breakpoints {
@include media-breakpoint-up($grid-breakpoint) {
.overflow-#{$grid-breakpoint}-#{$value} {
overflow: $value !important;
}
@each $axis in (y, x) {
.overflow-#{$grid-breakpoint}-#{$axis}-#{$value} {
overflow-#{$axis}: $value !important;
}
}
}
2020-11-12 19:25:04 +00:00
}
}
2021-01-12 16:33:21 +00:00
@each $spacer, $length in $spacers {
// Poder aumentar o disminuir el alto de la tipografía
.f-#{$spacer} {
font-size: $length !important;
}
// Columnas de texto
.text-column-#{$spacer} {
column-count: $spacer;
}
// Limitar la cantidad de líneas de un bloque de texto
.line-clamp-#{$spacer} {
overflow: hidden;
display: -webkit-box;
-webkit-line-clamp: $spacer;
-webkit-box-orient: vertical;
}
// Ubicación absoluta, usar con position-*
@each $direction in (top, right, bottom, left) {
.#{$direction}-#{$spacer} {
#{$direction}: $length
}
}
@each $grid-breakpoint, $_ in $grid-breakpoints {
@include media-breakpoint-up($grid-breakpoint) {
// Poder aumentar o disminuir el alto de la tipografía
.f-#{$grid-breakpoint}-#{$spacer} {
font-size: $length !important;
}
// Columnas de texto
.text-column-#{$grid-breakpoint}-#{$spacer} {
column-count: $spacer;
}
// Limitar la cantidad de líneas de un bloque de texto
.line-clamp-#{$grid-breakpoint}-#{$spacer} {
overflow: hidden;
display: -webkit-box;
-webkit-line-clamp: $spacer;
-webkit-box-orient: vertical;
}
// Ubicación absoluta, usar con position-*
@each $direction in (top, right, bottom, left) {
.#{$direction}-#{$grid-breakpoint}-#{$spacer} {
#{$direction}: $length
}
}
}
}
2020-11-12 19:25:04 +00:00
}
2021-01-12 16:33:21 +00:00
// anchos y altos
@each $prop, $abbrev in (width: w, height: h) {
@each $size, $length in $sizes {
2021-01-13 20:58:43 +00:00
.#{$abbrev}-#{$size} { #{$prop}: $length; }
2021-01-12 16:33:21 +00:00
.#{$abbrev}-#{$size} { #{$prop}: $length; }
.min-#{$abbrev}-#{$size} { min-#{$prop}: $length; }
.max-#{$abbrev}-#{$size} { max-#{$prop}: $length; }
@each $grid-breakpoint, $_ in $grid-breakpoints {
@include media-breakpoint-up($grid-breakpoint) {
.#{$abbrev}-#{$grid-breakpoint}-#{$size} { #{$prop}: $length; }
.min-#{$abbrev}-#{$grid-breakpoint}-#{$size} { min-#{$prop}: $length; }
.max-#{$abbrev}-#{$grid-breakpoint}-#{$size} { max-#{$prop}: $length; }
}
}
2020-11-12 19:25:04 +00:00
}
}
2021-01-12 16:33:21 +00:00
@each $scroll in (auto, smooth) {
.scroll-#{$scroll} {
scroll-behavior: #{$scroll};
2020-10-28 23:47:44 +00:00
}
2020-11-12 19:25:04 +00:00
2021-01-12 16:33:21 +00:00
@each $grid-breakpoint, $_ in $grid-breakpoints {
@include media-breakpoint-up($grid-breakpoint) {
.scroll-#{$grid-breakpoint}-#{$scroll} {
scroll-behavior: #{$scroll};
}
}
2020-11-12 19:25:04 +00:00
}
2020-10-28 23:47:44 +00:00
}
2021-01-12 16:33:21 +00:00
// Versiones responsive de utilidades Bootstrap
2020-10-28 23:47:44 +00:00
@each $grid-breakpoint, $_ in $grid-breakpoints {
@include media-breakpoint-up($grid-breakpoint) {
2021-01-12 16:33:21 +00:00
// Bordes
// node_modules/bootstrap/scss/utilities/_borders.scss
2020-10-28 23:47:44 +00:00
.border-#{$grid-breakpoint} { border: $border-width solid $border-color !important; }
.border-#{$grid-breakpoint}-top { border-top: $border-width solid $border-color !important; }
.border-#{$grid-breakpoint}-right { border-right: $border-width solid $border-color !important; }
.border-#{$grid-breakpoint}-bottom { border-bottom: $border-width solid $border-color !important; }
.border-#{$grid-breakpoint}-left { border-left: $border-width solid $border-color !important; }
.border-#{$grid-breakpoint}-0 { border: 0 !important; }
.border-#{$grid-breakpoint}-top-0 { border-top: 0 !important; }
.border-#{$grid-breakpoint}-right-0 { border-right: 0 !important; }
.border-#{$grid-breakpoint}-bottom-0 { border-bottom: 0 !important; }
.border-#{$grid-breakpoint}-left-0 { border-left: 0 !important; }
2021-01-12 16:33:21 +00:00
// Alineación
2020-10-28 23:47:44 +00:00
.text-#{$grid-breakpoint}-left { text-align: left !important; }
.text-#{$grid-breakpoint}-right { text-align: right !important; }
.text-#{$grid-breakpoint}-center { text-align: center !important; }
2021-01-12 16:33:21 +00:00
// Posicionamiento
2020-10-28 23:47:44 +00:00
@each $position in $positions {
.position-#{$grid-breakpoint}-#{$position} { position: $position !important; }
}
2021-01-12 16:33:21 +00:00
// Anchos y altos
2020-10-28 23:47:44 +00:00
@each $prop, $abbrev in (width: w, height: h) {
@each $size, $length in $sizes {
.#{$abbrev}-#{$grid-breakpoint}-#{$size} { #{$prop}: $length !important; }
2021-01-12 16:33:21 +00:00
.min-#{$abbrev}-#{$grid-breakpoint}-#{$size} { min-#{$prop}: $length !important; }
2020-11-12 19:25:04 +00:00
}
2020-10-28 23:47:44 +00:00
}
}
}
2021-01-12 16:33:21 +00:00
// Crea una propiedad con prefijos de navegador
2020-06-17 19:34:42 +00:00
@mixin vendor-prefix($property, $definition...) {
@each $prefix in $vendor-prefixes {
#{$prefix}$property: $definition;
}
}
2021-01-12 16:33:21 +00:00
// Colores
2021-01-13 20:58:43 +00:00
@each $color, $rgb in $colors {
2020-06-17 19:34:42 +00:00
.background-#{$color} {
background-color: var(--#{$color});
2020-10-28 23:47:44 +00:00
&:focus {
background-color: var(--#{$color});
}
2020-06-17 19:34:42 +00:00
}
2021-01-13 20:58:43 +00:00
@each $opacity, $degree in $opacities {
.background-#{$color}-t#{$opacity} {
background-color: scale-color($rgb, $alpha: $degree);
}
}
2021-01-12 16:33:21 +00:00
@each $attr in (stroke, fill) {
.#{$attr}-#{$color} {
svg {
* {
#{$attr}: var(--#{$color});
}
}
}
}
// Barras de scroll de colores
2020-11-12 19:25:04 +00:00
.scrollbar-#{$color} {
scrollbar-color: var(--#{$color}) transparent;
scrollbar-width: thin;
&::-webkit-scrollbar {
width: 5px;
height: 8px;
background-color: transparent;
}
&::-webkit-scrollbar-thumb {
background: var(--#{$color});
}
}
2021-01-12 16:33:21 +00:00
// Bordes
2020-11-12 19:25:04 +00:00
.border-#{$color} {
border-color: var(--#{$color}) !important;
}
2021-01-12 16:33:21 +00:00
// Cambiar el fondo al pasar por encima o hacer foco
2020-11-12 19:25:04 +00:00
.hover-bg-#{$color} {
2021-01-12 17:25:23 +00:00
&:hover,
&:focus-within {
2020-11-12 19:25:04 +00:00
background-color: var(--#{$color});
}
}
2021-01-12 16:33:21 +00:00
// Cambiar el color al pasar por encima o hacer foco
2020-11-12 19:25:04 +00:00
.hover-#{$color} {
2021-01-12 16:33:21 +00:00
&:hover,
&:focus-within {
2020-11-12 19:25:04 +00:00
color: var(--#{$color});
}
}
2021-01-12 16:33:21 +00:00
// Cambiar el color
2020-06-17 19:34:42 +00:00
.#{$color} {
2020-11-12 19:25:04 +00:00
color: var(--#{$color});
2020-10-28 23:47:44 +00:00
&:focus {
2020-11-12 19:25:04 +00:00
color: var(--#{$color});
2020-10-28 23:47:44 +00:00
}
2020-06-17 19:34:42 +00:00
2021-01-12 16:33:21 +00:00
// Invertir el color en la selección
2020-06-17 19:34:42 +00:00
::-moz-selection,
::selection {
background: var(--#{$color});
color: white;
}
2021-01-12 16:33:21 +00:00
// Ajustes para Bootstrap
2020-06-17 19:34:42 +00:00
.form-control {
border-color: var(--#{$color});
2020-11-12 19:25:04 +00:00
color: var(--#{$color});
2020-06-17 19:34:42 +00:00
}
hr {
border-color: var(--#{$color});
}
}
}