eddev 0.2.0-beta.11 → 0.2.0-beta.12
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/build/get-webpack-config.js +4 -1
- package/cli/cli.js +1 -1
- package/config/config-schema.d.ts +7 -22
- package/config/config-schema.js +1 -6
- package/config/get-config.d.ts +6 -15
- package/config/parse-config.d.ts +4 -10
- package/dev-ui/components/BreakpointItemHeader.d.ts +11 -0
- package/dev-ui/components/BreakpointItemHeader.js +50 -0
- package/dev-ui/components/BreakpointList.d.ts +6 -0
- package/dev-ui/components/BreakpointList.js +38 -0
- package/dev-ui/components/DevUI.d.ts +2 -0
- package/dev-ui/components/DevUI.js +19 -0
- package/dev-ui/components/Launcher.d.ts +9 -0
- package/dev-ui/components/Launcher.js +118 -0
- package/dev-ui/components/PanelWrapper.d.ts +4 -0
- package/dev-ui/components/PanelWrapper.js +21 -0
- package/dev-ui/components/Pill.d.ts +0 -0
- package/dev-ui/components/Pill.js +1 -0
- package/dev-ui/components/SpacingEditor.d.ts +2 -0
- package/dev-ui/components/SpacingEditor.js +10 -0
- package/dev-ui/components/Text.d.ts +39 -0
- package/dev-ui/components/Text.js +13 -0
- package/dev-ui/components/panels/SpacingEditor.d.ts +2 -0
- package/dev-ui/components/panels/SpacingEditor.js +56 -0
- package/dev-ui/hooks/usePersistState.d.ts +1 -0
- package/dev-ui/hooks/usePersistState.js +28 -0
- package/dev-ui/icons.d.ts +11 -0
- package/dev-ui/icons.js +25 -0
- package/dev-ui/index.d.ts +1 -0
- package/dev-ui/index.js +5 -0
- package/dev-ui/panels.d.ts +11 -0
- package/dev-ui/panels.js +31 -0
- package/dev-ui/theme.d.ts +135 -0
- package/dev-ui/theme.js +45 -0
- package/dynamic/dynamic-component.d.ts +0 -1
- package/entry/Root.js +6 -5
- package/package.json +1 -1
- package/serverless/create-rpc-client.d.ts +0 -1
- package/serverless-template/pages/_app.tsx +0 -2
- package/style/createStitches.d.ts +63 -2
- package/style/createStitches.js +182 -40
package/style/createStitches.js
CHANGED
|
@@ -11,7 +11,7 @@ var __assign = (this && this.__assign) || function () {
|
|
|
11
11
|
return __assign.apply(this, arguments);
|
|
12
12
|
};
|
|
13
13
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
14
|
-
exports.createStitches = void 0;
|
|
14
|
+
exports.createStitches = exports.getResponsiveObjectStyles = exports.parseResponsiveObject = exports.parseBreakpoints = void 0;
|
|
15
15
|
var react_1 = require("@stitches/react");
|
|
16
16
|
var typeKeyMap = {
|
|
17
17
|
fontSize: "fontSizes",
|
|
@@ -20,12 +20,14 @@ var typeKeyMap = {
|
|
|
20
20
|
letterSpacing: "letterSpacings",
|
|
21
21
|
fontWeight: "fontWeights",
|
|
22
22
|
};
|
|
23
|
-
function parseBreakpoints(medias) {
|
|
23
|
+
function parseBreakpoints(names, medias) {
|
|
24
24
|
var breakpoints = [];
|
|
25
25
|
// Add an initial breakpoint
|
|
26
26
|
breakpoints.push({ key: "initial", min: "0px", max: null });
|
|
27
27
|
// Parse each breakpoint
|
|
28
28
|
for (var key in medias) {
|
|
29
|
+
if (!names.includes(key))
|
|
30
|
+
continue;
|
|
29
31
|
var media = medias[key];
|
|
30
32
|
var minMatch = media.match(/min-width: ([0-9]+[a-z]+)/);
|
|
31
33
|
var maxMatch = media.match(/max-width: ([0-9]+[a-z]+)/);
|
|
@@ -51,6 +53,7 @@ function parseBreakpoints(medias) {
|
|
|
51
53
|
}
|
|
52
54
|
return breakpoints;
|
|
53
55
|
}
|
|
56
|
+
exports.parseBreakpoints = parseBreakpoints;
|
|
54
57
|
var unitless = function (value) { return parseFloat(value); };
|
|
55
58
|
function parseTypography(theme, breakpoints, typography) {
|
|
56
59
|
var globals = {};
|
|
@@ -151,47 +154,184 @@ function parseGrid(theme, media, grid) {
|
|
|
151
154
|
}
|
|
152
155
|
return { gridVariants: {}, globalGrid: globalGrid };
|
|
153
156
|
}
|
|
154
|
-
function
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
return
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
157
|
+
function parseResponsiveValue(val) {
|
|
158
|
+
if (Array.isArray(val)) {
|
|
159
|
+
return __assign(__assign({}, parseResponsiveValue(val[0])), { lerpStart: true });
|
|
160
|
+
}
|
|
161
|
+
else if (typeof val === "string") {
|
|
162
|
+
if (val.match(/^x[0-9\.]+$/)) {
|
|
163
|
+
return {
|
|
164
|
+
lerpStart: false,
|
|
165
|
+
type: "multiplier",
|
|
166
|
+
value: parseFloat(val.replace(/^x/, "")),
|
|
167
|
+
};
|
|
164
168
|
}
|
|
165
|
-
else {
|
|
166
|
-
return
|
|
169
|
+
else if (val.match(/^[0-9\.]+px$/)) {
|
|
170
|
+
return {
|
|
171
|
+
lerpStart: false,
|
|
172
|
+
type: "px",
|
|
173
|
+
value: parseFloat(val.replace(/px$/, "")),
|
|
174
|
+
};
|
|
167
175
|
}
|
|
176
|
+
}
|
|
177
|
+
else if (typeof val === "number") {
|
|
178
|
+
return {
|
|
179
|
+
lerpStart: false,
|
|
180
|
+
type: "number",
|
|
181
|
+
value: val,
|
|
182
|
+
};
|
|
183
|
+
}
|
|
184
|
+
else if (val === undefined || val === null) {
|
|
185
|
+
return {
|
|
186
|
+
lerpStart: false,
|
|
187
|
+
type: "undefined",
|
|
188
|
+
};
|
|
189
|
+
}
|
|
190
|
+
return {
|
|
191
|
+
lerpStart: false,
|
|
192
|
+
type: "unknown",
|
|
193
|
+
value: val,
|
|
168
194
|
};
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
var
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
195
|
+
}
|
|
196
|
+
function parseResponsiveObject(breakpoints, object) {
|
|
197
|
+
// Breakpoint hash
|
|
198
|
+
var breakpointHash = {};
|
|
199
|
+
for (var _i = 0, breakpoints_1 = breakpoints; _i < breakpoints_1.length; _i++) {
|
|
200
|
+
var bp = breakpoints_1[_i];
|
|
201
|
+
breakpointHash[bp.key] = {
|
|
202
|
+
min: bp.min ? parseFloat(bp.min) : null,
|
|
203
|
+
max: bp.max ? parseFloat(bp.max) : null,
|
|
204
|
+
};
|
|
205
|
+
}
|
|
206
|
+
var result = [];
|
|
207
|
+
var lerpStart = "initial";
|
|
208
|
+
var lastDefined = "initial";
|
|
209
|
+
var concreteValues = {};
|
|
210
|
+
for (var _a = 0, breakpoints_2 = breakpoints; _a < breakpoints_2.length; _a++) {
|
|
211
|
+
var bp = breakpoints_2[_a];
|
|
212
|
+
var value = parseResponsiveValue(object["@" + bp.key]);
|
|
213
|
+
var defined = value.type !== "undefined";
|
|
214
|
+
var base = !defined || value.type === "multiplier" ? lastDefined : bp.key;
|
|
215
|
+
lerpStart = value.lerpStart ? bp.key : lerpStart && !defined ? lerpStart : null;
|
|
216
|
+
if (value.type === "px" || value.type === "number") {
|
|
217
|
+
concreteValues[bp.key] = value.value;
|
|
218
|
+
}
|
|
219
|
+
else if (value.type === "multiplier") {
|
|
220
|
+
concreteValues[bp.key] = value.value * concreteValues[base];
|
|
221
|
+
}
|
|
222
|
+
result.push(__assign(__assign({}, value), { defined: defined, breakpoint: bp.key, baseBreakpoint: base, lerping: lerpStart
|
|
223
|
+
? {
|
|
224
|
+
fromBP: lerpStart,
|
|
225
|
+
toBP: null,
|
|
226
|
+
minMedia: 0,
|
|
227
|
+
maxMedia: 0,
|
|
228
|
+
minValue: 0,
|
|
229
|
+
maxValue: 0,
|
|
230
|
+
}
|
|
231
|
+
: undefined, concreteValue: concreteValues[bp.key] }));
|
|
232
|
+
if (defined) {
|
|
233
|
+
lastDefined = bp.key;
|
|
234
|
+
}
|
|
235
|
+
}
|
|
236
|
+
var nextBreakpoints = [];
|
|
237
|
+
var lastBreakpoint = null;
|
|
238
|
+
for (var i = breakpoints.length - 1; i >= 0; i--) {
|
|
239
|
+
var bp = breakpoints[i];
|
|
240
|
+
nextBreakpoints[i] = lastBreakpoint;
|
|
241
|
+
if (result[i].defined) {
|
|
242
|
+
lastBreakpoint = bp.key;
|
|
243
|
+
}
|
|
244
|
+
}
|
|
245
|
+
console.log("Next BPs", nextBreakpoints);
|
|
246
|
+
result.forEach(function (item, i) {
|
|
247
|
+
if (item.lerping) {
|
|
248
|
+
item.lerping.toBP = nextBreakpoints[i];
|
|
190
249
|
}
|
|
191
|
-
globals[bpName][varName] = responsiveValue;
|
|
192
250
|
});
|
|
193
|
-
|
|
251
|
+
result.forEach(function (item, i) {
|
|
252
|
+
var lerp = item.lerping;
|
|
253
|
+
if (lerp) {
|
|
254
|
+
var fromBP = lerp.fromBP ? breakpointHash[lerp.fromBP] : null;
|
|
255
|
+
var toBP = lerp.toBP ? breakpointHash[lerp.toBP] : null;
|
|
256
|
+
if (!fromBP || fromBP.min === null) {
|
|
257
|
+
throw new Error("Cannot create responsive style for first breakpoint");
|
|
258
|
+
}
|
|
259
|
+
if (!toBP || toBP.min === null) {
|
|
260
|
+
throw new Error("Cannot create responsive style for last breakpoint");
|
|
261
|
+
}
|
|
262
|
+
lerp.minMedia = fromBP.min;
|
|
263
|
+
lerp.maxMedia = toBP.min;
|
|
264
|
+
lerp.minValue = item.concreteValue;
|
|
265
|
+
lerp.maxValue = result.find(function (o) { return o.breakpoint === lerp.toBP; }).concreteValue;
|
|
266
|
+
}
|
|
267
|
+
});
|
|
268
|
+
return result;
|
|
269
|
+
}
|
|
270
|
+
exports.parseResponsiveObject = parseResponsiveObject;
|
|
271
|
+
function getResponsiveObjectStyles(theme, breakpoints, object, varName, scale, unit) {
|
|
272
|
+
var _a, _b;
|
|
273
|
+
var _c;
|
|
274
|
+
if (unit === void 0) { unit = "px"; }
|
|
275
|
+
// Prescale object
|
|
276
|
+
object = __assign({}, object);
|
|
277
|
+
var parsed = parseResponsiveObject(breakpoints, object);
|
|
278
|
+
// console.log("Result", object, parsed)
|
|
279
|
+
var globals = {};
|
|
280
|
+
for (var _i = 0, parsed_1 = parsed; _i < parsed_1.length; _i++) {
|
|
281
|
+
var atom = parsed_1[_i];
|
|
282
|
+
if (atom.lerpStart && atom.lerping) {
|
|
283
|
+
var lerp = atom.lerping;
|
|
284
|
+
globals["@" + atom.breakpoint] = (_a = {},
|
|
285
|
+
_a[varName] = "calc(".concat(lerp.minValue).concat(unit, " + (100vw - ").concat(lerp.minMedia).concat(unit, ") / (").concat(lerp.maxMedia, " - ").concat(lerp.minMedia, ") * (").concat(lerp.maxValue, " - ").concat(lerp.minValue, "))"),
|
|
286
|
+
_a);
|
|
287
|
+
}
|
|
288
|
+
else if (atom.concreteValue) {
|
|
289
|
+
globals["@" + atom.breakpoint] = (_b = {},
|
|
290
|
+
_b[varName] = atom.concreteValue + unit,
|
|
291
|
+
_b);
|
|
292
|
+
}
|
|
293
|
+
}
|
|
294
|
+
// console.log("globals", globals)
|
|
295
|
+
// Util for grabbing the raw value of a token, for lerping
|
|
296
|
+
// const resolveValue = (value: any) => {
|
|
297
|
+
// if (typeof value === "string" && value.match(/^\$[a-z0-9\-\_]+$/) && scale) {
|
|
298
|
+
// // Single scale
|
|
299
|
+
// return theme[scale][value.replace("$", "")]
|
|
300
|
+
// } else if (typeof value === "number") {
|
|
301
|
+
// return value + "px"
|
|
302
|
+
// } else {
|
|
303
|
+
// return value
|
|
304
|
+
// }
|
|
305
|
+
// }
|
|
306
|
+
// const globals2: any = {}
|
|
307
|
+
// const initial: any = {}
|
|
308
|
+
// const entries = Object.entries(object)
|
|
309
|
+
// entries.forEach(([bpName, responsiveValue], i) => {
|
|
310
|
+
// globals2[bpName] = {}
|
|
311
|
+
// if (Array.isArray(responsiveValue)) {
|
|
312
|
+
// responsiveValue = responsiveValue[0]
|
|
313
|
+
// // An array in the format [value] signifies font locking between the current breakpoint and the next defined one
|
|
314
|
+
// const minSize = breakpoints.find((bp) => "@" + bp.key === bpName)?.min
|
|
315
|
+
// const nextBreakpoint = breakpoints.find((bp) => "@" + bp.key === entries[i + 1]?.[0])
|
|
316
|
+
// if (!nextBreakpoint)
|
|
317
|
+
// throw new Error(
|
|
318
|
+
// `Cannot create responsive '${varName}' at breakpoint '${bpName}', since it is the last-defined breakpoint. Your last size should be a string/number/token.`
|
|
319
|
+
// )
|
|
320
|
+
// const maxSize = nextBreakpoint.min
|
|
321
|
+
// let responsiveValue2 = (object as any)["@" + nextBreakpoint.key]
|
|
322
|
+
// if (Array.isArray(responsiveValue2)) responsiveValue2 = responsiveValue2[0]
|
|
323
|
+
// let size1 = resolveValue(responsiveValue)
|
|
324
|
+
// let size2 = resolveValue(responsiveValue2)
|
|
325
|
+
// responsiveValue = `calc(${size1} + (100vw - ${minSize}) / (${unitless(maxSize)} - ${unitless(
|
|
326
|
+
// minSize
|
|
327
|
+
// )}) * (${unitless(size2)} - ${unitless(size1)}))`
|
|
328
|
+
// }
|
|
329
|
+
// globals2[bpName][varName] = responsiveValue
|
|
330
|
+
// })
|
|
331
|
+
// console.log(globals, globals2)
|
|
332
|
+
return [globals, (_c = globals["@initial"]) === null || _c === void 0 ? void 0 : _c[varName]];
|
|
194
333
|
}
|
|
334
|
+
exports.getResponsiveObjectStyles = getResponsiveObjectStyles;
|
|
195
335
|
// parseResponsiveTokens({'@initial': blah, '@desktop': blah}, breakpoints, )
|
|
196
336
|
function parseResponsiveTokens(theme, breakpoints) {
|
|
197
337
|
var globalResponsive = {
|
|
@@ -204,7 +344,8 @@ function parseResponsiveTokens(theme, breakpoints) {
|
|
|
204
344
|
for (var key in theme[scale]) {
|
|
205
345
|
var val = theme[scale][key];
|
|
206
346
|
if (val && typeof val === "object") {
|
|
207
|
-
var _a =
|
|
347
|
+
var _a = getResponsiveObjectStyles(theme, breakpoints, val, "--" + scale + "-" + key, scale), tokenGlobals = _a[0], initial = _a[1];
|
|
348
|
+
console.log("TOKEN", tokenGlobals, initial);
|
|
208
349
|
for (var bp in tokenGlobals) {
|
|
209
350
|
globalResponsive[bp] = __assign(__assign({}, globalResponsive[bp]), tokenGlobals[bp]);
|
|
210
351
|
}
|
|
@@ -218,7 +359,8 @@ function parseResponsiveTokens(theme, breakpoints) {
|
|
|
218
359
|
return { initialResponsive: initialResponsive, globalResponsive: globalResponsive };
|
|
219
360
|
}
|
|
220
361
|
function createStitches(config) {
|
|
221
|
-
var breakpoints = parseBreakpoints(config.media);
|
|
362
|
+
var breakpoints = parseBreakpoints(config.breakpoints, config.media);
|
|
363
|
+
console.log("PARSED BREAKPOINTS", breakpoints);
|
|
222
364
|
var _a = parseTypography(config.theme, breakpoints, config.typography), typeVariants = _a.typeVariants, globalTypography = _a.globalTypography;
|
|
223
365
|
var _b = parseGrid(config.theme, config.media, config.grid), gridVariants = _b.gridVariants, globalGrid = _b.globalGrid;
|
|
224
366
|
var _c = parseResponsiveTokens(config.responsive, breakpoints), initialResponsive = _c.initialResponsive, globalResponsive = _c.globalResponsive;
|
|
@@ -309,6 +451,6 @@ function createStitches(config) {
|
|
|
309
451
|
});
|
|
310
452
|
stitches.globalCss(responsiveGlobals)();
|
|
311
453
|
var responsiveTokens = {};
|
|
312
|
-
return __assign(__assign({}, stitches), { typeVariants: typeVariants, gridVariants: gridVariants, responsiveTokens: responsiveTokens });
|
|
454
|
+
return __assign(__assign({}, stitches), { originalConfig: config, breakpoints: breakpoints, typeVariants: typeVariants, gridVariants: gridVariants, responsiveTokens: responsiveTokens, responsiveGlobals: responsiveGlobals });
|
|
313
455
|
}
|
|
314
456
|
exports.createStitches = createStitches;
|