mirror of
https://github.com/locomotivemtl/locomotive-boilerplate.git
synced 2026-01-15 00:55:08 +08:00
Merge pull request #169 from locomotivemtl/feature/config-spacing
Rework spacing css config
This commit is contained in:
@@ -1,3 +1,3 @@
|
|||||||
{
|
{
|
||||||
"version": 1706549368176
|
"version": 1711476341450
|
||||||
}
|
}
|
||||||
@@ -20,14 +20,14 @@
|
|||||||
// Settings
|
// Settings
|
||||||
// ==========================================================================
|
// ==========================================================================
|
||||||
|
|
||||||
|
@import "settings/config";
|
||||||
@import "settings/config.breakpoints";
|
@import "settings/config.breakpoints";
|
||||||
@import "settings/config.colors";
|
@import "settings/config.colors";
|
||||||
@import "settings/config.eases";
|
@import "settings/config.eases";
|
||||||
@import "settings/config.fonts";
|
@import "settings/config.fonts";
|
||||||
@import "settings/config.spacers";
|
@import "settings/config.spacings";
|
||||||
@import "settings/config.timings";
|
@import "settings/config.timings";
|
||||||
@import "settings/config.zindexes";
|
@import "settings/config.zindexes";
|
||||||
@import "settings/config";
|
|
||||||
@import "settings/config.variables";
|
@import "settings/config.variables";
|
||||||
|
|
||||||
// Generic
|
// Generic
|
||||||
|
|||||||
@@ -32,12 +32,13 @@ $easing: ease("power2.out");
|
|||||||
|
|
||||||
// Spacing Units
|
// Spacing Units
|
||||||
// =============================================================================
|
// =============================================================================
|
||||||
$unit: 60px;
|
$unit: 60px;
|
||||||
$unit-small: 20px;
|
$unit-small: 20px;
|
||||||
|
$vw-viewport: 1440;
|
||||||
|
|
||||||
// Container
|
// Container
|
||||||
// ==========================================================================
|
// ==========================================================================
|
||||||
$padding: $unit;
|
$padding: $unit;
|
||||||
|
|
||||||
// Grid
|
// Grid
|
||||||
// ==========================================================================
|
// ==========================================================================
|
||||||
|
|||||||
@@ -1,40 +0,0 @@
|
|||||||
// ==========================================================================
|
|
||||||
// Settings / Config / Spacers
|
|
||||||
// ==========================================================================
|
|
||||||
|
|
||||||
// Spacers
|
|
||||||
// ==========================================================================
|
|
||||||
|
|
||||||
$spacers: (
|
|
||||||
'gutter': var(--grid-gutter),
|
|
||||||
'xs': #{vh(5)},
|
|
||||||
'sm': #{vh(7.5)},
|
|
||||||
'md': #{vh(10)},
|
|
||||||
'lg': #{vh(12.5)},
|
|
||||||
'xl': #{vh(15)},
|
|
||||||
);
|
|
||||||
|
|
||||||
// Function
|
|
||||||
// ==========================================================================
|
|
||||||
|
|
||||||
// Returns spacer.
|
|
||||||
//
|
|
||||||
// ```scss
|
|
||||||
// .c-box {
|
|
||||||
// margin-top: spacer(gutter);
|
|
||||||
// }
|
|
||||||
// ```
|
|
||||||
//
|
|
||||||
// @param {string} $key - The spacer key in $spacers.
|
|
||||||
// @param {number} $multiplier - The multiplier of the spacer value.
|
|
||||||
// @return {size}
|
|
||||||
|
|
||||||
@function spacer($spacer: $spacer-default, $multiplier: 1) {
|
|
||||||
@if not map-has-key($spacers, $spacer) {
|
|
||||||
@error "Unknown master spacer: #{$spacer}";
|
|
||||||
}
|
|
||||||
|
|
||||||
$index: map-get($spacers, $spacer);
|
|
||||||
|
|
||||||
@return calc(#{$index} * #{$multiplier});
|
|
||||||
}
|
|
||||||
69
assets/styles/settings/_config.spacings.scss
Normal file
69
assets/styles/settings/_config.spacings.scss
Normal file
@@ -0,0 +1,69 @@
|
|||||||
|
// ==========================================================================
|
||||||
|
// Settings / Config / Spacings
|
||||||
|
// ==========================================================================
|
||||||
|
|
||||||
|
:root {
|
||||||
|
--spacing-2xs-mobile: 6;
|
||||||
|
--spacing-2xs-desktop: 10;
|
||||||
|
|
||||||
|
--spacing-xs-mobile: 12;
|
||||||
|
--spacing-xs-desktop: 16;
|
||||||
|
|
||||||
|
--spacing-sm-mobile: 22;
|
||||||
|
--spacing-sm-desktop: 32;
|
||||||
|
|
||||||
|
--spacing-md-mobile: 32;
|
||||||
|
--spacing-md-desktop: 56;
|
||||||
|
|
||||||
|
--spacing-lg-mobile: 48;
|
||||||
|
--spacing-lg-desktop: 96;
|
||||||
|
|
||||||
|
--spacing-xl-mobile: 64;
|
||||||
|
--spacing-xl-desktop: 128;
|
||||||
|
|
||||||
|
--spacing-2xl-mobile: 88;
|
||||||
|
--spacing-2xl-desktop: 176;
|
||||||
|
|
||||||
|
--spacing-3xl-mobile: 122;
|
||||||
|
--spacing-3xl-desktop: 224;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Spacings
|
||||||
|
// ==========================================================================
|
||||||
|
|
||||||
|
$spacings: (
|
||||||
|
'gutter': var(--grid-gutter),
|
||||||
|
'2xs': #{size-clamp('2xs')},
|
||||||
|
'xs': #{size-clamp('xs')},
|
||||||
|
'sm': #{size-clamp('sm')},
|
||||||
|
'md': #{size-clamp('md')},
|
||||||
|
'lg': #{size-clamp('lg')},
|
||||||
|
'xl': #{size-clamp('xl')},
|
||||||
|
'2xl': #{size-clamp('2xl')},
|
||||||
|
'3xl': #{size-clamp('3xl')},
|
||||||
|
);
|
||||||
|
|
||||||
|
// Function
|
||||||
|
// ==========================================================================
|
||||||
|
|
||||||
|
// Returns spacing.
|
||||||
|
//
|
||||||
|
// ```scss
|
||||||
|
// .c-box {
|
||||||
|
// margin-top: spacing(gutter);
|
||||||
|
// }
|
||||||
|
// ```
|
||||||
|
//
|
||||||
|
// @param {string} $key - The spacing key in $spacings.
|
||||||
|
// @param {number} $multiplier - The multiplier of the spacing value.
|
||||||
|
// @return {size}
|
||||||
|
|
||||||
|
@function spacing($spacing: 'sm', $multiplier: 1) {
|
||||||
|
@if not map-has-key($spacings, $spacing) {
|
||||||
|
@error "Unknown master spacing: #{$spacing}";
|
||||||
|
}
|
||||||
|
|
||||||
|
$index: map-get($spacings, $spacing);
|
||||||
|
|
||||||
|
@return calc(#{$index} * #{$multiplier});
|
||||||
|
}
|
||||||
@@ -178,6 +178,19 @@ $context: 'frontend' !default;
|
|||||||
@return calc(#{$number} * var(--vw, 1vw));
|
@return calc(#{$number} * var(--vw, 1vw));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@function clamp-with-max($min, $size, $max) {
|
||||||
|
$vw-context: $vw-viewport * 0.01;
|
||||||
|
@return clamp(#{$min}, calc(#{$size} / #{$vw-context} * 1vw), #{$max});
|
||||||
|
}
|
||||||
|
|
||||||
|
@function size-clamp($size) {
|
||||||
|
@return clamp-with-max(
|
||||||
|
calc(#{rem(1px)} * var(--spacing-#{$size}-mobile)),
|
||||||
|
var(--spacing-#{$size}-desktop),
|
||||||
|
calc(#{rem(1px)} * var(--spacing-#{$size}-desktop))
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
// Returns clamp of calculated preferred responsive font size
|
// Returns clamp of calculated preferred responsive font size
|
||||||
// within a font size and breakpoint range.
|
// within a font size and breakpoint range.
|
||||||
//
|
//
|
||||||
|
|||||||
@@ -8,12 +8,11 @@
|
|||||||
///
|
///
|
||||||
/// @example
|
/// @example
|
||||||
/// .u-margin-top {}
|
/// .u-margin-top {}
|
||||||
/// .u-padding-left-large {}
|
/// .u-margin-top-xs {}
|
||||||
/// .u-margin-right-small {}
|
/// .u-padding-left-lg {}
|
||||||
|
/// .u-margin-right-sm {}
|
||||||
/// .u-padding {}
|
/// .u-padding {}
|
||||||
/// .u-padding-right-none {}
|
/// .u-padding-right-none {}
|
||||||
/// .u-padding-horizontal {}
|
|
||||||
/// .u-padding-vertical-small {}
|
|
||||||
///
|
///
|
||||||
/// @link https://github.com/inuitcss/inuitcss/blob/512977a/utilities/_utilities.spacing.scss
|
/// @link https://github.com/inuitcss/inuitcss/blob/512977a/utilities/_utilities.spacing.scss
|
||||||
////
|
////
|
||||||
@@ -35,7 +34,7 @@ $spacing-properties: (
|
|||||||
'margin': 'margin',
|
'margin': 'margin',
|
||||||
) !default;
|
) !default;
|
||||||
|
|
||||||
$spacing-sizes: join($spacers, (
|
$spacing-sizes: join($spacings, (
|
||||||
null: var(--grid-gutter),
|
null: var(--grid-gutter),
|
||||||
'none': 0
|
'none': 0
|
||||||
));
|
));
|
||||||
@@ -51,7 +50,7 @@ $spacing-sizes: join($spacers, (
|
|||||||
// Base class
|
// Base class
|
||||||
$base-class: ".u-" + #{$property-namespace}#{$direction-namespace}#{$size-namespace};
|
$base-class: ".u-" + #{$property-namespace}#{$direction-namespace}#{$size-namespace};
|
||||||
|
|
||||||
// Spacer without media query
|
// Spacing without media query
|
||||||
@if $breakpoint == "tiny" {
|
@if $breakpoint == "tiny" {
|
||||||
#{$base-class} {
|
#{$base-class} {
|
||||||
@each $direction in $directions {
|
@each $direction in $directions {
|
||||||
@@ -60,7 +59,7 @@ $spacing-sizes: join($spacers, (
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Spacer min-width breakpoints `@from-*`
|
// Spacing min-width breakpoints `@from-*`
|
||||||
#{$base-class}\@from-#{$breakpoint} {
|
#{$base-class}\@from-#{$breakpoint} {
|
||||||
@media #{mq-min($breakpoint)} {
|
@media #{mq-min($breakpoint)} {
|
||||||
@each $direction in $directions {
|
@each $direction in $directions {
|
||||||
@@ -69,7 +68,7 @@ $spacing-sizes: join($spacers, (
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Spacer max-width breakpoints @to-*`
|
// Spacing max-width breakpoints @to-*`
|
||||||
#{$base-class}\@to-#{$breakpoint} {
|
#{$base-class}\@to-#{$breakpoint} {
|
||||||
@media #{mq-max($breakpoint)} {
|
@media #{mq-max($breakpoint)} {
|
||||||
@each $direction in $directions {
|
@each $direction in $directions {
|
||||||
|
|||||||
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
Reference in New Issue
Block a user