unit.gl 0.0.35 → 0.0.39
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/LICENSE +21 -201
- package/README.md +30 -74
- package/css/unit.gl.css +28 -65
- package/css/unit.gl.min.css +1 -1
- package/package.json +13 -8
- package/scss/_global.scss +5 -23
- package/scss/_reset.scss +13 -15
- package/scss/classes/_guide.scss +126 -0
- package/scss/classes/_index.scss +25 -11
- package/scss/classes/_ratio.scss +30 -0
- package/scss/dev/_banner.scss +30 -1
- package/scss/dev/_index.scss +0 -0
- package/scss/functions/_color.scss +40 -0
- package/scss/functions/_index.scss +39 -16
- package/scss/functions/_layer.scss +48 -0
- package/scss/functions/_ratio.scss +58 -157
- package/scss/functions/_scale.scss +55 -49
- package/scss/functions/_sequence.scss +154 -126
- package/scss/functions/_view.scss +40 -0
- package/scss/functions/math/_arithmetic.scss +102 -0
- package/scss/functions/math/_index.scss +30 -0
- package/scss/functions/unit/_index.scss +30 -0
- package/scss/functions/unit/_unit_conversion.scss +94 -0
- package/scss/functions/{_unit_functions.scss → unit/_unit_functions.scss} +70 -36
- package/scss/index.scss +2 -16
- package/scss/maps/_color.scss +43 -0
- package/scss/maps/_index.scss +1 -0
- package/scss/mixins/_device.scss +63 -25
- package/scss/mixins/_display.scss +106 -44
- package/scss/mixins/_guide.scss +191 -158
- package/scss/mixins/_helper.scss +287 -52
- package/scss/mixins/_index.scss +50 -17
- package/scss/mixins/_paper.scss +38 -17
- package/scss/mixins/_ratio.scss +30 -13
- package/scss/mixins/_unit.scss +94 -0
- package/scss/mixins/_view.scss +123 -44
- package/scss/tags/_index.scss +30 -0
- package/scss/tags/_unit.scss +40 -0
- package/scss/utilities/_guides.scss +103 -0
- package/scss/utilities/_index.scss +6 -0
- package/scss/variables/_color.scss +83 -0
- package/scss/variables/_device.scss +140 -50
- package/scss/variables/_index.scss +84 -16
- package/scss/variables/_layer.scss +148 -51
- package/scss/variables/_paper.scss +243 -17
- package/scss/variables/_ratio.scss +224 -0
- package/scss/variables/_scale.scss +230 -104
- package/scss/variables/_unit.scss +76 -72
- package/scss/variables/_view.scss +135 -39
- package/ts/AspectRatio.ts +29 -0
- package/ts/Border.ts +29 -0
- package/ts/BoxModel.ts +40 -0
- package/ts/FlexContainer.ts +48 -0
- package/ts/Grid.ts +21 -0
- package/ts/GridContainer.ts +33 -0
- package/ts/Layout.ts +34 -0
- package/ts/Position.ts +28 -0
- package/ts/Rectangle.ts +28 -0
- package/ts/ResponsiveImage.ts +28 -0
- package/ts/ResponsiveScale.ts +21 -0
- package/ts/Size.ts +32 -0
- package/ts/Spacing.ts +68 -0
- package/ts/Transform.ts +38 -0
- package/ts/Typography.ts +41 -0
- package/ts/Unit.ts +57 -0
- package/ts/Viewport.ts +24 -0
- package/js/index.d.ts +0 -1
- package/js/index.js +0 -3
- package/js/unit.gl.min.js +0 -1
- package/scss/classes/_paper.scss +0 -97
- package/scss/functions/_arithmetic.scss +0 -64
- package/scss/functions/_unit_conversion.scss +0 -77
|
@@ -1,96 +1,100 @@
|
|
|
1
|
-
//
|
|
1
|
+
// ============================================================================
|
|
2
|
+
// Poster
|
|
3
|
+
// ============================================================================
|
|
2
4
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
5
|
+
////
|
|
6
|
+
///
|
|
7
|
+
/// Sequence Functions Module
|
|
8
|
+
/// ===========================================================================
|
|
9
|
+
///
|
|
10
|
+
/// This module provides various functions to calculate terms in well-known
|
|
11
|
+
/// mathematical sequences such as Fibonacci, Lucas, Prime numbers, and more.
|
|
12
|
+
/// Each function is designed to compute the nth term in the respective
|
|
13
|
+
/// sequence using a straightforward algorithm.
|
|
14
|
+
///
|
|
15
|
+
/// @group Sequence
|
|
16
|
+
/// @author Scape Agency
|
|
17
|
+
/// @link https://unit.gl
|
|
18
|
+
/// @since 0.1.0 initial release
|
|
19
|
+
/// @todo None
|
|
20
|
+
/// @access public
|
|
21
|
+
///
|
|
22
|
+
////
|
|
6
23
|
|
|
7
|
-
// http://www.apache.org/licenses/LICENSE-2.0
|
|
8
24
|
|
|
9
|
-
//
|
|
10
|
-
//
|
|
11
|
-
//
|
|
12
|
-
// See the License for the specific language governing permissions and
|
|
13
|
-
// limitations under the License.
|
|
25
|
+
// ============================================================================
|
|
26
|
+
// Use
|
|
27
|
+
// ============================================================================
|
|
14
28
|
|
|
15
29
|
|
|
16
30
|
// ============================================================================
|
|
17
|
-
//
|
|
31
|
+
// Functions
|
|
18
32
|
// ============================================================================
|
|
19
33
|
|
|
20
34
|
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
35
|
+
///
|
|
36
|
+
/// Fibonacci Number Sequence
|
|
37
|
+
/// ---------------------------------------------------------------------------
|
|
38
|
+
///
|
|
24
39
|
/// Calculates the nth Fibonacci number using a recursive approach.
|
|
25
|
-
///
|
|
26
|
-
///
|
|
40
|
+
/// Fibonacci numbers form a sequence where each number is the sum of the two
|
|
41
|
+
/// preceding ones, starting with 0 and 1.
|
|
42
|
+
///
|
|
43
|
+
/// @name sequence_fibonacci
|
|
27
44
|
/// @param {Number} $n - The position in the Fibonacci sequence to calculate.
|
|
28
45
|
/// @return {Number} - The nth Fibonacci number.
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
// Return null for negative index to avoid unnecessary recursion
|
|
46
|
+
///
|
|
47
|
+
@function sequence_fibonacci($n) {
|
|
32
48
|
@if $n < 0 {
|
|
33
|
-
@warn "Index #{$n} is not valid for Fibonacci sequence.";
|
|
49
|
+
@warn "Index #{$n} is not valid for the Fibonacci sequence.";
|
|
34
50
|
@return null;
|
|
35
51
|
}
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
@
|
|
39
|
-
@return 0;
|
|
40
|
-
} @else if $n == 1 {
|
|
41
|
-
@return 1;
|
|
42
|
-
} @else {
|
|
43
|
-
// Recursive case
|
|
52
|
+
@if $n == 0 { @return 0; }
|
|
53
|
+
@else if $n == 1 { @return 1; }
|
|
54
|
+
@else {
|
|
44
55
|
@return sequence_fibonacci($n - 1) + sequence_fibonacci($n - 2);
|
|
45
56
|
}
|
|
46
|
-
|
|
47
57
|
}
|
|
48
58
|
|
|
49
59
|
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
60
|
+
///
|
|
61
|
+
/// Lucas Number Sequence
|
|
62
|
+
/// ---------------------------------------------------------------------------
|
|
63
|
+
///
|
|
53
64
|
/// Calculates the nth Lucas number using a recursive approach.
|
|
54
|
-
///
|
|
55
|
-
///
|
|
56
|
-
///
|
|
57
|
-
///
|
|
65
|
+
/// Lucas numbers form a sequence similar to Fibonacci numbers but start with
|
|
66
|
+
/// 2 and 1 instead of 0 and 1.
|
|
67
|
+
///
|
|
68
|
+
/// @name sequence_lucas
|
|
58
69
|
/// @param {Number} $n - The position in the Lucas sequence to calculate.
|
|
59
70
|
/// @return {Number} - The nth Lucas number.
|
|
71
|
+
///
|
|
60
72
|
@function sequence_lucas($n) {
|
|
61
|
-
|
|
62
|
-
// Return null for negative index to avoid unnecessary recursion
|
|
63
73
|
@if $n < 0 {
|
|
64
|
-
@warn "Index #{$n} is not valid for Lucas sequence.";
|
|
74
|
+
@warn "Index #{$n} is not valid for the Lucas sequence.";
|
|
65
75
|
@return null;
|
|
66
76
|
}
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
@
|
|
70
|
-
@return 2;
|
|
71
|
-
} @else if $n == 1 {
|
|
72
|
-
@return 1;
|
|
73
|
-
} @else {
|
|
74
|
-
// Recursive case
|
|
77
|
+
@if $n == 0 { @return 2; }
|
|
78
|
+
@else if $n == 1 { @return 1; }
|
|
79
|
+
@else {
|
|
75
80
|
@return sequence_lucas($n - 1) + sequence_lucas($n - 2);
|
|
76
81
|
}
|
|
77
|
-
|
|
78
82
|
}
|
|
79
83
|
|
|
80
84
|
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
///
|
|
85
|
-
///
|
|
86
|
-
///
|
|
87
|
-
///
|
|
85
|
+
///
|
|
86
|
+
/// Prime Number Check
|
|
87
|
+
/// ---------------------------------------------------------------------------
|
|
88
|
+
///
|
|
89
|
+
/// Checks if a number is prime.
|
|
90
|
+
/// A prime number is a natural number greater than 1 that has no positive
|
|
91
|
+
/// divisors other than 1 and itself.
|
|
92
|
+
/// @name is_prime
|
|
88
93
|
/// @param {Number} $n - The number to check.
|
|
89
94
|
/// @return {Boolean} - `true` if the number is prime, `false` otherwise.
|
|
95
|
+
///
|
|
90
96
|
@function is_prime($n) {
|
|
91
|
-
@if $n <= 1 {
|
|
92
|
-
@return false;
|
|
93
|
-
}
|
|
97
|
+
@if $n <= 1 { @return false; }
|
|
94
98
|
@for $i from 2 through math.sqrt($n) {
|
|
95
99
|
@if $n % $i == 0 {
|
|
96
100
|
@return false;
|
|
@@ -100,12 +104,17 @@
|
|
|
100
104
|
}
|
|
101
105
|
|
|
102
106
|
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
107
|
+
///
|
|
108
|
+
/// Factorial
|
|
109
|
+
/// ---------------------------------------------------------------------------
|
|
110
|
+
///
|
|
106
111
|
/// Calculates the factorial of a number.
|
|
107
|
-
///
|
|
112
|
+
/// Factorial is the product of all positive integers up to a given number.
|
|
113
|
+
///
|
|
114
|
+
/// @name factorial
|
|
115
|
+
/// @param {Number} $n - The number to calculate the factorial for.
|
|
108
116
|
/// @return {Number} - The factorial of $n.
|
|
117
|
+
///
|
|
109
118
|
@function factorial($n) {
|
|
110
119
|
$result: 1;
|
|
111
120
|
@for $i from 1 through $n {
|
|
@@ -114,59 +123,75 @@
|
|
|
114
123
|
@return $result;
|
|
115
124
|
}
|
|
116
125
|
|
|
126
|
+
///
|
|
127
|
+
/// Catalan Number Sequence
|
|
128
|
+
/// ---------------------------------------------------------------------------
|
|
129
|
+
///
|
|
117
130
|
/// Calculates the nth Catalan number.
|
|
118
|
-
/// Catalan numbers are a sequence of natural numbers
|
|
119
|
-
///
|
|
120
|
-
///
|
|
121
|
-
/// @
|
|
131
|
+
/// Catalan numbers are a sequence of natural numbers with applications in
|
|
132
|
+
/// combinatorial mathematics, such as counting certain types of lattice paths.
|
|
133
|
+
///
|
|
134
|
+
/// @name sequence_catalan
|
|
135
|
+
/// @param {Number} $n - The position in the Catalan sequence to calculate.
|
|
122
136
|
/// @return {Number} - The nth Catalan number.
|
|
137
|
+
///
|
|
123
138
|
@function sequence_catalan($n) {
|
|
124
139
|
@return factorial(2 * $n) / (factorial($n + 1) * factorial($n));
|
|
125
140
|
}
|
|
126
141
|
|
|
127
142
|
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
143
|
+
///
|
|
144
|
+
/// Harmonic Sequence
|
|
145
|
+
/// ---------------------------------------------------------------------------
|
|
146
|
+
///
|
|
131
147
|
/// Calculates the nth term of the harmonic series.
|
|
132
|
-
/// The harmonic series is the sum of reciprocals of the positive integers.
|
|
133
|
-
///
|
|
148
|
+
/// The harmonic series is the sum of the reciprocals of the positive integers.
|
|
149
|
+
///
|
|
150
|
+
/// @name sequence_harmonic
|
|
134
151
|
/// @param {Number} $n - The position in the harmonic series to calculate.
|
|
135
152
|
/// @return {Number} - The nth term of the harmonic series.
|
|
153
|
+
///
|
|
136
154
|
@function sequence_harmonic($n) {
|
|
137
155
|
@if $n <= 0 {
|
|
138
|
-
@warn "Index #{$n} is not valid for harmonic series.";
|
|
156
|
+
@warn "Index #{$n} is not valid for the harmonic series.";
|
|
139
157
|
@return null;
|
|
140
158
|
}
|
|
141
159
|
@return 1 / $n;
|
|
142
160
|
}
|
|
143
161
|
|
|
144
162
|
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
163
|
+
///
|
|
164
|
+
/// Geometric Sequence
|
|
165
|
+
/// ----------------------------------------------------------------------------
|
|
166
|
+
///
|
|
148
167
|
/// Calculates the nth term of a geometric series with a ratio of 2.
|
|
149
|
-
///
|
|
150
|
-
///
|
|
151
|
-
///
|
|
168
|
+
/// A geometric series has a constant ratio between successive terms.
|
|
169
|
+
/// This function calculates the nth term for a series where each term doubles.
|
|
170
|
+
///
|
|
171
|
+
/// @name sequence_geometric
|
|
152
172
|
/// @param {Number} $n - The position in the geometric series to calculate.
|
|
153
173
|
/// @return {Number} - The nth term of the geometric series.
|
|
174
|
+
///
|
|
154
175
|
@function sequence_geometric($n) {
|
|
155
176
|
@if $n < 0 {
|
|
156
|
-
@warn "Negative index #{$n} is not valid for geometric series.";
|
|
177
|
+
@warn "Negative index #{$n} is not valid for the geometric series.";
|
|
157
178
|
@return null;
|
|
158
179
|
}
|
|
159
180
|
@return pow(2, $n - 1);
|
|
160
181
|
}
|
|
161
182
|
|
|
162
183
|
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
184
|
+
///
|
|
185
|
+
/// Superfactorial Sequence
|
|
186
|
+
/// ---------------------------------------------------------------------------
|
|
187
|
+
///
|
|
166
188
|
/// Calculates the superfactorial of a number.
|
|
167
189
|
/// The superfactorial of a number n is the product of the first n factorials.
|
|
168
|
-
///
|
|
190
|
+
///
|
|
191
|
+
/// @name sequence_superfactorial
|
|
192
|
+
/// @param {Number} $n - The number to calculate the superfactorial for.
|
|
169
193
|
/// @return {Number} - The superfactorial of $n.
|
|
194
|
+
///
|
|
170
195
|
@function sequence_superfactorial($n) {
|
|
171
196
|
$result: 1;
|
|
172
197
|
@for $i from 1 through $n {
|
|
@@ -180,98 +205,101 @@
|
|
|
180
205
|
}
|
|
181
206
|
|
|
182
207
|
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
208
|
+
///
|
|
209
|
+
/// Triangular Number Sequence
|
|
210
|
+
/// ---------------------------------------------------------------------------
|
|
211
|
+
///
|
|
186
212
|
/// Calculates the nth triangular number.
|
|
187
|
-
///
|
|
188
|
-
///
|
|
189
|
-
///
|
|
190
|
-
/// triangular number is n(n + 1)/2.
|
|
191
|
-
/// composing a triangle with n dots on a side.
|
|
213
|
+
/// Triangular numbers are the sum of the first n natural numbers.
|
|
214
|
+
///
|
|
215
|
+
/// @name sequence_triangular
|
|
192
216
|
/// @param {Number} $n - The position in the triangular series to calculate.
|
|
193
217
|
/// @return {Number} - The nth triangular number.
|
|
218
|
+
///
|
|
194
219
|
@function sequence_triangular($n) {
|
|
195
|
-
|
|
196
|
-
// Return null for non-positive index to avoid invalid numbers
|
|
197
220
|
@if $n <= 0 {
|
|
198
|
-
@warn "Index #{$n} is not valid for triangular series.";
|
|
221
|
+
@warn "Index #{$n} is not valid for the triangular series.";
|
|
199
222
|
@return null;
|
|
200
223
|
}
|
|
201
|
-
|
|
202
|
-
// Calculate the nth triangular number
|
|
203
224
|
@return $n * ($n + 1) / 2;
|
|
204
|
-
|
|
205
225
|
}
|
|
206
226
|
|
|
207
227
|
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
228
|
+
///
|
|
229
|
+
/// Square Number Sequence
|
|
230
|
+
/// ---------------------------------------------------------------------------
|
|
231
|
+
///
|
|
211
232
|
/// Calculates the nth square number.
|
|
212
|
-
/// Square numbers are numbers that can be expressed as the product of an
|
|
213
|
-
/// integer with itself
|
|
233
|
+
/// Square numbers are numbers that can be expressed as the product of an
|
|
234
|
+
/// integer with itself (n²).
|
|
235
|
+
///
|
|
236
|
+
/// @name sequence_square
|
|
214
237
|
/// @param {Number} $n - The position in the square series to calculate.
|
|
215
238
|
/// @return {Number} - The nth square number.
|
|
239
|
+
///
|
|
216
240
|
@function sequence_square($n) {
|
|
217
241
|
@if $n < 0 {
|
|
218
|
-
@warn "Negative index #{$n} is not valid for square series.";
|
|
242
|
+
@warn "Negative index #{$n} is not valid for the square series.";
|
|
219
243
|
@return null;
|
|
220
244
|
}
|
|
221
245
|
@return $n * $n;
|
|
222
246
|
}
|
|
223
247
|
|
|
224
248
|
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
249
|
+
///
|
|
250
|
+
/// Pentagonal Number Sequence
|
|
251
|
+
/// ---------------------------------------------------------------------------
|
|
252
|
+
///
|
|
228
253
|
/// Calculates the nth pentagonal number.
|
|
229
|
-
///
|
|
230
|
-
///
|
|
254
|
+
/// Pentagonal numbers are figurate numbers that represent a pentagon.
|
|
255
|
+
///
|
|
256
|
+
/// @name sequence_pentagonal
|
|
231
257
|
/// @param {Number} $n - The position in the pentagonal series to calculate.
|
|
232
258
|
/// @return {Number} - The nth pentagonal number.
|
|
259
|
+
///
|
|
233
260
|
@function sequence_pentagonal($n) {
|
|
234
|
-
|
|
235
|
-
// Return null for non-positive index to avoid invalid numbers
|
|
236
261
|
@if $n <= 0 {
|
|
237
|
-
@warn "Index #{$n} is not valid for pentagonal series.";
|
|
262
|
+
@warn "Index #{$n} is not valid for the pentagonal series.";
|
|
238
263
|
@return null;
|
|
239
264
|
}
|
|
240
|
-
|
|
241
|
-
// Calculate the nth pentagonal number
|
|
242
265
|
@return (3 * $n * $n - $n) / 2;
|
|
243
|
-
|
|
244
266
|
}
|
|
245
267
|
|
|
246
268
|
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
269
|
+
///
|
|
270
|
+
/// Hexagonal Number Sequence
|
|
271
|
+
/// ---------------------------------------------------------------------------
|
|
272
|
+
///
|
|
250
273
|
/// Calculates the nth hexagonal number.
|
|
251
|
-
/// Hexagonal numbers are figurate numbers that represent a hexagon.
|
|
252
|
-
///
|
|
274
|
+
/// Hexagonal numbers are figurate numbers that represent a hexagon.
|
|
275
|
+
///
|
|
276
|
+
/// @name sequence_hexagonal
|
|
253
277
|
/// @param {Number} $n - The position in the hexagonal series to calculate.
|
|
254
278
|
/// @return {Number} - The nth hexagonal number.
|
|
279
|
+
///
|
|
255
280
|
@function sequence_hexagonal($n) {
|
|
256
281
|
@if $n <= 0 {
|
|
257
|
-
@warn "Index #{$n} is not valid for hexagonal series.";
|
|
282
|
+
@warn "Index #{$n} is not valid for the hexagonal series.";
|
|
258
283
|
@return null;
|
|
259
284
|
}
|
|
260
285
|
@return 2 * $n * $n - $n;
|
|
261
286
|
}
|
|
262
287
|
|
|
263
288
|
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
289
|
+
///
|
|
290
|
+
/// Cube Number Sequence
|
|
291
|
+
/// ---------------------------------------------------------------------------
|
|
292
|
+
///
|
|
267
293
|
/// Calculates the nth cube number.
|
|
268
|
-
/// Cube numbers are
|
|
269
|
-
///
|
|
294
|
+
/// Cube numbers are numbers raised to the power of three (n³).
|
|
295
|
+
///
|
|
296
|
+
/// @name sequence_cube
|
|
270
297
|
/// @param {Number} $n - The position in the cube series to calculate.
|
|
271
298
|
/// @return {Number} - The nth cube number.
|
|
299
|
+
///
|
|
272
300
|
@function sequence_cube($n) {
|
|
273
301
|
@if $n < 0 {
|
|
274
|
-
@warn "Negative index #{$n} is not valid for cube series.";
|
|
302
|
+
@warn "Negative index #{$n} is not valid for the cube series.";
|
|
275
303
|
@return null;
|
|
276
304
|
}
|
|
277
305
|
@return $n * $n * $n;
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
// ============================================================================
|
|
2
|
+
// Poster
|
|
3
|
+
// ============================================================================
|
|
4
|
+
|
|
5
|
+
////
|
|
6
|
+
///
|
|
7
|
+
/// View Functions Module
|
|
8
|
+
/// ===========================================================================
|
|
9
|
+
///
|
|
10
|
+
/// @group View
|
|
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
|
+
// ============================================================================
|
|
21
|
+
// Use
|
|
22
|
+
// ============================================================================
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
// ============================================================================
|
|
26
|
+
// Functions
|
|
27
|
+
// ============================================================================
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
///
|
|
31
|
+
/// A function to calculate breakpoints based on a multiplier of the base
|
|
32
|
+
/// screen unit.
|
|
33
|
+
///
|
|
34
|
+
/// @name calc_breakpoint
|
|
35
|
+
/// @param {Number} $multiplier - The multiplier to apply to the base unit.
|
|
36
|
+
/// @return {Length} The calculated breakpoint value in pixels.
|
|
37
|
+
///
|
|
38
|
+
@function calc_breakpoint($base_screen_unit, $multiplier) {
|
|
39
|
+
@return $base_screen_unit * $multiplier;
|
|
40
|
+
}
|
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
// ============================================================================
|
|
2
|
+
// Poster
|
|
3
|
+
// ============================================================================
|
|
4
|
+
|
|
5
|
+
////
|
|
6
|
+
///
|
|
7
|
+
/// Math Functions Module
|
|
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
|
|
12
|
+
/// are mismatched, a warning is issued, and the operation returns null.
|
|
13
|
+
///
|
|
14
|
+
/// Functions:
|
|
15
|
+
/// - add: Adds two values, handling units appropriately.
|
|
16
|
+
/// - subtract: Subtracts one value from another, with unit handling.
|
|
17
|
+
///
|
|
18
|
+
/// @group Math
|
|
19
|
+
/// @author Scape Agency
|
|
20
|
+
/// @link https://unit.gl
|
|
21
|
+
/// @since 0.1.0 initial release
|
|
22
|
+
/// @todo None
|
|
23
|
+
/// @access public
|
|
24
|
+
///
|
|
25
|
+
////
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
// ============================================================================
|
|
29
|
+
// Use
|
|
30
|
+
// ============================================================================
|
|
31
|
+
|
|
32
|
+
|
|
33
|
+
// ============================================================================
|
|
34
|
+
// Functions
|
|
35
|
+
// ============================================================================
|
|
36
|
+
|
|
37
|
+
|
|
38
|
+
///
|
|
39
|
+
/// Adds two values, handling units appropriately.
|
|
40
|
+
///
|
|
41
|
+
/// This function performs arithmetic addition on two values, ensuring that
|
|
42
|
+
/// units are properly handled. If both values are unitless, they are added
|
|
43
|
+
/// 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
|
|
47
|
+
/// `null` is returned.
|
|
48
|
+
///
|
|
49
|
+
/// @param {Number} $value1 - The first value, which may or may not include units.
|
|
50
|
+
/// @param {Number} $value2 - The second value, which may or may not include units.
|
|
51
|
+
/// @return {Number} - The sum of the two values, or null if the units are incompatible.
|
|
52
|
+
///
|
|
53
|
+
@function add(
|
|
54
|
+
$value1,
|
|
55
|
+
$value2
|
|
56
|
+
) {
|
|
57
|
+
@if unitless($value1) and unitless($value2) {
|
|
58
|
+
@return $value1 + $value2;
|
|
59
|
+
} @else if unitless($value1) {
|
|
60
|
+
@return $value1 + unit-strip($value2);
|
|
61
|
+
} @else if unitless($value2) {
|
|
62
|
+
@return unit-strip($value1) + $value2;
|
|
63
|
+
} @else if unit($value1) == unit($value2) {
|
|
64
|
+
@return $value1 + $value2;
|
|
65
|
+
} @else {
|
|
66
|
+
@warn "Cannot add values with different units: #{$value1} and #{$value2}";
|
|
67
|
+
@return null;
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
///
|
|
72
|
+
/// Subtracts one value from another, handling units appropriately.
|
|
73
|
+
///
|
|
74
|
+
/// This function performs arithmetic subtraction on two values, ensuring that
|
|
75
|
+
/// units are properly handled. If both values are unitless, they are
|
|
76
|
+
/// 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
|
|
80
|
+
/// `null` is returned.
|
|
81
|
+
///
|
|
82
|
+
/// @param {Number} $value1 - The first value, which may or may not include units.
|
|
83
|
+
/// @param {Number} $value2 - The second value, which may or may not include units.
|
|
84
|
+
/// @return {Number} - The difference between the two values, or null if the units are incompatible.
|
|
85
|
+
///
|
|
86
|
+
@function subtract(
|
|
87
|
+
$value1,
|
|
88
|
+
$value2
|
|
89
|
+
) {
|
|
90
|
+
@if unitless($value1) and unitless($value2) {
|
|
91
|
+
@return $value1 - $value2;
|
|
92
|
+
} @else if unitless($value1) {
|
|
93
|
+
@return $value1 - unit-strip($value2);
|
|
94
|
+
} @else if unitless($value2) {
|
|
95
|
+
@return unit-strip($value1) - $value2;
|
|
96
|
+
} @else if unit($value1) == unit($value2) {
|
|
97
|
+
@return $value1 - $value2;
|
|
98
|
+
} @else {
|
|
99
|
+
@warn "Cannot subtract values with different units: #{$value1} and #{$value2}";
|
|
100
|
+
@return null;
|
|
101
|
+
}
|
|
102
|
+
}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
// ============================================================================
|
|
2
|
+
// Poster
|
|
3
|
+
// ============================================================================
|
|
4
|
+
|
|
5
|
+
////
|
|
6
|
+
///
|
|
7
|
+
/// Math Functions Module
|
|
8
|
+
/// ===========================================================================
|
|
9
|
+
///
|
|
10
|
+
/// @group Math
|
|
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
|
+
// ============================================================================
|
|
21
|
+
// Use
|
|
22
|
+
// ============================================================================
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
// ============================================================================
|
|
26
|
+
// Forward
|
|
27
|
+
// ============================================================================
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
@forward "arithmetic"; // Basic arithmetic operations
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
// ============================================================================
|
|
2
|
+
// Poster
|
|
3
|
+
// ============================================================================
|
|
4
|
+
|
|
5
|
+
////
|
|
6
|
+
///
|
|
7
|
+
/// Unit Functions Module
|
|
8
|
+
/// ===========================================================================
|
|
9
|
+
///
|
|
10
|
+
/// @group Unit
|
|
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
|
+
// ============================================================================
|
|
21
|
+
// Use
|
|
22
|
+
// ============================================================================
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
// ============================================================================
|
|
26
|
+
// Forward
|
|
27
|
+
// ============================================================================
|
|
28
|
+
|
|
29
|
+
@forward "unit_conversion"; // Unit conversion functions
|
|
30
|
+
@forward "unit_functions"; // Additional utility functions for units
|