@undp/create-app 0.2.12 → 0.2.14
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.
|
@@ -67,7 +67,59 @@ export default defineConfig({
|
|
|
67
67
|
const containerRules = [];
|
|
68
68
|
|
|
69
69
|
function extractMinWidth(params) {
|
|
70
|
-
|
|
70
|
+
let match = params.match(/min-width:\\s*([\\d.]+)(px|rem)/);
|
|
71
|
+
if (!match) {
|
|
72
|
+
match = params.match(/width\\s*>=\\s*([\\d.]+)(px|rem)/);
|
|
73
|
+
}
|
|
74
|
+
if (!match) return null;
|
|
75
|
+
|
|
76
|
+
const value = parseFloat(match[1]);
|
|
77
|
+
const unit = match[2];
|
|
78
|
+
return unit === 'rem' ? value * 16 : value;
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
root.walkAtRules(rule => {
|
|
82
|
+
if (rule.name !== 'media' && rule.name !== 'container') return;
|
|
83
|
+
|
|
84
|
+
const pxValue = extractMinWidth(rule.params);
|
|
85
|
+
if (pxValue === null) return;
|
|
86
|
+
|
|
87
|
+
const entry = {
|
|
88
|
+
pxValue,
|
|
89
|
+
rule: rule.clone(),
|
|
90
|
+
};
|
|
91
|
+
|
|
92
|
+
if (rule.name === 'media') {
|
|
93
|
+
mediaRules.push(entry);
|
|
94
|
+
} else {
|
|
95
|
+
containerRules.push(entry);
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
rule.remove();
|
|
99
|
+
});
|
|
100
|
+
|
|
101
|
+
// 1. Append media first
|
|
102
|
+
mediaRules
|
|
103
|
+
.sort((a, b) => a.pxValue - b.pxValue)
|
|
104
|
+
.forEach(({ rule }) => root.append(rule));
|
|
105
|
+
|
|
106
|
+
// 2. Append container after
|
|
107
|
+
containerRules
|
|
108
|
+
.sort((a, b) => a.pxValue - b.pxValue)
|
|
109
|
+
.forEach(({ rule }) => root.append(rule));
|
|
110
|
+
},
|
|
111
|
+
},` : `
|
|
112
|
+
{
|
|
113
|
+
postcssPlugin: 'move-responsive-queries',
|
|
114
|
+
OnceExit(root) {
|
|
115
|
+
const mediaRules = [];
|
|
116
|
+
const containerRules = [];
|
|
117
|
+
|
|
118
|
+
function extractMinWidth(params) {
|
|
119
|
+
let match = params.match(/min-width:\\s*([\\d.]+)(px|rem)/);
|
|
120
|
+
if (!match) {
|
|
121
|
+
match = params.match(/width\\s*>=\\s*([\\d.]+)(px|rem)/);
|
|
122
|
+
}
|
|
71
123
|
if (!match) return null;
|
|
72
124
|
|
|
73
125
|
const value = parseFloat(match[1]);
|
|
@@ -105,7 +157,8 @@ export default defineConfig({
|
|
|
105
157
|
.sort((a, b) => a.pxValue - b.pxValue)
|
|
106
158
|
.forEach(({ rule }) => root.append(rule));
|
|
107
159
|
},
|
|
108
|
-
},`
|
|
160
|
+
},`
|
|
161
|
+
}
|
|
109
162
|
],
|
|
110
163
|
},
|
|
111
164
|
},
|
package/bin/promptUser.js
CHANGED
|
@@ -81,7 +81,7 @@ export async function promptUser(name) {
|
|
|
81
81
|
type: 'list',
|
|
82
82
|
name: 'postCSS',
|
|
83
83
|
message: chalk.yellow(
|
|
84
|
-
'⚙️ Add PostCSS script to
|
|
84
|
+
'⚙️ Add PostCSS script to wrap all classes in `.undp-container` (recommended if embedding in another app)?'
|
|
85
85
|
),
|
|
86
86
|
choices: ['Yes', 'No'],
|
|
87
87
|
default: 'Yes',
|