@astryxdesign/cli 0.7.15 → 0.7.16-canary.g54dd64e
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/README.md +5 -3
- package/api/component/_adapter.d.mts +1 -1
- package/api/component/_adapter.mjs +28 -1
- package/api/doctor/_adapter.d.mts +17 -0
- package/api/doctor/_adapter.mjs +35 -0
- package/api/doctor/doctor.mjs +18 -4
- package/api/integration/pack-check.mjs +13 -7
- package/api/integration/validate-integration.mjs +1 -1
- package/api/theme/_adapter.d.mts +5 -2
- package/api/theme/_adapter.mjs +43 -12
- package/api/theme/build/build.d.mts +64 -27
- package/api/theme/build/build.mjs +341 -69
- package/api/theme/eject/eject.mjs +22 -1
- package/api/theme/template/template.d.mts +19 -0
- package/api/theme/template/template.mjs +102 -25
- package/api/theme/theme.type.d.mts +5 -1
- package/api/theme/theme.type.mjs +2 -1
- package/api/theme/themeBuild.doc.mjs +3 -3
- package/api/theme/themeEject.doc.mjs +1 -1
- package/api/theme/themeTemplate.doc.mjs +9 -3
- package/api/theme-edit/_adapter.d.mts +33 -0
- package/api/theme-edit/_adapter.mjs +208 -31
- package/api/theme-edit/_check.d.mts +38 -0
- package/api/theme-edit/_check.mjs +1326 -211
- package/api/theme-edit/_color.d.mts +2 -8
- package/api/theme-edit/_color.mjs +292 -219
- package/api/theme-edit/_compiler.d.mts +1 -0
- package/api/theme-edit/_compiler.mjs +20 -1
- package/api/theme-edit/_context.d.mts +29 -0
- package/api/theme-edit/_context.mjs +329 -30
- package/api/theme-edit/_css.d.mts +60 -1
- package/api/theme-edit/_css.mjs +404 -28
- package/api/theme-edit/_edit.d.mts +9 -0
- package/api/theme-edit/_edit.mjs +1025 -126
- package/api/theme-edit/_how-commands.d.mts +11 -26
- package/api/theme-edit/_how-commands.mjs +30 -2
- package/api/theme-edit/_how-question.d.mts +7 -0
- package/api/theme-edit/_how-question.mjs +1304 -176
- package/api/theme-edit/_how.mjs +144 -30
- package/api/theme-edit/_overview.mjs +2 -0
- package/api/theme-edit/_palette.d.mts +11 -0
- package/api/theme-edit/_palette.mjs +194 -65
- package/api/theme-edit/_parts.d.mts +16 -0
- package/api/theme-edit/_parts.mjs +59 -7
- package/api/theme-edit/_png.mjs +19 -14
- package/api/theme-edit/_preview-app.d.mts +3 -0
- package/api/theme-edit/_preview-app.mjs +843 -45
- package/api/theme-edit/_preview.d.mts +16 -3
- package/api/theme-edit/_preview.mjs +310 -29
- package/api/theme-edit/_project.d.mts +11 -0
- package/api/theme-edit/_project.mjs +46 -12
- package/api/theme-edit/_settings.d.mts +178 -5
- package/api/theme-edit/_settings.mjs +2035 -86
- package/api/theme-edit/_tables.d.mts +24 -0
- package/api/theme-edit/_tables.mjs +211 -149
- package/api/theme-edit/_vet.d.mts +42 -0
- package/api/theme-edit/_vet.mjs +144 -0
- package/api/theme-edit/theme-edit.type.d.mts +2 -1
- package/api/theme-edit/theme-edit.type.mjs +1 -1
- package/api/theme-edit/themeEditNew.doc.mjs +1 -1
- package/api/theme-edit/themeEditShow.doc.mjs +11 -3
- package/api/upgrade/registry/registry.mjs +6 -1
- package/assets/docs/tree/single-component.doc.mjs +11 -2
- package/assets/docs/tree/tokens-and-setup.doc.mjs +39 -3
- package/assets/docs.generated.json +2 -2
- package/assets/preview-app/next.config.mjs +7 -1
- package/assets/preview-app/package.json +1 -0
- package/assets/preview-app/src/app/globals.css +1 -0
- package/assets/self-audit.generated.json +1 -1
- package/assets/templates/blocks/components/Table/ColumnsVirtualizationHookUsage.doc.mjs +14 -0
- package/assets/templates/blocks/components/Table/ColumnsVirtualizationHookUsage.tsx +53 -0
- package/assets/templates/blocks/components/Table/InfiniteScrollHookUsage.doc.mjs +14 -0
- package/assets/templates/blocks/components/Table/InfiniteScrollHookUsage.tsx +33 -0
- package/assets/templates/components.generated.json +1 -1
- package/assets/templates/pages/dashboard/page.tsx +1 -1
- package/authoring/doctypes/_schema.d.mts +52 -5
- package/authoring/doctypes/_schema.mjs +62 -7
- package/authoring/doctypes/base/type.ts +10 -0
- package/authoring/doctypes/component/component.doc.mjs +1 -1
- package/authoring/doctypes/function/function.doc.mjs +6 -0
- package/authoring/doctypes/function/type.ts +3 -0
- package/authoring/doctypes/legacy.mjs +5 -1
- package/authoring/index.d.ts +1 -0
- package/clients/cli/build-id.generated.json +1 -1
- package/clients/cli/commands/doctor.doc.mjs +2 -2
- package/clients/cli/commands/experimental/theme.mjs +190 -37
- package/clients/cli/commands/experimental-theme-compile.doc.mjs +2 -2
- package/clients/cli/commands/experimental-theme-editor-new.doc.mjs +1 -1
- package/clients/cli/commands/experimental-theme-editor-show.doc.mjs +2 -2
- package/clients/cli/commands/experimental-theme-editor-undo.doc.mjs +1 -1
- package/clients/cli/commands/experimental-theme-editor.doc.mjs +1 -1
- package/clients/cli/commands/experimental-theme-eject.doc.mjs +1 -1
- package/clients/cli/commands/experimental-theme-template.doc.mjs +2 -2
- package/clients/cli/commands/theme-build.doc.mjs +2 -2
- package/clients/cli/commands/theme-eject.doc.mjs +1 -1
- package/clients/cli/commands/theme-template.doc.mjs +3 -1
- package/clients/cli/commands/theme.mjs +168 -45
- package/clients/cli/formatters/index.mjs +7 -4
- package/clients/cli/lib/cli-error.mjs +9 -3
- package/clients/cli/lib/component-format.mjs +27 -9
- package/clients/cli/lib/json-shim.mjs +40 -2
- package/clients/cli/manifest.generated.json +1 -1
- package/clients/cli/run.mjs +49 -0
- package/foundation/config/project.mjs +50 -14
- package/foundation/discovery/theme-discovery.d.mts +5 -1
- package/foundation/discovery/theme-discovery.mjs +24 -3
- package/foundation/fs/gather-cache.d.mts +9 -2
- package/foundation/fs/gather-cache.mjs +79 -15
- package/foundation/fs/paths.d.mts +31 -0
- package/foundation/fs/paths.mjs +43 -10
- package/foundation/render/host-exit.d.mts +8 -0
- package/foundation/render/host-exit.mjs +11 -0
- package/foundation/render/page-host.mjs +56 -10
- package/foundation/render/page-worker.mjs +14 -0
- package/foundation/render/render-page.mjs +37 -2
- package/foundation/response/error-codes.d.mts +2 -1
- package/foundation/response/error-codes.d.ts +1 -0
- package/foundation/response/error-codes.doc.mjs +5 -0
- package/foundation/response/error-codes.mjs +3 -0
- package/foundation/response/json.d.mts +15 -0
- package/foundation/response/json.mjs +52 -1
- package/foundation/response/response-types.doc.mjs +1 -1
- package/package.json +7 -6
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
* @position api/theme-edit — imported only by _how.mjs
|
|
10
10
|
*/
|
|
11
11
|
|
|
12
|
-
import {hex, parseColor, ratio} from './_color.mjs';
|
|
12
|
+
import {COLOR_NAMES, hex, parseColor, ratio} from './_color.mjs';
|
|
13
13
|
import {
|
|
14
14
|
DESIGN,
|
|
15
15
|
DIALS,
|
|
@@ -23,6 +23,7 @@ import {
|
|
|
23
23
|
COLOR_PROPS,
|
|
24
24
|
GROUPS,
|
|
25
25
|
isSystemFamily,
|
|
26
|
+
wordTable,
|
|
26
27
|
} from './_tables.mjs';
|
|
27
28
|
import {PALETTE_DIALS, isGraySeed, seedOf} from './_palette.mjs';
|
|
28
29
|
import {focusStateOf} from './_settings.mjs';
|
|
@@ -59,6 +60,7 @@ const TRANSLATE = /** @type {Array<[RegExp, string]>} */ (
|
|
|
59
60
|
'圆|丸く|丸い|둥글게|둥근',
|
|
60
61
|
'rounded',
|
|
61
62
|
],
|
|
63
|
+
['cuadrad[oa]s|carrés|eckige\\p{L}*', '四角|方形|네모', 'square'],
|
|
62
64
|
['esquinas?|coins|ecken|углы', '角', 'corners'],
|
|
63
65
|
[
|
|
64
66
|
'sombras?|ombres?|ombra|ombre|schatten|тен[ьи]|ظل',
|
|
@@ -136,25 +138,36 @@ const DESIGN_WORDS = [
|
|
|
136
138
|
];
|
|
137
139
|
|
|
138
140
|
/** Short forms people type, and the word each means. */
|
|
139
|
-
const SHORT =
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
141
|
+
const SHORT = wordTable(
|
|
142
|
+
/** @type {Record<string, string>} */ ({
|
|
143
|
+
btn: 'button',
|
|
144
|
+
btns: 'buttons',
|
|
145
|
+
bttn: 'button',
|
|
146
|
+
bttns: 'buttons',
|
|
147
|
+
brdr: 'border',
|
|
148
|
+
bdr: 'border',
|
|
149
|
+
hdr: 'header',
|
|
150
|
+
rad: 'radius',
|
|
151
|
+
dlg: 'dialog',
|
|
152
|
+
txt: 'text',
|
|
153
|
+
clr: 'color',
|
|
154
|
+
shdw: 'shadow',
|
|
155
|
+
squre: 'square',
|
|
156
|
+
sqaure: 'square',
|
|
157
|
+
suqare: 'square',
|
|
158
|
+
fnot: 'font',
|
|
159
|
+
fnt: 'font',
|
|
160
|
+
}),
|
|
161
|
+
);
|
|
155
162
|
|
|
156
163
|
/** Plain words that are never corrected, though one letter off a VOCAB word. */
|
|
157
164
|
const KEEP = new Set([
|
|
165
|
+
'selection',
|
|
166
|
+
'placeholder',
|
|
167
|
+
'cursor',
|
|
168
|
+
'tablets',
|
|
169
|
+
'mobile',
|
|
170
|
+
'printing',
|
|
158
171
|
'lines',
|
|
159
172
|
'block',
|
|
160
173
|
'blocks',
|
|
@@ -286,56 +299,60 @@ function grayStop(family, stop) {
|
|
|
286
299
|
}
|
|
287
300
|
|
|
288
301
|
/** Hues people name, as fills a part can take. */
|
|
289
|
-
const HUES =
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
302
|
+
const HUES = wordTable(
|
|
303
|
+
/** @type {Record<string, string>} */ ({
|
|
304
|
+
red: '#dc2626',
|
|
305
|
+
orange: '#f97316',
|
|
306
|
+
amber: '#f59e0b',
|
|
307
|
+
yellow: '#eab308',
|
|
308
|
+
lime: '#65a30d',
|
|
309
|
+
green: '#16a34a',
|
|
310
|
+
mint: '#34d399',
|
|
311
|
+
minty: '#34d399',
|
|
312
|
+
teal: '#0d9488',
|
|
313
|
+
cyan: '#0891b2',
|
|
314
|
+
blue: '#2563eb',
|
|
315
|
+
navy: '#1e3a8a',
|
|
316
|
+
indigo: '#4f46e5',
|
|
317
|
+
purple: '#7c3aed',
|
|
318
|
+
charcoal: '#333333',
|
|
319
|
+
violet: '#7c3aed',
|
|
320
|
+
pink: '#db2777',
|
|
321
|
+
magenta: '#c026d3',
|
|
322
|
+
brown: '#92400e',
|
|
323
|
+
gray: '#9ca3af',
|
|
324
|
+
grey: '#9ca3af',
|
|
325
|
+
black: '#000000',
|
|
326
|
+
white: '#ffffff',
|
|
327
|
+
cream: '#fef3c7',
|
|
328
|
+
beige: '#f5f5dc',
|
|
329
|
+
}),
|
|
330
|
+
);
|
|
316
331
|
/** A hue with light, pale or dark before it. */
|
|
317
|
-
const SHADED =
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
}
|
|
332
|
+
const SHADED = wordTable(
|
|
333
|
+
/** @type {Record<string, Record<string, string>>} */ ({
|
|
334
|
+
light: {
|
|
335
|
+
gray: '#e5e7eb',
|
|
336
|
+
grey: '#e5e7eb',
|
|
337
|
+
blue: '#dbeafe',
|
|
338
|
+
green: '#dcfce7',
|
|
339
|
+
red: '#fee2e2',
|
|
340
|
+
yellow: '#fef9c3',
|
|
341
|
+
purple: '#ede9fe',
|
|
342
|
+
pink: '#fce7f3',
|
|
343
|
+
orange: '#ffedd5',
|
|
344
|
+
},
|
|
345
|
+
pale: {gray: '#f3f4f6', grey: '#f3f4f6', blue: '#eff6ff', green: '#f0fdf4'},
|
|
346
|
+
dark: {
|
|
347
|
+
gray: '#374151',
|
|
348
|
+
grey: '#374151',
|
|
349
|
+
blue: '#1e40af',
|
|
350
|
+
green: '#166534',
|
|
351
|
+
red: '#991b1b',
|
|
352
|
+
purple: '#5b21b6',
|
|
353
|
+
},
|
|
354
|
+
}),
|
|
355
|
+
);
|
|
339
356
|
|
|
340
357
|
/** The color tokens a word for a color the theme uses names. */
|
|
341
358
|
const THEME_COLOR_WORDS = /** @type {Array<[RegExp, string, string]>} */ ([
|
|
@@ -626,6 +643,23 @@ const OVERRIDES = [
|
|
|
626
643
|
[/\bbody( text)?\b/, {on: 'body', role: 'body'}],
|
|
627
644
|
];
|
|
628
645
|
|
|
646
|
+
/**
|
|
647
|
+
* The part or group a plain word names, as how reads it (`checkboxes` is
|
|
648
|
+
* the checks group, `panels` the containers), or null.
|
|
649
|
+
* @param {string} word
|
|
650
|
+
* @returns {string | null}
|
|
651
|
+
*/
|
|
652
|
+
export function partForWord(word) {
|
|
653
|
+
const w = String(word ?? '')
|
|
654
|
+
.trim()
|
|
655
|
+
.toLowerCase();
|
|
656
|
+
if (!w) return null;
|
|
657
|
+
for (const [re, hit] of OVERRIDES)
|
|
658
|
+
if (/** @type {RegExp} */ (re).test(w))
|
|
659
|
+
return /** @type {{on: string}} */ (hit).on;
|
|
660
|
+
return null;
|
|
661
|
+
}
|
|
662
|
+
|
|
629
663
|
/**
|
|
630
664
|
* Target names in Core's catalog that are plain words a question uses for
|
|
631
665
|
* something else ("more padding", "align the text").
|
|
@@ -689,7 +723,18 @@ function partLexicon(ctx) {
|
|
|
689
723
|
.flatMap(key => [key, `${key}s`]),
|
|
690
724
|
]),
|
|
691
725
|
];
|
|
692
|
-
const lex = {
|
|
726
|
+
const lex = {
|
|
727
|
+
parts: [
|
|
728
|
+
...OVERRIDES,
|
|
729
|
+
...derived,
|
|
730
|
+
// "smaller labels on form fields": a field's label.
|
|
731
|
+
/** @type {[RegExp, PartRef]} */ ([
|
|
732
|
+
/(?<!\b(?:button|tab|badge|chip|nav|menu|link|checkbox|switch|radio)s? )\b(field |form |input )?labels?\b/,
|
|
733
|
+
{on: 'field-label'},
|
|
734
|
+
]),
|
|
735
|
+
],
|
|
736
|
+
vocab,
|
|
737
|
+
};
|
|
693
738
|
lexicons.set(project, lex);
|
|
694
739
|
return lex;
|
|
695
740
|
}
|
|
@@ -716,6 +761,8 @@ const STATE_WORDS = /** @type {Array<[RegExp, string]>} */ ([
|
|
|
716
761
|
[/\b(after i check|once checked|i check)\b/, 'checked'],
|
|
717
762
|
[/\b(picked|chosen|choose|pick)\b/, 'selected'],
|
|
718
763
|
[/\b(invalid|errors? state|has an error|with an error)\b/, 'invalid'],
|
|
764
|
+
[/\bvisited\b/, 'visited'],
|
|
765
|
+
[/\b(opened|expanded)\b/, 'open'],
|
|
719
766
|
// Words for states a part may not have: the answer says so.
|
|
720
767
|
[/\bread-?only\b/, 'readonly'],
|
|
721
768
|
[
|
|
@@ -796,6 +843,10 @@ function aspectsOf(text) {
|
|
|
796
843
|
if (/\bitalics?\b/.test(c)) add('italic');
|
|
797
844
|
if (
|
|
798
845
|
/\b(bold(er)?|unbold\w*|weight|heav(y|ier)|semibold)\b/.test(c) ||
|
|
846
|
+
// "body 16px regular": a weight word after a size.
|
|
847
|
+
/\b\d+(\.\d+)?(px|rem|em|pt) (regular|normal|medium)\b|\b(body|text|headings?) (regular|normal)$/.test(
|
|
848
|
+
c,
|
|
849
|
+
) ||
|
|
799
850
|
/\bthin(ner)? (body |button |heading |label )?(font|text|type|letters|headings?|labels?|copy)\b/.test(
|
|
800
851
|
c,
|
|
801
852
|
) ||
|
|
@@ -822,7 +873,7 @@ function aspectsOf(text) {
|
|
|
822
873
|
(/\b(bigger|larger|smaller)\b/.test(c) &&
|
|
823
874
|
/\b(text|font|headings?|titles?|h[1-6]|body)\b/.test(c)) ||
|
|
824
875
|
/\b\d+(px|rem) (text|font|labels?|type)\b/.test(c) ||
|
|
825
|
-
/\b(text|font|headings?|titles?|labels?|h[1-6])\s+\d+(\.\d+)?(px|rem|em|pt)\b/.test(
|
|
876
|
+
/\b(text|font|body|headings?|titles?|labels?|h[1-6])\s+\d+(\.\d+)?(px|rem|em|pt)\b/.test(
|
|
826
877
|
c,
|
|
827
878
|
) ||
|
|
828
879
|
/\b(text|font|type)( is)? (way |far |much )?too (small|tiny|big|large)\b|\btoo (small|tiny) to read\b/.test(
|
|
@@ -857,16 +908,18 @@ function aspectsOf(text) {
|
|
|
857
908
|
/\b(transitions?|animations?|animate[sd]?|fade[sd]? (in|out)|motion)\b/.test(
|
|
858
909
|
c,
|
|
859
910
|
) &&
|
|
860
|
-
/\b(fast(er)?|slow(er)?|quick(er)?|snappier|speed|duration|\d+m?s|off|no|none|disable|stop|remove)\b/.test(
|
|
911
|
+
(/\b(fast(er)?|slow(er)?|quick(er)?|snappier|speed|duration|\d+(\.\d+)?m?s|off|no|none|disable|stop|remove)\b/.test(
|
|
861
912
|
c,
|
|
862
|
-
)
|
|
913
|
+
) ||
|
|
914
|
+
/\bfade[sd]?[- ](in|out)\b/.test(c))
|
|
863
915
|
) {
|
|
864
916
|
a.splice(0, a.length);
|
|
865
917
|
add('motion');
|
|
866
918
|
return a;
|
|
867
919
|
}
|
|
868
920
|
if (
|
|
869
|
-
|
|
921
|
+
// Washed-out colors are a vibrancy ask, not an opacity one.
|
|
922
|
+
/\b(faded|fade|opacity|see-through|washed out(?! colou?rs?\b))\b/.test(c) ||
|
|
870
923
|
// A percent is an opacity only beside an opacity word, never inside a
|
|
871
924
|
// function or after a color ("#2563eb 0%" is a gradient stop).
|
|
872
925
|
(/\d+%/.test(withoutFunctions(c)) &&
|
|
@@ -985,7 +1038,7 @@ function clausesOf(q, partWords) {
|
|
|
985
1038
|
/\?/.test(text));
|
|
986
1039
|
const neg =
|
|
987
1040
|
!askedFor &&
|
|
988
|
-
/\b(no|not|nothing|none of|don'?t|do not|never|without|remove|removing|get rid of|lose|drop|ditch|nix|scrap|kill|none|shouldn'?t|should not|mustn'?t|turn off|turn (the|it|them) off|switch off|stop|unbold\w*|unround\w*|disable|(?:revert|undo|take back) (?:the|those|that|these|my|our|all)|(?:shadows?|borders?|underlines?|outlines?|gradients?|uppercase|caps) (?:off|out|gone))\b/.test(
|
|
1041
|
+
/\b(no|not|nothing|none of|don'?t|do not|never|avoid|without|remove|removing|get rid of|lose|drop|ditch|nix|scrap|kill|none|shouldn'?t|should not|mustn'?t|turn off|turn (the|it|them) off|switch off|stop|unbold\w*|unround\w*|disable|(?:revert|undo|take back) (?:the|those|that|these|my|our|all)|(?:shadows?|borders?|underlines?|outlines?|gradients?|uppercase|caps) (?:off|out|gone))\b/.test(
|
|
989
1042
|
negText
|
|
990
1043
|
.replace(/\bdisabled\b/g, ' ')
|
|
991
1044
|
// "not round enough" asks for more; "not so much" for less.
|
|
@@ -1004,7 +1057,7 @@ function clausesOf(q, partWords) {
|
|
|
1004
1057
|
? 'less'
|
|
1005
1058
|
: tooMore.test(text)
|
|
1006
1059
|
? 'more'
|
|
1007
|
-
: /\b(less|fewer|smaller|lower|reduce|softer|lighter|lighten|thinner|narrower|shorter|tight(en|er)?|dense(r)?|denser|compact|sharper|squarer|subtler|tone down|dimmer|halve|half|halved|least|minimum|min|minimal|barely|as little)\b|\bcut\b.*\bin half\b|\bx ?0?\.\d+\b|\b(knock|turn|dial|bring|tone)\b.*\bdown\b/.test(
|
|
1060
|
+
: /\b(less|fewer|smaller|lower|reduce|decrease|shrink|minimi[sz]e|scale down|trim|softer|lighter|lighten|thinner|narrower|shorter|tight(en|er)?|dense(r)?|denser|compact|sharper|squarer|subtler|tone down|dimmer|halve|half|halved|least|minimum|min|minimal|barely|as little)\b|\bcut\b.*\bin half\b|\bx ?0?\.\d+\b|\b(knock|turn|dial|bring|tone)\b.*\bdown\b/.test(
|
|
1008
1061
|
text,
|
|
1009
1062
|
)
|
|
1010
1063
|
? 'less'
|
|
@@ -1241,19 +1294,21 @@ const PLAIN_PROPERTIES = new Set([
|
|
|
1241
1294
|
]);
|
|
1242
1295
|
|
|
1243
1296
|
/** Words people write for a CSS property. */
|
|
1244
|
-
const PROPERTY_WORDS =
|
|
1245
|
-
|
|
1246
|
-
|
|
1247
|
-
|
|
1248
|
-
|
|
1249
|
-
|
|
1250
|
-
|
|
1251
|
-
|
|
1252
|
-
|
|
1253
|
-
|
|
1254
|
-
|
|
1255
|
-
|
|
1256
|
-
|
|
1297
|
+
const PROPERTY_WORDS = wordTable(
|
|
1298
|
+
/** @type {Record<string, string>} */ ({
|
|
1299
|
+
radius: 'border-radius',
|
|
1300
|
+
'min height': 'min-height',
|
|
1301
|
+
'max height': 'max-height',
|
|
1302
|
+
'min width': 'min-width',
|
|
1303
|
+
'max width': 'max-width',
|
|
1304
|
+
'line height': 'line-height',
|
|
1305
|
+
'letter spacing': 'letter-spacing',
|
|
1306
|
+
'font size': 'font-size',
|
|
1307
|
+
'font weight': 'font-weight',
|
|
1308
|
+
'border color': 'border-color',
|
|
1309
|
+
'border colour': 'border-color',
|
|
1310
|
+
}),
|
|
1311
|
+
);
|
|
1257
1312
|
|
|
1258
1313
|
/**
|
|
1259
1314
|
* The words of a value, with each function call kept whole, nested calls
|
|
@@ -1297,25 +1352,27 @@ function withoutFunctions(text) {
|
|
|
1297
1352
|
}
|
|
1298
1353
|
|
|
1299
1354
|
/** The settings each aspect names, for a reset; `*` matches a prefix. */
|
|
1300
|
-
const RESET_THINGS =
|
|
1301
|
-
|
|
1302
|
-
|
|
1303
|
-
|
|
1304
|
-
|
|
1305
|
-
|
|
1306
|
-
|
|
1307
|
-
|
|
1308
|
-
|
|
1309
|
-
|
|
1310
|
-
|
|
1311
|
-
|
|
1312
|
-
|
|
1313
|
-
|
|
1314
|
-
|
|
1315
|
-
|
|
1316
|
-
|
|
1317
|
-
|
|
1318
|
-
|
|
1355
|
+
const RESET_THINGS = wordTable(
|
|
1356
|
+
/** @type {Record<string, string[]>} */ ({
|
|
1357
|
+
corners: ['corners', 'border-radius', '--radius-*'],
|
|
1358
|
+
spacing: ['spacing', 'padding', 'gap', 'margin', '--spacing-*'],
|
|
1359
|
+
family: ['font', 'font-family', '--font-family-*'],
|
|
1360
|
+
background: ['background', 'background-color'],
|
|
1361
|
+
text: ['color', '--color-text-*'],
|
|
1362
|
+
shadow: ['box-shadow', 'surfaces', '--shadow-*'],
|
|
1363
|
+
border: [
|
|
1364
|
+
'border',
|
|
1365
|
+
'border-width',
|
|
1366
|
+
'border-color',
|
|
1367
|
+
'--border-width',
|
|
1368
|
+
'--color-border',
|
|
1369
|
+
],
|
|
1370
|
+
weight: ['headings', 'font-weight', '--text-body-weight'],
|
|
1371
|
+
fontsize: ['text-size', 'type', 'font-size'],
|
|
1372
|
+
leading: ['line-height', '--text-body-leading'],
|
|
1373
|
+
tracking: ['letter-spacing'],
|
|
1374
|
+
}),
|
|
1375
|
+
);
|
|
1319
1376
|
|
|
1320
1377
|
/** Words for a color the theme generates: the word, its dial, its token. */
|
|
1321
1378
|
const ROLE_DIALS = /** @type {Array<[RegExp, string, string]>} */ ([
|
|
@@ -1328,37 +1385,39 @@ const ROLE_DIALS = /** @type {Array<[RegExp, string, string]>} */ ([
|
|
|
1328
1385
|
]);
|
|
1329
1386
|
|
|
1330
1387
|
/** Number words, longest phrase first. */
|
|
1331
|
-
const NUMBER_WORDS =
|
|
1332
|
-
|
|
1333
|
-
|
|
1334
|
-
|
|
1335
|
-
|
|
1336
|
-
|
|
1337
|
-
|
|
1338
|
-
|
|
1339
|
-
|
|
1340
|
-
|
|
1341
|
-
|
|
1342
|
-
|
|
1343
|
-
|
|
1344
|
-
|
|
1345
|
-
|
|
1346
|
-
|
|
1347
|
-
|
|
1348
|
-
|
|
1349
|
-
|
|
1350
|
-
|
|
1351
|
-
|
|
1352
|
-
|
|
1353
|
-
|
|
1354
|
-
|
|
1355
|
-
|
|
1356
|
-
|
|
1357
|
-
|
|
1358
|
-
|
|
1359
|
-
|
|
1360
|
-
|
|
1361
|
-
|
|
1388
|
+
const NUMBER_WORDS = wordTable(
|
|
1389
|
+
/** @type {Record<string, number>} */ ({
|
|
1390
|
+
zero: 0,
|
|
1391
|
+
one: 1,
|
|
1392
|
+
two: 2,
|
|
1393
|
+
three: 3,
|
|
1394
|
+
four: 4,
|
|
1395
|
+
five: 5,
|
|
1396
|
+
six: 6,
|
|
1397
|
+
seven: 7,
|
|
1398
|
+
eight: 8,
|
|
1399
|
+
nine: 9,
|
|
1400
|
+
ten: 10,
|
|
1401
|
+
eleven: 11,
|
|
1402
|
+
twelve: 12,
|
|
1403
|
+
thirteen: 13,
|
|
1404
|
+
fourteen: 14,
|
|
1405
|
+
fifteen: 15,
|
|
1406
|
+
sixteen: 16,
|
|
1407
|
+
seventeen: 17,
|
|
1408
|
+
eighteen: 18,
|
|
1409
|
+
nineteen: 19,
|
|
1410
|
+
twenty: 20,
|
|
1411
|
+
thirty: 30,
|
|
1412
|
+
forty: 40,
|
|
1413
|
+
fifty: 50,
|
|
1414
|
+
sixty: 60,
|
|
1415
|
+
seventy: 70,
|
|
1416
|
+
eighty: 80,
|
|
1417
|
+
ninety: 90,
|
|
1418
|
+
hundred: 100,
|
|
1419
|
+
}),
|
|
1420
|
+
);
|
|
1362
1421
|
const NUMBER_WORDS_RE = new RegExp(
|
|
1363
1422
|
`\\b(?:(?:one|a) and a half|half an?|an? quarter(?: of an?)?|an? half|(?:twenty|thirty|forty|fifty|sixty|seventy|eighty|ninety)[- ](?:one|two|three|four|five|six|seven|eight|nine)|${Object.keys(NUMBER_WORDS).join('|')})\\b(?=\\s*(?:-|\\s)?\\s*(?:px|pixels?|rem|em|pt|percent|%|radius|corners?|line height|times|x\\b|\\w+ (?:tall|wide|thick)|tall|wide|thick))`,
|
|
1364
1423
|
'gi',
|
|
@@ -1403,10 +1462,531 @@ export function draftAnswer(ctx, env, question) {
|
|
|
1403
1462
|
const TARGET = ctx.project.target;
|
|
1404
1463
|
const TOKENS = ctx.project.core.tokenDefaults;
|
|
1405
1464
|
const lex = partLexicon(ctx);
|
|
1465
|
+
// "corners NaNpx": not a number; never a guess. After a CSS property the
|
|
1466
|
+
// property's own check says why.
|
|
1467
|
+
const notNumber = /\b(nan|-?infinity)(px|rem|em|%)?(?![a-z])/i.exec(question);
|
|
1468
|
+
const afterProperty = notNumber
|
|
1469
|
+
? cssProperties().has(
|
|
1470
|
+
(
|
|
1471
|
+
/([a-z-]+)\s*:?\s*$/i.exec(question.slice(0, notNumber.index))?.[1] ??
|
|
1472
|
+
''
|
|
1473
|
+
).toLowerCase(),
|
|
1474
|
+
)
|
|
1475
|
+
: false;
|
|
1476
|
+
if (notNumber && !afterProperty)
|
|
1477
|
+
return {
|
|
1478
|
+
parts: [],
|
|
1479
|
+
aspects: [],
|
|
1480
|
+
drafts: [
|
|
1481
|
+
{
|
|
1482
|
+
text: `${notNumber[0]} is not a number a theme can use; give a number, like 8px`,
|
|
1483
|
+
options: [],
|
|
1484
|
+
},
|
|
1485
|
+
],
|
|
1486
|
+
};
|
|
1487
|
+
// Sarcasm and dislike name the thing to drop: "enough with the shadows",
|
|
1488
|
+
// "nobody asked for borders", "who needs X", "shadows 👎".
|
|
1489
|
+
question = question
|
|
1490
|
+
.replace(/\b([a-z]+) (?:👎|❌)/gi, 'no $1')
|
|
1491
|
+
.replace(/(?:👎|❌)\s*([a-z]+)/gi, 'no $1')
|
|
1492
|
+
.replace(
|
|
1493
|
+
/\b(?:enough with|quit with|nobody asked for|no one asked for|who needs|get rid of all|(?:i )?loathe) (?:the |all the |these |those )?/gi,
|
|
1494
|
+
'no ',
|
|
1495
|
+
)
|
|
1496
|
+
.replace(/^\s*([a-z][a-z -]*?)\s*(?:👎|:-?\(|:thumbsdown:)\s*$/i, 'no $1')
|
|
1497
|
+
// "too dark, I hate it": the description is the ask.
|
|
1498
|
+
.replace(
|
|
1499
|
+
/[,.;!]?\s*(?:i )?(?:hate|dislike|can'?t stand) (?:it|this|that)\b[.!]*/gi,
|
|
1500
|
+
'',
|
|
1501
|
+
);
|
|
1502
|
+
// The gate works per clause: a clause that is a question, a "tell me",
|
|
1503
|
+
// a "stop …" or a "don't touch …" blocks only itself; the other clauses
|
|
1504
|
+
// are read, with the parts the blocked clause names.
|
|
1505
|
+
const GATE =
|
|
1506
|
+
/\b(tell me|explain|what does|how does|but not too|stop (making|turning|being|using)|don'?t (touch|change)(?! (the )?(dark|light) mode)|leave (?!(?:the )?(?:dark|light) mode)[a-z ]+ alone|who made|just what i wanted|eyes hurt|is a great)\b|^\s*(yeah|oh sure|sure|great|wow)\b|,\s*nice[.!]*\s*$/i;
|
|
1507
|
+
const QUESTION_CLAUSE =
|
|
1508
|
+
/^\s*(?!(?:can|could|would|will) you\b|why (?:are|is|aren'?t|isn'?t)\b[^?]*\bnot\b|why not\b|why don'?t (?:we|you)\b|what about\b|what if\b|how about\b|is it possible\b|is there a way\b|can we\b|could we\b)(what|whats|what's|which|why|where|who|when|is|are|does|do|did|can|could|should|will)\b[^?]*\?+!*\s*$|^\s*(?!why not\b|why don'?t (?:we|you)\b|what about\b|what if\b|why (?:are|is|aren'?t|isn'?t)\b[^?]*\bnot\b)(what|whats|what's|which|why|where)\b|^\s*(?!is it possible\b|is there a way\b)(are|is|does|did|would|should) (my|the|it|this|these|those|our|there|a|an|square|round|rounder|bigger|smaller|darker|lighter)\b/i;
|
|
1509
|
+
// "if you can", "if possible": politeness, not a condition. "no fewer
|
|
1510
|
+
// than 2px": a limit, the number.
|
|
1511
|
+
question = question
|
|
1512
|
+
.replace(
|
|
1513
|
+
/\b(?:if (?:you can|possible|you could|you don'?t mind|it'?s not too much trouble|it is not too much trouble)|when you get a chance)\b[,]?\s*/gi,
|
|
1514
|
+
'',
|
|
1515
|
+
)
|
|
1516
|
+
.replace(/\bno (?:less|fewer) than\s+(?=\d)/gi, '');
|
|
1517
|
+
// "dark page #0b0b0f", "dark.page=#…", "dark page: #…": the mode word
|
|
1518
|
+
// scopes the color. "dark mode only: accent #…" is that mode, not a
|
|
1519
|
+
// dark-only theme. Vocabulary that names a direction: nuke/kill/zap =
|
|
1520
|
+
// remove, sharpen = sharper, zero out = 0, flatten = flat, X++ / X-- =
|
|
1521
|
+
// more / less X, "X: off|none" = no X.
|
|
1522
|
+
question = question
|
|
1523
|
+
.replace(
|
|
1524
|
+
/\b(dark|light)[. ](page|background|body)( colou?r)?\s*[:=]?\s*(#[0-9a-f]{3,8})\b/gi,
|
|
1525
|
+
'$2 $4 in $1 mode',
|
|
1526
|
+
)
|
|
1527
|
+
.replace(/^\s*(dark|light) mode only\s*:\s*/i, 'in $1 mode: ')
|
|
1528
|
+
// "I need: 1. accent red 2. pill badges": inline list numbers are breaks,
|
|
1529
|
+
// not values.
|
|
1530
|
+
.replace(/(?:^|\s)\d{1,2}[.)]\s+(?=[a-z#])/gi, m =>
|
|
1531
|
+
(question.match(/(?:^|\s)\d{1,2}[.)]\s+[a-z#]/gi) ?? []).length >= 2
|
|
1532
|
+
? '; '
|
|
1533
|
+
: m,
|
|
1534
|
+
)
|
|
1535
|
+
// "only when dark mode is on", "except in dark mode": the mode itself.
|
|
1536
|
+
.replace(
|
|
1537
|
+
/\b(?:only )?(?:when|while|whenever) (?:the )?(dark|light) mode is (?:on|active|enabled|used)\b/gi,
|
|
1538
|
+
'in $1 mode',
|
|
1539
|
+
)
|
|
1540
|
+
.replace(
|
|
1541
|
+
/\b(?:except|but not|not) (?:in |for |on )?dark(?: mode| theme)?\b(?! enough\b)|\b(?:don'?t|do not) (?:touch|change) (?:the )?dark mode\b|\b(?:leave|keep) (?:the )?dark mode (?:alone|as it is|as is|untouched)\b/gi,
|
|
1542
|
+
'in light mode',
|
|
1543
|
+
)
|
|
1544
|
+
.replace(
|
|
1545
|
+
/\b(?:except|but not|not) (?:in |for |on )?light(?: mode| theme)?\b(?! enough\b)|\b(?:don'?t|do not) (?:touch|change) (?:the )?light mode\b|\b(?:leave|keep) (?:the )?light mode (?:alone|as it is|as is|untouched)\b/gi,
|
|
1546
|
+
'in dark mode',
|
|
1547
|
+
)
|
|
1548
|
+
// Removal words in other languages and 🚫: none of it.
|
|
1549
|
+
.replace(/(?:🚫|⛔)\s*/gu, 'no ')
|
|
1550
|
+
.replace(
|
|
1551
|
+
/\b(?:rimuovi|togli|elimina|entferne|quita|retire)\b\s*(?:l'|la |le |il |lo |el |los |las |o |a |os |as |die |der |das |den )?/gi,
|
|
1552
|
+
'no ',
|
|
1553
|
+
)
|
|
1554
|
+
.replace(
|
|
1555
|
+
/\b(?:sans|sin|sem|ohne)\s+(?=(?:l'|la |le |el |o |a |den )?(?:ombres?|bordures?|sombras?|bordes?|bordas?|schatten|rand)\b)/gi,
|
|
1556
|
+
'no ',
|
|
1557
|
+
)
|
|
1558
|
+
// "those dialog shadows are heavy": too heavy, so lighter.
|
|
1559
|
+
.replace(
|
|
1560
|
+
/\b(?:are|is|look|looks|seem|seems) (?:so |very |way |kinda |pretty |quite )?(heavy|strong|harsh|loud|thick|dark|bright)\b/gi,
|
|
1561
|
+
'too $1',
|
|
1562
|
+
)
|
|
1563
|
+
.replace(/\b(dark|light)mode\b/gi, '$1 mode')
|
|
1564
|
+
.replace(/\b(?:nuke|kill|zap|axe)\b/gi, 'remove')
|
|
1565
|
+
.replace(
|
|
1566
|
+
/\bsharpen (?:the |all the |every |all )?([a-z]+)/gi,
|
|
1567
|
+
'make the $1 sharper',
|
|
1568
|
+
)
|
|
1569
|
+
.replace(/\bzero out (?:the )?([a-z ]+?)(?=$|[,;.])/gi, '$1 0')
|
|
1570
|
+
.replace(/\bflatten (?:the )?([a-z]+)/gi, 'make the $1 flat')
|
|
1571
|
+
.replace(/\b([a-z][a-z -]*?)\s*\+\+/gi, 'more $1')
|
|
1572
|
+
.replace(/\b([a-z][a-z -]*?)\s*--(?![a-z])/gi, 'less $1')
|
|
1573
|
+
.replace(/\b([a-z][a-z -]*?)\s*[:=]\s*(?:off|none|no)\b/gi, 'no $1');
|
|
1574
|
+
const segments = question
|
|
1575
|
+
.split(
|
|
1576
|
+
/\s*(?:,(?![^(]*\))|[;\n|]|\s[/+]\s(?![^(]*\))|\.{2,}|[.?!](?=\s)|\bjust\b|\bthen\b|\s[-\u2013\u2014]\s|\bstep \d+\b|\bbut\b(?= (?:make|set|change|use|give|turn|remove|add)\b)|(?<=\S)(?<!\b(?:don'?t|never|do not|not|to|please|and|you|we|i|let'?s|can|could|would|will))\s+(?=(?:make|set|change|give|turn) (?:it|them|the|my|this|that|those|these)\b)|(?<=\S)\s+(?=(?:do|does|will) \w+ (?:follow|match)\b))\s*/i,
|
|
1577
|
+
)
|
|
1578
|
+
.map(x => x.replace(/^\s*(?:[-*•]|\d+[.)])\s*/, ''))
|
|
1579
|
+
.filter(x => x.trim());
|
|
1580
|
+
// "drop shadow: x 0, y 4, …", "card shadow: 0 1px …, 0 2px …": a label
|
|
1581
|
+
// with its value is one clause, commas and all.
|
|
1582
|
+
if (
|
|
1583
|
+
/^\s*[a-z][\w -]{0,30}:\s*[^?]*$/i.test(question) &&
|
|
1584
|
+
!/\n/.test(question) &&
|
|
1585
|
+
!/;/.test(question)
|
|
1586
|
+
)
|
|
1587
|
+
segments.splice(0, segments.length, question);
|
|
1588
|
+
// A clause writes only when it reads as a direct ask: an imperative, a
|
|
1589
|
+
// request, or a thing with a value or a direction; a condition, an
|
|
1590
|
+
// indirect question, a double negative or a statement of fact gets the
|
|
1591
|
+
// lookup instead. A wrong write is worse than no command.
|
|
1592
|
+
const CONDITION =
|
|
1593
|
+
/^\s*(?:if|unless|in case|provided|providing|only if|assuming|suppose|supposing|as long as|whenever|as soon as|once|given|in the event|should (?:the|it|they)|were (?:the|it|they)|otherwise|on condition)\b|\b(?:except if|on condition that|in the event)\b/i;
|
|
1594
|
+
const NOT_ASK =
|
|
1595
|
+
/\b(i wonder|wondering|curious|would like to know|let me see|help me understand|any idea|just checking|just asking|check if|check whether|can you check|look at|double check|idk|quick q|do you think)\b|\b(don'?t not|not without|not un-?(?:bold|round|rounded|flat|square|styled)\w*|never no|no lighter|no darker|not at all|isn'?t it time|weren'?t)\b|^\s*(?!(?:can|could|would|will) (?:you|i|we)\b|can (?:the|my|our|all) [\w -]+ be\b|is it possible\b|is there a way\b)(?:do|does|did|will|would|can(?!'t|not)|could|should|is|are)\b(?!n'?t)|^\s*checking\b|\bno less (?!than)|^\s*(would|could|should|does|do|is|are|will)\b[^.]*\b(work|look|be (?:a )?(?:good|better|too much|ok|okay)|good|better|accessible|clash|too much)\b[^.]*\??$|\bor\b[^.]*\?\s*$|^\s*how (?:would|round|big|dark|light|thick)\b|\b(right now|rn)\b(?!.*\b(make|set|change)\b)/i;
|
|
1596
|
+
const ASK_START =
|
|
1597
|
+
/^\s*(?:please |pls |ok,? |okay,? |also |and |now |so |anyway,? )*(?:make|set|change|use|give|turn|add|remove|increase|decrease|lighten|darken|round|square|put|switch|swap|replace|drop|ditch|kill|hide|bump|reduce|raise|lower|tighten|loosen|shrink|grow|enlarge|boost|soften|sharpen|undo|revert|reset|restore|bring|go|keep|let'?s|try|apply|get rid|take|knock|cut|paint|colou?r|fill|flatten|thicken|widen|narrow|underline|bold|unbold|uppercase|lowercase|no|without|stop|don'?t|never|avoid|less|more|bigger|smaller|rounder|sharper|darker|lighter|softer|bolder|thinner|thicker|wider|tighter|looser)\b|^\s*(?:can|could|would|will) (?:you|i|we)\b|^\s*can (?:the|my|our|all) [\w -]+ be\b|^\s*(?:i|we) (?:want|need|'d like|would like)\b|^\s*(?:i'd|id) like\b|^\s*please\b/i;
|
|
1598
|
+
// Strict: a clause writes only when it positively reads as an ask:
|
|
1599
|
+
// (a) an imperative from a closed verb list, after an optional politeness
|
|
1600
|
+
// prefix; (b) an assignment of a known thing ("<thing> <value>",
|
|
1601
|
+
// "<thing>: <value>"); (c) a bare comparative or style word with a part
|
|
1602
|
+
// ("rounder buttons", "serif headings"). Anything else is held back.
|
|
1603
|
+
const VETO =
|
|
1604
|
+
/^(?:don'?t|doesn'?t|isn'?t|aren'?t|won'?t|wouldn'?t|can'?t|shouldn'?t)\s+(?:the |my |our )?[a-z]+\s+(?:get|have|use|look|be|need|seem)\b|\b(no idea|who knows|not sure|no reason not|can'?t not|isn'?t wrong|not unlike|not never|wouldn'?t say no|can'?t say|it'?s not that|nobody said|hardly|imagine|picture|pretend|hypothetically|in theory|one day|might|toying|consider|someday|maybe|perhaps)\b|\b(?:don'?t|never|no)\b[^,;.]*\bnot\b|\bnever without\b/i;
|
|
1605
|
+
const POLITE =
|
|
1606
|
+
/^\s*(?:(?:please|pls|kindly|ok(?:ay)?|also|and|now|so|anyway|alright|hey|hi|then)[,\s]+|(?:can|could|would|will) (?:you|we|i) (?:please )?|i'?d like (?:you )?to |i'?d like |i (?:want|need|prefer) (?:you )?(?:to )?|we'?d (?:like|prefer) |we (?:want|need|prefer) |hoping for |my request is |let'?s (?:go with )?|lets (?:go with )?|how (?:about|'bout) |what about |why not |why don'?t we (?:go with )?|go ahead and |mind making |you'?d better |you can |you forgot to |only |just |everything |lol |umm+ |ugh,? |quick one:? |(?:way|much|much much|slightly|a bit|a little|a smidge|just slightly|even|super|really|very) |when (?:hovering|hovered|pressed|clicked|focused|i hover|i click|i tab to)(?: (?:on|over|a|an|the) [a-z]+)? |(?:the |our |my )?(?:designer|pm|client|boss|users?|marketing|legal|design spec|style guide|mockup|brand) (?:wants?|needs?|requires?|prefers?|asked for|said:?|says:?) |please and thank you:? |thank you:? |thanks:? |in (?:dark|light) mode[:,]?\s*|(?:dark|light) mode[:,]\s*)+/i;
|
|
1607
|
+
const VERB =
|
|
1608
|
+
/^(?:crank up|fix|make|set|change|use|turn|add|remove|drop|kill|increase|decrease|raise|lower|lighten|darken|round|sharpen|square|flatten|soften|tighten|loosen|beef up|bump|boost|tone down|thicken|thin|bold|unbold|underline|hide|put|switch|swap|replace|ditch|reduce|shrink|trim|minimi[sz]e|scale down|grow|enlarge|widen|narrow|paint|colou?r|fill|undo|revert|reset|restore|bring|go back|keep|apply|try|get rid|take|knock|cut|stop|don'?t|do not|never|avoid|no|without|scale|move|space|pad|center|align|uppercase|lowercase|italicize|enable|disable|switch)\b/i;
|
|
1609
|
+
const THING =
|
|
1610
|
+
/^(?:the |my |our |all |every |all the )?(?:--[a-z][\w-]*|accent|brand|primary|secondary|danger|success|warning|info|corners?|radius|border-radius|spacing|padding|gap|margin|density|headings?|titles?|text(?:-size)?|font(?:s|-size|-family|-weight)?|body|page|background|bg|vibrancy|shadows?|borders?|outlines?|underlines?|links?|mode|leading|line[- ]height|letter[- ]spacing|tracking|weight|focus(?: ring| outline)?|colou?rs?)\b/i;
|
|
1611
|
+
const STYLE =
|
|
1612
|
+
/^(?:muted|pastel|subdued|duller|vivid|saturated|desaturated|vibrant|\d+(?:\.\d+)?(?:px|rem|em|%)?|underlined?|more|less|extra|rounder|sharper|squarer|square|round(?:ed)?|pill|flat|serif|sans(?:-serif)?|mono(?:space)?|bold(?:er)?|italic|uppercase|lowercase|compact|roomy|dense|airy|tight(?:er)?|loose(?:r)?|wide(?:r)?|thin(?:ner)?|thick(?:er)?|big(?:ger)?|small(?:er)?|large(?:r)?|tiny|huge|dark(?:er)?|light(?:er)?|bright(?:er)?|soft(?:er)?|heav(?:y|ier)|no|without|#[0-9a-f]{3,8}|red|orange|yellow|green|teal|cyan|blue|indigo|purple|violet|pink|rose|gray|grey|black|white|navy|crimson|maroon)\b/i;
|
|
1613
|
+
const COPULA =
|
|
1614
|
+
/\b(is|are|was|were|has|have|had|isn'?t|aren'?t|doesn'?t|did|does|truly)\b|\?/i;
|
|
1615
|
+
// Clauses that only scope or give a value ("in dark mode", "on hover",
|
|
1616
|
+
// "4px", "at least 44px") join the ask next to them.
|
|
1617
|
+
const NEUTRAL =
|
|
1618
|
+
/^\s*(?:below|above|under|over)\s+\d+(?:px|em|rem)\s*$|^\s*(?:on|for) (?:mobile|phones?|tablets?|desktops?|print)\s*$|^\s*when printing\s*$|^\s*(?:(?:in|on) (?:the )?(?:dark|light) mode )?#[0-9a-f]{3,8}(?: in (?:dark|light)(?: mode)?)?\s*$|^\s*(?:leave|keep) (?:the )?(?:dark|light) mode (?:alone|as is|as it is|untouched)\s*$|^\s*(?:only |just )?(?:(?:in|on|for|when|while) )?(?:(?:the )?(?:dark|light) mode|hover(?:ed|ing)?|focus(?:ed)?|press(?:ed)?|click(?:ed)?|selected|checked|disabled)(?: only)?\s*$|^\s*(?:at (?:least|most) |about |around |roughly |maybe )?(?:-?\d*\.?\d+(?:px|rem|em|%|ms|s)?|#[0-9a-f]{3,8})\s*$/i;
|
|
1619
|
+
const isAsk = (/** @type {string} */ x) => {
|
|
1620
|
+
if (NEUTRAL.test(x)) return true;
|
|
1621
|
+
// A bare CSS value ("0 8px 10px -6px rgb(0 0 0 / 0.1)") continues the
|
|
1622
|
+
// clause before it.
|
|
1623
|
+
const bare = x.replace(
|
|
1624
|
+
/^\s*(?:like|e\.?g\.?|say|maybe|about|around|roughly)\s+/i,
|
|
1625
|
+
'',
|
|
1626
|
+
);
|
|
1627
|
+
if (
|
|
1628
|
+
/\d/.test(bare) &&
|
|
1629
|
+
!/[a-z]{3,}/i.test(
|
|
1630
|
+
bare.replace(
|
|
1631
|
+
/\b(?:px|rem|em|rgba?|hsla?|oklch|oklab|var|calc|inset)\b|\([^)]*\)/gi,
|
|
1632
|
+
'',
|
|
1633
|
+
),
|
|
1634
|
+
)
|
|
1635
|
+
)
|
|
1636
|
+
return true;
|
|
1637
|
+
const low = x.toLowerCase().trim();
|
|
1638
|
+
// "card shadow: 0 1px 3px …", "Airbnb: accent #ff385c": a label and its
|
|
1639
|
+
// value; "setRadius(4)"; "shouldn't links be underlined?"; a question in
|
|
1640
|
+
// another language the editor translates.
|
|
1641
|
+
if (
|
|
1642
|
+
/^([a-z][\w -]{0,30}):\s*\S/.test(low) &&
|
|
1643
|
+
!/^(?:just )?(?:checking|question|quick q|q|fyi|todo|note|changes)\s*:|:\s*(?:are|is|do|does|what|which|how|why)\b/.test(
|
|
1644
|
+
low,
|
|
1645
|
+
) &&
|
|
1646
|
+
!NOT_ASK.test(low) &&
|
|
1647
|
+
!CONDITION.test(low) &&
|
|
1648
|
+
!VETO.test(low) &&
|
|
1649
|
+
!/\?\s*$/.test(low)
|
|
1650
|
+
)
|
|
1651
|
+
return true;
|
|
1652
|
+
if (/^set[a-z]*\(|^shouldn'?t\b[^?]*\?\s*$/.test(low)) return true;
|
|
1653
|
+
// "I set the accent to red by mistake", "does nothing visible".
|
|
1654
|
+
if (
|
|
1655
|
+
/\b(by mistake|by accident|accidentally|does nothing|do nothing)\b/.test(
|
|
1656
|
+
low,
|
|
1657
|
+
)
|
|
1658
|
+
)
|
|
1659
|
+
return true;
|
|
1660
|
+
if (
|
|
1661
|
+
/\b(schatten|karten|ecken|knöpfe|entfernen|pulsanti|arrotondat\w*|ombra|ombre|bordure|cartes|esquinas|redond\w*|botones|boutons|arrondi\w*|rouges?|bleus?|verts?|sombra|couleur|tarjetas|espacio|angoli|cantos|botões)\b/.test(
|
|
1662
|
+
low,
|
|
1663
|
+
)
|
|
1664
|
+
)
|
|
1665
|
+
return true;
|
|
1666
|
+
// "I hate the shadows", "I can barely see the borders", "the client
|
|
1667
|
+
// wants …": a wish or a complaint about a named thing.
|
|
1668
|
+
if (
|
|
1669
|
+
/^(?:i|we|they|the client|the designer|stakeholders?|users?|the night shift)\b[^?]*\b(hate|want|wants|need|needs|like|prefer|barely see|can'?t see|think|wish)\b(?! to know)/.test(
|
|
1670
|
+
low,
|
|
1671
|
+
) &&
|
|
1672
|
+
!VETO.test(low) &&
|
|
1673
|
+
!CONDITION.test(low) &&
|
|
1674
|
+
(aspectsOf(low).length > 0 ||
|
|
1675
|
+
lex.parts.some(([re]) => re.test(low)) ||
|
|
1676
|
+
/#[0-9a-f]{3,8}|\b(accent|colou?r|brand|grays?|font|purple|blue|red|green|orange|teal|pink|navy|black|white|yellow|violet)\b/.test(
|
|
1677
|
+
low,
|
|
1678
|
+
))
|
|
1679
|
+
)
|
|
1680
|
+
return true;
|
|
1681
|
+
// Typos are read as the words they are near ("accnet" is accent).
|
|
1682
|
+
const t0 = x
|
|
1683
|
+
.toLowerCase()
|
|
1684
|
+
.trim()
|
|
1685
|
+
.replace(/[a-z]+/g, w => corrected(w, lex.vocab));
|
|
1686
|
+
// "our brand color is #0055ff": a value given for the brand; pasted CSS
|
|
1687
|
+
// ("html.dark .card { … }"); "X should be/look Y".
|
|
1688
|
+
if (
|
|
1689
|
+
/^(?:our|my|the) brand colou?r is #[0-9a-f]{3,8}\b|\{[^}]*:|\bshould (?:be|look|have|get|use|match|feel)\b(?![^?]*\?)/.test(
|
|
1690
|
+
t0,
|
|
1691
|
+
) &&
|
|
1692
|
+
!CONDITION.test(t0) &&
|
|
1693
|
+
!VETO.test(t0)
|
|
1694
|
+
)
|
|
1695
|
+
return true;
|
|
1696
|
+
const raw = x.toLowerCase();
|
|
1697
|
+
if (
|
|
1698
|
+
[t0, raw].some(v => CONDITION.test(v) || NOT_ASK.test(v) || VETO.test(v))
|
|
1699
|
+
)
|
|
1700
|
+
return false;
|
|
1701
|
+
// Questions in a script how cannot read word by word keep their ask.
|
|
1702
|
+
if (/[^ -~]/.test(t0.replace(/[\u{1F000}-\u{1FFFF}\u2000-\u2BFF]/gu, '')))
|
|
1703
|
+
return true;
|
|
1704
|
+
if (
|
|
1705
|
+
VERB.test(
|
|
1706
|
+
raw
|
|
1707
|
+
.replace(POLITE, '')
|
|
1708
|
+
.replace(/^(?:the|my|our|all|every|a|an)\s+/, '')
|
|
1709
|
+
.trim(),
|
|
1710
|
+
)
|
|
1711
|
+
)
|
|
1712
|
+
return true;
|
|
1713
|
+
const t = t0
|
|
1714
|
+
.replace(POLITE, '')
|
|
1715
|
+
.replace(
|
|
1716
|
+
/^(?:the|my|our|all|every|all the|a|an|those|these|this|that)\s+/,
|
|
1717
|
+
'',
|
|
1718
|
+
)
|
|
1719
|
+
.trim();
|
|
1720
|
+
// "could the buttons be rounder", "can I get a serif font".
|
|
1721
|
+
if (
|
|
1722
|
+
/^(?:can|could) (?:the|my|our|all) [\w -]+ be\b|^(?:can|could) i (?:get|have)\b/.test(
|
|
1723
|
+
t0,
|
|
1724
|
+
)
|
|
1725
|
+
)
|
|
1726
|
+
return true;
|
|
1727
|
+
if (VERB.test(t)) return true;
|
|
1728
|
+
// "give buttons 8px corners": give a thing a value; "give me …" asks.
|
|
1729
|
+
if (/^give (?!me\b|us\b)/.test(t)) return true;
|
|
1730
|
+
const short = t.split(/\s+/).length <= 7;
|
|
1731
|
+
const part = lex.parts.some(([re]) => re.exec(t)?.index === 0);
|
|
1732
|
+
if ((THING.test(t) || part) && short && !COPULA.test(t)) return true;
|
|
1733
|
+
if (
|
|
1734
|
+
STYLE.test(t) &&
|
|
1735
|
+
short &&
|
|
1736
|
+
!COPULA.test(t) &&
|
|
1737
|
+
(THING.test(t.replace(STYLE, '').trim()) ||
|
|
1738
|
+
lex.parts.some(([re]) => re.test(t)) ||
|
|
1739
|
+
/\b(corners?|spacing|padding|shadows?|borders?|accent|headings?|text|font|page|background|colou?rs?|colou?rful|pastel|muted|subdued|vivid|saturated|washed out)\b/.test(
|
|
1740
|
+
t,
|
|
1741
|
+
))
|
|
1742
|
+
)
|
|
1743
|
+
return true;
|
|
1744
|
+
// "why are my headings not bold", "I hate the purple": asks.
|
|
1745
|
+
if (/^why (?:are|is|aren'?t|isn'?t)\b.*\bnot\b/.test(t)) return true;
|
|
1746
|
+
if (/^(?:i )?(?:hate|dislike|(?:am )?not a fan of|don'?t like)\b/.test(t))
|
|
1747
|
+
return true;
|
|
1748
|
+
// A description of the look wanted ("stronger shadow on dialogs",
|
|
1749
|
+
// "headings are 600 weight", "the page is white") names a thing and asks
|
|
1750
|
+
// nothing back: an ask. An info request ("show me …") is a lookup.
|
|
1751
|
+
if (
|
|
1752
|
+
!/\?|\b(isn'?t|aren'?t|doesn'?t|don'?t|won'?t|wouldn'?t|did|does|was|were|could|might|should)\b/.test(
|
|
1753
|
+
t,
|
|
1754
|
+
) &&
|
|
1755
|
+
!/^(?:i|we|you|it|this|that|there|they|(?:show|give|tell|remind|walk) (?:me|us))\b/.test(
|
|
1756
|
+
t,
|
|
1757
|
+
) &&
|
|
1758
|
+
(aspectsOf(t).length > 0 ||
|
|
1759
|
+
lex.parts.some(([re]) => re.test(t)) ||
|
|
1760
|
+
/\b(accent|contrast|neutrals?|grays?|greys?|colou?rs?|font|fonts|everywhere|error|danger|success|warning|info|purple|blue|red|green|orange|teal|pink|navy|black|white|yellow|violet)\b/.test(
|
|
1761
|
+
t,
|
|
1762
|
+
))
|
|
1763
|
+
)
|
|
1764
|
+
return true;
|
|
1765
|
+
return false;
|
|
1766
|
+
};
|
|
1767
|
+
// "don't touch the buttons", "leave the corners": an exclusion. It writes
|
|
1768
|
+
// nothing, and it gives nothing to the clause after it.
|
|
1769
|
+
const EXCLUDE =
|
|
1770
|
+
/^\s*(?:don'?t (?:touch|change)|do not (?:touch|change)|leave(?! (?:the )?(?:dark|light) mode\b)|keep (?:the )?[\w -]+ (?:alone|as is|as it is|unchanged|untouched|the same))\b/i;
|
|
1771
|
+
const blocked = (/** @type {string} */ x) =>
|
|
1772
|
+
EXCLUDE.test(x) ||
|
|
1773
|
+
(!/^\s*(?:please )?(?:can|could) (?:the|my|our|all) [\w -]+ be\b|^\s*(?:can|could) i (?:get|have)\b/i.test(
|
|
1774
|
+
x,
|
|
1775
|
+
) &&
|
|
1776
|
+
(GATE.test(x) ||
|
|
1777
|
+
(QUESTION_CLAUSE.test(x) && !ASK_START.test(x.toLowerCase())) ||
|
|
1778
|
+
!isAsk(x)));
|
|
1779
|
+
const gated = segments.filter(blocked);
|
|
1780
|
+
// A condition holds back the whole question: the ask depends on it.
|
|
1781
|
+
// Sarcasm makes every clause unsure, not only the one with the marker.
|
|
1782
|
+
const SARCASM =
|
|
1783
|
+
/^\s*(yeah|oh sure|sure|great|wow|oh great|brilliant|perfect|cool cool|amazing|thrilled|nothing says)\b|\bjust what i wanted\b|,\s*nice[.!]*\s*$|\bis a great\b|\bsaid no one\b|\btruly\b|🙃/iu;
|
|
1784
|
+
// A hypothetical anywhere makes every clause one.
|
|
1785
|
+
const HYPOTHETICAL =
|
|
1786
|
+
/\b(imagine|picture|pretend|hypothetically|in theory|toying with)\b/i;
|
|
1787
|
+
// A tag question ("corners are 10px, eh", "cards have a shadow, right?")
|
|
1788
|
+
// asks back about the whole line.
|
|
1789
|
+
const TAG =
|
|
1790
|
+
/^(?:eh|right|correct|yeah|huh|no|isn'?t it|aren'?t they|are they|is it|are we|do they|does it|ok|okay)\s*[?!.]*$/i;
|
|
1791
|
+
const gateAll =
|
|
1792
|
+
segments.some(x => TAG.test(x.trim())) ||
|
|
1793
|
+
SARCASM.test(question) ||
|
|
1794
|
+
HYPOTHETICAL.test(question) ||
|
|
1795
|
+
(gated.length > 0 && gated.length === segments.length) ||
|
|
1796
|
+
segments.some(x => CONDITION.test(x.replace(/^[^:]*:\s*/, '')));
|
|
1797
|
+
if (gated.length && !gateAll) {
|
|
1798
|
+
// A held-back clause gives the next clause what it names: its part, and
|
|
1799
|
+
// the thing a "them" or "it" there stands for.
|
|
1800
|
+
/** @type {string[]} */
|
|
1801
|
+
const kept = [];
|
|
1802
|
+
let carry = '';
|
|
1803
|
+
let carryPart = '';
|
|
1804
|
+
for (const x of segments) {
|
|
1805
|
+
if (gated.includes(x) && EXCLUDE.test(x)) {
|
|
1806
|
+
carry = '';
|
|
1807
|
+
carryPart = '';
|
|
1808
|
+
continue;
|
|
1809
|
+
}
|
|
1810
|
+
if (gated.includes(x)) {
|
|
1811
|
+
const part = [
|
|
1812
|
+
...lex.parts.map(([re]) => re.exec(x.toLowerCase())?.[0]),
|
|
1813
|
+
/\b(accent|brand|primary|secondary|danger|success|warning|info)\b/i.exec(
|
|
1814
|
+
x,
|
|
1815
|
+
)?.[0],
|
|
1816
|
+
].find(Boolean);
|
|
1817
|
+
const thing =
|
|
1818
|
+
/\b(borders?|shadows?|radius|corners|padding|spacing|gap|font|underlines?|background)\b/i.exec(
|
|
1819
|
+
x,
|
|
1820
|
+
)?.[0];
|
|
1821
|
+
carry = [part, thing].filter(Boolean).join(' ');
|
|
1822
|
+
carryPart = part ?? '';
|
|
1823
|
+
continue;
|
|
1824
|
+
}
|
|
1825
|
+
if (carry && /\b(them|it)\b/i.test(x))
|
|
1826
|
+
kept.push(x.replace(/\b(them|it)\b/i, carry));
|
|
1827
|
+
else if (carryPart) kept.push(carryPart, x);
|
|
1828
|
+
else kept.push(x);
|
|
1829
|
+
carry = '';
|
|
1830
|
+
carryPart = '';
|
|
1831
|
+
}
|
|
1832
|
+
if (carryPart) kept.push(carryPart);
|
|
1833
|
+
question = kept.filter(Boolean).join(', ');
|
|
1834
|
+
}
|
|
1406
1835
|
/** Family names written in quotes, kept as typed: qq<n>qq in the text. */
|
|
1407
1836
|
const quoted = /** @type {string[]} */ ([]);
|
|
1408
1837
|
let q = question
|
|
1409
1838
|
.normalize('NFKC')
|
|
1839
|
+
// "more muted", "pastel", "duller", "subdued": less vivid colors (free
|
|
1840
|
+
// words only: never inside a token name like --color-background-muted).
|
|
1841
|
+
.replace(
|
|
1842
|
+
/(?<![-\w])less (?:muted|pastel|dull|subdued)(?![-\w])/gi,
|
|
1843
|
+
'more saturated',
|
|
1844
|
+
)
|
|
1845
|
+
.replace(
|
|
1846
|
+
/(?<![-\w])(?:more )?(?:muted|pastel|duller|subdued|desaturated)(?![-\w])/gi,
|
|
1847
|
+
'less saturated',
|
|
1848
|
+
)
|
|
1849
|
+
// "less light", "less heavy", "less tight", "less thin": one step back on
|
|
1850
|
+
// the same aspect.
|
|
1851
|
+
.replace(
|
|
1852
|
+
/\bless (?:light|thin|skinny)\b(?= (?:headings?|titles?|text|fonts?|weight)|\s*$)/gi,
|
|
1853
|
+
'bolder',
|
|
1854
|
+
)
|
|
1855
|
+
.replace(
|
|
1856
|
+
/\b(headings?|titles?|text|fonts?) (?:a bit |slightly )?less (?:light|thin)\b/gi,
|
|
1857
|
+
'$1 bolder',
|
|
1858
|
+
)
|
|
1859
|
+
.replace(/\bless heavy\b/gi, 'less bold')
|
|
1860
|
+
.replace(/\bless tight\b/gi, 'wider letter spacing')
|
|
1861
|
+
// "too dark" asks for lighter, "too light" for darker.
|
|
1862
|
+
.replace(/\btoo dark\b(?! mode)/gi, 'lighter')
|
|
1863
|
+
.replace(/\btoo light(?: gray| grey)?\b(?! mode)/gi, 'darker')
|
|
1864
|
+
// "no big gaps": less room.
|
|
1865
|
+
.replace(
|
|
1866
|
+
/\bno (?:big|large|huge) (?:gaps|spaces|spacing)\b/gi,
|
|
1867
|
+
'less spacing',
|
|
1868
|
+
)
|
|
1869
|
+
// "too airy", "headings too thin", "not bright enough": the other way.
|
|
1870
|
+
.replace(
|
|
1871
|
+
/\btoo (airy|spacious|roomy|loose|spread out)\b/gi,
|
|
1872
|
+
'tighter spacing',
|
|
1873
|
+
)
|
|
1874
|
+
.replace(
|
|
1875
|
+
/\b(headings?|titles?|fonts?) (?:are |is |look |looks )?too (thin|light|weak)\b|\b(text|labels?) (?:are |is |looks? )?too (thin)\b/gi,
|
|
1876
|
+
(_, a, _b, t) => `${a ?? t} bolder`,
|
|
1877
|
+
)
|
|
1878
|
+
.replace(
|
|
1879
|
+
/\bnot (bright|dark|bold|round|big|light|soft|warm|cool) enough\b/gi,
|
|
1880
|
+
(_, w) =>
|
|
1881
|
+
`${{bright: 'brighter', dark: 'darker', bold: 'bolder', round: 'rounder', big: 'bigger', light: 'lighter', soft: 'softer', warm: 'warmer', cool: 'cooler'}[/** @type {'bright'} */ (w.toLowerCase())]}`,
|
|
1882
|
+
)
|
|
1883
|
+
// "change only light to violet": light mode, not a light-only theme.
|
|
1884
|
+
.replace(
|
|
1885
|
+
/\b(?:change |set |make )?only (light|dark)(?: mode)? (?=to\b)/gi,
|
|
1886
|
+
'in $1 mode change ',
|
|
1887
|
+
)
|
|
1888
|
+
// "links not underlined until hover": none, then underlined on hover.
|
|
1889
|
+
.replace(
|
|
1890
|
+
/\b([a-z]+) (?:are |is )?not underlined until (?:you )?hover\w*/gi,
|
|
1891
|
+
'$1 no underline; $1 underlined on hover',
|
|
1892
|
+
)
|
|
1893
|
+
// "3 pixels sharper": pixels are px.
|
|
1894
|
+
.replace(/(\d+(?:\.\d+)?)\s*pixels?\b/gi, '$1px')
|
|
1895
|
+
// "take 2px off", "remove 4px from": an amount down.
|
|
1896
|
+
.replace(
|
|
1897
|
+
/\b(?:take|knock|shave|cut)\s+(\d+(?:\.\d+)?(?:px|rem|em))\s+off\b/gi,
|
|
1898
|
+
'minus $1 off',
|
|
1899
|
+
)
|
|
1900
|
+
.replace(
|
|
1901
|
+
/\bremove\s+(\d+(?:\.\d+)?(?:px|rem|em))\s+(?=from\b)/gi,
|
|
1902
|
+
'minus $1 ',
|
|
1903
|
+
)
|
|
1904
|
+
// "darkmode", "html.dark .card", "@media (prefers-color-scheme: dark)".
|
|
1905
|
+
.replace(/\b(dark|light)mode\b/gi, '$1 mode')
|
|
1906
|
+
.replace(
|
|
1907
|
+
/@media\s*\(\s*prefers-color-scheme\s*:\s*(dark|light)\s*\)\s*\{/gi,
|
|
1908
|
+
'in $1 mode {',
|
|
1909
|
+
)
|
|
1910
|
+
.replace(
|
|
1911
|
+
/(?:\bhtml)?\.(dark|light)\s+(?=\.)|\[data-(?:theme|mode)=["']?(dark|light)["']?\]\s*/gi,
|
|
1912
|
+
(_, a, b) => `in ${a ?? b} mode `,
|
|
1913
|
+
)
|
|
1914
|
+
// "I hate the shadows", "skip the shadows", "not a fan of": none of it.
|
|
1915
|
+
// "I hate the shadows", "not a fan of the rounded buttons": none of it,
|
|
1916
|
+
// when that is the whole ask.
|
|
1917
|
+
.replace(
|
|
1918
|
+
/^\s*(?:i )?(?:hate|dislike|can'?t stand|don'?t like|am not a fan of|not a fan of|skip|ditch)(?: the)? ([^,.;?!]+?)[.!]?\s*$/i,
|
|
1919
|
+
'no $1',
|
|
1920
|
+
)
|
|
1921
|
+
// "pointer cursor on hover": the cursor, no state needed.
|
|
1922
|
+
.replace(
|
|
1923
|
+
/\bpointer cursor(?: on hover)?\b|\bcursor:?\s+pointer(?: on hover)?\b/gi,
|
|
1924
|
+
'cursor: pointer',
|
|
1925
|
+
)
|
|
1926
|
+
// "cards look flat": a complaint that asks for depth.
|
|
1927
|
+
.replace(
|
|
1928
|
+
/\b(look|looks|feel|feels|seem|seems) (?:too |so |very )?flat\b(?!.*\bshadow)/gi,
|
|
1929
|
+
'need more shadow',
|
|
1930
|
+
)
|
|
1931
|
+
// "darker while being clicked": the pressed state.
|
|
1932
|
+
.replace(
|
|
1933
|
+
/\b(darker|lighter) while being (clicked|pressed|tapped)\b/gi,
|
|
1934
|
+
'get $1 when clicked',
|
|
1935
|
+
)
|
|
1936
|
+
// "except in dark mode", "but not in dark mode", "leave dark mode alone":
|
|
1937
|
+
// the other mode.
|
|
1938
|
+
.replace(
|
|
1939
|
+
/\b(?:except|but not|not) (?:in |for |on )?dark(?: mode| theme)?\b(?! enough\b)|\b(?:leave|keep) dark mode (?:alone|as it is|as is|untouched)\b|\bdon'?t (?:touch|change) dark mode\b/gi,
|
|
1940
|
+
'in light mode',
|
|
1941
|
+
)
|
|
1942
|
+
.replace(
|
|
1943
|
+
/\b(?:except|but not|not) (?:in |for |on )?light(?: mode| theme)?\b(?! enough\b)|\b(?:leave|keep) light mode (?:alone|as it is|as is|untouched)\b|\bdon'?t (?:touch|change) light mode\b/gi,
|
|
1944
|
+
'in dark mode',
|
|
1945
|
+
)
|
|
1946
|
+
// "not pure black": a near-black; "not pure white": a near-white.
|
|
1947
|
+
.replace(/\bnot (?:pure |true |full )?black\b/gi, '#111111')
|
|
1948
|
+
.replace(/\bnot (?:pure |true |full )?white\b/gi, '#fafafa')
|
|
1949
|
+
// "dropdown shadow": the dropdown's menu, the part that floats.
|
|
1950
|
+
.replace(/\bdropdowns? (?=shadows?|elevation)/gi, 'dropdown-menu ')
|
|
1951
|
+
// "½rem": a fraction is a number.
|
|
1952
|
+
.replace(/(\d*)(?:½|1\u20442)/g, (_, n) => `${n ? Number(n) + 0.5 : '0.5'}`)
|
|
1953
|
+
.replace(
|
|
1954
|
+
/(\d*)(?:¼|1\u20444)/g,
|
|
1955
|
+
(_, n) => `${n ? Number(n) + 0.25 : '0.25'}`,
|
|
1956
|
+
)
|
|
1957
|
+
.replace(
|
|
1958
|
+
/(\d*)(?:¾|3\u20444)/g,
|
|
1959
|
+
(_, n) => `${n ? Number(n) + 0.75 : '0.75'}`,
|
|
1960
|
+
)
|
|
1961
|
+
// "radius sm", "setRadius(4)": the corner rungs and a number.
|
|
1962
|
+
.replace(/\bset-?radius\s*\(\s*(\d+(?:\.\d+)?)\s*\)/gi, 'corners $1px')
|
|
1963
|
+
.replace(
|
|
1964
|
+
/\b(?:radius|corners|rounded)[- ](xs|sm|md|lg|xl)\b/gi,
|
|
1965
|
+
(_, /** @type {string} */ r) =>
|
|
1966
|
+
`corners ${/** @type {Record<string, string>} */ ({xs: '4px', sm: '8px', md: '10px', lg: '12px', xl: '16px'})[r.toLowerCase()]}`,
|
|
1967
|
+
)
|
|
1968
|
+
// "midnight blue": the CSS named color.
|
|
1969
|
+
.replace(/\b([a-z]+) ([a-z]+)\b/gi, (m, a, b) =>
|
|
1970
|
+
COLOR_NAMES.includes(`${a}${b}`.toLowerCase()) &&
|
|
1971
|
+
!/^(dark|light)$/i.test(a)
|
|
1972
|
+
? `${a}${b}`.toLowerCase()
|
|
1973
|
+
: m,
|
|
1974
|
+
)
|
|
1975
|
+
// "translateY(-2px) on hover": a transform.
|
|
1976
|
+
.replace(
|
|
1977
|
+
/(?<!transform\s*:?\s*)\b((?:translate[xyz]?|scale[xy]?|rotate)\([^)]*\))/gi,
|
|
1978
|
+
(_, fn) => `transform: ${fn.toLowerCase()}`,
|
|
1979
|
+
)
|
|
1980
|
+
// "#22c55e in light, #4ade80 in dark": the accent, per mode.
|
|
1981
|
+
.replace(
|
|
1982
|
+
/^\s*(#[0-9a-f]{3,8}) in (light|dark)(?: mode)?\s*(,|and|;)\s*(#[0-9a-f]{3,8}) in (light|dark)(?: mode)?\s*$/i,
|
|
1983
|
+
'accent $1 in $2 mode$3 accent $4 in $5 mode',
|
|
1984
|
+
)
|
|
1985
|
+
// ".btn-primary { … }": the primary button.
|
|
1986
|
+
.replace(
|
|
1987
|
+
/\.btn-(primary|secondary|ghost|destructive|danger)\b/g,
|
|
1988
|
+
(_, v) => `${v === 'danger' ? 'destructive' : v} button `,
|
|
1989
|
+
)
|
|
1410
1990
|
// Markup and comment text are not part of the ask.
|
|
1411
1991
|
.replace(/<(script|style)\b[^>]*>[\s\S]*?<\/\1\s*>/gi, ' ')
|
|
1412
1992
|
.replace(/<\/?[a-z][^>]*>/gi, ' ')
|
|
@@ -1471,6 +2051,15 @@ export function draftAnswer(ctx, env, question) {
|
|
|
1471
2051
|
.replace(/\b(?:no|not) more than\s+|\bat most\s+|\bmax(?:imum)? of\s+/g, '')
|
|
1472
2052
|
// Numbers written as words are numbers.
|
|
1473
2053
|
.replace(NUMBER_WORDS_RE, m => numberWord(m))
|
|
2054
|
+
// "less black", "not so white": a direction away from that color.
|
|
2055
|
+
.replace(
|
|
2056
|
+
/\b(?:slightly |a bit |a little )?(?:less|not so|not as) (black|dark)\b/g,
|
|
2057
|
+
'lighter',
|
|
2058
|
+
)
|
|
2059
|
+
.replace(
|
|
2060
|
+
/\b(?:slightly |a bit |a little )?(?:less|not so|not as) (white|bright)\b/g,
|
|
2061
|
+
'dimmer',
|
|
2062
|
+
)
|
|
1474
2063
|
// "8 or so px", "about 8 px": the number.
|
|
1475
2064
|
.replace(/\b(\d+(?:\.\d+)?)\s+or so\s+(?=px|rem|em|pixels?)/g, '$1 ')
|
|
1476
2065
|
// "0.5 rem", "14 px": a number and its unit are one length.
|
|
@@ -1585,12 +2174,31 @@ export function draftAnswer(ctx, env, question) {
|
|
|
1585
2174
|
// "bordes redondeados": rounded edges are corners.
|
|
1586
2175
|
.replace(/\bborders?\s+rounded\b/g, 'rounded corners')
|
|
1587
2176
|
.replace(/\bbutton-s\b/g, 'buttons')
|
|
1588
|
-
.replace(/[a-z]+/g, w =>
|
|
2177
|
+
.replace(/[a-z]+/g, w => {
|
|
2178
|
+
const fixed = corrected(w, lex.vocab);
|
|
2179
|
+
return fixed;
|
|
2180
|
+
})
|
|
1589
2181
|
// "buttons, but not bold": the "not" is about the buttons.
|
|
1590
2182
|
.replace(
|
|
1591
2183
|
/,?\s*\bbut not\s+(?=(bold|italic|uppercase|rounded|round|shadowed|underlined|bordered|faded|dark|light|bright|big|small|too \w+)\b)/g,
|
|
1592
2184
|
' not ',
|
|
1593
2185
|
)
|
|
2186
|
+
// Tailwind classes: "border-2" is 2px, "rounded-full" a pill.
|
|
2187
|
+
.replace(/\bborder-(\d)\b/g, 'border width $1px')
|
|
2188
|
+
.replace(/\brounded-full\b/g, 'pill corners')
|
|
2189
|
+
.replace(/\brounded-none\b/g, 'square corners')
|
|
2190
|
+
// "1e3px" is 1000px.
|
|
2191
|
+
.replace(
|
|
2192
|
+
/\b(\d+(?:\.\d+)?)e([+-]?\d+)(px|rem|em)\b/gi,
|
|
2193
|
+
(_, n, e, u) => `${Number(n) * 10 ** Number(e)}${u}`,
|
|
2194
|
+
)
|
|
2195
|
+
// "not so round", "not that dark": one step less, not the opposite.
|
|
2196
|
+
.replace(
|
|
2197
|
+
/\bnot (?:so|that|as|too) (round(?:ed)?|bold|dark|big|bright|spacious|thick)\b/g,
|
|
2198
|
+
'less $1',
|
|
2199
|
+
)
|
|
2200
|
+
// "flat cards, not flat buttons": the second part stays as it is.
|
|
2201
|
+
.replace(/^(.*\b(\w{3,})\b.*?),\s*(?:but )?not \2 [a-z ]+$/, '$1')
|
|
1594
2202
|
.replace(/\b(everything|everywhere|all) but\b/g, '$1 except')
|
|
1595
2203
|
.replace(
|
|
1596
2204
|
/\b(apart from|other than|excluding|but not (on|in|for)|but not)\b/g,
|
|
@@ -1598,7 +2206,75 @@ export function draftAnswer(ctx, env, question) {
|
|
|
1598
2206
|
)
|
|
1599
2207
|
.replace(/\s+/g, ' ')
|
|
1600
2208
|
.trim();
|
|
2209
|
+
// "cramped on mobile": the editor has no media conditions; the rest of
|
|
2210
|
+
// the ask is answered, with a note.
|
|
2211
|
+
const MEDIA_RE = new RegExp(
|
|
2212
|
+
String.raw`(?<!\bno |\bnot )\b(?:below|above|under|over|wider than|narrower than)\s+(?:\d{3,}px|\d+em)\b|\b(?:screens?|viewports?|windows?) (?:below|above|under|over|less than|more than|wider than|narrower than)\s+\d+(?:px|em|rem)\b|\b(?:on|for) (?:mobile|phones?|tablets?|desktops?|touch(?: screens?)?|small screens?|large screens?|wide screens?|landscape|portrait)\b|\b(?:when )?print(?:ing)?\b|\b(?:the )?print version\b`,
|
|
2213
|
+
'g',
|
|
2214
|
+
);
|
|
2215
|
+
const media = MEDIA_RE.test(q);
|
|
2216
|
+
if (media) q = q.replace(MEDIA_RE, ' ').replace(/\s+/g, ' ').trim();
|
|
1601
2217
|
const clauses = clausesOf(q, lex.parts);
|
|
2218
|
+
// "checkboxes green": the color a checked box fills with.
|
|
2219
|
+
for (const c of clauses)
|
|
2220
|
+
if (
|
|
2221
|
+
c.parts.length === 1 &&
|
|
2222
|
+
c.parts[0].on === 'checks' &&
|
|
2223
|
+
c.colors.length &&
|
|
2224
|
+
!c.state &&
|
|
2225
|
+
!c.named &&
|
|
2226
|
+
!/\b(border|outline|background|unchecked)\b/.test(c.text)
|
|
2227
|
+
)
|
|
2228
|
+
c.state = 'checked';
|
|
2229
|
+
// "labels on form fields": the label, not the field it sits on.
|
|
2230
|
+
for (const c of clauses)
|
|
2231
|
+
if (c.parts.some(p => p.on === 'field-label')) {
|
|
2232
|
+
// A checkbox's or switch's own label part, when Core has one.
|
|
2233
|
+
const own = c.parts
|
|
2234
|
+
.map(p => ({
|
|
2235
|
+
on:
|
|
2236
|
+
/** @type {Record<string, string>} */ ({
|
|
2237
|
+
checks: 'checkbox-label',
|
|
2238
|
+
checkbox: 'checkbox-label',
|
|
2239
|
+
switch: 'switch-label',
|
|
2240
|
+
})[p.on] ?? p.on,
|
|
2241
|
+
}))
|
|
2242
|
+
.filter(
|
|
2243
|
+
p =>
|
|
2244
|
+
/-label$/.test(p.on) && p.on !== 'field-label' && TARGET.has(p.on),
|
|
2245
|
+
);
|
|
2246
|
+
// "button labels": the label is the button's own text.
|
|
2247
|
+
const owner = c.parts.filter(
|
|
2248
|
+
p =>
|
|
2249
|
+
p.on !== 'field-label' &&
|
|
2250
|
+
![
|
|
2251
|
+
'inputs',
|
|
2252
|
+
'field',
|
|
2253
|
+
'checks',
|
|
2254
|
+
'checkbox',
|
|
2255
|
+
'switch',
|
|
2256
|
+
'text-input',
|
|
2257
|
+
].includes(p.on),
|
|
2258
|
+
);
|
|
2259
|
+
c.parts = own.length
|
|
2260
|
+
? own
|
|
2261
|
+
: owner.length
|
|
2262
|
+
? owner
|
|
2263
|
+
: c.parts.filter(p => p.on === 'field-label');
|
|
2264
|
+
}
|
|
2265
|
+
// "captions 12px": a clause led by a plural noun that names no part and
|
|
2266
|
+
// no change takes nothing from its neighbors.
|
|
2267
|
+
const unknownLead = (/** @type {Clause} */ c) => {
|
|
2268
|
+
const lead = /^(?:the |my |our |all )?([a-z]{4,}s)\b/.exec(c.text)?.[1];
|
|
2269
|
+
return Boolean(
|
|
2270
|
+
lead &&
|
|
2271
|
+
!c.parts.length &&
|
|
2272
|
+
!lex.vocab.includes(lead) &&
|
|
2273
|
+
!lex.vocab.includes(singular(lead)) &&
|
|
2274
|
+
!aspectsOf(lead).length &&
|
|
2275
|
+
!KEEP.has(lead),
|
|
2276
|
+
);
|
|
2277
|
+
};
|
|
1602
2278
|
for (const c of clauses) {
|
|
1603
2279
|
c.quoted = [...c.text.matchAll(/qq(\d+)qq/g)].map(
|
|
1604
2280
|
m => quoted[Number(m[1])],
|
|
@@ -1705,6 +2381,8 @@ export function draftAnswer(ctx, env, question) {
|
|
|
1705
2381
|
c.dir &&
|
|
1706
2382
|
!c.aspects.length &&
|
|
1707
2383
|
!c.colors.length &&
|
|
2384
|
+
// "tooltips darker" is a color, never the border of the clause before.
|
|
2385
|
+
!/\b(dark|light|bright|dim)(er)?\b/.test(c.text) &&
|
|
1708
2386
|
prev.aspects.length
|
|
1709
2387
|
)
|
|
1710
2388
|
c.aspects = [...prev.aspects];
|
|
@@ -1974,6 +2652,7 @@ export function draftAnswer(ctx, env, question) {
|
|
|
1974
2652
|
!(ROLE_WORDS.test(c.text) && !c.aspects.length) &&
|
|
1975
2653
|
// "Circular font" after "12px cards" is the theme's font.
|
|
1976
2654
|
!(c.aspects.length && c.aspects.every(a => a === 'family')) &&
|
|
2655
|
+
!unknownLead(c) &&
|
|
1977
2656
|
// "serif headings, no shadows": a type part does not take a shadow,
|
|
1978
2657
|
// corner or border ask.
|
|
1979
2658
|
!(
|
|
@@ -1991,6 +2670,7 @@ export function draftAnswer(ctx, env, question) {
|
|
|
1991
2670
|
if (
|
|
1992
2671
|
!c.aspects.length &&
|
|
1993
2672
|
!ROLE_WORDS.test(c.text) &&
|
|
2673
|
+
!unknownLead(c) &&
|
|
1994
2674
|
(c.lengths.length || /\b(stay|keep)\b/.test(c.text))
|
|
1995
2675
|
) {
|
|
1996
2676
|
const from = prev?.aspects.length
|
|
@@ -1998,7 +2678,12 @@ export function draftAnswer(ctx, env, question) {
|
|
|
1998
2678
|
: next?.aspects.length
|
|
1999
2679
|
? next
|
|
2000
2680
|
: null;
|
|
2001
|
-
|
|
2681
|
+
// Only the aspects a length can set: "headings 32px bold, captions
|
|
2682
|
+
// 12px" gives captions a size, not the headings' bold.
|
|
2683
|
+
if (from)
|
|
2684
|
+
c.aspects = from.aspects.filter(
|
|
2685
|
+
a => !['weight', 'italic', 'case', 'family'].includes(a),
|
|
2686
|
+
);
|
|
2002
2687
|
}
|
|
2003
2688
|
// "in dark mode, cards are #1c1c1e": a clause that only names the mode
|
|
2004
2689
|
// gives it to the clauses after it.
|
|
@@ -2034,12 +2719,28 @@ export function draftAnswer(ctx, env, question) {
|
|
|
2034
2719
|
c.parts = [];
|
|
2035
2720
|
c.text = '';
|
|
2036
2721
|
}
|
|
2722
|
+
// "the same accent in light and dark": every mode, so no mode.
|
|
2723
|
+
if (
|
|
2724
|
+
/\b(light and dark|dark and light|both modes|every mode|all modes|same in (both|light and dark))\b/.test(
|
|
2725
|
+
q,
|
|
2726
|
+
)
|
|
2727
|
+
)
|
|
2728
|
+
for (const c of clauses) c.mode = null;
|
|
2037
2729
|
// "only in dark mode, …": a clause that only names a mode scopes every
|
|
2038
2730
|
// clause after it.
|
|
2039
2731
|
for (let i = 0; i < clauses.length; i++) {
|
|
2040
2732
|
const c = clauses[i];
|
|
2041
|
-
if (c.mode && !c.parts.length && !c.aspects.length && !c.colors.length)
|
|
2042
|
-
|
|
2733
|
+
if (c.mode && !c.parts.length && !c.aspects.length && !c.colors.length) {
|
|
2734
|
+
// "don't touch dark mode, …": the other mode.
|
|
2735
|
+
const scope = c.neg ? (c.mode === 'dark' ? 'light' : 'dark') : c.mode;
|
|
2736
|
+
for (const o of c.neg ? clauses : clauses.slice(i + 1))
|
|
2737
|
+
if (o !== c) o.mode ??= scope;
|
|
2738
|
+
if (c.neg) {
|
|
2739
|
+
for (const o of clauses)
|
|
2740
|
+
if (o !== c && o.mode === c.mode) o.mode = scope;
|
|
2741
|
+
c.text = '';
|
|
2742
|
+
}
|
|
2743
|
+
}
|
|
2043
2744
|
}
|
|
2044
2745
|
// The tab's text is on the tab, not on its underline.
|
|
2045
2746
|
for (const c of clauses)
|
|
@@ -2067,8 +2768,49 @@ export function draftAnswer(ctx, env, question) {
|
|
|
2067
2768
|
if (!aspectsSeen.includes(a)) aspectsSeen.push(a);
|
|
2068
2769
|
};
|
|
2069
2770
|
/** @param {string} token @param {'light' | 'dark'} [mode] */
|
|
2771
|
+
// The theme's own value (its settings applied), else the base theme's.
|
|
2070
2772
|
const current = (token, mode = 'light') =>
|
|
2071
|
-
env.
|
|
2773
|
+
env.own?.[mode]?.[token] ??
|
|
2774
|
+
env.base[mode]?.[token] ??
|
|
2775
|
+
String(TOKENS[token] ?? '');
|
|
2776
|
+
/**
|
|
2777
|
+
* What the theme itself sets for a CSS property on a part (its plain
|
|
2778
|
+
* setting: no variant, state or mode), so a change by an amount starts
|
|
2779
|
+
* from the theme, not from Core.
|
|
2780
|
+
* @param {string} on @param {string} prop
|
|
2781
|
+
*/
|
|
2782
|
+
const partValue = (on, prop) =>
|
|
2783
|
+
[...env.data.settings]
|
|
2784
|
+
.reverse()
|
|
2785
|
+
.find(
|
|
2786
|
+
st =>
|
|
2787
|
+
st.thing === prop &&
|
|
2788
|
+
st.on === on &&
|
|
2789
|
+
!st.when &&
|
|
2790
|
+
!st.state &&
|
|
2791
|
+
!st.mode,
|
|
2792
|
+
)?.value ?? null;
|
|
2793
|
+
/**
|
|
2794
|
+
* The theme's own whole-theme value for a dial (its last plain setting).
|
|
2795
|
+
* @param {string} thing
|
|
2796
|
+
*/
|
|
2797
|
+
const ownDial = thing =>
|
|
2798
|
+
[...env.data.settings]
|
|
2799
|
+
.reverse()
|
|
2800
|
+
.find(
|
|
2801
|
+
st => st.thing === thing && !st.on && !st.when && !st.state && !st.mode,
|
|
2802
|
+
)?.value ?? null;
|
|
2803
|
+
/**
|
|
2804
|
+
* The text-size a step takes from the theme's own size: a number moves by
|
|
2805
|
+
* the dial's step of 2px; a named size steps with more/less.
|
|
2806
|
+
* @param {'more' | 'less'} dir
|
|
2807
|
+
*/
|
|
2808
|
+
const textSizeStep = dir => {
|
|
2809
|
+
const own = ownDial('text-size');
|
|
2810
|
+
return own && /^\d+(\.\d+)?$/.test(own)
|
|
2811
|
+
? String(Number(own) + (dir === 'less' ? -2 : 2))
|
|
2812
|
+
: dir;
|
|
2813
|
+
};
|
|
2072
2814
|
/** The member a group's checks read. @param {string} on */
|
|
2073
2815
|
const one = on => (FAMILIES[on] ? FAMILIES[on][0] : on);
|
|
2074
2816
|
/**
|
|
@@ -2229,6 +2971,15 @@ export function draftAnswer(ctx, env, question) {
|
|
|
2229
2971
|
thing,
|
|
2230
2972
|
value,
|
|
2231
2973
|
...Object.fromEntries(Object.entries(flags).filter(([, v]) => v)),
|
|
2974
|
+
// One member of a group ("the text area") is that member only; set
|
|
2975
|
+
// otherwise reaches the whole group.
|
|
2976
|
+
// (set spreads only the inputs and checks groups).
|
|
2977
|
+
...(flags.on &&
|
|
2978
|
+
['inputs', 'checks'].some(g =>
|
|
2979
|
+
(FAMILIES[g] ?? []).includes(/** @type {string} */ (flags.on)),
|
|
2980
|
+
)
|
|
2981
|
+
? {only: true}
|
|
2982
|
+
: {}),
|
|
2232
2983
|
});
|
|
2233
2984
|
/** A color for the clause, for a fill or a text color. @param {Clause} c @param {'fill' | 'text'} kind */
|
|
2234
2985
|
const colorFor = (c, kind) => {
|
|
@@ -2399,6 +3150,234 @@ export function draftAnswer(ctx, env, question) {
|
|
|
2399
3150
|
continue;
|
|
2400
3151
|
}
|
|
2401
3152
|
}
|
|
3153
|
+
// "decrease the radius by 2px", "add 8px to the padding": a change from
|
|
3154
|
+
// the value now, never the new value itself.
|
|
3155
|
+
// "shrink headings by 20%": a change by a share, from the value now.
|
|
3156
|
+
const share = /\bby (\d+(?:\.\d+)?)%/.exec(c.text);
|
|
3157
|
+
if (
|
|
3158
|
+
share &&
|
|
3159
|
+
/\b(shrink|grow|increase|decrease|reduce|raise|lower|bigger|smaller|more|less)\b/.test(
|
|
3160
|
+
c.text,
|
|
3161
|
+
)
|
|
3162
|
+
) {
|
|
3163
|
+
push({
|
|
3164
|
+
text: `set takes the new value, not a change by ${share[1]}%; look up what it is now, then set that value ${/\b(shrink|decrease|reduce|lower|smaller|less)\b/.test(c.text) ? 'minus' : 'plus'} ${share[1]}%`,
|
|
3165
|
+
options: [],
|
|
3166
|
+
lookup: c.parts[0]
|
|
3167
|
+
? `${HOW} ${c.parts[0].on}`
|
|
3168
|
+
: `${P} show ${env.slug}`,
|
|
3169
|
+
});
|
|
3170
|
+
continue;
|
|
3171
|
+
}
|
|
3172
|
+
// "2px rounder", "8px larger", "4px wider": a change too.
|
|
3173
|
+
const COMPARATIVE =
|
|
3174
|
+
'more|less|bigger|smaller|rounder|sharper|squarer|larger|wider|narrower|taller|shorter|thicker|thinner|higher|lower|tighter|looser|roomier|airier|denser|bolder|heavier|lighter';
|
|
3175
|
+
// A weight moved by a number ("100 bolder"): set takes the new weight.
|
|
3176
|
+
const weightDelta = /\b(\d{2,3}) (bolder|heavier|lighter|thinner)\b/.exec(
|
|
3177
|
+
c.text,
|
|
3178
|
+
);
|
|
3179
|
+
if (weightDelta) {
|
|
3180
|
+
push({
|
|
3181
|
+
text: `set takes the new weight, not a change by ${weightDelta[1]}; look up the weight now, then set it ${/lighter|thinner/.test(weightDelta[2]) ? 'minus' : 'plus'} ${weightDelta[1]}`,
|
|
3182
|
+
options: [],
|
|
3183
|
+
lookup: c.parts[0]
|
|
3184
|
+
? `${HOW} ${c.parts[0].on}`
|
|
3185
|
+
: `${P} show ${env.slug}`,
|
|
3186
|
+
});
|
|
3187
|
+
continue;
|
|
3188
|
+
}
|
|
3189
|
+
// Amounts in rem or em count at a 16px root.
|
|
3190
|
+
const delta = new RegExp(
|
|
3191
|
+
`\\b(?:by|add(?:ing)?|plus|minus|subtract(?:ing)?)\\s+(\\d*\\.?\\d+)(px|rem|em)\\b|\\b(\\d*\\.?\\d+)(px|rem|em) (?:${COMPARATIVE})\\b`,
|
|
3192
|
+
).exec(c.text);
|
|
3193
|
+
if (
|
|
3194
|
+
delta &&
|
|
3195
|
+
new RegExp(
|
|
3196
|
+
`\\b(by|add|adding|plus|minus|subtract|subtracting|increase|decrease|reduce|${COMPARATIVE})\\b`,
|
|
3197
|
+
).test(c.text)
|
|
3198
|
+
) {
|
|
3199
|
+
const unit = delta[2] ?? delta[4];
|
|
3200
|
+
const n =
|
|
3201
|
+
Math.round(
|
|
3202
|
+
Number(delta[1] ?? delta[3]) * (unit === 'px' ? 1 : 16) * 100,
|
|
3203
|
+
) / 100;
|
|
3204
|
+
const down =
|
|
3205
|
+
/\b(decrease|reduce|less|smaller|minus|subtract|subtracting|lower|shrink|sharper|squarer|narrower|shorter|thinner|tighter|denser|lighter)\b/.test(
|
|
3206
|
+
c.text,
|
|
3207
|
+
);
|
|
3208
|
+
const cornerAsk =
|
|
3209
|
+
c.aspects.includes('corners') ||
|
|
3210
|
+
/\b(rounder|sharper|squarer)\b/.test(c.text);
|
|
3211
|
+
// A part's corners: its radius token, moved by the amount.
|
|
3212
|
+
if (cornerAsk && c.parts.length) {
|
|
3213
|
+
const on = c.parts[0].on;
|
|
3214
|
+
const read = C.partReads(one(on), 'corners')[0];
|
|
3215
|
+
// A radius the theme set on the part in px moves from that value.
|
|
3216
|
+
const ownRadius = partValue(on, 'border-radius');
|
|
3217
|
+
if (ownRadius && /^\d*\.?\d+px$/.test(ownRadius)) {
|
|
3218
|
+
const next = Math.max(0, parseFloat(ownRadius) + (down ? -n : n));
|
|
3219
|
+
const d = {
|
|
3220
|
+
text: `${on}'s corners ${down ? 'down' : 'up'} by ${n}px: from ${ownRadius} to ${next}px`,
|
|
3221
|
+
options: [[set('border-radius', `${next}px`, {on})]],
|
|
3222
|
+
};
|
|
3223
|
+
push(d);
|
|
3224
|
+
recordTop(c, d.options[0] ?? []);
|
|
3225
|
+
continue;
|
|
3226
|
+
}
|
|
3227
|
+
if (read) {
|
|
3228
|
+
const d = {
|
|
3229
|
+
text: `${on}'s corners ${down ? 'down' : 'up'} by ${n}px: ${read.token} ${down ? '-' : '+'} ${n}px`,
|
|
3230
|
+
options: [
|
|
3231
|
+
[
|
|
3232
|
+
set(
|
|
3233
|
+
'border-radius',
|
|
3234
|
+
`max(0px, calc(var(${read.token}) ${down ? '-' : '+'} ${n}px))`,
|
|
3235
|
+
{on},
|
|
3236
|
+
),
|
|
3237
|
+
],
|
|
3238
|
+
],
|
|
3239
|
+
};
|
|
3240
|
+
push(d);
|
|
3241
|
+
recordTop(c, d.options[0] ?? []);
|
|
3242
|
+
continue;
|
|
3243
|
+
}
|
|
3244
|
+
}
|
|
3245
|
+
if (cornerAsk && !c.parts.length) {
|
|
3246
|
+
const now = parseFloat(current('--radius-element'));
|
|
3247
|
+
const nowPx = /rem$/.test(current('--radius-element')) ? now * 16 : now;
|
|
3248
|
+
const next = Math.max(
|
|
3249
|
+
0,
|
|
3250
|
+
Math.round((nowPx + (down ? -n : n)) * 100) / 100,
|
|
3251
|
+
);
|
|
3252
|
+
const d = {
|
|
3253
|
+
text: `corners ${down ? 'down' : 'up'} by ${n}px: from ${Math.round(nowPx * 100) / 100}px to ${next}px`,
|
|
3254
|
+
options: [[set('corners', `${next}px`)]],
|
|
3255
|
+
};
|
|
3256
|
+
push(d);
|
|
3257
|
+
recordTop(c, d.options[0] ?? []);
|
|
3258
|
+
continue;
|
|
3259
|
+
}
|
|
3260
|
+
push({
|
|
3261
|
+
text: `set takes the new value, not a change by ${n}px; look up what it is now, then set it ${down ? 'minus' : 'plus'} ${n}px`,
|
|
3262
|
+
options: [],
|
|
3263
|
+
lookup: c.parts[0]
|
|
3264
|
+
? `${HOW} ${c.parts[0].on}`
|
|
3265
|
+
: `${P} show ${env.slug}`,
|
|
3266
|
+
});
|
|
3267
|
+
continue;
|
|
3268
|
+
}
|
|
3269
|
+
// "all corners like the buttons": every other radius token takes the
|
|
3270
|
+
// one the named part reads.
|
|
3271
|
+
if (
|
|
3272
|
+
c.parts.length === 1 &&
|
|
3273
|
+
c.aspects.includes('corners') &&
|
|
3274
|
+
/\b(all|every|other|everything|everywhere)\b/.test(c.text) &&
|
|
3275
|
+
/\b(like|match(es|ing)?|same as)\b/.test(c.text)
|
|
3276
|
+
) {
|
|
3277
|
+
const source = c.parts[0].on;
|
|
3278
|
+
const read = C.partReads(one(source), 'corners')[0];
|
|
3279
|
+
if (read) {
|
|
3280
|
+
const others = Object.keys(TOKENS).filter(
|
|
3281
|
+
t =>
|
|
3282
|
+
/^--radius-/.test(t) &&
|
|
3283
|
+
t !== read.token &&
|
|
3284
|
+
!/^--radius-(none|full)$/.test(t),
|
|
3285
|
+
);
|
|
3286
|
+
const d = {
|
|
3287
|
+
text: `every corner like ${source}'s: the other radius tokens take ${read.token}, which ${source} reads`,
|
|
3288
|
+
options: [others.map(t => set(t, `var(${read.token})`))],
|
|
3289
|
+
sequence: others.length > 1,
|
|
3290
|
+
};
|
|
3291
|
+
push(d);
|
|
3292
|
+
recordTop(c, d.options[0] ?? []);
|
|
3293
|
+
continue;
|
|
3294
|
+
}
|
|
3295
|
+
}
|
|
3296
|
+
// "text on the accent color is hard to read": the on-accent text color,
|
|
3297
|
+
// the one of black or white that reads on the accent in each mode.
|
|
3298
|
+
if (
|
|
3299
|
+
/\btext on (?:the )?accent\b/.test(c.text) &&
|
|
3300
|
+
TOKENS['--color-on-accent'] !== undefined
|
|
3301
|
+
) {
|
|
3302
|
+
const steps = /** @type {Array<'light' | 'dark'>} */ (['light', 'dark'])
|
|
3303
|
+
.filter(m => env.data.mode === 'both' || m === 'light')
|
|
3304
|
+
.map(m => {
|
|
3305
|
+
const acc = parseColor(current('--color-accent', m));
|
|
3306
|
+
const pick =
|
|
3307
|
+
acc && ratio(acc, [255, 255, 255]) >= ratio(acc, [0, 0, 0])
|
|
3308
|
+
? '#ffffff'
|
|
3309
|
+
: '#000000';
|
|
3310
|
+
return set(
|
|
3311
|
+
'--color-on-accent',
|
|
3312
|
+
pick,
|
|
3313
|
+
env.data.mode === 'both' ? {mode: m} : {},
|
|
3314
|
+
);
|
|
3315
|
+
});
|
|
3316
|
+
const d = {
|
|
3317
|
+
text: 'the text on the accent: --color-on-accent, black or white, whichever reads better on the accent',
|
|
3318
|
+
options: [steps],
|
|
3319
|
+
sequence: steps.length > 1,
|
|
3320
|
+
};
|
|
3321
|
+
push(d);
|
|
3322
|
+
recordTop(c, d.options[0] ?? []);
|
|
3323
|
+
continue;
|
|
3324
|
+
}
|
|
3325
|
+
// "5 lines tall text box": a text area's height in lines.
|
|
3326
|
+
const lines = /\b(\d+) (?:lines?|rows?) (?:tall|high)\b/.exec(c.text);
|
|
3327
|
+
if (lines && TARGET.has('text-area')) {
|
|
3328
|
+
const d = {
|
|
3329
|
+
text: `a text area ${lines[1]} lines tall: min-height ${lines[1]}lh`,
|
|
3330
|
+
options: [[set('min-height', `${lines[1]}lh`, {on: 'text-area'})]],
|
|
3331
|
+
};
|
|
3332
|
+
push(d);
|
|
3333
|
+
recordTop(c, d.options[0] ?? []);
|
|
3334
|
+
continue;
|
|
3335
|
+
}
|
|
3336
|
+
// "outline offset 3px on focus": the focus ring's offset, not a border.
|
|
3337
|
+
if (
|
|
3338
|
+
!c.parts.length &&
|
|
3339
|
+
/\boutline[- ]offset\b/.test(c.text) &&
|
|
3340
|
+
c.lengths[0]
|
|
3341
|
+
) {
|
|
3342
|
+
const d = {
|
|
3343
|
+
text: "the focus ring's offset: --focus-outline-offset",
|
|
3344
|
+
options: [[set('--focus-outline-offset', c.lengths[0])]],
|
|
3345
|
+
};
|
|
3346
|
+
push(d);
|
|
3347
|
+
recordTop(c, d.options[0] ?? []);
|
|
3348
|
+
continue;
|
|
3349
|
+
}
|
|
3350
|
+
// Placeholder, caret and selection colors.
|
|
3351
|
+
if (
|
|
3352
|
+
/\b(placeholders?|caret|cursor colou?r|colou?r (of )?the cursor|selection|selected text highlight|text highlight)\b/.test(
|
|
3353
|
+
c.text,
|
|
3354
|
+
) &&
|
|
3355
|
+
!/\bloading placeholder/.test(c.text)
|
|
3356
|
+
) {
|
|
3357
|
+
const color = colorFor(c, 'fill');
|
|
3358
|
+
const caret =
|
|
3359
|
+
/\bcaret\b|\bcursor colou?r\b|\bcolou?r (of )?the cursor\b/.test(
|
|
3360
|
+
c.text,
|
|
3361
|
+
);
|
|
3362
|
+
if (caret && color) {
|
|
3363
|
+
const on = c.parts[0]?.on ?? 'inputs';
|
|
3364
|
+
const d = {
|
|
3365
|
+
text: `the text cursor color on ${on}: caret-color`,
|
|
3366
|
+
options: [[set('caret-color', color, {on})]],
|
|
3367
|
+
};
|
|
3368
|
+
push(d);
|
|
3369
|
+
recordTop(c, d.options[0] ?? []);
|
|
3370
|
+
continue;
|
|
3371
|
+
}
|
|
3372
|
+
push({
|
|
3373
|
+
text: caret
|
|
3374
|
+
? 'name the cursor color: caret-color takes a color'
|
|
3375
|
+
: `${/\bplaceholder/.test(c.text) ? 'placeholder text' : 'the text selection highlight'} has no setting: the editor themes parts, not ${/\bplaceholder/.test(c.text) ? '::placeholder' : '::selection'}; it takes your own CSS`,
|
|
3376
|
+
options: [],
|
|
3377
|
+
lookup: `${HOW} inputs`,
|
|
3378
|
+
});
|
|
3379
|
+
continue;
|
|
3380
|
+
}
|
|
2402
3381
|
// "… and set --border-width 2px": a real token typed in a clause.
|
|
2403
3382
|
// The value runs to the clause end ("--shadow-high 0 4px 12px black").
|
|
2404
3383
|
const tok = /(?:^|\s)(--[a-z][a-z0-9-]*)\s*:?\s+([^;]+?)\s*$/.exec(c.text);
|
|
@@ -2421,10 +3400,7 @@ export function draftAnswer(ctx, env, question) {
|
|
|
2421
3400
|
}
|
|
2422
3401
|
// "error text red", "labels smaller": text that belongs to parts how
|
|
2423
3402
|
// cannot pick alone is a lookup, never the whole theme's text.
|
|
2424
|
-
if (
|
|
2425
|
-
!c.parts.length &&
|
|
2426
|
-
/\b(error (text|messages?)|(field |form |input )?labels?)\b/.test(c.text)
|
|
2427
|
-
) {
|
|
3403
|
+
if (!c.parts.length && /\berror (text|messages?)\b/.test(c.text)) {
|
|
2428
3404
|
const which = /\berror\b/.test(c.text) ? 'error text' : 'labels';
|
|
2429
3405
|
push({
|
|
2430
3406
|
text: `${which} belong to the parts that show them (an input's error message, a field's label); name the part, or look it up`,
|
|
@@ -2545,7 +3521,7 @@ export function draftAnswer(ctx, env, question) {
|
|
|
2545
3521
|
function resetAnswer(c) {
|
|
2546
3522
|
// "go back to the neutral theme", "start over": every setting.
|
|
2547
3523
|
if (
|
|
2548
|
-
/\b(back to|reset to|revert to|restore) (the )?(neutral|base|original|default|plain) theme\b|\bstart over\b|\breset (the )?(whole )?theme\b/.test(
|
|
3524
|
+
/\b(back to|reset to|revert to|restore) (the )?(neutral|base|original|default|plain) theme\b|\bstart over\b|\breset (the )?(whole )?theme\b|\b(remove|undo|clear|drop|revert) (all|every one of|each of) (my |the )?(changes|settings|edits|overrides)\b|\bundo everything\b/.test(
|
|
2549
3525
|
c.text,
|
|
2550
3526
|
)
|
|
2551
3527
|
) {
|
|
@@ -2574,7 +3550,7 @@ export function draftAnswer(ctx, env, question) {
|
|
|
2574
3550
|
};
|
|
2575
3551
|
}
|
|
2576
3552
|
if (
|
|
2577
|
-
!/\b(reset|revert|restore|back to|default|original|what it was|standard|clear|no custom|remove the override|(remove|clear|drop|delete) (my |the )?(\w+ )?overrides?|by mistake|by accident|accidentally|put .* back|.* back to normal)\b/.test(
|
|
3553
|
+
!/\b(reset|revert|restore|back to|default|original|what it was|standard|clear|no custom|remove the override|(remove|clear|drop|delete) (my |the )?(\w+ )?overrides?|by mistake|^undo|take back|like before|as before|the way (it|they) (was|were)|by accident|accidentally|put .* back|.* back to normal)\b/.test(
|
|
2578
3554
|
c.text,
|
|
2579
3555
|
) ||
|
|
2580
3556
|
/\bby default\b|\bthe last change\b|\beverything\b/.test(c.text) ||
|
|
@@ -2751,6 +3727,21 @@ export function draftAnswer(ctx, env, question) {
|
|
|
2751
3727
|
],
|
|
2752
3728
|
sequence: true,
|
|
2753
3729
|
};
|
|
3730
|
+
// "remove the focus outline": a ring keyboard users need; set it to
|
|
3731
|
+
// nothing only on the ask, and say what that costs.
|
|
3732
|
+
if (c.neg || /\b(remove|hide|get rid of)\b/.test(c.text))
|
|
3733
|
+
return {
|
|
3734
|
+
text: 'no focus ring: --focus-outline-width 0px. Keyboard users then cannot see where they are, so keep a visible focus style another way',
|
|
3735
|
+
options: [[set('--focus-outline-width', '0px')]],
|
|
3736
|
+
};
|
|
3737
|
+
// "focus ring offset 2px": the gap between the part and its ring.
|
|
3738
|
+
if (/\boffset\b/.test(c.text))
|
|
3739
|
+
return c.lengths[0]
|
|
3740
|
+
? {
|
|
3741
|
+
text: "the focus ring's offset: --focus-outline-offset",
|
|
3742
|
+
options: [[set('--focus-outline-offset', c.lengths[0])]],
|
|
3743
|
+
}
|
|
3744
|
+
: null;
|
|
2754
3745
|
if (
|
|
2755
3746
|
(a === 'border' && !ringColor) ||
|
|
2756
3747
|
a === 'size' ||
|
|
@@ -2824,7 +3815,14 @@ export function draftAnswer(ctx, env, question) {
|
|
|
2824
3815
|
sequence: true,
|
|
2825
3816
|
};
|
|
2826
3817
|
}
|
|
2827
|
-
const
|
|
3818
|
+
const typedTime = /\b(\d+(?:\.\d+)?)(ms|s)\b/.exec(c.text);
|
|
3819
|
+
const typedMs = typedTime
|
|
3820
|
+
? String(
|
|
3821
|
+
Math.round(
|
|
3822
|
+
Number(typedTime[1]) * (typedTime[2] === 's' ? 1000 : 1),
|
|
3823
|
+
),
|
|
3824
|
+
)
|
|
3825
|
+
: undefined;
|
|
2828
3826
|
if (typedMs && !on)
|
|
2829
3827
|
return {
|
|
2830
3828
|
text: `every motion at ${typedMs}ms: the shared duration tokens`,
|
|
@@ -2980,7 +3978,12 @@ export function draftAnswer(ctx, env, question) {
|
|
|
2980
3978
|
return {
|
|
2981
3979
|
text: 'the body text size: text-size (every heading scales from it)',
|
|
2982
3980
|
options: [
|
|
2983
|
-
[
|
|
3981
|
+
[
|
|
3982
|
+
set(
|
|
3983
|
+
'text-size',
|
|
3984
|
+
px ?? textSizeStep(c.dir === 'less' ? 'less' : 'more'),
|
|
3985
|
+
),
|
|
3986
|
+
],
|
|
2984
3987
|
],
|
|
2985
3988
|
};
|
|
2986
3989
|
}
|
|
@@ -3400,6 +4403,33 @@ export function draftAnswer(ctx, env, question) {
|
|
|
3400
4403
|
const rung = Object.entries(HEADING_WEIGHTS).find(
|
|
3401
4404
|
([, v]) => v === value,
|
|
3402
4405
|
)?.[0];
|
|
4406
|
+
// A step ("bolder", "a bit lighter") moves one rung from the
|
|
4407
|
+
// headings rung the theme sets, never back to a fixed one.
|
|
4408
|
+
const ownRung = ownDial('headings');
|
|
4409
|
+
const rungs = Object.keys(HEADING_WEIGHTS);
|
|
4410
|
+
const stepAsk =
|
|
4411
|
+
!typedW &&
|
|
4412
|
+
!c.neg &&
|
|
4413
|
+
!/\btoo /.test(c.text) &&
|
|
4414
|
+
/\b(bolder|heavier|lighter|thinner|less bold)\b/.test(c.text);
|
|
4415
|
+
if (
|
|
4416
|
+
stepAsk &&
|
|
4417
|
+
ownRung &&
|
|
4418
|
+
rungs.includes(ownRung) &&
|
|
4419
|
+
((!on && /\b(headings?|titles?)\b/.test(c.text)) ||
|
|
4420
|
+
(on === 'heading' && !f.when))
|
|
4421
|
+
) {
|
|
4422
|
+
const next = rungs[rungs.indexOf(ownRung) + (light ? -1 : 1)];
|
|
4423
|
+
if (!next)
|
|
4424
|
+
return {
|
|
4425
|
+
text: `the headings are already ${light ? 'the lightest' : 'the boldest'} rung (${ownRung}), so nothing changes`,
|
|
4426
|
+
options: [],
|
|
4427
|
+
};
|
|
4428
|
+
return {
|
|
4429
|
+
text: `${next} headings: one rung ${light ? 'lighter' : 'bolder'} than ${ownRung}`,
|
|
4430
|
+
options: [[set('headings', next)]],
|
|
4431
|
+
};
|
|
4432
|
+
}
|
|
3403
4433
|
if (
|
|
3404
4434
|
(!on && /\b(headings?|titles?)\b/.test(c.text)) ||
|
|
3405
4435
|
(on === 'heading' && !f.when)
|
|
@@ -3450,6 +4480,49 @@ export function draftAnswer(ctx, env, question) {
|
|
|
3450
4480
|
const px = c.lengths[0];
|
|
3451
4481
|
const f2 = /\bmuch\b/.test(c.text) ? 1.5 : 1.25;
|
|
3452
4482
|
const factor = c.dir === 'less' ? 1 / f2 : f2;
|
|
4483
|
+
// An exact --font-size-base wins over the text-size dial, so the
|
|
4484
|
+
// dial would change nothing there: step that token instead.
|
|
4485
|
+
const pinned = on
|
|
4486
|
+
? null
|
|
4487
|
+
: ([...env.data.settings]
|
|
4488
|
+
.reverse()
|
|
4489
|
+
.find(
|
|
4490
|
+
st =>
|
|
4491
|
+
st.source === 'token' &&
|
|
4492
|
+
st.thing === '--font-size-base' &&
|
|
4493
|
+
!st.on &&
|
|
4494
|
+
!st.when &&
|
|
4495
|
+
!st.state &&
|
|
4496
|
+
!st.mode,
|
|
4497
|
+
)?.value ?? null);
|
|
4498
|
+
if (pinned != null) {
|
|
4499
|
+
const m = /^(\d*\.?\d+)(px|rem|em)$/i.exec(pinned.trim());
|
|
4500
|
+
const next = px
|
|
4501
|
+
? px
|
|
4502
|
+
: m
|
|
4503
|
+
? `${Math.round(parseFloat(m[1]) * factor * 100) / 100}${m[2].toLowerCase()}`
|
|
4504
|
+
: null;
|
|
4505
|
+
return next
|
|
4506
|
+
? {
|
|
4507
|
+
text: `the base text size: --font-size-base, set exactly to ${pinned} (it wins over the text-size dial)`,
|
|
4508
|
+
options: [[set('--font-size-base', next)]],
|
|
4509
|
+
}
|
|
4510
|
+
: {
|
|
4511
|
+
text: `the base text size: --font-size-base is set exactly to ${pinned}, which wins over the text-size dial; remove it, then text-size changes the size`,
|
|
4512
|
+
options: [
|
|
4513
|
+
[
|
|
4514
|
+
/** @type {Step} */ ({
|
|
4515
|
+
verb: 'undo',
|
|
4516
|
+
thing: '--font-size-base',
|
|
4517
|
+
}),
|
|
4518
|
+
set(
|
|
4519
|
+
'text-size',
|
|
4520
|
+
textSizeStep(c.dir === 'less' ? 'less' : 'more'),
|
|
4521
|
+
),
|
|
4522
|
+
],
|
|
4523
|
+
],
|
|
4524
|
+
};
|
|
4525
|
+
}
|
|
3453
4526
|
if (!on)
|
|
3454
4527
|
return {
|
|
3455
4528
|
text: 'the base text size: text-size (every heading scales from it)',
|
|
@@ -3463,9 +4536,7 @@ export function draftAnswer(ctx, env, question) {
|
|
|
3463
4536
|
? Math.round(parseFloat(px) * 16 * 100) / 100
|
|
3464
4537
|
: parseFloat(px),
|
|
3465
4538
|
)
|
|
3466
|
-
: c.dir === 'less'
|
|
3467
|
-
? 'less'
|
|
3468
|
-
: 'more',
|
|
4539
|
+
: textSizeStep(c.dir === 'less' ? 'less' : 'more'),
|
|
3469
4540
|
),
|
|
3470
4541
|
],
|
|
3471
4542
|
],
|
|
@@ -3495,12 +4566,16 @@ export function draftAnswer(ctx, env, question) {
|
|
|
3495
4566
|
r.props.includes('font-size'),
|
|
3496
4567
|
)?.token ??
|
|
3497
4568
|
Object.keys(C.MAP[one(on)]?.own?.['font-size']?.tokens ?? {})[0]);
|
|
3498
|
-
//
|
|
3499
|
-
|
|
3500
|
-
|
|
3501
|
-
|
|
3502
|
-
|
|
3503
|
-
|
|
4569
|
+
// The theme's own size on the part first; a part with no size token
|
|
4570
|
+
// of its own starts from the body size.
|
|
4571
|
+
const own = on ? partValue(on, 'font-size') : null;
|
|
4572
|
+
const now = own
|
|
4573
|
+
? own
|
|
4574
|
+
: sizeTok
|
|
4575
|
+
? current(sizeTok)
|
|
4576
|
+
: on !== 'heading' && '--text-body-size' in TOKENS
|
|
4577
|
+
? current('--text-body-size')
|
|
4578
|
+
: null;
|
|
3504
4579
|
const value = px ?? (now ? scaled(now, factor) : null);
|
|
3505
4580
|
if (!value) return null;
|
|
3506
4581
|
return {
|
|
@@ -3972,7 +5047,11 @@ export function draftAnswer(ctx, env, question) {
|
|
|
3972
5047
|
options: [steps],
|
|
3973
5048
|
sequence: steps.length > 1,
|
|
3974
5049
|
}
|
|
3975
|
-
:
|
|
5050
|
+
: {
|
|
5051
|
+
// The theme's own page is already at the end of the range.
|
|
5052
|
+
text: `the page background of ${env.slug} is already ${lighter ? 'as light' : 'as dark'} as it goes (${current('--color-background-body')}), so nothing changes`,
|
|
5053
|
+
options: [],
|
|
5054
|
+
};
|
|
3976
5055
|
}
|
|
3977
5056
|
if (c.decl.background || c.decl['background-color'])
|
|
3978
5057
|
return {
|
|
@@ -4094,13 +5173,15 @@ export function draftAnswer(ctx, env, question) {
|
|
|
4094
5173
|
options: [],
|
|
4095
5174
|
};
|
|
4096
5175
|
if (/\bswap\b/.test(t)) {
|
|
4097
|
-
const ROLE_TOKEN =
|
|
4098
|
-
|
|
4099
|
-
|
|
4100
|
-
|
|
4101
|
-
|
|
4102
|
-
|
|
4103
|
-
|
|
5176
|
+
const ROLE_TOKEN = wordTable(
|
|
5177
|
+
/** @type {Record<string, string>} */ ({
|
|
5178
|
+
accent: '--color-accent',
|
|
5179
|
+
danger: '--color-error',
|
|
5180
|
+
success: '--color-success',
|
|
5181
|
+
warning: '--color-warning',
|
|
5182
|
+
info: '--color-info',
|
|
5183
|
+
}),
|
|
5184
|
+
);
|
|
4104
5185
|
const named = Object.keys(ROLE_TOKEN).filter(r =>
|
|
4105
5186
|
new RegExp(`\\b${r === 'danger' ? '(danger|error)' : r}\\b`).test(t),
|
|
4106
5187
|
);
|
|
@@ -4178,6 +5259,9 @@ export function draftAnswer(ctx, env, question) {
|
|
|
4178
5259
|
// "dark only" with no "mode" word describes the theme's look.
|
|
4179
5260
|
(/\balways dark\b|\b(theme|app)\b/.test(t) ||
|
|
4180
5261
|
!/\bmode\b|\bin dark\b/.test(t) ||
|
|
5262
|
+
// "… accent and dark mode only": the last ask, scoping nothing.
|
|
5263
|
+
(clauses.indexOf(c) === clauses.length - 1 &&
|
|
5264
|
+
!/\b(in|for)\b/.test(c.text)) ||
|
|
4181
5265
|
!clauses.some(
|
|
4182
5266
|
o =>
|
|
4183
5267
|
o.text !== c.text &&
|
|
@@ -4189,7 +5273,17 @@ export function draftAnswer(ctx, env, question) {
|
|
|
4189
5273
|
options: [[set('mode', 'dark-only')]],
|
|
4190
5274
|
};
|
|
4191
5275
|
if (
|
|
4192
|
-
/\blight[- ]?(mode|theme)? only\b|\bonly light\b|\blight-only\b/.test(
|
|
5276
|
+
/\blight[- ]?(mode|theme)? only\b|\bonly light\b|\blight-only\b/.test(
|
|
5277
|
+
t,
|
|
5278
|
+
) &&
|
|
5279
|
+
// "light only" removes dark mode only when the ask is about the
|
|
5280
|
+
// theme's modes, never beside another change.
|
|
5281
|
+
(/\b(theme|app)\b/.test(t) ||
|
|
5282
|
+
!clauses.some(
|
|
5283
|
+
o =>
|
|
5284
|
+
o.text !== c.text &&
|
|
5285
|
+
(o.parts.length || o.colors.length || o.aspects.length),
|
|
5286
|
+
))
|
|
4193
5287
|
)
|
|
4194
5288
|
return {
|
|
4195
5289
|
text: 'a theme with only a light mode: mode light-only',
|
|
@@ -4220,10 +5314,14 @@ export function draftAnswer(ctx, env, question) {
|
|
|
4220
5314
|
}
|
|
4221
5315
|
if (vib) {
|
|
4222
5316
|
seenAspect('colors');
|
|
5317
|
+
// "More" goes with the word after it: more washed out, more muted
|
|
5318
|
+
// and more pastel are less vibrant; less muted is more.
|
|
5319
|
+
const dim =
|
|
5320
|
+
/\b(desaturat\w*|muted|dull|washed|pastel|gr[ae]yer|calm\w*|softer)\b/;
|
|
4223
5321
|
const less =
|
|
4224
|
-
/\
|
|
4225
|
-
|
|
4226
|
-
|
|
5322
|
+
/\bless (desaturat\w*|muted|dull|washed|pastel|gr[ae]y\w*)\b/.test(t)
|
|
5323
|
+
? false
|
|
5324
|
+
: dim.test(t) || (/\bless\b/.test(t) && !/\bmore\b/.test(t));
|
|
4227
5325
|
const step = set('vibrancy', less ? 'less' : 'more');
|
|
4228
5326
|
const colored = (/** @type {string} */ v) => !isGraySeed(seedOf(v));
|
|
4229
5327
|
const hasColor = env.data.settings.some(
|
|
@@ -4441,12 +5539,14 @@ export function draftAnswer(ctx, env, question) {
|
|
|
4441
5539
|
? '#78716c'
|
|
4442
5540
|
: null;
|
|
4443
5541
|
// "make the error red darker": the hue names the color; the change is darker.
|
|
4444
|
-
const NATURAL =
|
|
4445
|
-
|
|
4446
|
-
|
|
4447
|
-
|
|
4448
|
-
|
|
4449
|
-
|
|
5542
|
+
const NATURAL = wordTable(
|
|
5543
|
+
/** @type {Record<string, string>} */ ({
|
|
5544
|
+
danger: HUES.red,
|
|
5545
|
+
success: HUES.green,
|
|
5546
|
+
warning: HUES.yellow,
|
|
5547
|
+
info: HUES.blue,
|
|
5548
|
+
}),
|
|
5549
|
+
);
|
|
4450
5550
|
if (c.dir && color && (color === NATURAL[dial] || color === HUES.amber))
|
|
4451
5551
|
color = null;
|
|
4452
5552
|
if (!color && c.dir && !/\btoo (warm|cool)\b/.test(t)) {
|
|
@@ -4533,7 +5633,18 @@ export function draftAnswer(ctx, env, question) {
|
|
|
4533
5633
|
})[a] ?? a;
|
|
4534
5634
|
if (!C.MAP[one(on)] || !Object.hasOwn(GROUPS, group)) return '';
|
|
4535
5635
|
// Reads that always apply first; partReads sorts them so.
|
|
5636
|
+
// Only the reads of the property the aspect is about (a weight question
|
|
5637
|
+
// never lists the size tokens).
|
|
5638
|
+
const prop = /** @type {Record<string, RegExp>} */ ({
|
|
5639
|
+
weight: /^font-weight$/,
|
|
5640
|
+
family: /^font-family$/,
|
|
5641
|
+
fontsize: /^font-size$/,
|
|
5642
|
+
tracking: /^letter-spacing$/,
|
|
5643
|
+
case: /^text-transform$/,
|
|
5644
|
+
italic: /^font-style$/,
|
|
5645
|
+
})[a];
|
|
4536
5646
|
const toks = C.partReads(one(on), group)
|
|
5647
|
+
.filter(r => !prop || r.props.some(x => prop.test(x)))
|
|
4537
5648
|
.map(r => r.token)
|
|
4538
5649
|
.slice(0, 4);
|
|
4539
5650
|
return toks.length ? `; ${one(on)} reads ${toks.join(', ')} for it` : '';
|
|
@@ -4606,6 +5717,23 @@ export function draftAnswer(ctx, env, question) {
|
|
|
4606
5717
|
});
|
|
4607
5718
|
}
|
|
4608
5719
|
result.push(...drafts.slice(0, clashes.length ? 0 : undefined));
|
|
5720
|
+
// A confidence gate: a question, a "tell me", a "but not too" or a typo
|
|
5721
|
+
// read as a direction leaves how unsure which way to go; a wrong write is
|
|
5722
|
+
// worse than none, so it gives the lookup and asks for the ask.
|
|
5723
|
+
const unsure = gateAll;
|
|
5724
|
+
if (unsure && result.some(d => d.options.some(o => o.length))) {
|
|
5725
|
+
const part = partsSeen[0];
|
|
5726
|
+
result.splice(0, result.length, {
|
|
5727
|
+
text: `how is not sure which change you want; say it as an ask instead (for example "rounder cards" or "no shadows on buttons")`,
|
|
5728
|
+
options: [],
|
|
5729
|
+
lookup: part ? `${HOW} ${part}` : `${P} show ${env.slug}`,
|
|
5730
|
+
});
|
|
5731
|
+
}
|
|
5732
|
+
if (media)
|
|
5733
|
+
result.push({
|
|
5734
|
+
text: 'the theme editor has no screen-size, print or device conditions: this applies on every screen; a media query needs your own CSS',
|
|
5735
|
+
options: [],
|
|
5736
|
+
});
|
|
4609
5737
|
return {parts: partsSeen, aspects: aspectsSeen, drafts: result};
|
|
4610
5738
|
}
|
|
4611
5739
|
|