rw-elements-tools 1.3.4 → 1.3.6
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
CHANGED
|
@@ -1,13 +1,28 @@
|
|
|
1
|
-
const getOrderClasses = (orderByBreakpoint = {}, orderCustomByBreakpoint = {}) => {
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
const getOrderClasses = (orderByBreakpoint = {}, orderCustomByBreakpoint = {}, breakpointNames = []) => {
|
|
2
|
+
const allBreakpoints = ["base", ...breakpointNames];
|
|
3
|
+
|
|
4
|
+
// Find custom value by cascading back through previous breakpoints
|
|
5
|
+
const getCustomValue = (currentBreakpoint) => {
|
|
6
|
+
const currentIndex = allBreakpoints.indexOf(currentBreakpoint);
|
|
7
|
+
for (let i = currentIndex; i >= 0; i--) {
|
|
8
|
+
const bp = allBreakpoints[i];
|
|
9
|
+
if (orderCustomByBreakpoint[bp] !== undefined) {
|
|
10
|
+
return orderCustomByBreakpoint[bp];
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
return undefined;
|
|
14
|
+
};
|
|
15
|
+
|
|
16
|
+
return allBreakpoints
|
|
17
|
+
.filter(bp => orderByBreakpoint[bp] !== undefined)
|
|
18
|
+
.map((breakpoint) => {
|
|
19
|
+
const value = orderByBreakpoint[breakpoint];
|
|
4
20
|
const prefix = breakpoint === "base" ? "" : `${breakpoint}:`;
|
|
5
|
-
const orderValue = value === "
|
|
6
|
-
?
|
|
7
|
-
: value
|
|
8
|
-
return
|
|
21
|
+
const orderValue = value === "custom"
|
|
22
|
+
? `order-[${getCustomValue(breakpoint)}]`
|
|
23
|
+
: `order-${value}`;
|
|
24
|
+
return `${prefix}${orderValue}`;
|
|
9
25
|
})
|
|
10
|
-
.filter(Boolean)
|
|
11
26
|
.join(" ");
|
|
12
27
|
};
|
|
13
28
|
|
|
@@ -41,6 +56,8 @@ const globalActAsGridOrFlexItem = (app) => {
|
|
|
41
56
|
globalGridOrFlexItemOrderCustom: orderCustomByBreakpoint,
|
|
42
57
|
} = app.responsiveProps;
|
|
43
58
|
|
|
59
|
+
const { names: breakpointNames } = app.theme.breakpoints;
|
|
60
|
+
|
|
44
61
|
if (displayAs == "default") {
|
|
45
62
|
return false;
|
|
46
63
|
}
|
|
@@ -56,7 +73,7 @@ const globalActAsGridOrFlexItem = (app) => {
|
|
|
56
73
|
shrink,
|
|
57
74
|
grow,
|
|
58
75
|
basis == "custom" ? basisCustom : basis,
|
|
59
|
-
getOrderClasses(orderByBreakpoint, orderCustomByBreakpoint)
|
|
76
|
+
getOrderClasses(orderByBreakpoint, orderCustomByBreakpoint, breakpointNames)
|
|
60
77
|
] : [])
|
|
61
78
|
);
|
|
62
79
|
}
|
|
@@ -72,7 +89,7 @@ const globalActAsGridOrFlexItem = (app) => {
|
|
|
72
89
|
rowEnd !== "row-end-auto" ? rowEnd : undefined,
|
|
73
90
|
alignSelf,
|
|
74
91
|
justifySelf,
|
|
75
|
-
getOrderClasses(orderByBreakpoint, orderCustomByBreakpoint)
|
|
92
|
+
getOrderClasses(orderByBreakpoint, orderCustomByBreakpoint, breakpointNames)
|
|
76
93
|
] : [])
|
|
77
94
|
);
|
|
78
95
|
}
|