@curiousmedia/breakpoint 2.0.1 → 3.0.0
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/package.json +1 -1
- package/src/_breakpoint.import.scss +29 -24
- package/src/_breakpoint.scss +29 -24
package/package.json
CHANGED
|
@@ -1,17 +1,22 @@
|
|
|
1
|
+
@use "sass:map";
|
|
2
|
+
@use "sass:string";
|
|
3
|
+
@use "sass:list";
|
|
4
|
+
@use "sass:meta";
|
|
5
|
+
|
|
1
6
|
$breakpoints: () !default;
|
|
2
7
|
|
|
3
8
|
@function breakpointPresets($queries) {
|
|
4
9
|
$output: ();
|
|
5
10
|
|
|
6
11
|
@each $query in $queries {
|
|
7
|
-
$output: append($output, breakpointPreset($query))
|
|
12
|
+
$output: list.append($output, breakpointPreset($query))
|
|
8
13
|
}
|
|
9
14
|
|
|
10
15
|
@return $output;
|
|
11
16
|
}
|
|
12
17
|
|
|
13
18
|
@function breakpointPreset($query) {
|
|
14
|
-
$preset: map
|
|
19
|
+
$preset: map.get($breakpoints, $query);
|
|
15
20
|
|
|
16
21
|
@if ($preset == null) {
|
|
17
22
|
@return $query;
|
|
@@ -24,14 +29,14 @@ $breakpoints: () !default;
|
|
|
24
29
|
$output: ();
|
|
25
30
|
|
|
26
31
|
@each $query in $queries {
|
|
27
|
-
$output: append($output, breakpointParse($query))
|
|
32
|
+
$output: list.append($output, breakpointParse($query))
|
|
28
33
|
}
|
|
29
34
|
|
|
30
35
|
@return $output;
|
|
31
36
|
}
|
|
32
37
|
|
|
33
38
|
@function breakpointParse($query) {
|
|
34
|
-
$ruleIndex:
|
|
39
|
+
$ruleIndex: string.index($query, ' ');
|
|
35
40
|
|
|
36
41
|
@if ($ruleIndex == null) {
|
|
37
42
|
@return(
|
|
@@ -40,8 +45,8 @@ $breakpoints: () !default;
|
|
|
40
45
|
);
|
|
41
46
|
} @else {
|
|
42
47
|
@return (
|
|
43
|
-
rule:
|
|
44
|
-
condition:
|
|
48
|
+
rule: string.slice($query, 1, $ruleIndex - 1),
|
|
49
|
+
condition: string.slice($query, $ruleIndex + 1)
|
|
45
50
|
);
|
|
46
51
|
}
|
|
47
52
|
}
|
|
@@ -51,19 +56,19 @@ $breakpoints: () !default;
|
|
|
51
56
|
@function breakpointRemoveNth($list, $index) {
|
|
52
57
|
$result: null;
|
|
53
58
|
|
|
54
|
-
@if type-of($index) != number {
|
|
59
|
+
@if meta.type-of($index) != number {
|
|
55
60
|
@warn "$index: #{quote($index)} is not a number for `remove-nth`.";
|
|
56
61
|
} @else if $index == 0 {
|
|
57
62
|
@warn "List index 0 must be a non-zero integer for `remove-nth`.";
|
|
58
|
-
} @else if abs($index) > length($list) {
|
|
59
|
-
@warn "List index is #{$index} but list is only #{length($list)} item long for `remove-nth`.";
|
|
63
|
+
} @else if abs($index) > list.length($list) {
|
|
64
|
+
@warn "List index is #{$index} but list is only #{list.length($list)} item long for `remove-nth`.";
|
|
60
65
|
} @else {
|
|
61
66
|
$result: ();
|
|
62
|
-
$index: if($index < 0
|
|
67
|
+
$index: if(sass($index < 0): list.length($list) + $index + 1; else: $index);
|
|
63
68
|
|
|
64
|
-
@for $i from 1 through length($list) {
|
|
69
|
+
@for $i from 1 through list.length($list) {
|
|
65
70
|
@if $i != $index {
|
|
66
|
-
$result: append($result, nth($list, $i));
|
|
71
|
+
$result: list.append($result, list.nth($list, $i));
|
|
67
72
|
}
|
|
68
73
|
}
|
|
69
74
|
}
|
|
@@ -72,10 +77,10 @@ $breakpoints: () !default;
|
|
|
72
77
|
}
|
|
73
78
|
|
|
74
79
|
@function breakpointMatchingRules($queries) {
|
|
75
|
-
$rule: (map
|
|
80
|
+
$rule: (map.get(list.nth($queries, 1), 'rule'));
|
|
76
81
|
|
|
77
82
|
@each $query in $queries {
|
|
78
|
-
@if($rule != map
|
|
83
|
+
@if($rule != map.get($query, 'rule')) {
|
|
79
84
|
@return false;
|
|
80
85
|
}
|
|
81
86
|
}
|
|
@@ -87,19 +92,19 @@ $breakpoints: () !default;
|
|
|
87
92
|
$condition: "";
|
|
88
93
|
$rule: null;
|
|
89
94
|
|
|
90
|
-
@for $i from 1 through length($queries) {
|
|
91
|
-
$query: nth($queries, $i);
|
|
95
|
+
@for $i from 1 through list.length($queries) {
|
|
96
|
+
$query: list.nth($queries, $i);
|
|
92
97
|
|
|
93
98
|
@if($i == 1) {
|
|
94
|
-
$rule: map
|
|
99
|
+
$rule: map.get($query, 'rule');
|
|
95
100
|
}
|
|
96
101
|
|
|
97
|
-
@if(map
|
|
102
|
+
@if(map.get($query, 'condition') != null) {
|
|
98
103
|
@if($i > 1) {
|
|
99
104
|
$condition: $condition + ", ";
|
|
100
105
|
}
|
|
101
106
|
|
|
102
|
-
$condition: $condition + map
|
|
107
|
+
$condition: $condition + map.get($query, "condition");
|
|
103
108
|
}
|
|
104
109
|
}
|
|
105
110
|
|
|
@@ -107,8 +112,8 @@ $breakpoints: () !default;
|
|
|
107
112
|
}
|
|
108
113
|
|
|
109
114
|
@mixin breakpointBuild($query) {
|
|
110
|
-
$rule: map
|
|
111
|
-
$condition: map
|
|
115
|
+
$rule: map.get($query, 'rule');
|
|
116
|
+
$condition: map.get($query, 'condition');
|
|
112
117
|
|
|
113
118
|
@if($rule == '@media') {
|
|
114
119
|
@media #{$condition} {
|
|
@@ -150,8 +155,8 @@ $breakpoints: () !default;
|
|
|
150
155
|
}
|
|
151
156
|
|
|
152
157
|
@mixin breakpointAll($queries...) {
|
|
153
|
-
@if (length($queries) >= 1) {
|
|
154
|
-
$query: nth($queries, 1);
|
|
158
|
+
@if (list.length($queries) >= 1) {
|
|
159
|
+
$query: list.nth($queries, 1);
|
|
155
160
|
$queries: breakpointRemoveNth($queries, 1);
|
|
156
161
|
|
|
157
162
|
$query: breakpointParse(breakpointPreset($query));
|
|
@@ -172,4 +177,4 @@ $breakpoints: () !default;
|
|
|
172
177
|
#{$property}: $value;
|
|
173
178
|
}
|
|
174
179
|
}
|
|
175
|
-
}
|
|
180
|
+
}
|
package/src/_breakpoint.scss
CHANGED
|
@@ -1,17 +1,22 @@
|
|
|
1
|
+
@use "sass:map";
|
|
2
|
+
@use "sass:string";
|
|
3
|
+
@use "sass:list";
|
|
4
|
+
@use "sass:meta";
|
|
5
|
+
|
|
1
6
|
$breakpoints: () !default;
|
|
2
7
|
|
|
3
8
|
@function presets($queries) {
|
|
4
9
|
$output: ();
|
|
5
10
|
|
|
6
11
|
@each $query in $queries {
|
|
7
|
-
$output: append($output, preset($query))
|
|
12
|
+
$output: list.append($output, preset($query))
|
|
8
13
|
}
|
|
9
14
|
|
|
10
15
|
@return $output;
|
|
11
16
|
}
|
|
12
17
|
|
|
13
18
|
@function preset($query) {
|
|
14
|
-
$preset: map
|
|
19
|
+
$preset: map.get($breakpoints, $query);
|
|
15
20
|
|
|
16
21
|
@if ($preset == null) {
|
|
17
22
|
@return $query;
|
|
@@ -24,14 +29,14 @@ $breakpoints: () !default;
|
|
|
24
29
|
$output: ();
|
|
25
30
|
|
|
26
31
|
@each $query in $queries {
|
|
27
|
-
$output: append($output, parse($query))
|
|
32
|
+
$output: list.append($output, parse($query))
|
|
28
33
|
}
|
|
29
34
|
|
|
30
35
|
@return $output;
|
|
31
36
|
}
|
|
32
37
|
|
|
33
38
|
@function parse($query) {
|
|
34
|
-
$ruleIndex:
|
|
39
|
+
$ruleIndex: string.index($query, ' ');
|
|
35
40
|
|
|
36
41
|
@if ($ruleIndex == null) {
|
|
37
42
|
@return(
|
|
@@ -40,8 +45,8 @@ $breakpoints: () !default;
|
|
|
40
45
|
);
|
|
41
46
|
} @else {
|
|
42
47
|
@return (
|
|
43
|
-
rule:
|
|
44
|
-
condition:
|
|
48
|
+
rule: string.slice($query, 1, $ruleIndex - 1),
|
|
49
|
+
condition: string.slice($query, $ruleIndex + 1)
|
|
45
50
|
);
|
|
46
51
|
}
|
|
47
52
|
}
|
|
@@ -51,19 +56,19 @@ $breakpoints: () !default;
|
|
|
51
56
|
@function removeNth($list, $index) {
|
|
52
57
|
$result: null;
|
|
53
58
|
|
|
54
|
-
@if type-of($index) != number {
|
|
59
|
+
@if meta.type-of($index) != number {
|
|
55
60
|
@warn "$index: #{quote($index)} is not a number for `remove-nth`.";
|
|
56
61
|
} @else if $index == 0 {
|
|
57
62
|
@warn "List index 0 must be a non-zero integer for `remove-nth`.";
|
|
58
|
-
} @else if abs($index) > length($list) {
|
|
59
|
-
@warn "List index is #{$index} but list is only #{length($list)} item long for `remove-nth`.";
|
|
63
|
+
} @else if abs($index) > list.length($list) {
|
|
64
|
+
@warn "List index is #{$index} but list is only #{list.length($list)} item long for `remove-nth`.";
|
|
60
65
|
} @else {
|
|
61
66
|
$result: ();
|
|
62
|
-
$index: if($index < 0
|
|
67
|
+
$index: if(sass($index < 0): list.length($list) + $index + 1; else: $index);
|
|
63
68
|
|
|
64
|
-
@for $i from 1 through length($list) {
|
|
69
|
+
@for $i from 1 through list.length($list) {
|
|
65
70
|
@if $i != $index {
|
|
66
|
-
$result: append($result, nth($list, $i));
|
|
71
|
+
$result: list.append($result, list.nth($list, $i));
|
|
67
72
|
}
|
|
68
73
|
}
|
|
69
74
|
}
|
|
@@ -72,10 +77,10 @@ $breakpoints: () !default;
|
|
|
72
77
|
}
|
|
73
78
|
|
|
74
79
|
@function matchingRules($queries) {
|
|
75
|
-
$rule: (map
|
|
80
|
+
$rule: (map.get(list.nth($queries, 1), 'rule'));
|
|
76
81
|
|
|
77
82
|
@each $query in $queries {
|
|
78
|
-
@if($rule != map
|
|
83
|
+
@if($rule != map.get($query, 'rule')) {
|
|
79
84
|
@return false;
|
|
80
85
|
}
|
|
81
86
|
}
|
|
@@ -87,19 +92,19 @@ $breakpoints: () !default;
|
|
|
87
92
|
$condition: "";
|
|
88
93
|
$rule: null;
|
|
89
94
|
|
|
90
|
-
@for $i from 1 through length($queries) {
|
|
91
|
-
$query: nth($queries, $i);
|
|
95
|
+
@for $i from 1 through list.length($queries) {
|
|
96
|
+
$query: list.nth($queries, $i);
|
|
92
97
|
|
|
93
98
|
@if($i == 1) {
|
|
94
|
-
$rule: map
|
|
99
|
+
$rule: map.get($query, 'rule');
|
|
95
100
|
}
|
|
96
101
|
|
|
97
|
-
@if(map
|
|
102
|
+
@if(map.get($query, 'condition') != null) {
|
|
98
103
|
@if($i > 1) {
|
|
99
104
|
$condition: $condition + ", ";
|
|
100
105
|
}
|
|
101
106
|
|
|
102
|
-
$condition: $condition + map
|
|
107
|
+
$condition: $condition + map.get($query, "condition");
|
|
103
108
|
}
|
|
104
109
|
}
|
|
105
110
|
|
|
@@ -107,8 +112,8 @@ $breakpoints: () !default;
|
|
|
107
112
|
}
|
|
108
113
|
|
|
109
114
|
@mixin build($query) {
|
|
110
|
-
$rule: map
|
|
111
|
-
$condition: map
|
|
115
|
+
$rule: map.get($query, 'rule');
|
|
116
|
+
$condition: map.get($query, 'condition');
|
|
112
117
|
|
|
113
118
|
@if($rule == '@media') {
|
|
114
119
|
@media #{$condition} {
|
|
@@ -150,8 +155,8 @@ $breakpoints: () !default;
|
|
|
150
155
|
}
|
|
151
156
|
|
|
152
157
|
@mixin all($queries...) {
|
|
153
|
-
@if (length($queries) >= 1) {
|
|
154
|
-
$query: nth($queries, 1);
|
|
158
|
+
@if (list.length($queries) >= 1) {
|
|
159
|
+
$query: list.nth($queries, 1);
|
|
155
160
|
$queries: removeNth($queries, 1);
|
|
156
161
|
|
|
157
162
|
$query: parse(preset($query));
|
|
@@ -172,4 +177,4 @@ $breakpoints: () !default;
|
|
|
172
177
|
#{$property}: $value;
|
|
173
178
|
}
|
|
174
179
|
}
|
|
175
|
-
}
|
|
180
|
+
}
|