@undp/create-app 0.2.12 → 0.2.13
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.
|
@@ -66,6 +66,55 @@ export default defineConfig({
|
|
|
66
66
|
const mediaRules = [];
|
|
67
67
|
const containerRules = [];
|
|
68
68
|
|
|
69
|
+
function extractMinWidth(params) {
|
|
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
|
+
|
|
69
118
|
function extractMinWidth(params) {
|
|
70
119
|
const match = params.match(/min-width:\s*([\d.]+)(px|rem)/);
|
|
71
120
|
if (!match) return null;
|
|
@@ -105,7 +154,8 @@ export default defineConfig({
|
|
|
105
154
|
.sort((a, b) => a.pxValue - b.pxValue)
|
|
106
155
|
.forEach(({ rule }) => root.append(rule));
|
|
107
156
|
},
|
|
108
|
-
},`
|
|
157
|
+
},`
|
|
158
|
+
}
|
|
109
159
|
],
|
|
110
160
|
},
|
|
111
161
|
},
|
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',
|