unit.gl 0.0.40 → 0.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +0 -1
- package/css/unit.gl.css +54 -42
- package/css/unit.gl.min.css +1 -1
- package/package.json +2 -22
- package/scss/_reset.scss +20 -12
- package/scss/classes/_guide.scss +35 -40
- package/scss/classes/_guides.scss +141 -0
- package/scss/classes/_index.scss +3 -5
- package/scss/classes/_ratio.scss +3 -5
- package/scss/dev/_banner.scss +4 -7
- package/scss/dev/_index.scss +7 -0
- package/scss/functions/_color.scss +8 -11
- package/scss/functions/_index.scss +18 -11
- package/scss/functions/_layer.scss +6 -10
- package/scss/functions/_ratio.scss +13 -16
- package/scss/functions/_scale.scss +20 -18
- package/scss/functions/_sequence.scss +64 -72
- package/scss/functions/_view.scss +6 -9
- package/scss/functions/math/_arithmetic.scss +21 -30
- package/scss/functions/math/_index.scss +4 -7
- package/scss/functions/unit/_index.scss +8 -7
- package/scss/functions/unit/_unit_conversion.scss +42 -29
- package/scss/functions/unit/_unit_functions.scss +55 -43
- package/scss/index.scss +0 -1
- package/scss/maps/_color.scss +14 -14
- package/scss/maps/_index.scss +26 -0
- package/scss/mixins/_device.scss +9 -10
- package/scss/mixins/_display.scss +52 -57
- package/scss/mixins/_guide.scss +59 -81
- package/scss/mixins/_helper.scss +74 -92
- package/scss/mixins/_index.scss +12 -14
- package/scss/mixins/_paper.scss +10 -11
- package/scss/mixins/_ratio.scss +172 -76
- package/scss/mixins/_unit.scss +33 -23
- package/scss/mixins/_view.scss +47 -54
- package/scss/{_global.scss → tags/_global.scss} +12 -11
- package/scss/tags/_index.scss +5 -6
- package/scss/tags/_unit.scss +4 -11
- package/scss/variables/_color.scss +18 -20
- package/scss/variables/_device.scss +179 -73
- package/scss/variables/_index.scss +21 -22
- package/scss/variables/_layer.scss +26 -35
- package/scss/variables/_paper.scss +1022 -241
- package/scss/variables/_ratio.scss +148 -90
- package/scss/variables/_scale.scss +141 -115
- package/scss/variables/_unit.scss +20 -35
- package/scss/variables/_view.scss +54 -57
- package/ts/AspectRatio.ts +27 -6
- package/ts/Border.ts +35 -4
- package/ts/BoxModel.ts +32 -4
- package/ts/FlexContainer.ts +36 -9
- package/ts/Grid.ts +28 -3
- package/ts/GridContainer.ts +29 -3
- package/ts/Layout.ts +37 -7
- package/ts/Position.ts +29 -4
- package/ts/Rectangle.ts +26 -3
- package/ts/ResponsiveImage.ts +22 -3
- package/ts/ResponsiveScale.ts +25 -2
- package/ts/Size.ts +25 -3
- package/ts/Spacing.ts +45 -7
- package/ts/Transform.ts +37 -4
- package/ts/Typography.ts +40 -6
- package/ts/Unit.ts +34 -10
- package/ts/Viewport.ts +31 -3
- package/ts/index.ts +1 -16
- package/scss/utilities/_guides.scss +0 -103
- package/scss/utilities/_index.scss +0 -6
|
@@ -3,38 +3,35 @@
|
|
|
3
3
|
// ============================================================================
|
|
4
4
|
|
|
5
5
|
////
|
|
6
|
-
///
|
|
6
|
+
///
|
|
7
7
|
/// View Functions Module
|
|
8
8
|
/// ===========================================================================
|
|
9
|
-
///
|
|
9
|
+
///
|
|
10
10
|
/// @group View
|
|
11
11
|
/// @author Scape Agency
|
|
12
12
|
/// @link https://unit.gl
|
|
13
13
|
/// @since 0.1.0 initial release
|
|
14
14
|
/// @todo None
|
|
15
15
|
/// @access public
|
|
16
|
-
///
|
|
16
|
+
///
|
|
17
17
|
////
|
|
18
18
|
|
|
19
|
-
|
|
20
19
|
// ============================================================================
|
|
21
20
|
// Use
|
|
22
21
|
// ============================================================================
|
|
23
22
|
|
|
24
|
-
|
|
25
23
|
// ============================================================================
|
|
26
24
|
// Functions
|
|
27
25
|
// ============================================================================
|
|
28
26
|
|
|
29
|
-
|
|
30
|
-
///
|
|
27
|
+
///
|
|
31
28
|
/// A function to calculate breakpoints based on a multiplier of the base
|
|
32
29
|
/// screen unit.
|
|
33
|
-
///
|
|
30
|
+
///
|
|
34
31
|
/// @name calc_breakpoint
|
|
35
32
|
/// @param {Number} $multiplier - The multiplier to apply to the base unit.
|
|
36
33
|
/// @return {Length} The calculated breakpoint value in pixels.
|
|
37
|
-
///
|
|
34
|
+
///
|
|
38
35
|
@function calc_breakpoint($base_screen_unit, $multiplier) {
|
|
39
36
|
@return $base_screen_unit * $multiplier;
|
|
40
37
|
}
|
|
@@ -3,57 +3,51 @@
|
|
|
3
3
|
// ============================================================================
|
|
4
4
|
|
|
5
5
|
////
|
|
6
|
-
///
|
|
6
|
+
///
|
|
7
7
|
/// Math Functions Module
|
|
8
8
|
/// ===========================================================================
|
|
9
|
-
///
|
|
10
|
-
/// These functions allow for arithmetic operations on values with or without
|
|
11
|
-
/// units, ensuring compatibility and proper handling of CSS units. When units
|
|
9
|
+
///
|
|
10
|
+
/// These functions allow for arithmetic operations on values with or without
|
|
11
|
+
/// units, ensuring compatibility and proper handling of CSS units. When units
|
|
12
12
|
/// are mismatched, a warning is issued, and the operation returns null.
|
|
13
13
|
///
|
|
14
14
|
/// Functions:
|
|
15
15
|
/// - add: Adds two values, handling units appropriately.
|
|
16
16
|
/// - subtract: Subtracts one value from another, with unit handling.
|
|
17
|
-
///
|
|
17
|
+
///
|
|
18
18
|
/// @group Math
|
|
19
19
|
/// @author Scape Agency
|
|
20
20
|
/// @link https://unit.gl
|
|
21
21
|
/// @since 0.1.0 initial release
|
|
22
22
|
/// @todo None
|
|
23
23
|
/// @access public
|
|
24
|
-
///
|
|
24
|
+
///
|
|
25
25
|
////
|
|
26
26
|
|
|
27
|
-
|
|
28
27
|
// ============================================================================
|
|
29
28
|
// Use
|
|
30
29
|
// ============================================================================
|
|
31
30
|
|
|
32
|
-
|
|
33
31
|
// ============================================================================
|
|
34
32
|
// Functions
|
|
35
33
|
// ============================================================================
|
|
36
34
|
|
|
37
|
-
|
|
38
|
-
///
|
|
35
|
+
///
|
|
39
36
|
/// Adds two values, handling units appropriately.
|
|
40
|
-
///
|
|
37
|
+
///
|
|
41
38
|
/// This function performs arithmetic addition on two values, ensuring that
|
|
42
39
|
/// units are properly handled. If both values are unitless, they are added
|
|
43
40
|
/// directly.
|
|
44
|
-
/// If one value has a unit and the other is unitless, the unitless value is
|
|
45
|
-
/// treated as having the same unit as the other value. If both values have
|
|
46
|
-
/// units, they must be the same unit; otherwise, a warning is issued and
|
|
41
|
+
/// If one value has a unit and the other is unitless, the unitless value is
|
|
42
|
+
/// treated as having the same unit as the other value. If both values have
|
|
43
|
+
/// units, they must be the same unit; otherwise, a warning is issued and
|
|
47
44
|
/// `null` is returned.
|
|
48
|
-
///
|
|
45
|
+
///
|
|
49
46
|
/// @param {Number} $value1 - The first value, which may or may not include units.
|
|
50
47
|
/// @param {Number} $value2 - The second value, which may or may not include units.
|
|
51
48
|
/// @return {Number} - The sum of the two values, or null if the units are incompatible.
|
|
52
|
-
///
|
|
53
|
-
@function add(
|
|
54
|
-
$value1,
|
|
55
|
-
$value2
|
|
56
|
-
) {
|
|
49
|
+
///
|
|
50
|
+
@function add($value1, $value2) {
|
|
57
51
|
@if unitless($value1) and unitless($value2) {
|
|
58
52
|
@return $value1 + $value2;
|
|
59
53
|
} @else if unitless($value1) {
|
|
@@ -70,23 +64,20 @@
|
|
|
70
64
|
|
|
71
65
|
///
|
|
72
66
|
/// Subtracts one value from another, handling units appropriately.
|
|
73
|
-
///
|
|
67
|
+
///
|
|
74
68
|
/// This function performs arithmetic subtraction on two values, ensuring that
|
|
75
69
|
/// units are properly handled. If both values are unitless, they are
|
|
76
70
|
/// subtracted directly.
|
|
77
|
-
/// If one value has a unit and the other is unitless, the unitless value is
|
|
78
|
-
/// treated as having the same unit as the other value. If both values have
|
|
79
|
-
/// units, they must be the same unit; otherwise, a warning is issued and
|
|
71
|
+
/// If one value has a unit and the other is unitless, the unitless value is
|
|
72
|
+
/// treated as having the same unit as the other value. If both values have
|
|
73
|
+
/// units, they must be the same unit; otherwise, a warning is issued and
|
|
80
74
|
/// `null` is returned.
|
|
81
|
-
///
|
|
75
|
+
///
|
|
82
76
|
/// @param {Number} $value1 - The first value, which may or may not include units.
|
|
83
77
|
/// @param {Number} $value2 - The second value, which may or may not include units.
|
|
84
78
|
/// @return {Number} - The difference between the two values, or null if the units are incompatible.
|
|
85
|
-
///
|
|
86
|
-
@function subtract(
|
|
87
|
-
$value1,
|
|
88
|
-
$value2
|
|
89
|
-
) {
|
|
79
|
+
///
|
|
80
|
+
@function subtract($value1, $value2) {
|
|
90
81
|
@if unitless($value1) and unitless($value2) {
|
|
91
82
|
@return $value1 - $value2;
|
|
92
83
|
} @else if unitless($value1) {
|
|
@@ -3,28 +3,25 @@
|
|
|
3
3
|
// ============================================================================
|
|
4
4
|
|
|
5
5
|
////
|
|
6
|
-
///
|
|
6
|
+
///
|
|
7
7
|
/// Math Functions Module
|
|
8
8
|
/// ===========================================================================
|
|
9
|
-
///
|
|
9
|
+
///
|
|
10
10
|
/// @group Math
|
|
11
11
|
/// @author Scape Agency
|
|
12
12
|
/// @link https://unit.gl
|
|
13
13
|
/// @since 0.1.0 initial release
|
|
14
14
|
/// @todo None
|
|
15
15
|
/// @access public
|
|
16
|
-
///
|
|
16
|
+
///
|
|
17
17
|
////
|
|
18
18
|
|
|
19
|
-
|
|
20
19
|
// ============================================================================
|
|
21
20
|
// Use
|
|
22
21
|
// ============================================================================
|
|
23
22
|
|
|
24
|
-
|
|
25
23
|
// ============================================================================
|
|
26
24
|
// Forward
|
|
27
25
|
// ============================================================================
|
|
28
26
|
|
|
29
|
-
|
|
30
|
-
@forward "arithmetic"; // Basic arithmetic operations
|
|
27
|
+
@forward "arithmetic"; // Basic arithmetic operations
|
|
@@ -3,28 +3,29 @@
|
|
|
3
3
|
// ============================================================================
|
|
4
4
|
|
|
5
5
|
////
|
|
6
|
-
///
|
|
6
|
+
///
|
|
7
7
|
/// Unit Functions Module
|
|
8
8
|
/// ===========================================================================
|
|
9
|
-
///
|
|
9
|
+
///
|
|
10
10
|
/// @group Unit
|
|
11
11
|
/// @author Scape Agency
|
|
12
12
|
/// @link https://unit.gl
|
|
13
13
|
/// @since 0.1.0 initial release
|
|
14
14
|
/// @todo None
|
|
15
15
|
/// @access public
|
|
16
|
-
///
|
|
16
|
+
///
|
|
17
17
|
////
|
|
18
18
|
|
|
19
|
-
|
|
20
19
|
// ============================================================================
|
|
21
20
|
// Use
|
|
22
21
|
// ============================================================================
|
|
23
22
|
|
|
24
|
-
|
|
25
23
|
// ============================================================================
|
|
26
24
|
// Forward
|
|
27
25
|
// ============================================================================
|
|
28
26
|
|
|
29
|
-
|
|
30
|
-
@forward "
|
|
27
|
+
// Unit conversion functions
|
|
28
|
+
@forward "unit_conversion";
|
|
29
|
+
|
|
30
|
+
// Additional utility functions for units
|
|
31
|
+
@forward "unit_functions";
|
|
@@ -3,61 +3,68 @@
|
|
|
3
3
|
// ============================================================================
|
|
4
4
|
|
|
5
5
|
////
|
|
6
|
-
///
|
|
6
|
+
///
|
|
7
7
|
/// Unit Functions Module
|
|
8
8
|
/// ===========================================================================
|
|
9
|
-
///
|
|
9
|
+
///
|
|
10
10
|
/// @group Unit
|
|
11
11
|
/// @author Scape Agency
|
|
12
12
|
/// @link https://unit.gl
|
|
13
13
|
/// @since 0.1.0 initial release
|
|
14
14
|
/// @todo None
|
|
15
15
|
/// @access public
|
|
16
|
-
///
|
|
16
|
+
///
|
|
17
17
|
////
|
|
18
18
|
|
|
19
|
-
|
|
20
19
|
// ============================================================================
|
|
21
20
|
// Use
|
|
22
21
|
// ============================================================================
|
|
23
22
|
|
|
24
23
|
|
|
24
|
+
/// Base font-size for the document
|
|
25
|
+
$base-font-size: 16px !default;
|
|
26
|
+
|
|
27
|
+
|
|
25
28
|
// ============================================================================
|
|
26
29
|
// Functions
|
|
27
30
|
// ============================================================================
|
|
28
31
|
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
32
|
/// Unit Conversion Functions
|
|
34
33
|
/// ---------------------------------------------------------------------------
|
|
35
34
|
/// Create functions to convert between different measurement units, such as
|
|
36
35
|
/// pixels to rem, em to pixels, etc.
|
|
37
36
|
|
|
38
|
-
@function px_to_rem(
|
|
37
|
+
@function px_to_rem(
|
|
38
|
+
$size,
|
|
39
|
+
$base: 16px
|
|
40
|
+
) {
|
|
39
41
|
@return $size / $base * 1rem;
|
|
40
42
|
}
|
|
41
43
|
|
|
42
|
-
@function rem_to_px(
|
|
44
|
+
@function rem_to_px(
|
|
45
|
+
$size,
|
|
46
|
+
$base: 16px
|
|
47
|
+
) {
|
|
43
48
|
@return $size * $base;
|
|
44
49
|
}
|
|
45
50
|
|
|
46
|
-
@function em_to_px(
|
|
51
|
+
@function em_to_px(
|
|
52
|
+
$size,
|
|
53
|
+
$context: 16px
|
|
54
|
+
) {
|
|
47
55
|
@return $size * $context;
|
|
48
56
|
}
|
|
49
57
|
|
|
50
|
-
@function px_to_em(
|
|
58
|
+
@function px_to_em(
|
|
59
|
+
$size,
|
|
60
|
+
$context: 16px
|
|
61
|
+
) {
|
|
51
62
|
@return $size / $context * 1em;
|
|
52
63
|
}
|
|
53
64
|
|
|
54
|
-
|
|
55
|
-
/// Base font-size for the document
|
|
56
|
-
$base-font-size: 16px !default;
|
|
57
|
-
|
|
58
65
|
/// Validate that the input is a pixel value
|
|
59
|
-
@function
|
|
60
|
-
@if unit($value) !=
|
|
66
|
+
@function validate_px($value) {
|
|
67
|
+
@if unit($value) != "px" {
|
|
61
68
|
@error "Expected a pixel value, but got `#{$value}`.";
|
|
62
69
|
}
|
|
63
70
|
@return $value;
|
|
@@ -65,30 +72,36 @@ $base-font-size: 16px !default;
|
|
|
65
72
|
|
|
66
73
|
/// Convert pixels to rem
|
|
67
74
|
@function px_to_rem($size) {
|
|
68
|
-
$
|
|
69
|
-
@return $
|
|
75
|
+
$validated_size: validate_px($size);
|
|
76
|
+
@return $validated_size / $base-font-size * 1rem;
|
|
70
77
|
}
|
|
71
78
|
|
|
72
79
|
/// Convert rem to pixels
|
|
73
80
|
@function rem_to_px($size) {
|
|
74
|
-
@if unit($size) !=
|
|
81
|
+
@if unit($size) != "rem" {
|
|
75
82
|
@error "Expected a rem value, but got `#{$size}`.";
|
|
76
83
|
}
|
|
77
84
|
@return $size * $base-font-size;
|
|
78
85
|
}
|
|
79
86
|
|
|
80
87
|
/// Convert em to pixels
|
|
81
|
-
@function em_to_px(
|
|
82
|
-
$
|
|
83
|
-
|
|
88
|
+
@function em_to_px(
|
|
89
|
+
$size,
|
|
90
|
+
$context: $base-font-size
|
|
91
|
+
) {
|
|
92
|
+
$validated_context: validate_px($context);
|
|
93
|
+
@if unit($size) != "em" {
|
|
84
94
|
@error "Expected an em value, but got `#{$size}`.";
|
|
85
95
|
}
|
|
86
|
-
@return $size * $
|
|
96
|
+
@return $size * $validated_context;
|
|
87
97
|
}
|
|
88
98
|
|
|
89
99
|
/// Convert pixels to em
|
|
90
|
-
@function px_to_em(
|
|
91
|
-
$
|
|
92
|
-
$
|
|
93
|
-
|
|
100
|
+
@function px_to_em(
|
|
101
|
+
$size,
|
|
102
|
+
$context: $base-font-size
|
|
103
|
+
) {
|
|
104
|
+
$validated_size: validate_px($size);
|
|
105
|
+
$validated_context: validate_px($context);
|
|
106
|
+
@return $validated_size / $validated_context * 1em;
|
|
94
107
|
}
|
|
@@ -3,83 +3,96 @@
|
|
|
3
3
|
// ============================================================================
|
|
4
4
|
|
|
5
5
|
////
|
|
6
|
-
///
|
|
6
|
+
///
|
|
7
7
|
/// Unit Functions Module
|
|
8
8
|
/// ===========================================================================
|
|
9
|
-
///
|
|
9
|
+
///
|
|
10
10
|
/// @group Unit
|
|
11
11
|
/// @author Scape Agency
|
|
12
12
|
/// @link https://unit.gl
|
|
13
13
|
/// @since 0.1.0 initial release
|
|
14
14
|
/// @todo None
|
|
15
15
|
/// @access public
|
|
16
|
-
///
|
|
16
|
+
///
|
|
17
17
|
////
|
|
18
18
|
|
|
19
|
-
|
|
20
19
|
// ============================================================================
|
|
21
20
|
// Use
|
|
22
21
|
// ============================================================================
|
|
23
22
|
|
|
23
|
+
@use "sass:meta";
|
|
24
|
+
@use "sass:math";
|
|
25
|
+
@use "sass:string";
|
|
24
26
|
|
|
25
27
|
// ============================================================================
|
|
26
28
|
// Functions
|
|
27
29
|
// ============================================================================
|
|
28
30
|
|
|
29
|
-
|
|
30
|
-
///
|
|
31
|
+
///
|
|
31
32
|
/// Strip Unit Function
|
|
32
33
|
/// ---------------------------------------------------------------------------
|
|
33
|
-
///
|
|
34
|
+
///
|
|
34
35
|
/// Removes the unit from a numerical value, ensuring compatibility with various SCSS versions.
|
|
35
|
-
///
|
|
36
|
+
///
|
|
36
37
|
/// @param {Number} $value - The numerical value with or without a unit.
|
|
37
38
|
/// @return {Number} - The raw numerical value without its unit, or the original value if unitless or non-numerical.
|
|
38
|
-
///
|
|
39
|
+
///
|
|
39
40
|
@function unit_strip($value) {
|
|
40
41
|
// Check if the input is a number with a unit
|
|
41
|
-
@if type-of($value)
|
|
42
|
+
@if meta.type-of($value)=="number" and not math.is-unitless($value) {
|
|
43
|
+
|
|
42
44
|
// Convert the value to a string
|
|
43
|
-
$value-str: inspect($value);
|
|
45
|
+
// $value-str: inspect($value);
|
|
46
|
+
$value-str: meta.inspect($value);
|
|
47
|
+
|
|
44
48
|
// Remove the unit part from the string
|
|
45
|
-
$value-no-unit:
|
|
49
|
+
$value-no-unit: string.slice(
|
|
46
50
|
$value-str,
|
|
47
51
|
1,
|
|
48
|
-
|
|
52
|
+
string.index($value-str, math.unit($value)) - 1
|
|
49
53
|
);
|
|
54
|
+
|
|
50
55
|
// Return the number without its unit
|
|
51
56
|
@return $value-no-unit;
|
|
57
|
+
|
|
52
58
|
} @else if type-of($value) != "number" {
|
|
59
|
+
|
|
53
60
|
// Handle non-number inputs gracefully
|
|
54
61
|
// @warn "Input `#{$value}` is not a number. Returning value as-is.";
|
|
55
62
|
@return $value;
|
|
56
63
|
}
|
|
64
|
+
|
|
57
65
|
// Return the value as-is for unitless numbers or non-number inputs
|
|
58
66
|
@return $value;
|
|
59
67
|
}
|
|
60
68
|
|
|
61
|
-
|
|
62
69
|
///
|
|
63
70
|
/// Linear Interpolation Function
|
|
64
71
|
/// ---------------------------------------------------------------------------
|
|
65
|
-
///
|
|
72
|
+
///
|
|
66
73
|
/// Interpolates linearly between two values across a range, useful for
|
|
67
74
|
/// fluid scaling.
|
|
68
|
-
///
|
|
75
|
+
///
|
|
69
76
|
/// @param {Number} $start - Starting value at the lower bound (can include units).
|
|
70
77
|
/// @param {Number} $end - Ending value at the upper bound (can include units).
|
|
71
78
|
/// @param {Number} $min - Lower bound for interpolation (must be unitless or in 'px').
|
|
72
79
|
/// @param {Number} $max - Upper bound for interpolation (must be unitless or in 'px').
|
|
73
80
|
/// @param {Number} $actual - Current value to interpolate (default is 100vw).
|
|
74
81
|
/// @return {Number} - Interpolated value (in the same units as $start and $end).
|
|
75
|
-
///
|
|
76
|
-
@function linear_interpolation(
|
|
82
|
+
///
|
|
83
|
+
@function linear_interpolation(
|
|
84
|
+
$start,
|
|
85
|
+
$end,
|
|
86
|
+
$min,
|
|
87
|
+
$max,
|
|
88
|
+
$actual: 100vw
|
|
89
|
+
) {
|
|
77
90
|
|
|
78
91
|
// Validate parameters
|
|
79
|
-
@if unitless($min) == false and unit($min) !=
|
|
92
|
+
@if unitless($min) == false and unit($min) != "px" {
|
|
80
93
|
@error "Parameter `$min` must be unitless or in 'px'.";
|
|
81
94
|
}
|
|
82
|
-
@if unitless($max) == false and unit($max) !=
|
|
95
|
+
@if unitless($max) == false and unit($max) != "px" {
|
|
83
96
|
@error "Parameter `$max` must be unitless or in 'px'.";
|
|
84
97
|
}
|
|
85
98
|
@if $max <= $min {
|
|
@@ -106,27 +119,25 @@
|
|
|
106
119
|
|
|
107
120
|
// Return the `calc` expression
|
|
108
121
|
@return $value;
|
|
109
|
-
|
|
110
122
|
}
|
|
111
123
|
|
|
112
|
-
|
|
113
124
|
///
|
|
114
125
|
/// Clamp-based Responsive Typography Function
|
|
115
126
|
/// ---------------------------------------------------------------------------
|
|
116
|
-
///
|
|
127
|
+
///
|
|
117
128
|
/// Calculates font size using clamp-based responsive typography.
|
|
118
|
-
///
|
|
129
|
+
///
|
|
119
130
|
/// @param {Number} $_font_size_min - Minimum font size.
|
|
120
131
|
/// @param {Number} $_font_size_max - Maximum font size.
|
|
121
132
|
/// @param {Number} $_viewport_width_min - Minimum viewport width where scaling starts.
|
|
122
133
|
/// @param {Number} $_viewport_width_max - Maximum viewport width where scaling stops.
|
|
123
134
|
/// @return {Number} - Calculated size using clamp.
|
|
124
|
-
///
|
|
135
|
+
///
|
|
125
136
|
@function scale_dynamic_clamp(
|
|
126
137
|
$_viewport_width_min,
|
|
127
138
|
$_viewport_width_max,
|
|
128
139
|
$_font_size_min,
|
|
129
|
-
$_font_size_max
|
|
140
|
+
$_font_size_max
|
|
130
141
|
) {
|
|
131
142
|
@return clamp(
|
|
132
143
|
$_font_size_min,
|
|
@@ -140,8 +151,6 @@
|
|
|
140
151
|
);
|
|
141
152
|
}
|
|
142
153
|
|
|
143
|
-
|
|
144
|
-
|
|
145
154
|
/// Fluid Typography Mixin
|
|
146
155
|
/// ---------------------------------------------------------------------------
|
|
147
156
|
/// Mixin: fluid_type
|
|
@@ -189,28 +198,27 @@
|
|
|
189
198
|
// }
|
|
190
199
|
// }
|
|
191
200
|
|
|
192
|
-
|
|
193
201
|
///
|
|
194
202
|
/// Dynamic Scaling Function
|
|
195
203
|
/// ---------------------------------------------------------------------------
|
|
196
|
-
///
|
|
204
|
+
///
|
|
197
205
|
/// Calculates font size dynamically based on viewport width, allowing for
|
|
198
206
|
/// fluid scaling.
|
|
199
|
-
///
|
|
207
|
+
///
|
|
200
208
|
/// @param {Number} $_viewport_width_min - Minimum viewport width where scaling starts.
|
|
201
209
|
/// @param {Number} $_viewport_width_max - Maximum viewport width where scaling stops.
|
|
202
210
|
/// @param {Number} $_font_size_min - Minimum font size.
|
|
203
211
|
/// @param {Number} $_font_size_max - Maximum font size.
|
|
204
212
|
/// @param {Number} $_current_width - Current viewport width.
|
|
205
213
|
/// @return {Number} - The calculated font size based on the current width, or null if units are inconsistent.
|
|
206
|
-
///
|
|
214
|
+
///
|
|
207
215
|
@function scale_dynamic(
|
|
208
216
|
$_viewport_width_min,
|
|
209
217
|
$_viewport_width_max,
|
|
210
218
|
$_font_size_min,
|
|
211
219
|
$_font_size_max,
|
|
212
|
-
$_current_width
|
|
213
|
-
|
|
220
|
+
$_current_width
|
|
221
|
+
) {
|
|
214
222
|
// Ensure the units are consistent
|
|
215
223
|
// $u1: unit($_viewport_width_min);
|
|
216
224
|
// $u2: unit($_viewport_width_max);
|
|
@@ -224,15 +232,19 @@
|
|
|
224
232
|
// Validate unit consistency
|
|
225
233
|
@if $u1 == $u2 and $u1 == $u3 and $u1 == $u4 {
|
|
226
234
|
// Check if the current width is within the specified range
|
|
227
|
-
@if $_current_width >=
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
$
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
235
|
+
@if $_current_width >=
|
|
236
|
+
$_viewport_width_min and
|
|
237
|
+
$_current_width <=
|
|
238
|
+
$_viewport_width_max
|
|
239
|
+
{
|
|
240
|
+
// Calculate and return the interpolated font size
|
|
241
|
+
@return linear_interpolation(
|
|
242
|
+
$_font_size_min,
|
|
243
|
+
$_font_size_max,
|
|
244
|
+
$_viewport_width_min,
|
|
245
|
+
$_viewport_width_max,
|
|
246
|
+
100vw
|
|
247
|
+
);
|
|
236
248
|
} @else if $_current_width < $_viewport_width_min {
|
|
237
249
|
// Return the minimum font size
|
|
238
250
|
@return $_font_size_min;
|
package/scss/index.scss
CHANGED
package/scss/maps/_color.scss
CHANGED
|
@@ -3,28 +3,28 @@
|
|
|
3
3
|
// ============================================================================
|
|
4
4
|
|
|
5
5
|
////
|
|
6
|
-
///
|
|
7
|
-
/// Color
|
|
6
|
+
///
|
|
7
|
+
/// Color Maps Module
|
|
8
8
|
/// ===========================================================================
|
|
9
|
-
///
|
|
10
|
-
/// These colors are used for visual guides such as grid overlays, baselines,
|
|
11
|
-
/// and alignment guides. The colors are defined with varying levels of opacity
|
|
9
|
+
///
|
|
10
|
+
/// These colors are used for visual guides such as grid overlays, baselines,
|
|
11
|
+
/// and alignment guides. The colors are defined with varying levels of opacity
|
|
12
12
|
/// to ensure they are visible yet non-intrusive on the design.
|
|
13
|
-
///
|
|
13
|
+
///
|
|
14
14
|
/// @group Color
|
|
15
15
|
/// @author Scape Agency
|
|
16
16
|
/// @link https://unit.gl
|
|
17
17
|
/// @since 0.1.0 initial release
|
|
18
18
|
/// @todo None
|
|
19
19
|
/// @access public
|
|
20
|
-
///
|
|
20
|
+
///
|
|
21
21
|
////
|
|
22
22
|
|
|
23
|
-
|
|
24
23
|
// ============================================================================
|
|
25
24
|
// Use
|
|
26
25
|
// ============================================================================
|
|
27
26
|
|
|
27
|
+
@use "../variables" as *;
|
|
28
28
|
|
|
29
29
|
// ============================================================================
|
|
30
30
|
// Maps
|
|
@@ -32,12 +32,12 @@
|
|
|
32
32
|
|
|
33
33
|
/// Color Set for Easy Adjustments
|
|
34
34
|
/// ---------------------------------------------------------------------------
|
|
35
|
-
///
|
|
35
|
+
///
|
|
36
36
|
$guide_colors: (
|
|
37
|
-
"primary":
|
|
38
|
-
"secondary":
|
|
39
|
-
"tertiary":
|
|
37
|
+
"primary": $guide_color_primary,
|
|
38
|
+
"secondary": $guide_color_secondary,
|
|
39
|
+
"tertiary": $guide_color_tertiary,
|
|
40
40
|
"quaternary": $guide_color_quaternary,
|
|
41
|
-
"light":
|
|
42
|
-
"dark":
|
|
41
|
+
"light": $guide_color_light,
|
|
42
|
+
"dark": $guide_color_dark
|
|
43
43
|
);
|
package/scss/maps/_index.scss
CHANGED
|
@@ -1 +1,27 @@
|
|
|
1
|
+
// ============================================================================
|
|
2
|
+
// Poster
|
|
3
|
+
// ============================================================================
|
|
4
|
+
|
|
5
|
+
////
|
|
6
|
+
///
|
|
7
|
+
/// Maps Module
|
|
8
|
+
/// ===========================================================================
|
|
9
|
+
///
|
|
10
|
+
///
|
|
11
|
+
/// @author Scape Agency
|
|
12
|
+
/// @link https://unit.gl
|
|
13
|
+
/// @since 0.1.0 initial release
|
|
14
|
+
/// @todo None
|
|
15
|
+
/// @access public
|
|
16
|
+
///
|
|
17
|
+
////
|
|
18
|
+
|
|
19
|
+
// ============================================================================
|
|
20
|
+
// Use
|
|
21
|
+
// ============================================================================
|
|
22
|
+
|
|
23
|
+
// ============================================================================
|
|
24
|
+
// Forward
|
|
25
|
+
// ============================================================================
|
|
26
|
+
|
|
1
27
|
@forward "color";
|