@astryxdesign/cli 0.7.17-canary.g4ea41ce → 0.7.17-canary.g5a3fd39
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 +7 -2
- package/api/build/_adapter.d.mts +7 -6
- package/api/build/_adapter.mjs +18 -11
- package/api/build/build.type.mjs +1 -1
- package/api/build/kit/kind.d.mts +6 -0
- package/api/build/kit/kind.mjs +1 -1
- package/api/build/kit/rank.d.mts +7 -1
- package/api/build/kit/rank.mjs +15 -5
- package/api/build/kit/signals.mjs +58 -57
- package/api/build/kit/start.d.mts +2 -1
- package/api/build/kit/start.mjs +62 -9
- package/api/build/kit/words.d.mts +6 -2
- package/api/build/kit/words.mjs +7 -3
- package/api/component/__fixtures__/resolutions/modules.txt +2 -2
- package/api/component/_adapter.d.mts +30 -24
- package/api/component/_adapter.mjs +72 -31
- package/api/component/component.mjs +4 -4
- package/api/component/detail/detail.d.mts +2 -2
- package/api/component/detail/detail.mjs +1 -1
- package/api/component/list/list.d.mts +2 -2
- package/api/component/list/list.mjs +4 -4
- package/api/discover/_adapter.mjs +15 -15
- package/api/docs/_adapter.d.mts +13 -5
- package/api/docs/_adapter.mjs +37 -10
- package/api/doctor/_adapter.d.mts +32 -0
- package/api/doctor/_adapter.mjs +56 -1
- package/api/doctor/doctor.mjs +28 -5
- package/api/doctor/theme-checks.mjs +165 -83
- package/api/error.d.mts +4 -3
- package/api/error.mjs +3 -2
- package/api/hook/_adapter.d.mts +5 -4
- package/api/hook/_adapter.mjs +6 -5
- package/api/icon/_options.d.mts +17 -0
- package/api/icon/_options.mjs +54 -0
- package/api/icon/exportIconIndex.doc.d.mts +10 -0
- package/api/icon/exportIconIndex.doc.mjs +59 -0
- package/api/icon/icon.mjs +11 -34
- package/api/icon/icon.type.d.mts +49 -0
- package/api/icon/icon.type.mjs +24 -0
- package/api/icon/rankIconIndex.doc.d.mts +10 -0
- package/api/icon/rankIconIndex.doc.mjs +79 -0
- package/api/icon/search/icon-index.d.mts +41 -0
- package/api/icon/search/icon-index.mjs +139 -0
- package/api/icon/search/search.d.mts +18 -0
- package/api/icon/search/search.mjs +13 -0
- package/api/index.d.mts +1 -0
- package/api/index.mjs +1 -0
- package/api/search/_adapter.d.mts +8 -5
- package/api/search/_adapter.mjs +14 -10
- package/api/search/_gather-components.d.mts +4 -4
- package/api/search/_gather-components.mjs +4 -3
- package/api/search/_gather-hooks.d.mts +2 -2
- package/api/search/_gather-hooks.mjs +1 -1
- package/api/search/_lexical.mjs +12 -2
- package/api/search/_priority.d.mts +10 -2
- package/api/search/_priority.mjs +37 -7
- package/api/search/_score.d.mts +12 -3
- package/api/search/_score.mjs +6 -3
- package/api/search/_words.mjs +12 -3
- package/api/search/search.d.mts +7 -1
- package/api/search/search.mjs +37 -4
- package/api/swizzle/_adapter.d.mts +7 -5
- package/api/swizzle/_adapter.mjs +7 -3
- package/api/swizzle/copy/copy.mjs +5 -4
- package/api/theme/build/build.d.mts +5 -0
- package/api/theme/build/build.mjs +400 -21
- package/api/theme/build/family.mjs +18 -7
- package/api/theme/build/font-warning.mjs +5 -4
- package/api/theme/build/input-fields.d.mts +21 -6
- package/api/theme/build/input-fields.mjs +104 -13
- package/api/theme/build/typography-values.d.mts +22 -0
- package/api/theme/build/typography-values.mjs +172 -22
- package/api/theme/build/written-values.d.mts +7 -0
- package/api/theme/build/written-values.mjs +57 -8
- package/api/theme/generateTonalPalette.doc.mjs +1 -1
- package/api/theme/palette/generate/generator.d.mts +14 -2
- package/api/theme/palette/generate/generator.mjs +94 -8
- package/api/theme/theme.type.d.mts +21 -4
- package/api/theme/theme.type.mjs +14 -5
- package/api/theme/themePaletteGenerate.doc.mjs +1 -1
- package/api/theme/themeTemplate.doc.mjs +18 -3
- package/api/theme-edit/_adapter.d.mts +1 -1
- package/api/theme-edit/_adapter.mjs +1 -1
- package/api/theme-edit/_catalog.d.mts +10 -4
- package/api/theme-edit/_catalog.mjs +81 -22
- package/api/theme-edit/_check.mjs +402 -88
- package/api/theme-edit/_color.d.mts +11 -2
- package/api/theme-edit/_color.mjs +23 -7
- package/api/theme-edit/_compiler.mjs +11 -3
- package/api/theme-edit/_context.d.mts +87 -6
- package/api/theme-edit/_context.mjs +224 -17
- package/api/theme-edit/_css.mjs +4 -0
- package/api/theme-edit/_edit.mjs +331 -58
- package/api/theme-edit/_how-question.d.mts +11 -0
- package/api/theme-edit/_how-question.mjs +2514 -234
- package/api/theme-edit/_how.mjs +79 -14
- package/api/theme-edit/_missed.mjs +294 -32
- package/api/theme-edit/_normal.d.mts +3 -1
- package/api/theme-edit/_normal.mjs +4 -1
- package/api/theme-edit/_palette.mjs +36 -5
- package/api/theme-edit/_part-words.mjs +20 -2
- package/api/theme-edit/_parts.d.mts +12 -1
- package/api/theme-edit/_parts.mjs +116 -11
- package/api/theme-edit/_preview-app.mjs +40 -2
- package/api/theme-edit/_preview.d.mts +45 -5
- package/api/theme-edit/_preview.mjs +173 -21
- package/api/theme-edit/_settings.d.mts +20 -0
- package/api/theme-edit/_settings.mjs +1033 -94
- package/api/theme-edit/_tables.mjs +2 -2
- package/api/theme-edit/theme-edit.type.d.mts +6 -5
- package/api/theme-edit/theme-edit.type.mjs +8 -8
- package/api/upgrade/_adapter.mjs +13 -2
- package/assets/component-list.generated.json +1 -1
- package/assets/docs/tree/authoring.doc.mjs +1 -0
- package/assets/docs/tree/cli.doc.mjs +1 -0
- package/assets/docs/tree/computer-agent-guide.doc.mjs +1 -1
- package/assets/docs/tree/generate-a-palette.doc.mjs +2 -2
- package/assets/docs/tree/global.doc.mjs +1 -0
- package/assets/docs/tree/single-component.doc.mjs +40 -2
- package/assets/docs/tree/updates.doc.mjs +1 -1
- package/assets/docs/tree/who-answers.doc.mjs +2 -2
- package/assets/docs-routes.generated.json +1 -1
- package/assets/docs.generated.json +2 -2
- package/assets/search-catalog.generated.json +2 -2
- package/assets/self-audit.generated.json +1 -1
- package/assets/templates/blocks/components/Blockquote/BlockquoteShowcase.tsx +1 -1
- package/assets/templates/blocks/components/BreadcrumbItem/BreadcrumbItemShowcase.tsx +4 -4
- package/assets/templates/blocks/components/Breadcrumbs/BreadcrumbsCustomSeparator.tsx +1 -0
- package/assets/templates/blocks/components/Breadcrumbs/BreadcrumbsSupportingVariant.tsx +2 -2
- package/assets/templates/blocks/components/Card/CardElevations.tsx +1 -1
- package/assets/templates/blocks/components/Card/CardWithInnerLayout.tsx +19 -3
- package/assets/templates/blocks/components/Card/ClickableCardWithNestedButton.tsx +11 -1
- package/assets/templates/blocks/components/Card/SelectableCardElevated.tsx +1 -1
- package/assets/templates/blocks/components/Card/SelectableCardMulti.tsx +1 -1
- package/assets/templates/blocks/components/Center/CenterHorizontal.tsx +1 -1
- package/assets/templates/blocks/components/Center/CenterInsideACard.tsx +1 -1
- package/assets/templates/blocks/components/ChatComposer/ChatComposerFullFeatured.tsx +8 -0
- package/assets/templates/blocks/components/ChatComposerDrawer/ChatComposerDrawerWithProgress.tsx +8 -2
- package/assets/templates/blocks/components/ChatLayout/ChatLayoutPanelChat.tsx +1 -0
- package/assets/templates/blocks/components/ChatLayout/ChatLayoutShowcase.tsx +1 -1
- package/assets/templates/blocks/components/ChatMessageBubble/ChatMessageBubbleCustomContent.tsx +9 -1
- package/assets/templates/blocks/components/ChatMessageBubble/ChatMessageBubbleMetadata.tsx +12 -2
- package/assets/templates/blocks/components/ChatMessageMetadata/ChatMessageMetadataFooter.tsx +28 -7
- package/assets/templates/blocks/components/ChatMessageMetadata/ChatMessageMetadataShowcase.tsx +35 -7
- package/assets/templates/blocks/components/Collapsible/CollapsibleShowcase.tsx +1 -1
- package/assets/templates/blocks/components/CommandPaletteGroup/CommandPaletteGroupBasic.tsx +20 -4
- package/assets/templates/blocks/components/CommandPaletteList/CommandPaletteListBasic.tsx +15 -3
- package/assets/templates/blocks/components/CommandPaletteList/CommandPaletteListShowcase.tsx +29 -6
- package/assets/templates/blocks/components/ContextMenu/ContextMenuBasic.tsx +2 -2
- package/assets/templates/blocks/components/ContextMenu/ContextMenuBottomSheet.tsx +1 -1
- package/assets/templates/blocks/components/ContextMenu/ContextMenuShowcase.tsx +2 -2
- package/assets/templates/blocks/components/Divider/DividerFullBleed.tsx +1 -1
- package/assets/templates/blocks/components/Divider/DividerShowcase.tsx +1 -1
- package/assets/templates/blocks/components/Divider/DividerVariants.tsx +1 -1
- package/assets/templates/blocks/components/DropdownMenuGroup/DropdownMenuGroupShowcase.tsx +23 -4
- package/assets/templates/blocks/components/EmptyState/EmptyStateActions.tsx +18 -2
- package/assets/templates/blocks/components/EmptyState/EmptyStateCompact.tsx +20 -2
- package/assets/templates/blocks/components/EmptyState/EmptyStateContainer.tsx +16 -2
- package/assets/templates/blocks/components/EmptyState/EmptyStateShowcase.tsx +11 -1
- package/assets/templates/blocks/components/Heading/HeadingTruncation.tsx +12 -2
- package/assets/templates/blocks/components/InternationalizationProvider/useDirectionHookUsage.tsx +1 -1
- package/assets/templates/blocks/components/LayoutContent/LayoutContentBasic.tsx +1 -1
- package/assets/templates/blocks/components/LayoutContent/LayoutContentShowcase.tsx +1 -1
- package/assets/templates/blocks/components/LayoutFooter/LayoutFooterActions.tsx +17 -3
- package/assets/templates/blocks/components/LayoutFooter/LayoutFooterShowcase.tsx +17 -3
- package/assets/templates/blocks/components/LayoutHeader/LayoutHeaderShowcase.tsx +15 -3
- package/assets/templates/blocks/components/LayoutHeader/LayoutHeaderWithActions.tsx +9 -2
- package/assets/templates/blocks/components/LayoutPanel/LayoutPanelNavigation.tsx +1 -1
- package/assets/templates/blocks/components/LayoutPanel/LayoutPanelShowcase.tsx +1 -1
- package/assets/templates/blocks/components/MoreMenu/MoreMenuBottomSheet.tsx +1 -1
- package/assets/templates/blocks/components/MultiSelector/MultiSelectorGhostToolbar.tsx +14 -2
- package/assets/templates/blocks/components/Outline/OutlineDensity.tsx +2 -0
- package/assets/templates/blocks/components/OverflowList/OverflowListShowcase.tsx +6 -1
- package/assets/templates/blocks/components/Pagination/PaginationVariants.tsx +4 -0
- package/assets/templates/blocks/components/Popover/PopoverHookUsage.tsx +17 -2
- package/assets/templates/blocks/components/SegmentedControl/SegmentedControlFillLayout.tsx +1 -1
- package/assets/templates/blocks/components/Selector/SelectorGhostToolbar.tsx +14 -2
- package/assets/templates/blocks/components/Selector/SelectorOptionDescriptions.tsx +8 -1
- package/assets/templates/blocks/components/SideNav/SideNavWithHeaderMenu.tsx +2 -2
- package/assets/templates/blocks/components/SideNavHeading/SideNavHeadingShowcase.tsx +2 -0
- package/assets/templates/blocks/components/Switch/SwitchWithStatus.tsx +1 -1
- package/assets/templates/blocks/components/TabList/TabListTabsFillLayout.tsx +1 -1
- package/assets/templates/blocks/components/TabList/TabListTabsWithActions.tsx +12 -1
- package/assets/templates/blocks/components/Table/TableBulkActionsTable.tsx +11 -1
- package/assets/templates/blocks/components/Table/TableInCard.tsx +2 -2
- package/assets/templates/blocks/components/Text/TextTruncation.tsx +1 -1
- package/assets/templates/blocks/components/Text/TextWordBreak.tsx +12 -2
- package/assets/templates/blocks/components/Text/TextWrap.tsx +19 -4
- package/assets/templates/blocks/components/TextArea/TextAreaCharacterCount.tsx +1 -1
- package/assets/templates/blocks/components/TextArea/TextAreaShowcase.tsx +1 -1
- package/assets/templates/blocks/components/TextArea/TextAreaStates.tsx +1 -1
- package/assets/templates/blocks/components/TextArea/TextAreaValidation.tsx +1 -1
- package/assets/templates/blocks/components/TextArea/TextAreaWithIcon.tsx +1 -1
- package/assets/templates/blocks/components/TextInput/TextInputStatusVariant.tsx +2 -2
- package/assets/templates/blocks/components/Timestamp/TimestampAutoFormat.tsx +15 -1
- package/assets/templates/blocks/components/Timestamp/TimestampRelativeFormat.tsx +15 -1
- package/assets/templates/blocks/components/Toolbar/ToolbarCardHeader.tsx +8 -0
- package/assets/templates/blocks/components/Toolbar/ToolbarSizes.tsx +12 -1
- package/assets/templates/blocks/components/Toolbar/ToolbarThreeSlot.tsx +18 -3
- package/assets/templates/blocks/components/TopNav/TopNavCenteredNavigation.tsx +6 -0
- package/assets/templates/blocks/components/TopNav/TopNavEnterpriseDashboard.tsx +7 -1
- package/assets/templates/blocks/components/TopNav/TopNavMegaMenu.tsx +2 -2
- package/assets/templates/blocks/components/TopNav/TopNavShowcase.tsx +9 -0
- package/assets/templates/components.generated.json +1 -1
- package/assets/templates/pages/ai-chat/page.tsx +102 -6
- package/assets/templates/pages/canvas-editor/page.tsx +73 -2
- package/assets/templates/pages/centered-hero/page.tsx +10 -4
- package/assets/templates/pages/course-detail/page.tsx +46 -2
- package/assets/templates/pages/dashboard/page.tsx +45 -16
- package/assets/templates/pages/dashboard-cohort-funnel/page.tsx +31 -20
- package/assets/templates/pages/dashboard-comparison/page.tsx +9 -0
- package/assets/templates/pages/dashboard-composition/page.tsx +22 -9
- package/assets/templates/pages/dashboard-progress/page.tsx +27 -15
- package/assets/templates/pages/dashboard-scorecard/page.tsx +9 -0
- package/assets/templates/pages/detail-page/page.tsx +105 -77
- package/assets/templates/pages/documentation/page.tsx +15 -2
- package/assets/templates/pages/documentation-design/page.tsx +7 -34
- package/assets/templates/pages/documentation-technical/page.tsx +76 -12
- package/assets/templates/pages/editor/page.tsx +26 -21
- package/assets/templates/pages/file-explorer/page.tsx +35 -1
- package/assets/templates/pages/form-two-column/page.tsx +2 -3
- package/assets/templates/pages/form-wizard/page.tsx +31 -3
- package/assets/templates/pages/form-wizard-vertical/page.tsx +32 -3
- package/assets/templates/pages/gallery-hero/page.tsx +2 -1
- package/assets/templates/pages/ide/page.tsx +15 -1
- package/assets/templates/pages/incident-console/page.tsx +2 -1
- package/assets/templates/pages/incident-console/template.doc.mjs +1 -1
- package/assets/templates/pages/kanban-board/page.tsx +39 -2
- package/assets/templates/pages/payment-form/page.tsx +77 -39
- package/assets/templates/pages/product-gallery/page.tsx +16 -14
- package/assets/templates/pages/settings/page.tsx +35 -3
- package/assets/templates/pages/settings-dialog/page.tsx +34 -5
- package/assets/templates/pages/settings-sidebar/page.tsx +23 -3
- package/assets/templates/pages/shell-nav/page.tsx +28 -12
- package/assets/templates/pages/shell-side-nav/page.tsx +16 -1
- package/assets/templates/pages/shell-top-nav/page.tsx +27 -1
- package/assets/templates/pages/side-gallery/page.tsx +1 -1
- package/assets/templates/pages/table/page.tsx +2 -1
- package/assets/templates/pages/table/template.doc.mjs +1 -1
- package/assets/templates/pages/table-collapsible/page.tsx +1 -1
- package/assets/templates/pages/table-comparison/page.tsx +1 -1
- package/assets/templates/pages/table-filter/page.tsx +9 -2
- package/assets/templates/pages/table-grouped/page.tsx +16 -6
- package/assets/templates/pages/table-inbox/page.tsx +60 -1
- package/assets/templates/pages/table-page/page.tsx +10 -2
- package/assets/templates/pages/table-tree/page.tsx +95 -13
- package/assets/templates/pages/theme-showcase/page.tsx +107 -11
- package/assets/templates/pages/work-item-detail/page.tsx +88 -74
- package/assets/templates/pages/work-item-detail/template.doc.mjs +0 -1
- package/assets/templates/themes/gothic/gothicPaletteRefs.generated.ts +1 -1
- package/assets/templates/themes/gothic/gothicTheme.ts +5 -0
- package/assets/templates/themes/neutral/neutralTheme.ts +1 -1
- package/assets/templates/themes/y2k/y2kPaletteRefs.generated.ts +1 -1
- package/assets/templates/themes/y2k/y2kTheme.ts +1 -1
- package/authoring/debug/parse.d.mts +1 -1
- package/authoring/doctypes/_schema.d.mts +22 -8
- package/authoring/doctypes/_schema.mjs +31 -0
- package/authoring/doctypes/command/command.doc.mjs +24 -0
- package/authoring/doctypes/command/type.ts +31 -0
- package/authoring/doctypes/component/component.doc.mjs +1 -1
- package/authoring/doctypes/component/type.ts +8 -5
- package/authoring/doctypes/namespace/namespace.doc.mjs +6 -0
- package/authoring/doctypes/namespace/type.ts +4 -0
- package/authoring/doctypes/template/type.ts +0 -7
- package/authoring/index.d.ts +6 -1
- package/authoring/integration/integration.doc.mjs +7 -0
- package/authoring/integration/schema.d.mts +6 -0
- package/authoring/integration/schema.mjs +3 -0
- package/authoring/integration/type.ts +34 -0
- package/clients/cli/build-id.generated.json +1 -1
- package/clients/cli/commands/component.doc.mjs +1 -0
- package/clients/cli/commands/component.mjs +5 -1
- package/clients/cli/commands/docs.doc.mjs +1 -1
- package/clients/cli/commands/experimental/index.mjs +4 -1
- package/clients/cli/commands/experimental/theme.mjs +139 -64
- package/clients/cli/commands/experimental-render.doc.mjs +2 -0
- package/clients/cli/commands/experimental-theme-add.doc.mjs +2 -0
- package/clients/cli/commands/experimental-theme-compile.doc.mjs +1 -0
- package/clients/cli/commands/experimental-theme-editor-how.doc.mjs +1 -0
- package/clients/cli/commands/experimental-theme-editor-new.doc.mjs +3 -1
- package/clients/cli/commands/experimental-theme-editor-set.doc.mjs +3 -2
- package/clients/cli/commands/experimental-theme-editor-show.doc.mjs +2 -1
- package/clients/cli/commands/experimental-theme-editor-undo.doc.mjs +3 -2
- package/clients/cli/commands/experimental-theme-eject.doc.mjs +1 -0
- package/clients/cli/commands/experimental-theme-preview-add.doc.mjs +1 -0
- package/clients/cli/commands/experimental-theme-preview-app.doc.mjs +1 -0
- package/clients/cli/commands/experimental-theme-remove.doc.mjs +2 -0
- package/clients/cli/commands/experimental-theme-targets.doc.mjs +1 -0
- package/clients/cli/commands/experimental-theme-template.doc.mjs +1 -0
- package/clients/cli/commands/experimental-theme-use.doc.mjs +2 -0
- package/clients/cli/commands/gap-report.doc.mjs +1 -0
- package/clients/cli/commands/hook.doc.mjs +1 -1
- package/clients/cli/commands/init.doc.mjs +1 -1
- package/clients/cli/commands/integration-add.doc.mjs +1 -0
- package/clients/cli/commands/manifest.mjs +10 -3
- package/clients/cli/commands/swizzle.doc.mjs +8 -1
- package/clients/cli/commands/swizzle.mjs +13 -6
- package/clients/cli/commands/template.doc.mjs +3 -0
- package/clients/cli/commands/theme-add.doc.mjs +2 -1
- package/clients/cli/commands/theme-build.doc.mjs +2 -1
- package/clients/cli/commands/theme-eject.doc.mjs +1 -1
- package/clients/cli/commands/theme-palette-generate.doc.mjs +3 -2
- package/clients/cli/commands/theme-remove.doc.mjs +2 -1
- package/clients/cli/commands/theme-targets.doc.mjs +1 -0
- package/clients/cli/commands/theme-template.doc.mjs +1 -0
- package/clients/cli/commands/theme-use.doc.mjs +2 -1
- package/clients/cli/commands/theme.doc.mjs +7 -2
- package/clients/cli/commands/theme.mjs +21 -5
- package/clients/cli/index.mjs +167 -59
- package/clients/cli/lib/base-gate.mjs +522 -0
- package/clients/cli/lib/command-path.mjs +26 -0
- package/clients/cli/lib/define-command.mjs +161 -12
- package/clients/cli/lib/json-shim.mjs +34 -31
- package/clients/cli/lib/manifest.d.ts +14 -0
- package/clients/cli/lib/manifest.mjs +78 -22
- package/clients/cli/lib/root-args.mjs +79 -0
- package/clients/cli/lib/stray-option.mjs +21 -8
- package/clients/cli/lib/unknown-command.mjs +27 -6
- package/clients/cli/manifest.generated.json +1 -1
- package/clients/cli/run.mjs +13 -1
- package/foundation/agent-docs/computer-agent-text.mjs +1 -1
- package/foundation/bases/core-docs.d.mts +10 -0
- package/foundation/bases/core-docs.mjs +42 -0
- package/foundation/bases/core.d.mts +11 -0
- package/foundation/bases/core.mjs +32 -0
- package/foundation/bases/requirements.d.mts +128 -0
- package/foundation/bases/requirements.mjs +193 -0
- package/foundation/bases/resolve.d.mts +134 -0
- package/foundation/bases/resolve.mjs +295 -0
- package/foundation/bases/state.d.mts +24 -0
- package/foundation/bases/state.mjs +46 -0
- package/foundation/bases/steps.d.mts +49 -0
- package/foundation/bases/steps.mjs +88 -0
- package/foundation/config/project.d.mts +14 -0
- package/foundation/config/project.mjs +68 -1
- package/foundation/discovery/cli-self-docs.mjs +9 -1
- package/foundation/discovery/command-pointers.d.mts +28 -0
- package/foundation/discovery/command-pointers.mjs +31 -0
- package/foundation/discovery/component-discovery.d.mts +9 -8
- package/foundation/discovery/component-discovery.mjs +9 -4
- package/foundation/discovery/docs-discovery.d.mts +13 -5
- package/foundation/discovery/docs-discovery.mjs +25 -6
- package/foundation/discovery/hook-discovery.d.mts +6 -6
- package/foundation/discovery/hook-discovery.mjs +6 -4
- package/foundation/discovery/template-adapter.mjs +5 -0
- package/foundation/discovery/template-ids.d.mts +1 -1
- package/foundation/discovery/template-ids.mjs +5 -1
- package/foundation/discovery/theme-discovery.mjs +3 -0
- package/foundation/discovery/theme-imports.mjs +19 -1
- package/foundation/doc-compiler/tree.d.mts +4 -2
- package/foundation/doc-compiler/tree.mjs +46 -1
- package/foundation/env/package-manager.d.mts +7 -0
- package/foundation/env/package-manager.mjs +21 -0
- package/foundation/fonts/font-stylesheet.d.mts +8 -0
- package/foundation/fonts/font-stylesheet.mjs +26 -2
- package/foundation/fs/gather-cache.mjs +44 -13
- package/foundation/fs/own-modules.d.mts +29 -0
- package/foundation/fs/own-modules.mjs +57 -0
- package/foundation/fs/paths.d.mts +30 -2
- package/foundation/fs/paths.mjs +49 -2
- package/foundation/integrations/integrations.d.mts +4 -0
- package/foundation/integrations/integrations.mjs +6 -1
- package/foundation/release/choose.d.mts +7 -0
- package/foundation/release/choose.mjs +16 -2
- package/foundation/release/notices.d.mts +26 -0
- package/foundation/release/notices.mjs +48 -19
- package/foundation/release/project.d.mts +3 -2
- package/foundation/release/project.mjs +4 -5
- package/foundation/release/run-context.d.mts +7 -2
- package/foundation/release/run-context.mjs +6 -2
- package/foundation/render/css-cut.mjs +86 -6
- package/foundation/render/cut-short.d.mts +35 -0
- package/foundation/render/cut-short.mjs +124 -0
- package/foundation/render/font-probe.d.mts +27 -0
- package/foundation/render/font-probe.mjs +77 -0
- package/foundation/render/layers.d.mts +1 -9
- package/foundation/render/layers.mjs +2 -111
- package/foundation/render/page-worker.mjs +83 -6
- package/foundation/render/picture-chrome.mjs +24 -2
- package/foundation/render/picture-playwright.mjs +22 -2
- package/foundation/render/picture-window.d.mts +20 -4
- package/foundation/render/picture-window.mjs +137 -4
- package/foundation/response/base.d.ts +25 -0
- package/foundation/response/error-codes.d.mts +4 -1
- package/foundation/response/error-codes.d.ts +4 -1
- package/foundation/response/error-codes.doc.mjs +17 -0
- package/foundation/response/error-codes.mjs +21 -0
- package/foundation/response/json.d.mts +3 -1
- package/foundation/response/json.mjs +7 -2
- package/foundation/response/response-types.doc.mjs +2 -2
- package/foundation/suggest/name-index.d.mts +2 -1
- package/foundation/suggest/name-index.mjs +1 -1
- package/foundation/suggest/other-command.d.mts +4 -1
- package/foundation/suggest/other-command.mjs +23 -6
- package/foundation/text/string-utils.d.mts +7 -2
- package/foundation/text/string-utils.mjs +24 -10
- package/package.json +6 -6
- package/assets/templates/pages/access-denied/page.tsx +0 -101
- package/assets/templates/pages/access-denied/template.doc.mjs +0 -24
- package/assets/templates/pages/error-page/page.tsx +0 -130
- package/assets/templates/pages/error-page/template.doc.mjs +0 -22
- package/assets/templates/pages/not-found/page.tsx +0 -124
- package/assets/templates/pages/not-found/template.doc.mjs +0 -30
- package/assets/templates/pages/review-workspace/page.tsx +0 -551
- package/assets/templates/pages/review-workspace/template.doc.mjs +0 -31
- package/assets/templates/pages/run-console/page.tsx +0 -945
- package/assets/templates/pages/run-console/template.doc.mjs +0 -27
- package/assets/templates/pages/welcome-portal/page.tsx +0 -538
- package/assets/templates/pages/welcome-portal/template.doc.mjs +0 -38
|
@@ -213,8 +213,19 @@ const SHORT = wordTable(
|
|
|
213
213
|
}),
|
|
214
214
|
);
|
|
215
215
|
|
|
216
|
+
/**
|
|
217
|
+
* Words that describe text, which may sit between a weight word and the
|
|
218
|
+
* text it describes ("thin elegant headings"): never a part, a thing or a
|
|
219
|
+
* value of their own.
|
|
220
|
+
*/
|
|
221
|
+
const TEXT_WORDS =
|
|
222
|
+
'elegant|graceful|delicate|refined|classy|modern|clean|simple|fine|light(?:er)?|wide|narrow|serif|sans|display|body';
|
|
223
|
+
|
|
216
224
|
/** Plain words that are never corrected, though one letter off a VOCAB word. */
|
|
217
225
|
const KEEP = new Set([
|
|
226
|
+
// A reader (a book reader, a feed reader) is no header.
|
|
227
|
+
'reader',
|
|
228
|
+
'readers',
|
|
218
229
|
'selection',
|
|
219
230
|
'placeholder',
|
|
220
231
|
'cursor',
|
|
@@ -385,8 +396,67 @@ const HUES = wordTable(
|
|
|
385
396
|
white: '#ffffff',
|
|
386
397
|
cream: '#fef3c7',
|
|
387
398
|
beige: '#f5f5dc',
|
|
399
|
+
silver: '#c0c0c0',
|
|
400
|
+
// (The color names designers use for a palette, beside the hues.)
|
|
401
|
+
terracotta: '#c2603d',
|
|
402
|
+
sage: '#87a96b',
|
|
403
|
+
rust: '#b7410e',
|
|
404
|
+
mustard: '#d4a017',
|
|
405
|
+
olive: '#6b8e23',
|
|
406
|
+
burgundy: '#800020',
|
|
407
|
+
maroon: '#7f1d1d',
|
|
408
|
+
coral: '#f87171',
|
|
409
|
+
salmon: '#fa8072',
|
|
410
|
+
sand: '#d6c6a5',
|
|
411
|
+
taupe: '#8b7d6b',
|
|
412
|
+
slate: '#64748b',
|
|
413
|
+
emerald: '#059669',
|
|
414
|
+
forest: '#166534',
|
|
415
|
+
ruby: '#be123c',
|
|
416
|
+
plum: '#7e22ce',
|
|
417
|
+
lavender: '#c4b5fd',
|
|
418
|
+
peach: '#fdba74',
|
|
419
|
+
ivory: '#fffff0',
|
|
420
|
+
khaki: '#c3b091',
|
|
421
|
+
ochre: '#cc7722',
|
|
422
|
+
copper: '#b87333',
|
|
423
|
+
gold: '#ca8a04',
|
|
424
|
+
bronze: '#a16207',
|
|
425
|
+
mauve: '#b784a7',
|
|
388
426
|
}),
|
|
389
427
|
);
|
|
428
|
+
/**
|
|
429
|
+
* The palette names among the hues (terracotta, sage, slate…): read when
|
|
430
|
+
* said whole, never a word a typo is corrected to ("state" is no slate).
|
|
431
|
+
*/
|
|
432
|
+
const PALETTE_NAMES = new Set([
|
|
433
|
+
'terracotta',
|
|
434
|
+
'sage',
|
|
435
|
+
'rust',
|
|
436
|
+
'mustard',
|
|
437
|
+
'olive',
|
|
438
|
+
'burgundy',
|
|
439
|
+
'maroon',
|
|
440
|
+
'coral',
|
|
441
|
+
'salmon',
|
|
442
|
+
'sand',
|
|
443
|
+
'taupe',
|
|
444
|
+
'slate',
|
|
445
|
+
'emerald',
|
|
446
|
+
'forest',
|
|
447
|
+
'ruby',
|
|
448
|
+
'plum',
|
|
449
|
+
'lavender',
|
|
450
|
+
'peach',
|
|
451
|
+
'ivory',
|
|
452
|
+
'khaki',
|
|
453
|
+
'ochre',
|
|
454
|
+
'copper',
|
|
455
|
+
'gold',
|
|
456
|
+
'bronze',
|
|
457
|
+
'mauve',
|
|
458
|
+
'silver',
|
|
459
|
+
]);
|
|
390
460
|
/** A hue with light, pale or dark before it. */
|
|
391
461
|
const SHADED = wordTable(
|
|
392
462
|
/** @type {Record<string, Record<string, string>>} */ ({
|
|
@@ -536,8 +606,26 @@ function colorsFound(c) {
|
|
|
536
606
|
// "gray-50", "zinc 900": a stop on a gray family, by its lightness.
|
|
537
607
|
for (const m of c.matchAll(GRAY_STOP))
|
|
538
608
|
found.push([m.index ?? 0, grayStop(m[1], Number(m[2])), true]);
|
|
609
|
+
// "a cool blue-gray", "greenish grey": a gray with that hue in it (a
|
|
610
|
+
// little of the hue in a mid gray), never the hue itself.
|
|
611
|
+
const TINTED = /\b([a-z]+?)(?:ish)?[- ](?:gray|grey)\b/g;
|
|
612
|
+
for (const m of c.matchAll(TINTED)) {
|
|
613
|
+
const hue = HUES[m[1]];
|
|
614
|
+
const h = hue ? parseColor(hue) : null;
|
|
615
|
+
if (!h || /^(?:gray|grey|light|dark|pale|warm|cool|mid|medium)$/.test(m[1]))
|
|
616
|
+
continue;
|
|
617
|
+
const g = [107, 114, 128];
|
|
618
|
+
found.push([
|
|
619
|
+
m.index ?? 0,
|
|
620
|
+
hex(g.map((v, k) => Math.round(v * 0.85 + h[k] * 0.15))),
|
|
621
|
+
]);
|
|
622
|
+
c =
|
|
623
|
+
c.slice(0, m.index) +
|
|
624
|
+
' '.repeat(m[0].length) +
|
|
625
|
+
c.slice((m.index ?? 0) + m[0].length);
|
|
626
|
+
}
|
|
539
627
|
const re =
|
|
540
|
-
/#[0-9a-f]{3,8}\b|\b(?:rgba?|hsla?|hwb|lab|lch|oklab|oklch|color-mix)\([^)]*\)|\b(?:(lighter|light|pale|darker|dark|subtle|soft)\s+)?([a-z]+)\b/g;
|
|
628
|
+
/#[0-9a-f]{3,8}\b|\b(?:rgba?|hsla?|hwb|lab|lch|oklab|oklch|color-mix)\([^)]*\)|\b(?:(lighter|light|pale|darker|dark|deep|rich|subtle|soft)\s+)?([a-z]+)\b/g;
|
|
541
629
|
for (const m of c
|
|
542
630
|
.replace(GRAY_STOP, s => ' '.repeat(s.length))
|
|
543
631
|
.matchAll(re)) {
|
|
@@ -561,12 +649,32 @@ function colorsFound(c) {
|
|
|
561
649
|
soft: 'pale',
|
|
562
650
|
lighter: 'light',
|
|
563
651
|
darker: 'dark',
|
|
652
|
+
deep: 'dark',
|
|
653
|
+
rich: 'dark',
|
|
564
654
|
})[m[1] ?? ''] ?? m[1];
|
|
565
655
|
const word = m[2];
|
|
566
656
|
if (shade && SHADED[shade]?.[word]) {
|
|
567
657
|
found.push([m.index ?? 0, SHADED[shade][word]]);
|
|
568
658
|
continue;
|
|
569
659
|
}
|
|
660
|
+
// (A shade of a hue the table has no shade for: the hue mixed toward
|
|
661
|
+
// black, or toward white.)
|
|
662
|
+
const base = shade && HUES[word] ? parseColor(HUES[word]) : null;
|
|
663
|
+
// (A hue already that dark, "dark brown", is itself.)
|
|
664
|
+
if (
|
|
665
|
+
base &&
|
|
666
|
+
(shade === 'light' ||
|
|
667
|
+
shade === 'pale' ||
|
|
668
|
+
(shade === 'dark' && Math.max(...base.slice(0, 3)) > 150))
|
|
669
|
+
) {
|
|
670
|
+
const to = shade === 'dark' ? 0 : 255;
|
|
671
|
+
const k = shade === 'dark' ? 0.4 : shade === 'light' ? 0.75 : 0.88;
|
|
672
|
+
found.push([
|
|
673
|
+
m.index ?? 0,
|
|
674
|
+
hex(base.slice(0, 3).map(v => Math.round(v + (to - v) * k))),
|
|
675
|
+
]);
|
|
676
|
+
continue;
|
|
677
|
+
}
|
|
570
678
|
if (HUES[word])
|
|
571
679
|
found.push([(m.index ?? 0) + (m[1] ? m[1].length + 1 : 0), HUES[word]]);
|
|
572
680
|
else if (word.length > 3 && !NOT_COLORS.has(word) && parseColor(word))
|
|
@@ -691,6 +799,29 @@ export function tempShift(color, way, amount) {
|
|
|
691
799
|
return hex(out);
|
|
692
800
|
}
|
|
693
801
|
|
|
802
|
+
/**
|
|
803
|
+
* Calmer: the color moved toward the gray of its own lightness, so it is
|
|
804
|
+
* less saturated and keeps its light/dark ("make the error toast calmer",
|
|
805
|
+
* "the accent softer").
|
|
806
|
+
* @param {string} color @param {number} amount 0 to 1
|
|
807
|
+
*/
|
|
808
|
+
export function calmShift(color, amount) {
|
|
809
|
+
const rgb = parseColor(color);
|
|
810
|
+
if (!rgb) return null;
|
|
811
|
+
const g = 0.2126 * rgb[0] + 0.7152 * rgb[1] + 0.0722 * rgb[2];
|
|
812
|
+
const out = rgb.slice(0, 3).map(x => Math.round(x + (g - x) * amount));
|
|
813
|
+
const a = alphaOf(color);
|
|
814
|
+
return a < 1
|
|
815
|
+
? `${hex(out)}${Math.round(a * 255)
|
|
816
|
+
.toString(16)
|
|
817
|
+
.padStart(2, '0')}`
|
|
818
|
+
: hex(out);
|
|
819
|
+
}
|
|
820
|
+
|
|
821
|
+
/** "calmer", "softer", "duller", "toned down", "less loud": less saturated. */
|
|
822
|
+
const CALMER =
|
|
823
|
+
/\b(?:calmer|calm (?:it )?down|duller|more muted|toned? down|less (?:saturated|vivid|loud|bright|intense|garish|vibrant|punchy))\b/;
|
|
824
|
+
|
|
694
825
|
/**
|
|
695
826
|
* The overlay made lighter or darker: only its alpha moves, by the amount
|
|
696
827
|
* asked (a step is a quarter), and it never turns fully opaque or vanishes.
|
|
@@ -1715,7 +1846,7 @@ export function exactFactor(text) {
|
|
|
1715
1846
|
return n && d && n < d ? n / d : null;
|
|
1716
1847
|
};
|
|
1717
1848
|
// (More see-through is less of the color: a share of it is fainter.)
|
|
1718
|
-
const WAY = String.raw`bigger|larger|more|wider|taller|thicker|higher|stronger|smaller|less|tighter|narrower|thinner|shorter|lower|fainter|weaker`;
|
|
1849
|
+
const WAY = String.raw`bigger|larger|more|wider|taller|thicker|higher|stronger|darker|lighter|smaller|less|tighter|narrower|thinner|shorter|lower|fainter|weaker`;
|
|
1719
1850
|
const seeThrough = /\bmore (?:transparent|translucent|see-through)\b/.test(t);
|
|
1720
1851
|
// "half again as big": one and a half; "a third again": four thirds.
|
|
1721
1852
|
if (/\bhalf again\b/.test(t)) return 1.5;
|
|
@@ -1779,7 +1910,7 @@ export function exactFactor(text) {
|
|
|
1779
1910
|
if (/\b\d*\.?\d+(?:px|rem|em)?\s*[x×]\s*\d*\.?\d+\b/.test(t)) return null;
|
|
1780
1911
|
// "3 times bigger", "2 times smaller", "4 times", "2x", "1.5x", "x2".
|
|
1781
1912
|
const nTimes =
|
|
1782
|
-
/\b(\d*\.?\d+)(?:px)?\s*(?:times|x)\b(?:\s+(bigger|larger|more|wider|taller|thicker|as|smaller|less|thinner|narrower))?/.exec(
|
|
1913
|
+
/\b(\d*\.?\d+)(?:px)?\s*(?:times|x)\b(?:\s+(bigger|larger|more|wider|taller|thicker|stronger|as|smaller|less|thinner|narrower|fainter|weaker))?/.exec(
|
|
1783
1914
|
t,
|
|
1784
1915
|
);
|
|
1785
1916
|
if (nTimes && Number(nTimes[1]) >= 0 && Number(nTimes[1]) <= 20) {
|
|
@@ -1876,7 +2007,7 @@ export function partLexicon(ctx) {
|
|
|
1876
2007
|
const vocab = [
|
|
1877
2008
|
...new Set([
|
|
1878
2009
|
...DESIGN_WORDS,
|
|
1879
|
-
...Object.keys(HUES).filter(w => w.length >= 5),
|
|
2010
|
+
...Object.keys(HUES).filter(w => w.length >= 5 && !PALETTE_NAMES.has(w)),
|
|
1880
2011
|
...[...project.target.keys()]
|
|
1881
2012
|
.filter(key => !key.includes('-'))
|
|
1882
2013
|
.flatMap(key => [key, `${key}s`]),
|
|
@@ -1995,6 +2126,15 @@ export function partLexicon(ctx) {
|
|
|
1995
2126
|
? held[0]
|
|
1996
2127
|
: null;
|
|
1997
2128
|
if (!real && keys.has(piece) && inside.includes(piece)) continue;
|
|
2129
|
+
// (A part that paints its own fill, a card: "the card fill" is its
|
|
2130
|
+
// background, never a piece.)
|
|
2131
|
+
if (
|
|
2132
|
+
piece === 'fill' &&
|
|
2133
|
+
['background-color', 'background'].some(
|
|
2134
|
+
p => Object.keys(ctx.C.MAP[key]?.own?.[p]?.tokens ?? {}).length,
|
|
2135
|
+
)
|
|
2136
|
+
)
|
|
2137
|
+
continue;
|
|
1998
2138
|
// Several such parts inside (a date and a time segment): each is
|
|
1999
2139
|
// named by its own name, so none is missing.
|
|
2000
2140
|
if (!real && held.length > 1) continue;
|
|
@@ -2103,13 +2243,17 @@ const STATE_WORDS = /** @type {Array<[RegExp, string]>} */ ([
|
|
|
2103
2243
|
/\bloading\b(?! (bars?|placeholders?|skeletons?|spinners?|states?|indicators?))/,
|
|
2104
2244
|
'loading',
|
|
2105
2245
|
],
|
|
2106
|
-
[
|
|
2246
|
+
[
|
|
2247
|
+
/\b(unchecked|not checked|unticked|when off|turned off|toggled off|switched off|is off)\b/,
|
|
2248
|
+
'unchecked',
|
|
2249
|
+
],
|
|
2107
2250
|
]);
|
|
2108
2251
|
|
|
2109
2252
|
/**
|
|
2110
2253
|
* One clause, read.
|
|
2111
2254
|
* @typedef {object} Clause
|
|
2112
2255
|
* @property {string} text
|
|
2256
|
+
* @property {string} [joint] - the words that joined the clause to the one before ("with", "and", ",", ";")
|
|
2113
2257
|
* @property {Array<{on: string, when?: string, role?: string, level?: string, missing?: string}>} parts
|
|
2114
2258
|
* @property {string[]} aspects
|
|
2115
2259
|
* @property {boolean} neg
|
|
@@ -2166,6 +2310,12 @@ function aspectsOf(text) {
|
|
|
2166
2310
|
// shape to make ("into circles", "as circles" still are).
|
|
2167
2311
|
c
|
|
2168
2312
|
.replace(/\bround \d+\b/g, ' ')
|
|
2313
|
+
// ("a rounded font", "a round typeface": a kind of font, its
|
|
2314
|
+
// letters, never corners.)
|
|
2315
|
+
.replace(
|
|
2316
|
+
/\b(?:round(?:ed)?|circular)(?:\s+(?:sans|serif|friendly|soft|bold|big))*\s+(?:fonts?|typefaces?|type|lettering|letters)\b/g,
|
|
2317
|
+
' font ',
|
|
2318
|
+
)
|
|
2169
2319
|
.replace(
|
|
2170
2320
|
/(?<!\b(?:into|as|to|like|be|them|it)\s)\bcircles?\b/g,
|
|
2171
2321
|
(m, at) => (colorsIn(c.slice(at)).length ? ' ' : m),
|
|
@@ -2220,9 +2370,12 @@ function aspectsOf(text) {
|
|
|
2220
2370
|
/\b\d+(\.\d+)?(px|rem|em|pt) (regular|normal|medium)\b|\b(body|text|headings?) (regular|normal)$/.test(
|
|
2221
2371
|
c,
|
|
2222
2372
|
) ||
|
|
2223
|
-
|
|
2224
|
-
|
|
2225
|
-
)
|
|
2373
|
+
// "thin headings", "thin elegant headings": a weight word before the
|
|
2374
|
+
// text it describes, whatever words sit between (each one a word about
|
|
2375
|
+
// the text, never a part or a thing of its own).
|
|
2376
|
+
new RegExp(
|
|
2377
|
+
String.raw`\bthin(?:ner)?\b(?:\s+(?:and|a|the|very|really|quite|more|${TEXT_WORDS}))*\s+(?:font|text|type|letters|lettering|headings?|titles?|labels?|copy)\b`,
|
|
2378
|
+
).test(c) ||
|
|
2226
2379
|
(/\blight(er)?\b/.test(c) &&
|
|
2227
2380
|
/\b(headings?|titles?|font|weight)\b/.test(c) &&
|
|
2228
2381
|
!/\b(text|colou?r|mode|background|bg)\b/.test(c))
|
|
@@ -2333,6 +2486,22 @@ function aspectsOf(text) {
|
|
|
2333
2486
|
}
|
|
2334
2487
|
|
|
2335
2488
|
/** Font names a question can name, as words. */
|
|
2489
|
+
/**
|
|
2490
|
+
* A font preset's whole stack as a CSS value (`ui-monospace, "SF Mono",
|
|
2491
|
+
* Menlo, Consolas, monospace`), an open font's with its fallbacks, or a
|
|
2492
|
+
* family name as written, quoted when it holds a space.
|
|
2493
|
+
* @param {string} font
|
|
2494
|
+
*/
|
|
2495
|
+
function presetStack(font) {
|
|
2496
|
+
return FONTS[font]
|
|
2497
|
+
? `${FONTS[font][0].includes(' ') ? `"${FONTS[font][0]}"` : FONTS[font][0]}, ${FONTS[font][1]}`
|
|
2498
|
+
: OPEN_FONTS[font]
|
|
2499
|
+
? `"${OPEN_FONTS[font].family}", ${OPEN_FONTS[font].fallbacks}`
|
|
2500
|
+
: /[\s,]/.test(font) && !font.includes(',')
|
|
2501
|
+
? `"${font}"`
|
|
2502
|
+
: font;
|
|
2503
|
+
}
|
|
2504
|
+
|
|
2336
2505
|
const FONT_NAMES = [...Object.keys(OPEN_FONTS), ...Object.keys(FONTS)]
|
|
2337
2506
|
.filter(k => !['system', 'serif', 'mono', 'rounded', 'comic'].includes(k))
|
|
2338
2507
|
.map(k => k.replace(/-/g, ' '))
|
|
@@ -2644,18 +2813,33 @@ function clausesOf(q, partWords) {
|
|
|
2644
2813
|
? `${a} & ${b} ${noun}`
|
|
2645
2814
|
: m,
|
|
2646
2815
|
);
|
|
2647
|
-
|
|
2648
|
-
|
|
2649
|
-
|
|
2650
|
-
|
|
2651
|
-
|
|
2652
|
-
|
|
2816
|
+
// (Each piece keeps the words that joined it to the one before, "with",
|
|
2817
|
+
// "and", a comma or a sentence's end: the clause-scope reader reads them.)
|
|
2818
|
+
/** @type {Array<{text: string, joint: string}>} */
|
|
2819
|
+
const pieces = [];
|
|
2820
|
+
{
|
|
2821
|
+
const split = (
|
|
2822
|
+
/\bswap\b/.test(bothStates)
|
|
2823
|
+
? bothStates.replace(/\band\b/g, '&')
|
|
2824
|
+
: sharedAsk(bothStates, partWords)
|
|
2825
|
+
).split(
|
|
2653
2826
|
// A font stack ("Georgia, serif") is one value, not two asks.
|
|
2654
|
-
|
|
2655
|
-
)
|
|
2656
|
-
|
|
2657
|
-
.
|
|
2658
|
-
|
|
2827
|
+
/(;|\.(?=\s|$)|,(?![^(]*\))(?!\s*(?:serif|sans-serif|monospace|system-ui|cursive|fantasy|ui-[a-z-]+)\b)|\b(?:and|but|then|plus|also|y|et|und|и)\b|(?<!\b(?:tint(?:ed|s)?|paint(?:ed|s)?|wash(?:ed|es)?)(?:\s+[a-z-]+){0,3}\s+)\bwith\b(?!\s+(?:an?\s+)?\d{1,3}(?:\.\d+)?\s?%\s+(?:alpha|opacity|transparency)\b)|\bwhile\b|(?=\bexcept\b))/,
|
|
2828
|
+
);
|
|
2829
|
+
let joint = '';
|
|
2830
|
+
for (let k = 0; k < split.length; k++) {
|
|
2831
|
+
const piece = split[k] ?? '';
|
|
2832
|
+
if (k % 2) {
|
|
2833
|
+
joint += piece;
|
|
2834
|
+
continue;
|
|
2835
|
+
}
|
|
2836
|
+
const text = piece.trim();
|
|
2837
|
+
if (!text) continue;
|
|
2838
|
+
pieces.push({text, joint});
|
|
2839
|
+
joint = '';
|
|
2840
|
+
}
|
|
2841
|
+
}
|
|
2842
|
+
return pieces.map(({text, joint}) => {
|
|
2659
2843
|
/** @type {Clause['parts']} */
|
|
2660
2844
|
const parts = [];
|
|
2661
2845
|
// A property name is not a part: "backdrop-filter" names no backdrop.
|
|
@@ -2742,15 +2926,19 @@ function clausesOf(q, partWords) {
|
|
|
2742
2926
|
// named again as the reference is its own color in that look.
|
|
2743
2927
|
if (parts.length >= 1 && parts.every(p => p.on === parts[0].on)) {
|
|
2744
2928
|
const places = placesOf(parts[0]);
|
|
2745
|
-
const again = places
|
|
2746
|
-
|
|
2747
|
-
|
|
2748
|
-
|
|
2749
|
-
|
|
2750
|
-
|
|
2751
|
-
|
|
2752
|
-
|
|
2753
|
-
|
|
2929
|
+
const again = places.slice(1).find(
|
|
2930
|
+
where =>
|
|
2931
|
+
// ("… the color of the primary button", "… the primary button
|
|
2932
|
+
// color".)
|
|
2933
|
+
(new RegExp(
|
|
2934
|
+
String.raw`\bcolou?r of\s+(?:the\s+|my\s+)?${ownWord}$`,
|
|
2935
|
+
).test(text.slice(0, where.index)) ||
|
|
2936
|
+
(new RegExp(String.raw`\b(?:the|my|a)\s+${ownWord}$`).test(
|
|
2937
|
+
text.slice(0, where.index),
|
|
2938
|
+
) &&
|
|
2939
|
+
/^(?:'s)?\s+colou?r\b/.test(text.slice(where.end)))) &&
|
|
2940
|
+
isOwnWord(text.slice(0, where.index)),
|
|
2941
|
+
);
|
|
2754
2942
|
if (again) {
|
|
2755
2943
|
colorRef = parts[0].on;
|
|
2756
2944
|
refSaid = text.slice(again.index, again.end);
|
|
@@ -3031,8 +3219,18 @@ function clausesOf(q, partWords) {
|
|
|
3031
3219
|
const tooMore = new RegExp(
|
|
3032
3220
|
`\\btoo (?:small|faded|light|thin|sharp|square|boxy|pointy|subtle|weak|narrow|dim|low|short|${densityWords('dense', 'crowded')})\\b`,
|
|
3033
3221
|
);
|
|
3222
|
+
// "softer corners", "gentler corners": a corner is softened by
|
|
3223
|
+
// rounding it, so the way is more (a softer shadow or color is still
|
|
3224
|
+
// less; "soften the corners" is read by the corner rungs).
|
|
3225
|
+
const softCorners =
|
|
3226
|
+
/\b(?:softer|gentler|smoother|friendlier|less harsh)\b/.test(text) &&
|
|
3227
|
+
/\b(?:corners?|radius|radii)\b/.test(text) &&
|
|
3228
|
+
!/\b(?:shadows?|colou?rs?|text|borders?|backgrounds?|fills?)\b/.test(
|
|
3229
|
+
text,
|
|
3230
|
+
);
|
|
3034
3231
|
// "half again", "a third again": more by that share, never less.
|
|
3035
3232
|
const dir =
|
|
3233
|
+
softCorners ||
|
|
3036
3234
|
/\bnot (\w+ ){0,2}enough\b|\b(half|a third|a quarter|1\/2|1\/3|1\/4) again\b/.test(
|
|
3037
3235
|
text,
|
|
3038
3236
|
)
|
|
@@ -3118,14 +3316,19 @@ function clausesOf(q, partWords) {
|
|
|
3118
3316
|
/\blight (mode|theme)\b|\bin light(?=\s*(?:[,;.!?]|$|and\b|only\b))/.test(
|
|
3119
3317
|
text,
|
|
3120
3318
|
);
|
|
3319
|
+
// (The theme's own mode, "a dark-only theme", scopes no ask.)
|
|
3320
|
+
const modeText = text.replace(
|
|
3321
|
+
/\b(?:dark|light)-only (?:theme|look|ui|interface|design)\b/g,
|
|
3322
|
+
' ',
|
|
3323
|
+
);
|
|
3121
3324
|
const darkPhrase =
|
|
3122
3325
|
labelMode === 'dark' ||
|
|
3123
|
-
/\bdark (mode|theme)\b|\bin dark\b|\boled\b/.test(
|
|
3326
|
+
/\bdark (mode|theme)\b|\bin dark\b|\boled\b/.test(modeText);
|
|
3124
3327
|
const mode =
|
|
3125
3328
|
darkPhrase ||
|
|
3126
3329
|
(!lightPhrase &&
|
|
3127
|
-
/\bdark( mode| theme)?\b/.test(
|
|
3128
|
-
/\b(mode|theme|in dark)\b/.test(
|
|
3330
|
+
/\bdark( mode| theme)?\b/.test(modeText) &&
|
|
3331
|
+
/\b(mode|theme|in dark)\b/.test(modeText))
|
|
3129
3332
|
? 'dark'
|
|
3130
3333
|
: // Only mode phrases: "all day" or "the selected day" is no mode.
|
|
3131
3334
|
// (Night and day are read as the modes when the question is.)
|
|
@@ -3142,6 +3345,7 @@ function clausesOf(q, partWords) {
|
|
|
3142
3345
|
/\b(not|except)( for| on| in| the)* [a-z]/.test(negText)));
|
|
3143
3346
|
return {
|
|
3144
3347
|
text,
|
|
3348
|
+
joint,
|
|
3145
3349
|
parts,
|
|
3146
3350
|
...(colorRef ? {colorRef} : {}),
|
|
3147
3351
|
...(refSpan ? {colorRefSpan: refSpan} : {}),
|
|
@@ -3541,6 +3745,19 @@ export function draftAnswer(ctx, env, question) {
|
|
|
3541
3745
|
// (A mode said with a typo that keeps its letters, "drak mode", "ligth
|
|
3542
3746
|
// theme", or in the editor's own label, "(drak)", "[dark only]", is that
|
|
3543
3747
|
// mode, by the one mode reader.)
|
|
3748
|
+
// A CSS custom property pasted from a stylesheet (`--brand-primary:
|
|
3749
|
+
// #4f46e5`) that is none of this Core's tokens names what it sets by its
|
|
3750
|
+
// last words, never the prefix a codebase repeats on every one of them:
|
|
3751
|
+
// `--brand-bg` is a background. A token this Core has is left as it is.
|
|
3752
|
+
{
|
|
3753
|
+
const tokens = ctx.project.core.tokenDefaults ?? {};
|
|
3754
|
+
question = String(question).replace(/--[a-z][\w-]*/gi, m => {
|
|
3755
|
+
const name = m.toLowerCase();
|
|
3756
|
+
if (Object.hasOwn(tokens, name)) return m;
|
|
3757
|
+
const parts = name.slice(2).split('-');
|
|
3758
|
+
return parts.length > 1 ? parts.slice(1).join(' ') : parts.join(' ');
|
|
3759
|
+
});
|
|
3760
|
+
}
|
|
3544
3761
|
question = String(question)
|
|
3545
3762
|
.replace(/\b([a-z]+)[- ]?(mode|theme)\b/gi, (m, w, k) => {
|
|
3546
3763
|
const mode = modeNear(w);
|
|
@@ -3625,12 +3842,96 @@ export function draftAnswer(ctx, env, question) {
|
|
|
3625
3842
|
'$2 more $1',
|
|
3626
3843
|
)
|
|
3627
3844
|
.replace(/\b([a-z]{3,}er)\s+by\s+(\d{1,3}(?:\.\d+)?)\s?%/gi, '$2% $1')
|
|
3845
|
+
// ("the warning color darker so it reads on the page": what it is read
|
|
3846
|
+
// on is the ground, never the thing changed; "readable" says the
|
|
3847
|
+
// purpose.)
|
|
3848
|
+
.replace(
|
|
3849
|
+
/[,;]?\s*\b(?:so|so that|until)\s+(?:it|they|its text|the text)\s+(?:reads?|shows?|stands? out|is readable|are readable|pops?|is visible|are visible|passes|pass)\b(?:\s+(?:better|clearly|well))?(?:\s+(?:on|against|over)\s+(?:the\s+|a\s+)?[a-z]+)?/gi,
|
|
3850
|
+
' readable',
|
|
3851
|
+
)
|
|
3852
|
+
// ("when inputs are focused, a 2px ring": a ring said of the focused
|
|
3853
|
+
// state is the focus ring, on the parts focused.)
|
|
3854
|
+
.replace(
|
|
3855
|
+
/\bwhen\s+(?:the\s+)?([a-z][a-z -]*?)\s+(?:are|is|get|gets)\s+focused\s*,?\s*(?:give\s+them\s+|show\s+)?(?:a|an)?\s*((?:[^,;.]*?\s)?)rings?\b/gi,
|
|
3856
|
+
'focus ring on $1 $2',
|
|
3857
|
+
)
|
|
3858
|
+
.replace(
|
|
3859
|
+
/\b(?<!focus(?:-visible|-within)?[\s-])rings?\b/gi,
|
|
3860
|
+
(m, _at, whole) =>
|
|
3861
|
+
/\bfocus(?:ed|ing)?\b/i.test(String(whole)) &&
|
|
3862
|
+
!/\bfocus\s+rings?\b/i.test(String(whole))
|
|
3863
|
+
? 'focus ring'
|
|
3864
|
+
: m,
|
|
3865
|
+
)
|
|
3866
|
+
// ("large text", "small type": the text's size the way said.)
|
|
3867
|
+
// ("small text" names the supporting text, never a way.)
|
|
3868
|
+
.replace(
|
|
3869
|
+
/\b(large|big|huge)\s+(text|type|print|lettering)\b(?!\s+(?:bigger|smaller|larger|on|in|for)\b)/gi,
|
|
3870
|
+
'larger $2',
|
|
3871
|
+
)
|
|
3872
|
+
// ("grayscale", "black and white only, no color": no color in the
|
|
3873
|
+
// generated colors, the vibrancy dial at 0.)
|
|
3874
|
+
.replace(
|
|
3875
|
+
/\b(?:gr[ae]yscale|monochrome|black[- ]and[- ]white(?:\s+only)?|colou?rless|no colou?rs?(?:\s+at\s+all)?)\b/gi,
|
|
3876
|
+
'vibrancy 0',
|
|
3877
|
+
)
|
|
3878
|
+
// ("so readers see which page they are on": why it is asked, never a
|
|
3879
|
+
// part to change.)
|
|
3880
|
+
.replace(
|
|
3881
|
+
/[,;]?\s*\bso\s+(?:that\s+)?(?:readers|users|people|you|they|we|visitors|customers)\s+(?:can\s+)?(?:see|know|tell|notice|find|spot)\b[^,;.]*/gi,
|
|
3882
|
+
' ',
|
|
3883
|
+
)
|
|
3884
|
+
// ("make text more readable", "easier to read": the text larger.)
|
|
3885
|
+
.replace(
|
|
3886
|
+
/\b(?:make\s+)?(?:the\s+)?text\s+(?:more\s+readable|easier\s+to\s+read)\b|\bmore\s+readable\s+text\b/gi,
|
|
3887
|
+
'larger text',
|
|
3888
|
+
)
|
|
3889
|
+
// ("a theme that works in dark mode": a theme with both modes, which it
|
|
3890
|
+
// has; never an ask scoped to dark.)
|
|
3891
|
+
.replace(
|
|
3892
|
+
/\b(?:that\s+|which\s+)?(?:works|looks good|holds up|also works|is usable|works well)\s+in\s+(?:both\s+)?(?:dark|light)(?:\s+(?:and|&)\s+(?:dark|light))?\s+modes?\b/gi,
|
|
3893
|
+
' ',
|
|
3894
|
+
)
|
|
3895
|
+
// ("almost square", "nearly square": a rung short of square, the
|
|
3896
|
+
// small corners.)
|
|
3897
|
+
.replace(
|
|
3898
|
+
/\b(?:almost|nearly|practically|close to|not quite)\s+square\b/gi,
|
|
3899
|
+
'small corners',
|
|
3900
|
+
)
|
|
3901
|
+
// ("high-contrast", "low-contrast": the words, as "high contrast".)
|
|
3902
|
+
.replace(/\b(high|higher|low|lower|more|less)-contrast\b/gi, '$1 contrast')
|
|
3903
|
+
// ("no dark mode": a theme with only its light mode; "no light mode"
|
|
3904
|
+
// the same, dark.)
|
|
3905
|
+
.replace(
|
|
3906
|
+
/\b(?:no|without(?: a)?)\s+(dark|light)\s+mode\b(?!\s+(?:for|on|in)\b)/gi,
|
|
3907
|
+
(_m, w) => `${/dark/i.test(w) ? 'light' : 'dark'}-only theme,`,
|
|
3908
|
+
)
|
|
3909
|
+
// "a calm, dark theme with a violet accent": a theme said to be dark
|
|
3910
|
+
// (or light) is the theme's mode, a piece of its own; never a mode
|
|
3911
|
+
// that scopes the asks beside it. ("Light and dark" asks both.)
|
|
3912
|
+
.replace(
|
|
3913
|
+
/\b(dark|light)(?:[- ]mode)?\s+(theme|look|ui|interface|design)\b(?!\s*(?:only\b|:))/gi,
|
|
3914
|
+
(m, w, n, _at, whole) =>
|
|
3915
|
+
/\b(?:light and dark|dark and light|light\s*[+/&]\s*dark|dark\s*[+/&]\s*light|both modes)\b/i.test(
|
|
3916
|
+
String(whole),
|
|
3917
|
+
)
|
|
3918
|
+
? m
|
|
3919
|
+
: `${String(w).toLowerCase()}-only ${n},`,
|
|
3920
|
+
)
|
|
3628
3921
|
// "the card's fainter text lighter": a fainter word right before the
|
|
3629
3922
|
// text, with another way said for it, says WHICH text (the secondary
|
|
3630
3923
|
// text), never the way.
|
|
3924
|
+
// (Or a color for it: "the card's fainter text red".)
|
|
3631
3925
|
.replace(
|
|
3632
|
-
/\b(?:fainter|subtler|faint|subtle)\s+(text|labels?|copy)\b
|
|
3633
|
-
|
|
3926
|
+
/\b(?:fainter|subtler|faint|subtle)\s+(text|labels?|copy)\b/gi,
|
|
3927
|
+
(m, what, at, whole) => {
|
|
3928
|
+
const rest = String(whole).slice(Number(at) + m.length);
|
|
3929
|
+
return /\b(?:lighter|darker|bigger|smaller|bolder|thinner|larger|brighter|paler|fainter|subtler)\b/i.test(
|
|
3930
|
+
rest,
|
|
3931
|
+
) || colorsIn(rest).length
|
|
3932
|
+
? `secondary ${what}`
|
|
3933
|
+
: m;
|
|
3934
|
+
},
|
|
3634
3935
|
);
|
|
3635
3936
|
const {C} = ctx;
|
|
3636
3937
|
const TARGET = ctx.project.target;
|
|
@@ -3783,10 +4084,27 @@ export function draftAnswer(ctx, env, question) {
|
|
|
3783
4084
|
// after it, with or without the hyphen. A thing taken away ("un-outlined",
|
|
3784
4085
|
// "border-less", "shadowless") is its removal, "no border"; a look taken
|
|
3785
4086
|
// away ("un-rounded", "non-bold") is its opposite, as NEGATED names it.
|
|
4087
|
+
// (Said before a part with another value or a way for it, "the
|
|
4088
|
+
// borderless buttons red", it says WHICH parts, the look drawn without
|
|
4089
|
+
// it: kept as one word for the look reader.)
|
|
3786
4090
|
question = question
|
|
3787
4091
|
.replace(
|
|
3788
4092
|
/\b(?:(?:un|non)-?(border|outline|shadow|stroke|underline|gradient)(?:d|ed|s)?|(border|outline|shadow|stroke|underline|gradient)-?less)\b/gi,
|
|
3789
|
-
(
|
|
4093
|
+
(m, a, b, at, whole) => {
|
|
4094
|
+
const thing = String(a ?? b).toLowerCase();
|
|
4095
|
+
const rest = String(whole).slice(Number(at) + m.length);
|
|
4096
|
+
const describes =
|
|
4097
|
+
/^\s+[a-z]+/.test(rest) &&
|
|
4098
|
+
!/^\s+(?:and|or|on|in|please|but|everywhere|anywhere)\b/i.test(
|
|
4099
|
+
rest,
|
|
4100
|
+
) &&
|
|
4101
|
+
(colorsIn(rest).length > 0 ||
|
|
4102
|
+
/\b(?:darker|lighter|bigger|smaller|rounder|bolder|taller|wider|thicker|thinner|brighter|paler)\b/i.test(
|
|
4103
|
+
rest,
|
|
4104
|
+
)) &&
|
|
4105
|
+
/^(?:border|outline|shadow)$/.test(thing);
|
|
4106
|
+
return describes ? `${thing}less` : `no ${thing}`;
|
|
4107
|
+
},
|
|
3790
4108
|
)
|
|
3791
4109
|
.replace(
|
|
3792
4110
|
new RegExp(`\\b(?:un|non)-?(${Object.keys(NEGATED).join('|')})\\b`, 'gi'),
|
|
@@ -4235,6 +4553,21 @@ export function draftAnswer(ctx, env, question) {
|
|
|
4235
4553
|
)
|
|
4236
4554
|
// "exactly 36px": the value said.
|
|
4237
4555
|
.replace(/\bexactly\s+(?=\d*\.?\d+\s?(?:px|rem|em|%)\b)/gi, '')
|
|
4556
|
+
// ("darker by a third": the share before the way, as said either way;
|
|
4557
|
+
// "a third darker", "a quarter lighter": that share of the way;
|
|
4558
|
+
// "half as dark" is half the darkness, lighter.)
|
|
4559
|
+
.replace(
|
|
4560
|
+
/\b(darker|lighter)\s+by\s+((?:a|an|one|two|three)\s+(?:half|thirds?|quarters?|fifths?)|half)\b/gi,
|
|
4561
|
+
'$2 $1',
|
|
4562
|
+
)
|
|
4563
|
+
.replace(
|
|
4564
|
+
/\b(a|an|one)\s+(third|quarter|fifth)\s+(darker|lighter)\b/gi,
|
|
4565
|
+
(_m, _a, d, way) =>
|
|
4566
|
+
`${Number(((1 / /** @type {Record<string, number>} */ ({third: 3, quarter: 4, fifth: 5})[String(d).toLowerCase()]) * 100).toFixed(3))}% ${way}`,
|
|
4567
|
+
)
|
|
4568
|
+
.replace(/\bhalf\s+as\s+(dark|light)\b/gi, (_m, w) =>
|
|
4569
|
+
/dark/i.test(w) ? '50% lighter' : '50% darker',
|
|
4570
|
+
)
|
|
4238
4571
|
// (A share before a way, "two thirds fainter", "1/3 bigger", is that
|
|
4239
4572
|
// share more or less, "N% fainter"; elsewhere that share of now.)
|
|
4240
4573
|
.replace(
|
|
@@ -4309,6 +4642,27 @@ export function draftAnswer(ctx, env, question) {
|
|
|
4309
4642
|
/^\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;
|
|
4310
4643
|
const isAsk = (/** @type {string} */ x) => {
|
|
4311
4644
|
if (NEUTRAL.test(x)) return true;
|
|
4645
|
+
// ("a calm, dark theme": a look said for the theme, its mode, is an
|
|
4646
|
+
// ask of its own.)
|
|
4647
|
+
if (/\b(?:dark|light)-only (?:theme|look|ui|interface|design)\b/i.test(x))
|
|
4648
|
+
return true;
|
|
4649
|
+
// ("the app should open in dark mode by default": the mode it shows
|
|
4650
|
+
// first, an ask about the theme.)
|
|
4651
|
+
if (
|
|
4652
|
+
/\b(?:opens?|starts?|launch(?:es)?|loads?)\s+(?:up\s+)?in\s+(?:dark|light)\b|\b(?:dark|light)(?:\s+mode)?\s+by\s+default\b/i.test(
|
|
4653
|
+
x,
|
|
4654
|
+
)
|
|
4655
|
+
)
|
|
4656
|
+
return true;
|
|
4657
|
+
// ("light only", "dark only", "no dark mode": the theme's mode;
|
|
4658
|
+
// "a right-to-left app": a question about the theme, answered.)
|
|
4659
|
+
if (
|
|
4660
|
+
/^\s*(?:(?:dark|light)(?:[- ]mode)?[- ]only|no (?:dark|light) mode|without (?:a )?(?:dark|light) mode)\s*[.!]?\s*$/i.test(
|
|
4661
|
+
x,
|
|
4662
|
+
) ||
|
|
4663
|
+
/\b(?:rtl|right[- ]to[- ]left)\b/i.test(x)
|
|
4664
|
+
)
|
|
4665
|
+
return true;
|
|
4312
4666
|
// A bare CSS value ("0 8px 10px -6px rgb(0 0 0 / 0.1)") continues the
|
|
4313
4667
|
// clause before it.
|
|
4314
4668
|
const bare = x.replace(
|
|
@@ -4493,7 +4847,7 @@ export function draftAnswer(ctx, env, question) {
|
|
|
4493
4847
|
// A tag question ("corners are 10px, eh", "cards have a shadow, right?")
|
|
4494
4848
|
// asks back about the whole line.
|
|
4495
4849
|
const TAG =
|
|
4496
|
-
/^(?: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;
|
|
4850
|
+
/^(?:eh|right|correct|yeah|huh|no|isn'?t it|aren'?t they|are they|is it|are we|do they|does it|ok|okay|(?:or )?am i (?:wrong|right|mistaken))\s*[?!.]*$/i;
|
|
4497
4851
|
const gateAll =
|
|
4498
4852
|
segments.some(x => TAG.test(x.trim())) ||
|
|
4499
4853
|
SARCASM.test(question) ||
|
|
@@ -4806,7 +5160,12 @@ export function draftAnswer(ctx, env, question) {
|
|
|
4806
5160
|
.replace(/\s*=\s*/g, ' ')
|
|
4807
5161
|
.replace(/\bon\s*:\s*/g, 'on ')
|
|
4808
5162
|
// Near-white and near-black are their own colors.
|
|
4809
|
-
|
|
5163
|
+
// ("off-white" is a color word; a typed value said with it wins.)
|
|
5164
|
+
.replace(/\boff[- ]?white\b/gi, (m, _at, whole) =>
|
|
5165
|
+
/#[0-9a-f]{3,8}\b|\b(?:rgba?|hsla?|oklch)\(/i.test(String(whole))
|
|
5166
|
+
? ' '
|
|
5167
|
+
: '#fafafa',
|
|
5168
|
+
)
|
|
4810
5169
|
.replace(/\boff[- ]?black\b/gi, '#111111')
|
|
4811
5170
|
// "match the header color to the sidebar": the first part is the one to
|
|
4812
5171
|
// change.
|
|
@@ -5312,10 +5671,393 @@ export function draftAnswer(ctx, env, question) {
|
|
|
5312
5671
|
);
|
|
5313
5672
|
const media = MEDIA_RE.test(q);
|
|
5314
5673
|
if (media) q = q.replace(MEDIA_RE, ' ').replace(/\s+/g, ' ').trim();
|
|
5315
|
-
const
|
|
5674
|
+
const clauses0 = clausesOf(q, lex.parts);
|
|
5675
|
+
// "cream background, terracotta accent, serif headings": a list whose
|
|
5676
|
+
// items each ask their own thing is each of them, never the first one's
|
|
5677
|
+
// part taking the rest.
|
|
5678
|
+
const clauses = clauses0.flatMap(c => {
|
|
5679
|
+
if (!/,/.test(c.text) || c.except) return [c];
|
|
5680
|
+
// (Only the commas between asks: never inside a value, "color-mix(in
|
|
5681
|
+
// srgb, #2563eb 10%, white)", nor between a list's values, "Inter,
|
|
5682
|
+
// sans-serif".)
|
|
5683
|
+
/** @type {string[]} */
|
|
5684
|
+
const pieces = [];
|
|
5685
|
+
let depth = 0;
|
|
5686
|
+
let cur = '';
|
|
5687
|
+
for (const ch of c.text) {
|
|
5688
|
+
if (ch === '(') depth++;
|
|
5689
|
+
if (ch === ')') depth = Math.max(0, depth - 1);
|
|
5690
|
+
if (ch === ',' && depth === 0) {
|
|
5691
|
+
pieces.push(cur);
|
|
5692
|
+
cur = '';
|
|
5693
|
+
} else cur += ch;
|
|
5694
|
+
}
|
|
5695
|
+
pieces.push(cur);
|
|
5696
|
+
if (pieces.filter(x => x.trim()).length < 2) return [c];
|
|
5697
|
+
if (
|
|
5698
|
+
pieces.some(
|
|
5699
|
+
x =>
|
|
5700
|
+
x.trim().split(/\s+/).length < 2 ||
|
|
5701
|
+
/[()]|\b\d/.test(x) ||
|
|
5702
|
+
!/[a-z]{3}/.test(x),
|
|
5703
|
+
)
|
|
5704
|
+
)
|
|
5705
|
+
return [c];
|
|
5706
|
+
// (A piece that only gives an example of the one before, "like 1 or
|
|
5707
|
+
// 2 px", "say 8px", stays with it.)
|
|
5708
|
+
if (
|
|
5709
|
+
pieces
|
|
5710
|
+
.slice(1)
|
|
5711
|
+
.some(x =>
|
|
5712
|
+
/^\s*(?:like|say|e\.?g\.?|about|around|roughly|maybe|or|ideally|preferably|approximately)\b/i.test(
|
|
5713
|
+
x,
|
|
5714
|
+
),
|
|
5715
|
+
)
|
|
5716
|
+
)
|
|
5717
|
+
return [c];
|
|
5718
|
+
const each = pieces.map(x => clausesOf(x, lex.parts));
|
|
5719
|
+
const asks = each.map(
|
|
5720
|
+
cs =>
|
|
5721
|
+
cs.length === 1 &&
|
|
5722
|
+
(cs[0].aspects.length > 0 ||
|
|
5723
|
+
cs[0].parts.length > 0 ||
|
|
5724
|
+
cs[0].colors.length === 1) &&
|
|
5725
|
+
(cs[0].aspects.length > 0 || cs[0].colors.length > 0 || cs[0].dir),
|
|
5726
|
+
);
|
|
5727
|
+
return asks.every(Boolean) ? each.flat() : [c];
|
|
5728
|
+
});
|
|
5729
|
+
/** The aspects each clause names in its own words. @type {WeakMap<Clause, string[]>} */
|
|
5730
|
+
const ownAspects = new WeakMap();
|
|
5731
|
+
for (const c of clauses) ownAspects.set(c, [...c.aspects]);
|
|
5732
|
+
// ── Clause scope. How each clause is joined to the one before it, and
|
|
5733
|
+
// the clause a list hangs from: the clause-scope reader (scopeOf, below)
|
|
5734
|
+
// reads these to decide each clause's part, state and mode.
|
|
5735
|
+
/**
|
|
5736
|
+
* @typedef {{
|
|
5737
|
+
* sep: 'break' | 'colon' | 'with' | 'and' | 'comma' | 'none',
|
|
5738
|
+
* list: 'colon' | 'with' | null,
|
|
5739
|
+
* }} Join
|
|
5740
|
+
*/
|
|
5741
|
+
/** @type {WeakMap<Clause, Join>} */
|
|
5742
|
+
const joinOf = new WeakMap();
|
|
5743
|
+
{
|
|
5744
|
+
/** @type {'colon' | 'with' | null} */
|
|
5745
|
+
let list = null;
|
|
5746
|
+
for (let i = 0; i < clauses.length; i++) {
|
|
5747
|
+
const c = clauses[i];
|
|
5748
|
+
// (A sentence's end as the words were asked: a ";" a reader put in,
|
|
5749
|
+
// "replace the shadow with a border", ends no sentence; it ties the
|
|
5750
|
+
// two halves of one ask.)
|
|
5751
|
+
const gap = String(c.joint ?? '')
|
|
5752
|
+
.toLowerCase()
|
|
5753
|
+
.replace(/[;.!?\n]/g, ch => (asked0.includes(ch) ? ch : ' and '));
|
|
5754
|
+
/** @type {Join['sep']} */
|
|
5755
|
+
const sep =
|
|
5756
|
+
i === 0
|
|
5757
|
+
? 'none'
|
|
5758
|
+
: /[;.!?\n]/.test(gap)
|
|
5759
|
+
? 'break'
|
|
5760
|
+
: /\bwith\b/.test(gap)
|
|
5761
|
+
? 'with'
|
|
5762
|
+
: /\b(?:and|plus|also|but|then|y|et|und)\b|&/.test(gap)
|
|
5763
|
+
? 'and'
|
|
5764
|
+
: 'comma';
|
|
5765
|
+
if (sep === 'break' || sep === 'none') list = null;
|
|
5766
|
+
// ("white cards with …": the part's with-list, to the end of the
|
|
5767
|
+
// sentence.)
|
|
5768
|
+
if (sep === 'with' && list !== 'colon') list = 'with';
|
|
5769
|
+
joinOf.set(c, {
|
|
5770
|
+
sep,
|
|
5771
|
+
list: sep === 'break' || sep === 'none' ? null : list,
|
|
5772
|
+
});
|
|
5773
|
+
// ("cards: …": the part's own list, after its colon; the part named
|
|
5774
|
+
// before the colon, never "Notion look: serif headings".)
|
|
5775
|
+
const head = /^([^:]+):\s*\S/.exec(c.text)?.[1];
|
|
5776
|
+
if (
|
|
5777
|
+
head &&
|
|
5778
|
+
c.parts.length &&
|
|
5779
|
+
lex.parts.some(
|
|
5780
|
+
([re, x]) => c.parts.some(p => p.on === x.on) && re.test(` ${head} `),
|
|
5781
|
+
)
|
|
5782
|
+
)
|
|
5783
|
+
list = 'colon';
|
|
5784
|
+
}
|
|
5785
|
+
}
|
|
5786
|
+
/** What a later clause's own words make the whole theme's. */
|
|
5787
|
+
const THEME_ASPECTS = ['family', 'fontsize', 'leading', 'tracking', 'motion'];
|
|
5788
|
+
/** Type aspects, a text part's own. */
|
|
5789
|
+
const TYPE_ASPECTS = [
|
|
5790
|
+
'family',
|
|
5791
|
+
'fontsize',
|
|
5792
|
+
'leading',
|
|
5793
|
+
'tracking',
|
|
5794
|
+
'weight',
|
|
5795
|
+
'case',
|
|
5796
|
+
'italic',
|
|
5797
|
+
];
|
|
5798
|
+
/**
|
|
5799
|
+
* The clause-scope reader: whether a clause that names no part takes the
|
|
5800
|
+
* part (and state) of the clause before it, or is the whole theme's.
|
|
5801
|
+
* A clause takes the part before it only as a modifier of it: said with
|
|
5802
|
+
* "with", in the part's own colon list ("cards: white background, 1px
|
|
5803
|
+
* border"), with only its way, value or color ("rounder and darker"),
|
|
5804
|
+
* as a state of it ("; when focused a 2px ring"), as the text color of a
|
|
5805
|
+
* part that holds text ("a dark card, white text"), or joined by "and"
|
|
5806
|
+
* with a look the part has. Anything else, a dial or text size or font,
|
|
5807
|
+
* a sentence of its own, a comma item with its own look ("big buttons,
|
|
5808
|
+
* thick borders"), is the whole theme's.
|
|
5809
|
+
* @param {Clause} c
|
|
5810
|
+
* @param {Clause | undefined} before the nearest clause before with a part
|
|
5811
|
+
* @returns {'own' | 'inherit' | 'theme'}
|
|
5812
|
+
*/
|
|
5813
|
+
const scopeOf = (c, before) => {
|
|
5814
|
+
const first = (/** @type {string} */ on) =>
|
|
5815
|
+
FAMILIES[on] ? FAMILIES[on][0] : on;
|
|
5816
|
+
if (c.parts.length) return 'own';
|
|
5817
|
+
if (!before) return 'theme';
|
|
5818
|
+
const j = joinOf.get(c) ?? {sep: 'comma', list: null};
|
|
5819
|
+
const own = ownAspects.get(c) ?? c.aspects;
|
|
5820
|
+
const subject =
|
|
5821
|
+
/^(?:the\s+|my\s+|our\s+)?([a-z]+)\b(?!-)(?:\s+([a-z-]+))?/.exec(c.text);
|
|
5822
|
+
const bare =
|
|
5823
|
+
!subject?.[2] ||
|
|
5824
|
+
/^colou?r$/.test(subject[2]) ||
|
|
5825
|
+
!aspectsOf(subject[2]).length;
|
|
5826
|
+
// The whole theme, said in so many words, or a theme color or dial as
|
|
5827
|
+
// the subject ("and the accent darker", "the text bigger").
|
|
5828
|
+
if (
|
|
5829
|
+
/\b(?:everything|everywhere|the whole (?:theme|app|ui|site|page)|across the board|all of it|surfaces)\b/.test(
|
|
5830
|
+
c.text,
|
|
5831
|
+
) ||
|
|
5832
|
+
(bare &&
|
|
5833
|
+
(ROLE_WORDS.test(subject?.[1] ?? '') ||
|
|
5834
|
+
Object.hasOwn(DIALS, subject?.[1] ?? ''))) ||
|
|
5835
|
+
/^the\s+(?:text|shadows|corners)\b(?!-)/.test(c.text) ||
|
|
5836
|
+
/^text\s+colou?r\b/.test(c.text) ||
|
|
5837
|
+
/\b(?:main|body|all)\s+text\b/.test(c.text)
|
|
5838
|
+
)
|
|
5839
|
+
return 'theme';
|
|
5840
|
+
// A state of the part before ("; when focused a 2px ring"), or the ask
|
|
5841
|
+
// after a clause that only sets where or when ("when I tab to a link,
|
|
5842
|
+
// show a thick outline", "only in dark mode and only on cards, darker
|
|
5843
|
+
// background", "buttons only, a bit rounder").
|
|
5844
|
+
if (c.state) return 'inherit';
|
|
5845
|
+
if (
|
|
5846
|
+
clauses[clauses.indexOf(c) - 1] === before &&
|
|
5847
|
+
!before.colors.length &&
|
|
5848
|
+
!before.lengths.length &&
|
|
5849
|
+
!before.dir &&
|
|
5850
|
+
(before.state ||
|
|
5851
|
+
/^(?:(?:only|just)\s+)?(?:when|while|on|in|for|if|inside|within)\b|\b(?:only|just)\b/.test(
|
|
5852
|
+
before.text,
|
|
5853
|
+
))
|
|
5854
|
+
)
|
|
5855
|
+
return 'inherit';
|
|
5856
|
+
if (j.sep === 'break' || j.sep === 'none') return 'theme';
|
|
5857
|
+
// A size or variant of the part before ("small buttons 6px, large stay
|
|
5858
|
+
// pill"; "the ghost ones").
|
|
5859
|
+
{
|
|
5860
|
+
const vals = Object.values(
|
|
5861
|
+
C.variantValues(first(before.parts[0]?.on ?? '')) ?? {},
|
|
5862
|
+
).flat();
|
|
5863
|
+
if (
|
|
5864
|
+
/\b(?:small|medium|large|sm|md|lg)\b/.test(c.text) ||
|
|
5865
|
+
vals.some(v => new RegExp(`\\b${v}\\b`).test(c.text))
|
|
5866
|
+
)
|
|
5867
|
+
return 'inherit';
|
|
5868
|
+
}
|
|
5869
|
+
// A look taken away from the part before ("rounded buttons, no
|
|
5870
|
+
// shadow"; never "serif headings, no shadows": a text part's look is
|
|
5871
|
+
// its type).
|
|
5872
|
+
if (c.neg && own.length && !before.parts.every(p => textOnlyPart(p.on)))
|
|
5873
|
+
return 'inherit';
|
|
5874
|
+
// A CSS property named with its value ("card padding-block 20px,
|
|
5875
|
+
// padding-inline 16px"): a declaration list, the part's.
|
|
5876
|
+
if (c.named) return 'inherit';
|
|
5877
|
+
// A text part's own type ("headings 600 weight and -0.02em tracking").
|
|
5878
|
+
if (
|
|
5879
|
+
own.length &&
|
|
5880
|
+
own.every(a => TYPE_ASPECTS.includes(a)) &&
|
|
5881
|
+
before.parts.every(p => textOnlyPart(p.on))
|
|
5882
|
+
)
|
|
5883
|
+
return 'inherit';
|
|
5884
|
+
// A text color after the page: the theme's text ("a black page with
|
|
5885
|
+
// green text"; a page holds no text of its own).
|
|
5886
|
+
const pageBefore = before.parts.every(p =>
|
|
5887
|
+
/^(?:page|body|app-shell)$/.test(p.on),
|
|
5888
|
+
);
|
|
5889
|
+
if (own.length && own.every(a => a === 'text') && pageBefore)
|
|
5890
|
+
return 'theme';
|
|
5891
|
+
if (j.sep === 'with' || j.list === 'colon') return 'inherit';
|
|
5892
|
+
// Only a way, a value or a color: the same part.
|
|
5893
|
+
if (!own.length) return 'inherit';
|
|
5894
|
+
// (The theme's spacing said as a dial, never a part's padding or gap.)
|
|
5895
|
+
if (
|
|
5896
|
+
own.some(a => THEME_ASPECTS.includes(a)) ||
|
|
5897
|
+
(own.includes('spacing') &&
|
|
5898
|
+
!/\b(?:padding|gaps?|margins?|inset)\b|\bpadding-/.test(c.text))
|
|
5899
|
+
)
|
|
5900
|
+
return 'theme';
|
|
5901
|
+
// A text color: the part's, when it holds text.
|
|
5902
|
+
if (own.every(a => a === 'text'))
|
|
5903
|
+
return c.colors.length && !before.parts.every(p => textOnlyPart(p.on))
|
|
5904
|
+
? 'inherit'
|
|
5905
|
+
: 'theme';
|
|
5906
|
+
if (j.list === 'with' || j.sep === 'and') return 'inherit';
|
|
5907
|
+
return 'theme';
|
|
5908
|
+
};
|
|
5909
|
+
// "a high contrast compact theme", "a dark theme with more contrast": the
|
|
5910
|
+
// theme-wide looks the readers take as a whole clause (contrast, the
|
|
5911
|
+
// theme's mode) said among other words are each a clause of their own.
|
|
5912
|
+
for (let i = clauses.length - 1; i >= 0; i--) {
|
|
5913
|
+
const c = clauses[i];
|
|
5914
|
+
if (c.parts.length || c.except) continue;
|
|
5915
|
+
for (const re of [
|
|
5916
|
+
/\b(?:more|higher|high|better) contrast\b/,
|
|
5917
|
+
/\b(?:dark|light)-only (?:theme|look|ui|interface|design)\b/,
|
|
5918
|
+
]) {
|
|
5919
|
+
const m = re.exec(c.text);
|
|
5920
|
+
if (!m) continue;
|
|
5921
|
+
const rest =
|
|
5922
|
+
`${c.text.slice(0, m.index)} ${c.text.slice(m.index + m[0].length)}`
|
|
5923
|
+
.replace(/\s+/g, ' ')
|
|
5924
|
+
.trim();
|
|
5925
|
+
const restClauses = clausesOf(rest, lex.parts);
|
|
5926
|
+
if (
|
|
5927
|
+
!restClauses.some(
|
|
5928
|
+
x => x.aspects.length || x.colors.length || x.parts.length,
|
|
5929
|
+
)
|
|
5930
|
+
)
|
|
5931
|
+
continue;
|
|
5932
|
+
const piece = clausesOf(m[0], lex.parts);
|
|
5933
|
+
clauses.splice(i, 1, ...piece, ...restClauses);
|
|
5934
|
+
break;
|
|
5935
|
+
}
|
|
5936
|
+
}
|
|
5937
|
+
// "navy", "a theme in navy, compact": a color the clause gives no part
|
|
5938
|
+
// or paint to is the theme's brand color, the accent (never dropped);
|
|
5939
|
+
// white, black and the grays name no brand.
|
|
5940
|
+
// (Never in a list of colors for a part: "the buttons red, green and
|
|
5941
|
+
// blue".)
|
|
5942
|
+
const paintsAPart = clauses.some(
|
|
5943
|
+
c =>
|
|
5944
|
+
c.parts.length &&
|
|
5945
|
+
(c.colors.length > 0 ||
|
|
5946
|
+
c.aspects.some(a => ['background', 'text', 'border'].includes(a))),
|
|
5947
|
+
);
|
|
5948
|
+
// (Only for a look said as a look, "a theme in navy", or a color said
|
|
5949
|
+
// alone; never a statement, "I set the accent to red by mistake", nor a
|
|
5950
|
+
// color another dial names, "a more muted success green".)
|
|
5951
|
+
const lookSaid =
|
|
5952
|
+
/\b(?:theme|look|feel|vibe|style|palette|brand|branding)\b/.test(q);
|
|
5953
|
+
const namesAPart = clauses.some(c => c.parts.length > 0);
|
|
5954
|
+
for (let i = clauses.length - 1; i >= 0 && !paintsAPart && !namesAPart; i--) {
|
|
5955
|
+
const c = clauses[i];
|
|
5956
|
+
if (c.parts.length || !c.colors.length || c.colors.length > 2 || c.except)
|
|
5957
|
+
continue;
|
|
5958
|
+
if (
|
|
5959
|
+
/\b(?:success|warning|danger|error|info|neutral|accent|brand|page|background|text|border)\b/.test(
|
|
5960
|
+
c.text,
|
|
5961
|
+
)
|
|
5962
|
+
)
|
|
5963
|
+
continue;
|
|
5964
|
+
if (
|
|
5965
|
+
!lookSaid &&
|
|
5966
|
+
(c.colors.length > 1 ||
|
|
5967
|
+
!/^\s*(?:a|an|the)?\s*(?:(?:light|dark|deep|rich|bright|pale|soft)\s+)?[a-z-]+\s*[.!]?\s*$/.test(
|
|
5968
|
+
c.text,
|
|
5969
|
+
))
|
|
5970
|
+
)
|
|
5971
|
+
continue;
|
|
5972
|
+
const paints = c.aspects.some(a =>
|
|
5973
|
+
['background', 'text', 'border', 'colors', 'shadow', 'gradient'].includes(
|
|
5974
|
+
a,
|
|
5975
|
+
),
|
|
5976
|
+
);
|
|
5977
|
+
if (paints) continue;
|
|
5978
|
+
// (Each color by what it is: a light, quiet one, sand or a warm
|
|
5979
|
+
// gray, is the neutral the grays are made from; a strong one the
|
|
5980
|
+
// accent; white and black name neither.)
|
|
5981
|
+
/** @type {Clause[]} */
|
|
5982
|
+
const dials = [];
|
|
5983
|
+
let accentTaken = false;
|
|
5984
|
+
// (Only colors said by name: a typed value continues the ask before
|
|
5985
|
+
// it, "their brand blue, #0057ff".)
|
|
5986
|
+
const named = colorsFound(c.text)
|
|
5987
|
+
.filter(x => !x[2])
|
|
5988
|
+
.map(x => x[1]);
|
|
5989
|
+
if (colorsFound(c.text).some(x => x[2])) continue;
|
|
5990
|
+
for (const color of named) {
|
|
5991
|
+
const rgb = parseColor(color);
|
|
5992
|
+
if (!rgb) continue;
|
|
5993
|
+
const hi = Math.max(...rgb.slice(0, 3));
|
|
5994
|
+
const lo = Math.min(...rgb.slice(0, 3));
|
|
5995
|
+
if (hi - lo < 12 && (lo > 235 || hi < 20)) continue;
|
|
5996
|
+
const quiet = hi - lo < 64 && hi > 120;
|
|
5997
|
+
if (!quiet && accentTaken) continue;
|
|
5998
|
+
const dial = clausesOf(
|
|
5999
|
+
`${quiet ? 'neutral' : 'accent'} ${color}`,
|
|
6000
|
+
lex.parts,
|
|
6001
|
+
);
|
|
6002
|
+
if (dial.length !== 1) continue;
|
|
6003
|
+
if (!quiet) accentTaken = true;
|
|
6004
|
+
dials.push(...dial);
|
|
6005
|
+
}
|
|
6006
|
+
if (!dials.length) continue;
|
|
6007
|
+
if (!c.aspects.length && !c.dir) clauses.splice(i, 1, ...dials);
|
|
6008
|
+
else {
|
|
6009
|
+
c.colors = [];
|
|
6010
|
+
clauses.splice(i + 1, 0, ...dials);
|
|
6011
|
+
}
|
|
6012
|
+
}
|
|
6013
|
+
// "make the brown content area deep green": a color said before the part,
|
|
6014
|
+
// with another after it, says how the part looks now; the one after is
|
|
6015
|
+
// the color asked.
|
|
6016
|
+
for (const c of clauses) {
|
|
6017
|
+
if (!c.parts.length || c.colors.length < 2) continue;
|
|
6018
|
+
const at = Math.min(
|
|
6019
|
+
...c.parts.flatMap(p =>
|
|
6020
|
+
lex.parts
|
|
6021
|
+
.filter(([, x]) => x.on === p.on)
|
|
6022
|
+
.map(([re]) => re.exec(c.text)?.index ?? Infinity),
|
|
6023
|
+
),
|
|
6024
|
+
);
|
|
6025
|
+
if (!Number.isFinite(at)) continue;
|
|
6026
|
+
const found = colorsFound(c.text);
|
|
6027
|
+
const after = found.filter(([i]) => i > at).map(([, v]) => v);
|
|
6028
|
+
if (after.length && found.some(([i]) => i < at)) c.colors = after;
|
|
6029
|
+
}
|
|
6030
|
+
// "the error toast is too bright red; make it calmer", "the violet
|
|
6031
|
+
// buttons feel a bit loud": a complaint says how a part looks now, its
|
|
6032
|
+
// colors the look it has, never a color to give it.
|
|
6033
|
+
/** @type {Set<Clause>} */
|
|
6034
|
+
const complaints = new Set();
|
|
6035
|
+
/** @type {Array<[Clause, Clause]>} */
|
|
6036
|
+
const carriedParts = [];
|
|
6037
|
+
for (const [ci, c] of clauses.entries())
|
|
6038
|
+
if (
|
|
6039
|
+
c.parts.length &&
|
|
6040
|
+
((/\b(?:is|are|looks?|feels?|seems?)\s+(?:a\s+bit\s+|a\s+little\s+|way\s+|far\s+|much\s+|kind\s+of\s+)?(?:too\b|loud|cold|harsh|garish)/.test(
|
|
6041
|
+
c.text,
|
|
6042
|
+
) &&
|
|
6043
|
+
Boolean(clauses[ci + 1])) ||
|
|
6044
|
+
// ("the main content area is white; make it cream": how it is,
|
|
6045
|
+
// then the ask for it.)
|
|
6046
|
+
(/\b(?:is|are)\s+(?:currently\s+|now\s+|still\s+)?[a-z#]/.test(
|
|
6047
|
+
c.text,
|
|
6048
|
+
) &&
|
|
6049
|
+
!/^\s*(?:make|set|turn|give|change)\b/.test(c.text) &&
|
|
6050
|
+
!/\b(?:should|must|needs?|has to|have to|wants?)\b/.test(c.text) &&
|
|
6051
|
+
/^\s*(?:and\s+|so\s+|but\s+)?(?:please\s+)?(?:make|turn|set|change)\s+(?:it|them)\b/.test(
|
|
6052
|
+
clauses[ci + 1]?.text ?? '',
|
|
6053
|
+
)))
|
|
6054
|
+
) {
|
|
6055
|
+
complaints.add(c);
|
|
6056
|
+
c.colors = [];
|
|
6057
|
+
}
|
|
5316
6058
|
// "… make them rounder", "and make it bold": a pronoun names the parts
|
|
5317
|
-
// the clause before named (a bound or a
|
|
5318
|
-
// names none of its own.
|
|
6059
|
+
// the clause before named (a bound, a keep or a complaint included), when
|
|
6060
|
+
// the clause names none of its own.
|
|
5319
6061
|
for (let i = 1; i < clauses.length; i++)
|
|
5320
6062
|
if (
|
|
5321
6063
|
!clauses[i].parts.length &&
|
|
@@ -5323,10 +6065,85 @@ export function draftAnswer(ctx, env, question) {
|
|
|
5323
6065
|
clauses[i - 1].parts.length &&
|
|
5324
6066
|
// (Of an ask, a bound or a keep: a clause that names a part in a
|
|
5325
6067
|
// state only, "when hovering a card, lift it", carries its state.)
|
|
5326
|
-
clauses[i - 1].aspects.length &&
|
|
5327
|
-
|
|
5328
|
-
|
|
6068
|
+
(clauses[i - 1].aspects.length || complaints.has(clauses[i - 1])) &&
|
|
6069
|
+
// (After a complaint, the ask that answers it is about that part:
|
|
6070
|
+
// "the dialogs look too flat, can we add some shadow".)
|
|
6071
|
+
(/\b(?:them|it|they|those|these)\b/.test(clauses[i].text) ||
|
|
6072
|
+
complaints.has(clauses[i - 1]))
|
|
6073
|
+
) {
|
|
5329
6074
|
clauses[i].parts = clauses[i - 1].parts.map(x => ({...x}));
|
|
6075
|
+
// (Its look, read later, follows: "the error toast … make it".)
|
|
6076
|
+
carriedParts.push([clauses[i - 1], clauses[i]]);
|
|
6077
|
+
}
|
|
6078
|
+
// ("table header text uppercase 12px": a length said with a text look,
|
|
6079
|
+
// its case or weight, is the text's size too, never dropped.)
|
|
6080
|
+
for (const [ci, c] of [...clauses.entries()].reverse())
|
|
6081
|
+
if (
|
|
6082
|
+
c.lengths.some(l => /^\d*\.?\d+(?:px|rem|em)$/.test(l)) &&
|
|
6083
|
+
/\b(?:text|labels?|font|type|letters)\b/.test(c.text) &&
|
|
6084
|
+
c.aspects.some(a =>
|
|
6085
|
+
['case', 'weight', 'italic', 'tracking', 'family'].includes(a),
|
|
6086
|
+
) &&
|
|
6087
|
+
!c.aspects.some(a =>
|
|
6088
|
+
[
|
|
6089
|
+
'fontsize',
|
|
6090
|
+
'spacing',
|
|
6091
|
+
'border',
|
|
6092
|
+
'corners',
|
|
6093
|
+
'shadow',
|
|
6094
|
+
'size',
|
|
6095
|
+
'leading',
|
|
6096
|
+
'tracking',
|
|
6097
|
+
].includes(a),
|
|
6098
|
+
)
|
|
6099
|
+
) {
|
|
6100
|
+
// (Its own ask beside the look, so both run in turn.)
|
|
6101
|
+
clauses.splice(ci + 1, 0, {
|
|
6102
|
+
...c,
|
|
6103
|
+
parts: c.parts.map(x => ({...x})),
|
|
6104
|
+
aspects: ['fontsize'],
|
|
6105
|
+
});
|
|
6106
|
+
c.lengths = [];
|
|
6107
|
+
}
|
|
6108
|
+
// ("make it calmer", "the error toast calmer": its color, the fill it
|
|
6109
|
+
// shows.)
|
|
6110
|
+
for (const c of clauses)
|
|
6111
|
+
if (c.parts.length && !c.aspects.length && CALMER.test(c.text))
|
|
6112
|
+
c.aspects = ['background'];
|
|
6113
|
+
// "the card text bigger and red", "the card's fainter text fainter and
|
|
6114
|
+
// red": a bare color after an ask on a part's text is that text's color
|
|
6115
|
+
// too, never dropped.
|
|
6116
|
+
for (let i = 1; i < clauses.length; i++) {
|
|
6117
|
+
const [a, b] = [clauses[i - 1], clauses[i]];
|
|
6118
|
+
if (
|
|
6119
|
+
!b.parts.length &&
|
|
6120
|
+
!b.aspects.length &&
|
|
6121
|
+
b.colors.length === 1 &&
|
|
6122
|
+
/^\s*(?:and\s+)?(?:make\s+(?:it|them)\s+)?[a-z#0-9-]+\s*$/i.test(
|
|
6123
|
+
b.text,
|
|
6124
|
+
) &&
|
|
6125
|
+
a.parts.length &&
|
|
6126
|
+
/\b(?:text|labels?|copy|writing)\b/.test(a.text)
|
|
6127
|
+
) {
|
|
6128
|
+
b.parts = a.parts.map(x => ({...x}));
|
|
6129
|
+
b.aspects = ['text'];
|
|
6130
|
+
b.text = `${a.text.replace(/\b(?:bigger|smaller|larger|bolder|fainter|subtler|lighter|darker|\d+(?:\.\d+)?\s?%\s+\w+)\b/g, '').trim()} ${b.text.trim()}`;
|
|
6131
|
+
// ("fainter and red": the red at that fainter alpha, one color, so
|
|
6132
|
+
// neither ask undoes the other.)
|
|
6133
|
+
const hex = /^#([0-9a-f]{6})$/i.exec(b.colors[0])?.[1];
|
|
6134
|
+
if (a.aspects.length === 1 && a.aspects[0] === 'opacity' && hex) {
|
|
6135
|
+
const k = exactFactor(a.text);
|
|
6136
|
+
const share = k != null && k > 0 && k < 1 ? k : 0.6;
|
|
6137
|
+
const faded = `#${hex}${Math.round(share * 255)
|
|
6138
|
+
.toString(16)
|
|
6139
|
+
.padStart(2, '0')}`;
|
|
6140
|
+
b.colors = [faded];
|
|
6141
|
+
b.text = `${b.text.replace(/\s*\S+\s*$/, '')} ${faded}`;
|
|
6142
|
+
clauses.splice(i - 1, 1);
|
|
6143
|
+
i--;
|
|
6144
|
+
}
|
|
6145
|
+
}
|
|
6146
|
+
}
|
|
5330
6147
|
// "the row hovered and selected red": a part in one state, joined by
|
|
5331
6148
|
// "and" to a second state that carries the ask, is the part in both at
|
|
5332
6149
|
// once (as "the checked and disabled checkbox"); never the first state
|
|
@@ -5662,6 +6479,8 @@ export function draftAnswer(ctx, env, question) {
|
|
|
5662
6479
|
}
|
|
5663
6480
|
// "success badge", "error toasts": a value of the part's variant, type
|
|
5664
6481
|
// or status right before the part.
|
|
6482
|
+
/** @type {Array<{c: Clause, p: any}>} */
|
|
6483
|
+
const lookCopies = [];
|
|
5665
6484
|
for (const c of clauses)
|
|
5666
6485
|
for (const p of c.parts) {
|
|
5667
6486
|
const member = FAMILIES[p.on] ? FAMILIES[p.on][0] : p.on;
|
|
@@ -5721,21 +6540,40 @@ export function draftAnswer(ctx, env, question) {
|
|
|
5721
6540
|
// names the variant drawn with none, never a fill to take away,
|
|
5722
6541
|
// when another value or a way is given ("transparent header" alone
|
|
5723
6542
|
// asks for no fill).
|
|
6543
|
+
// ("The borderless buttons", "the shadowless cards", "the
|
|
6544
|
+
// text-only buttons": the variants drawn without that paint.)
|
|
6545
|
+
const lookWithout = /^(?:transparent|see-through|clear|unfilled)$/.test(
|
|
6546
|
+
w,
|
|
6547
|
+
)
|
|
6548
|
+
? 'background'
|
|
6549
|
+
: w === 'only' && words[i - 1] === 'text'
|
|
6550
|
+
? 'background'
|
|
6551
|
+
: /^(?:border|outline)less$/.test(w)
|
|
6552
|
+
? 'border'
|
|
6553
|
+
: w === 'shadowless'
|
|
6554
|
+
? 'shadow'
|
|
6555
|
+
: null;
|
|
5724
6556
|
if (
|
|
5725
6557
|
!key0 &&
|
|
5726
|
-
|
|
6558
|
+
lookWithout &&
|
|
5727
6559
|
(moves || c.colors.some(x => x.toLowerCase() !== w))
|
|
5728
6560
|
) {
|
|
6561
|
+
const camel = /** @type {Record<string, string>} */ ({
|
|
6562
|
+
background: 'backgroundColor',
|
|
6563
|
+
border: 'borderWidth',
|
|
6564
|
+
shadow: 'boxShadow',
|
|
6565
|
+
})[lookWithout];
|
|
5729
6566
|
const unfilled = (vals.variant ?? []).filter(v => {
|
|
5730
6567
|
const own = /** @type {any} */ (env.base).components?.[member]?.[
|
|
5731
6568
|
`variant:${v}`
|
|
5732
|
-
]?.
|
|
5733
|
-
if (own != null)
|
|
6569
|
+
]?.[camel];
|
|
6570
|
+
if (own != null)
|
|
6571
|
+
return /^(?:transparent|none|0|0px)$/i.test(String(own));
|
|
5734
6572
|
// (Read at rest in that variant alone: no state, no overlay.)
|
|
5735
|
-
return !(C.partReads(member,
|
|
6573
|
+
return !(C.partReads(member, lookWithout) ?? []).some(
|
|
5736
6574
|
r =>
|
|
5737
|
-
/^--color-/.test(r.token) &&
|
|
5738
|
-
!/overlay|tint/.test(r.token) &&
|
|
6575
|
+
(lookWithout !== 'background' || /^--color-/.test(r.token)) &&
|
|
6576
|
+
!/overlay|tint|focus/.test(r.token) &&
|
|
5739
6577
|
r.when.some(wn => {
|
|
5740
6578
|
const bits = wn.trim().split(/\s+/);
|
|
5741
6579
|
return (
|
|
@@ -5749,10 +6587,15 @@ export function draftAnswer(ctx, env, question) {
|
|
|
5749
6587
|
}),
|
|
5750
6588
|
);
|
|
5751
6589
|
});
|
|
5752
|
-
if (unfilled.length
|
|
6590
|
+
if (unfilled.length) {
|
|
5753
6591
|
p.when = `variant:${unfilled[0]}`;
|
|
6592
|
+
// (Each of them when several are drawn so.)
|
|
6593
|
+
for (const v of unfilled.slice(1))
|
|
6594
|
+
lookCopies.push({c, p: {...p, when: `variant:${v}`}});
|
|
5754
6595
|
c.text = c.text.replace(
|
|
5755
|
-
new RegExp(
|
|
6596
|
+
new RegExp(
|
|
6597
|
+
`\\b${w === 'only' ? 'text[\\s-]only' : w}\\s+(?=${noun}\\b)`,
|
|
6598
|
+
),
|
|
5756
6599
|
'',
|
|
5757
6600
|
);
|
|
5758
6601
|
c.colors = c.colors.filter(x => x.toLowerCase() !== w);
|
|
@@ -5819,6 +6662,12 @@ export function draftAnswer(ctx, env, question) {
|
|
|
5819
6662
|
}
|
|
5820
6663
|
}
|
|
5821
6664
|
}
|
|
6665
|
+
for (const {c, p} of lookCopies) c.parts.push(p);
|
|
6666
|
+
for (const [from, to] of carriedParts)
|
|
6667
|
+
if (from.parts.length) to.parts = from.parts.map(x => ({...x}));
|
|
6668
|
+
// (A complaint answered by the ask after it writes nothing itself.)
|
|
6669
|
+
for (let i = clauses.length - 2; i >= 0; i--)
|
|
6670
|
+
if (complaints.has(clauses[i]) && clauses[i + 1]) clauses.splice(i, 1);
|
|
5822
6671
|
// "cards and dialogs with no shadow", "tooltips and toasts black": parts
|
|
5823
6672
|
// listed before the ask all take it.
|
|
5824
6673
|
// "headings twice as big", "dialog text twice as big": size words on
|
|
@@ -5915,9 +6764,19 @@ export function draftAnswer(ctx, env, question) {
|
|
|
5915
6764
|
c.unknownSubject = true;
|
|
5916
6765
|
continue;
|
|
5917
6766
|
}
|
|
5918
|
-
// (Nor a clause
|
|
5919
|
-
// darker", "and the text bigger".)
|
|
5920
|
-
if (
|
|
6767
|
+
// (Nor a clause the scope reader gives the whole theme: "and the
|
|
6768
|
+
// accent darker", "and the text bigger".)
|
|
6769
|
+
if (
|
|
6770
|
+
!c.parts.length &&
|
|
6771
|
+
scopeOf(
|
|
6772
|
+
c,
|
|
6773
|
+
clauses
|
|
6774
|
+
.slice(0, i)
|
|
6775
|
+
.reverse()
|
|
6776
|
+
.find(x => x.parts.length && !x.except),
|
|
6777
|
+
) === 'theme'
|
|
6778
|
+
)
|
|
6779
|
+
continue;
|
|
5921
6780
|
if (!c.parts.length) {
|
|
5922
6781
|
const own = /\b(primary|secondary|ghost|destructive|muted)\b/.exec(
|
|
5923
6782
|
c.text,
|
|
@@ -5981,8 +6840,10 @@ export function draftAnswer(ctx, env, question) {
|
|
|
5981
6840
|
)
|
|
5982
6841
|
c.aspects = ['text'];
|
|
5983
6842
|
}
|
|
5984
|
-
// An icon's color is its text color ("the close icon red")
|
|
5985
|
-
|
|
6843
|
+
// An icon's color is its text color ("the close icon red"); also once a
|
|
6844
|
+
// place's element is read as an icon ("the chevron in selects").
|
|
6845
|
+
/** @param {Clause} c */
|
|
6846
|
+
const iconColor = c => {
|
|
5986
6847
|
if (
|
|
5987
6848
|
c.parts.some(x => /-icon$/.test(x.on)) &&
|
|
5988
6849
|
(c.aspects.includes('background') ||
|
|
@@ -5992,6 +6853,8 @@ export function draftAnswer(ctx, env, question) {
|
|
|
5992
6853
|
c.aspects = c.aspects.length
|
|
5993
6854
|
? c.aspects.map(x => (x === 'background' ? 'text' : x))
|
|
5994
6855
|
: ['text'];
|
|
6856
|
+
};
|
|
6857
|
+
for (const c of clauses) iconColor(c);
|
|
5995
6858
|
/**
|
|
5996
6859
|
* The element a clause names in a place, by the part data: the place
|
|
5997
6860
|
* itself when the words name it ("the indicator in checkboxes"), a part
|
|
@@ -6012,8 +6875,9 @@ export function draftAnswer(ctx, env, question) {
|
|
|
6012
6875
|
// draw.)
|
|
6013
6876
|
/** @type {Array<{holderText: string, elementText: string, by: string}>} */
|
|
6014
6877
|
const places = [];
|
|
6878
|
+
// ("The icon after the button text": beside a part's text is in it.)
|
|
6015
6879
|
const preps =
|
|
6016
|
-
/\b(inside|within|of|in(?! (?:dark|light)\b))\s+(?:the\s+|a\s+|an\s+|my\s+)?/g;
|
|
6880
|
+
/\b(inside|within|of|after|before|next to|in(?! (?:dark|light)\b))\s+(?:the\s+|a\s+|an\s+|my\s+)?/g;
|
|
6017
6881
|
for (const m of text.matchAll(preps)) {
|
|
6018
6882
|
const after = text.slice(/** @type {number} */ (m.index) + m[0].length);
|
|
6019
6883
|
// (The place runs to the next place said.)
|
|
@@ -6026,6 +6890,18 @@ export function draftAnswer(ctx, env, question) {
|
|
|
6026
6890
|
by: m[1],
|
|
6027
6891
|
});
|
|
6028
6892
|
}
|
|
6893
|
+
// "The text after the checkbox", "the words beside the radio": the
|
|
6894
|
+
// label the place draws beside it.
|
|
6895
|
+
const beside =
|
|
6896
|
+
/^(.*?\b(?:text|words?|labels?|copy|writing))\s+(?:after|beside|next to|by)\s+(?:the\s+|a\s+|an\s+|my\s+)?([a-z][a-z -]*?)(?=\s+(?:red|blue|green|darker|lighter|bold|bigger|smaller|gr[ae]y|white|black|#|more|less|to\b)|\s*$)/i.exec(
|
|
6897
|
+
text,
|
|
6898
|
+
);
|
|
6899
|
+
if (beside)
|
|
6900
|
+
places.unshift({
|
|
6901
|
+
holderText: beside[2],
|
|
6902
|
+
elementText: `${beside[1].replace(/\b(?:text|words?|copy|writing)$/i, 'label')}`,
|
|
6903
|
+
by: 'beside',
|
|
6904
|
+
});
|
|
6029
6905
|
const poss = /\b([a-z][a-z -]*?)(?:'s|s'|’s|s’)\s+(.*)$/.exec(text);
|
|
6030
6906
|
if (poss)
|
|
6031
6907
|
places.unshift({
|
|
@@ -6033,6 +6909,21 @@ export function draftAnswer(ctx, env, question) {
|
|
|
6033
6909
|
elementText: poss[2],
|
|
6034
6910
|
by: 'possessive',
|
|
6035
6911
|
});
|
|
6912
|
+
// A part said right before its separators, "the dropdown separators",
|
|
6913
|
+
// "the context menu separators": the owner first, as a possessive.
|
|
6914
|
+
// (Only "separators": a table's "row dividers" are read as its cells'.)
|
|
6915
|
+
const lead = /\b(?:the\s+|my\s+)?([a-z][a-z ]*?)\s+(separators?\b.*)$/.exec(
|
|
6916
|
+
text,
|
|
6917
|
+
);
|
|
6918
|
+
if (lead && !poss)
|
|
6919
|
+
places.push({
|
|
6920
|
+
holderText: lead[1].replace(
|
|
6921
|
+
/^.*\b(?:make|set|turn|give|change)\s+/,
|
|
6922
|
+
'',
|
|
6923
|
+
),
|
|
6924
|
+
elementText: lead[2],
|
|
6925
|
+
by: 'possessive',
|
|
6926
|
+
});
|
|
6036
6927
|
// (The first place said first: "the item in menus in cards" is a
|
|
6037
6928
|
// menu's item; the words for the element end at the next place.)
|
|
6038
6929
|
/** @param {string} t @returns {{on: string, word: string, role?: string} | null} */
|
|
@@ -6128,15 +7019,34 @@ export function draftAnswer(ctx, env, question) {
|
|
|
6128
7019
|
(reordered.startsWith(`${h}-`) ||
|
|
6129
7020
|
(C.MAP[h]?.contains ?? []).includes(reordered))
|
|
6130
7021
|
)
|
|
6131
|
-
|
|
6132
|
-
|
|
6133
|
-
|
|
7022
|
+
// (Below a part named after the place by its whole rest, "the
|
|
7023
|
+
// table's header cells": table-header-cell over a phrase's cell.)
|
|
7024
|
+
found.push({k: reordered, score: 35});
|
|
7025
|
+
// Parts drawn inside it, by the last words of their names (never
|
|
7026
|
+
// when the words name a part of their own, "the inputs in
|
|
7027
|
+
// dialogs": the inputs, not a command palette's input).
|
|
7028
|
+
const ownName = partIn(nameText);
|
|
7029
|
+
for (const k of (ownName &&
|
|
7030
|
+
FAMILIES[ownName] &&
|
|
7031
|
+
!members.includes(ownName)
|
|
7032
|
+
? []
|
|
7033
|
+
: C.MAP[h]?.contains) ?? []) {
|
|
6134
7034
|
const w = k.split('-');
|
|
6135
7035
|
for (let i = 0; i < w.length; i++)
|
|
6136
7036
|
if (words(w.slice(i).join('-')).test(nameText))
|
|
6137
7037
|
found.push({k, score: 10 + (w.length - i)});
|
|
6138
7038
|
}
|
|
6139
7039
|
}
|
|
7040
|
+
// (Beside a part, "the text after the checkbox": the label its own
|
|
7041
|
+
// component draws next to it.)
|
|
7042
|
+
// (Its label: a "-label" part named as the place is, its first word,
|
|
7043
|
+
// "checkbox-label" beside "checkbox-indicator".)
|
|
7044
|
+
if (by === 'beside') {
|
|
7045
|
+
const stems = new Set(members.map(h => h.split('-')[0]));
|
|
7046
|
+
for (const k of keys)
|
|
7047
|
+
if (/-label$/.test(k) && stems.has(k.split('-')[0]))
|
|
7048
|
+
found.push({k, score: 60 - k.split('-').length});
|
|
7049
|
+
}
|
|
6140
7050
|
// A group of parts the place holds, named ("the buttons' icons").
|
|
6141
7051
|
const group = Object.keys(FAMILIES).find(
|
|
6142
7052
|
g =>
|
|
@@ -6152,11 +7062,34 @@ export function draftAnswer(ctx, env, question) {
|
|
|
6152
7062
|
// ("The card's muted text" is the cards' own text, as "the muted
|
|
6153
7063
|
// text in cards" says it: text is never a part of its own there.)
|
|
6154
7064
|
const ownPart0 = by === 'possessive' ? partIn(nameText) : null;
|
|
6155
|
-
|
|
6156
|
-
//
|
|
7065
|
+
// ("The separators of menus": the menu's own divider, when it has
|
|
7066
|
+
// one; never the plain part, which "of" may only compare with.)
|
|
7067
|
+
const ofPart = by === 'of' ? partIn(nameText) : null;
|
|
6157
7068
|
for (const h of members)
|
|
7069
|
+
if (ofPart && keys.includes(`${h}-${ofPart}`))
|
|
7070
|
+
found.push({k: `${h}-${ofPart}`, score: 45});
|
|
7071
|
+
const ownPart = ownPart0 === 'body' ? 'text' : ownPart0;
|
|
7072
|
+
// (The place's own part of that kind: a dropdown menu's own divider;
|
|
7073
|
+
// a part named by the place's own word that has one, "the dropdown
|
|
7074
|
+
// separators" the dropdown menu's; else one of that kind drawn inside
|
|
7075
|
+
// it, the context menu's rows' divider.)
|
|
7076
|
+
const word = named.split('-')[0];
|
|
7077
|
+
for (const h of [
|
|
7078
|
+
...members,
|
|
7079
|
+
...keys.filter(
|
|
7080
|
+
k =>
|
|
7081
|
+
ownPart &&
|
|
7082
|
+
!members.includes(k) &&
|
|
7083
|
+
k.split('-')[0] === word &&
|
|
7084
|
+
keys.includes(`${k}-${ownPart}`),
|
|
7085
|
+
),
|
|
7086
|
+
])
|
|
6158
7087
|
if (ownPart && keys.includes(`${h}-${ownPart}`))
|
|
6159
7088
|
found.push({k: `${h}-${ownPart}`, score: 45});
|
|
7089
|
+
for (const h of members)
|
|
7090
|
+
for (const k of C.MAP[h]?.contains ?? [])
|
|
7091
|
+
if (ownPart && k !== ownPart && k.endsWith(`-${ownPart}`))
|
|
7092
|
+
found.push({k, score: 44});
|
|
6160
7093
|
if (
|
|
6161
7094
|
ownPart &&
|
|
6162
7095
|
!members.includes(ownPart) &&
|
|
@@ -6276,8 +7209,10 @@ export function draftAnswer(ctx, env, question) {
|
|
|
6276
7209
|
.toLowerCase()
|
|
6277
7210
|
.replace(/^(?:the|a|an|my)\s+/, '')
|
|
6278
7211
|
.replace(/(?:'s|s'|s)$/, '');
|
|
7212
|
+
// (A group drawn in a place, "the inputs in cards", is as plain as
|
|
7213
|
+
// one part: every input, so it is kept to the place too.)
|
|
6279
7214
|
const specific =
|
|
6280
|
-
|
|
7215
|
+
by === 'beside' ||
|
|
6281
7216
|
pick === themeWide ||
|
|
6282
7217
|
members.includes(pick) ||
|
|
6283
7218
|
members.some(h => pick?.startsWith(`${h}-`)) ||
|
|
@@ -6312,6 +7247,39 @@ export function draftAnswer(ctx, env, question) {
|
|
|
6312
7247
|
/\btitle$/.test(String(x.missing)) &&
|
|
6313
7248
|
(C.MAP[x.on]?.contains ?? []).includes('heading'),
|
|
6314
7249
|
);
|
|
7250
|
+
// ("The card headings": a part said right before "heading(s)" that
|
|
7251
|
+
// draws a heading inside it, its title.)
|
|
7252
|
+
if (!title && c.parts.some(x => x.on === 'heading')) {
|
|
7253
|
+
const lead = /\b([a-z][a-z -]*?)(?:'s)?\s+headings?\b/.exec(c.text);
|
|
7254
|
+
const owner = lead
|
|
7255
|
+
? c.parts.find(
|
|
7256
|
+
x =>
|
|
7257
|
+
x.on !== 'heading' &&
|
|
7258
|
+
(C.MAP[x.on]?.contains ?? []).includes('heading') &&
|
|
7259
|
+
lex.parts.some(
|
|
7260
|
+
([re, y]) =>
|
|
7261
|
+
y.on === x.on && re.test(` ${lead[1].split(' ').at(-1)} `),
|
|
7262
|
+
),
|
|
7263
|
+
)
|
|
7264
|
+
: undefined;
|
|
7265
|
+
// (One with a title part of its own, a dialog's title block: that
|
|
7266
|
+
// part.)
|
|
7267
|
+
if (
|
|
7268
|
+
owner &&
|
|
7269
|
+
c.parts.length === 2 &&
|
|
7270
|
+
ctx.project.target.has(`${owner.on}-header-title-block`)
|
|
7271
|
+
) {
|
|
7272
|
+
c.parts = [{on: `${owner.on}-header-title-block`}];
|
|
7273
|
+
continue;
|
|
7274
|
+
}
|
|
7275
|
+
if (owner && c.parts.length === 2) {
|
|
7276
|
+
c.container = owner.on;
|
|
7277
|
+
c.parts = [{on: 'heading'}];
|
|
7278
|
+
c.placeStrict = {holder: owner.on, part: 'heading'};
|
|
7279
|
+
c.scopeWhy = `Core has no ${owner.on} title part of its own: its title is a heading inside it, and this change is the heading's own setting, which ${owner.on} cannot hold (it would change every heading); nothing is written`;
|
|
7280
|
+
continue;
|
|
7281
|
+
}
|
|
7282
|
+
}
|
|
6315
7283
|
if (title && c.parts.length === 1) {
|
|
6316
7284
|
c.container = title.on;
|
|
6317
7285
|
c.parts = [{on: 'heading'}];
|
|
@@ -6320,6 +7288,50 @@ export function draftAnswer(ctx, env, question) {
|
|
|
6320
7288
|
continue;
|
|
6321
7289
|
}
|
|
6322
7290
|
}
|
|
7291
|
+
// "the dialog buttons", "the button icon": a part's name said right
|
|
7292
|
+
// before another's names the second inside the first (no catalog part
|
|
7293
|
+
// goes by both words): kept to it, as "buttons in the dialog".
|
|
7294
|
+
if (c.parts.length === 2 && !c.container) {
|
|
7295
|
+
const at = (/** @type {{on: string}} */ p) =>
|
|
7296
|
+
lex.parts
|
|
7297
|
+
.filter(([, x]) => x.on === p.on && !x.when)
|
|
7298
|
+
.map(([re]) => re.exec(c.text))
|
|
7299
|
+
.filter(m => m != null)
|
|
7300
|
+
.map(m => ({
|
|
7301
|
+
start: /** @type {RegExpExecArray} */ (m).index,
|
|
7302
|
+
end:
|
|
7303
|
+
/** @type {RegExpExecArray} */ (m).index +
|
|
7304
|
+
/** @type {RegExpExecArray} */ (m)[0].length,
|
|
7305
|
+
}))
|
|
7306
|
+
.sort((x, y) => x.start - y.start)[0] ?? null;
|
|
7307
|
+
const [p1, p2] = c.parts;
|
|
7308
|
+
const [a1, a2] = [at(p1), at(p2)];
|
|
7309
|
+
const ordered =
|
|
7310
|
+
a1 && a2
|
|
7311
|
+
? a1.start < a2.start
|
|
7312
|
+
? [p1, a1, p2, a2]
|
|
7313
|
+
: [p2, a2, p1, a1]
|
|
7314
|
+
: null;
|
|
7315
|
+
if (ordered) {
|
|
7316
|
+
const [holder, hAt, inner, iAt] = /** @type {any[]} */ (ordered);
|
|
7317
|
+
const gap = c.text.slice(hAt.end, iAt.start);
|
|
7318
|
+
// (Not a part's text or line, which their own readers place: a
|
|
7319
|
+
// card's heading, a row's dividers.)
|
|
7320
|
+
if (
|
|
7321
|
+
/^\s+$/.test(gap) &&
|
|
7322
|
+
!C.MAP[`${holder.on}-${inner.on}`] &&
|
|
7323
|
+
C.MAP[holder.on] &&
|
|
7324
|
+
!textOnlyPart(inner.on) &&
|
|
7325
|
+
!(C.MAP[inner.on]?.line ?? []).length &&
|
|
7326
|
+
inner.on !== 'divider'
|
|
7327
|
+
) {
|
|
7328
|
+
c.parts = [inner];
|
|
7329
|
+
c.container = holder.on;
|
|
7330
|
+
c.placeStrict = {holder: holder.on, part: inner.on};
|
|
7331
|
+
continue;
|
|
7332
|
+
}
|
|
7333
|
+
}
|
|
7334
|
+
}
|
|
6323
7335
|
// "the menu separators": a part's own divider that draws no line of
|
|
6324
7336
|
// its own is Core's divider inside that part, which the editor cannot
|
|
6325
7337
|
// keep apart: every divider, said.
|
|
@@ -6353,6 +7365,7 @@ export function draftAnswer(ctx, env, question) {
|
|
|
6353
7365
|
const element = elementOfPlace(c);
|
|
6354
7366
|
if (element) {
|
|
6355
7367
|
c.parts = [element.part];
|
|
7368
|
+
iconColor(c);
|
|
6356
7369
|
c.container = element.holder;
|
|
6357
7370
|
if (element.state !== undefined) c.state = element.state;
|
|
6358
7371
|
if (element.note) placeNotes.push({c, text: element.note});
|
|
@@ -6375,7 +7388,28 @@ export function draftAnswer(ctx, env, question) {
|
|
|
6375
7388
|
// (A word that only says which of a thing, "the card's fainter
|
|
6376
7389
|
// text", "the card's main text", is skipped too: the thing is the
|
|
6377
7390
|
// child.)
|
|
6378
|
-
|
|
7391
|
+
// (A status or variant of the part named, "the input's error border":
|
|
7392
|
+
// that look of it, never an element.)
|
|
7393
|
+
const lookOf = (/** @type {string} */ w) => {
|
|
7394
|
+
for (const x of c.parts) {
|
|
7395
|
+
const member = FAMILIES[x.on] ? FAMILIES[x.on][0] : x.on;
|
|
7396
|
+
const vals = C.variantValues(member) ?? {};
|
|
7397
|
+
const k = Object.keys(vals).find(key =>
|
|
7398
|
+
(vals[key] ?? []).includes(w),
|
|
7399
|
+
);
|
|
7400
|
+
if (k && k !== 'size') return {x, when: `${k}:${w}`};
|
|
7401
|
+
}
|
|
7402
|
+
return null;
|
|
7403
|
+
};
|
|
7404
|
+
const ci = after.findIndex(w => {
|
|
7405
|
+
if (stateWord(w) != null || w === 'own') return false;
|
|
7406
|
+
const look = lookOf(w);
|
|
7407
|
+
if (look && !look.x.when) {
|
|
7408
|
+
look.x.when = look.when;
|
|
7409
|
+
return false;
|
|
7410
|
+
}
|
|
7411
|
+
return !look;
|
|
7412
|
+
});
|
|
6379
7413
|
const child =
|
|
6380
7414
|
ci >= 0 &&
|
|
6381
7415
|
/^(?:text|labels?|copy|writing|words)$/.test(after[ci + 1] ?? '') &&
|
|
@@ -6569,15 +7603,31 @@ export function draftAnswer(ctx, env, question) {
|
|
|
6569
7603
|
// (Kept to the place when the place draws the part: "buttons inside
|
|
6570
7604
|
// cards". A place that draws none of it is no place of it, "the menu
|
|
6571
7605
|
// item of the dropdown" read as a select.)
|
|
6572
|
-
|
|
6573
|
-
|
|
6574
|
-
|
|
6575
|
-
|
|
6576
|
-
|
|
6577
|
-
|
|
6578
|
-
|
|
6579
|
-
|
|
6580
|
-
|
|
7606
|
+
// (Whether or not the place draws it, a part kept to a place it
|
|
7607
|
+
// cannot be held to is never written everywhere: "menu items in the
|
|
7608
|
+
// dialog" writes nothing unless a token on the dialog holds it. A
|
|
7609
|
+
// place the part's own name already says, "the menu item of the
|
|
7610
|
+
// dropdown", is the part itself, wherever it is.)
|
|
7611
|
+
const placeWords = (
|
|
7612
|
+
/\b(?:in|of|on|inside|within)\s+(?:the\s+|a\s+|an\s+|my\s+)?([a-z][a-z ]*)$/.exec(
|
|
7613
|
+
inPlaceText,
|
|
7614
|
+
)?.[1] ?? ''
|
|
7615
|
+
).split(/\s+/);
|
|
7616
|
+
const drawn = c.parts.every(y =>
|
|
7617
|
+
(FAMILIES[y.on] ?? [y.on]).some(m =>
|
|
7618
|
+
(C.MAP[String(c.container)]?.contains ?? []).includes(m),
|
|
7619
|
+
),
|
|
7620
|
+
);
|
|
7621
|
+
const named = c.parts.every(y =>
|
|
7622
|
+
y.on
|
|
7623
|
+
.split('-')
|
|
7624
|
+
.some(w => placeWords.includes(w) || placeWords.includes(`${w}s`)),
|
|
7625
|
+
);
|
|
7626
|
+
if (c.container && !c.byState && !drawn && named) {
|
|
7627
|
+
c.container = undefined;
|
|
7628
|
+
continue;
|
|
7629
|
+
}
|
|
7630
|
+
if (c.container && !c.byState)
|
|
6581
7631
|
c.placeStrict = {
|
|
6582
7632
|
holder: String(c.container),
|
|
6583
7633
|
part: c.parts.map(x => x.on).join(', '),
|
|
@@ -7022,6 +8072,10 @@ export function draftAnswer(ctx, env, question) {
|
|
|
7022
8072
|
const [a, b] = [clauses[i - 1], clauses[i]];
|
|
7023
8073
|
if (a.except || b.except || !a.mode || !b.mode || a.mode === b.mode)
|
|
7024
8074
|
continue;
|
|
8075
|
+
// (Never across a sentence: "…; secondary text #4d4d4d in light
|
|
8076
|
+
// mode" is a subject of its own, not the other half of the pair
|
|
8077
|
+
// before it.)
|
|
8078
|
+
if (joinOf.get(b)?.sep === 'break') continue;
|
|
7025
8079
|
if (!a.parts.length !== !b.parts.length) {
|
|
7026
8080
|
const [from, to] = a.parts.length ? [a, b] : [b, a];
|
|
7027
8081
|
to.parts = from.parts.map(p => ({...p}));
|
|
@@ -7069,16 +8123,9 @@ export function draftAnswer(ctx, env, question) {
|
|
|
7069
8123
|
!(c.aspects.length && c.aspects.every(a => a === 'family')) &&
|
|
7070
8124
|
!unknownLead(c) &&
|
|
7071
8125
|
!unknownSlot(c.text) &&
|
|
7072
|
-
|
|
7073
|
-
//
|
|
7074
|
-
|
|
7075
|
-
!(
|
|
7076
|
-
before.parts.every(p => ['heading', 'body', 'code'].includes(p.on)) &&
|
|
7077
|
-
c.aspects.length &&
|
|
7078
|
-
c.aspects.every(a =>
|
|
7079
|
-
['shadow', 'corners', 'border', 'spacing'].includes(a),
|
|
7080
|
-
)
|
|
7081
|
-
) &&
|
|
8126
|
+
// (The clause-scope reader decides: a modifier of the part before
|
|
8127
|
+
// takes it; anything else is the whole theme's.)
|
|
8128
|
+
scopeOf(c, before) === 'inherit' &&
|
|
7082
8129
|
// (A second ask said with only its way or its color, "rounder and
|
|
7083
8130
|
// darker", "rounder and red", is about the same part.)
|
|
7084
8131
|
(c.aspects.length ||
|
|
@@ -7242,6 +8289,46 @@ export function draftAnswer(ctx, env, question) {
|
|
|
7242
8289
|
)
|
|
7243
8290
|
)
|
|
7244
8291
|
for (const c of clauses) c.mode = null;
|
|
8292
|
+
// "in dark mode: page #202020, cards #2b2b2b, card border #1d1d1d,
|
|
8293
|
+
// accent #4cc2ff": a mode said at the head of a sentence, before its
|
|
8294
|
+
// colon, is the mode of every clause in that sentence (an ask that is
|
|
8295
|
+
// the same in both modes, the corners, keeps none).
|
|
8296
|
+
for (let i = 0; i < clauses.length; i++) {
|
|
8297
|
+
const c = clauses[i];
|
|
8298
|
+
if (
|
|
8299
|
+
!c.mode ||
|
|
8300
|
+
c.except ||
|
|
8301
|
+
!/^\s*(?:(?:only\s+)?(?:in|for)\s+)?(?:light|dark)(?:[- ](?:mode|theme))?\s*:/i.test(
|
|
8302
|
+
c.text,
|
|
8303
|
+
)
|
|
8304
|
+
)
|
|
8305
|
+
continue;
|
|
8306
|
+
for (let k = i + 1; k < clauses.length; k++) {
|
|
8307
|
+
const o = clauses[k];
|
|
8308
|
+
if (joinOf.get(o)?.sep === 'break') break;
|
|
8309
|
+
if (
|
|
8310
|
+
o.mode ||
|
|
8311
|
+
o.except ||
|
|
8312
|
+
(o.aspects.length &&
|
|
8313
|
+
o.aspects.every(a =>
|
|
8314
|
+
[
|
|
8315
|
+
'corners',
|
|
8316
|
+
'spacing',
|
|
8317
|
+
'size',
|
|
8318
|
+
'fontsize',
|
|
8319
|
+
'weight',
|
|
8320
|
+
'family',
|
|
8321
|
+
'case',
|
|
8322
|
+
'italic',
|
|
8323
|
+
'leading',
|
|
8324
|
+
'tracking',
|
|
8325
|
+
].includes(a),
|
|
8326
|
+
))
|
|
8327
|
+
)
|
|
8328
|
+
continue;
|
|
8329
|
+
o.mode = c.mode;
|
|
8330
|
+
}
|
|
8331
|
+
}
|
|
7245
8332
|
// "only in dark mode, …": a clause that only names a mode scopes every
|
|
7246
8333
|
// clause after it.
|
|
7247
8334
|
for (let i = 0; i < clauses.length; i++) {
|
|
@@ -7289,6 +8376,74 @@ export function draftAnswer(ctx, env, question) {
|
|
|
7289
8376
|
});
|
|
7290
8377
|
fillAspect();
|
|
7291
8378
|
const modal = env.data.mode === 'both';
|
|
8379
|
+
/**
|
|
8380
|
+
* The mode a page color is for: the mode said, else, on a theme with
|
|
8381
|
+
* both modes, a clearly light color's light mode and a clearly dark
|
|
8382
|
+
* color's dark mode, typed or named (the other mode keeps its own page,
|
|
8383
|
+
* so its text stays readable); every mode's when the ask says so.
|
|
8384
|
+
* @param {Clause} c
|
|
8385
|
+
* @param {string} color
|
|
8386
|
+
* @returns {'light' | 'dark' | null}
|
|
8387
|
+
*/
|
|
8388
|
+
const pageModeOf = (c, color) => {
|
|
8389
|
+
if (c.mode === 'light' || c.mode === 'dark') return c.mode;
|
|
8390
|
+
// (Written whole on a one-mode theme, or when the ask says so: "in
|
|
8391
|
+
// both modes", "everywhere".)
|
|
8392
|
+
if (
|
|
8393
|
+
!modal ||
|
|
8394
|
+
/\b(?:(?:in\s+)?(?:both|all)\s+modes|every\s+mode|everywhere|light\s+and\s+dark|dark\s+and\s+light)\b/i.test(
|
|
8395
|
+
`${c.text} ${question}`,
|
|
8396
|
+
)
|
|
8397
|
+
)
|
|
8398
|
+
return null;
|
|
8399
|
+
const rgb = parseColor(String(color));
|
|
8400
|
+
if (!rgb) return null;
|
|
8401
|
+
// (Clearly light or clearly dark only: as readable as a page is.)
|
|
8402
|
+
return ratio(rgb, [0, 0, 0]) >= 12
|
|
8403
|
+
? 'light'
|
|
8404
|
+
: ratio(rgb, [255, 255, 255]) >= 12
|
|
8405
|
+
? 'dark'
|
|
8406
|
+
: null;
|
|
8407
|
+
};
|
|
8408
|
+
/** How a page color's mode reads. @param {Clause} c @param {'light' | 'dark' | null} m */
|
|
8409
|
+
const pageModeSaid = (c, m) => {
|
|
8410
|
+
if (!m || !modal) return '';
|
|
8411
|
+
const other = m === 'light' ? 'dark' : 'light';
|
|
8412
|
+
return ` in ${m} mode${c.mode ? '' : ` (a ${m} color: the ${other} mode keeps its own page, so its text stays readable; for the ${other} mode too, set a ${other} color with --mode ${other}, or say "in both modes")`}`;
|
|
8413
|
+
};
|
|
8414
|
+
/**
|
|
8415
|
+
* The one mode a text color is readable in (at least `min`:1 against
|
|
8416
|
+
* that mode's page), on a theme that draws both modes, when the other
|
|
8417
|
+
* mode's page would make it unreadable and the ask names no mode and
|
|
8418
|
+
* not both; else null.
|
|
8419
|
+
* @param {Clause} c
|
|
8420
|
+
* @param {string} color
|
|
8421
|
+
* @param {number} [min]
|
|
8422
|
+
* @returns {'light' | 'dark' | null}
|
|
8423
|
+
*/
|
|
8424
|
+
const readableModeOf = (c, color, min = 3) => {
|
|
8425
|
+
if (c.mode || !modal) return null;
|
|
8426
|
+
if (
|
|
8427
|
+
/\b(?:everywhere|both modes|all modes|always|in every mode)\b/i.test(
|
|
8428
|
+
`${c.text} ${question}`,
|
|
8429
|
+
)
|
|
8430
|
+
)
|
|
8431
|
+
return null;
|
|
8432
|
+
const rgb = parseColor(color);
|
|
8433
|
+
if (!rgb) return null;
|
|
8434
|
+
/** @param {'light' | 'dark'} m */
|
|
8435
|
+
const r = m => {
|
|
8436
|
+
const page = parseColor(current('--color-background-body', m));
|
|
8437
|
+
return page ? ratio(rgb, page) : Infinity;
|
|
8438
|
+
};
|
|
8439
|
+
const [l, d] = [r('light'), r('dark')];
|
|
8440
|
+
if (l >= min !== d >= min) return l >= min ? 'light' : 'dark';
|
|
8441
|
+
// (Neither page reaches it: the page it reads clearly better on, so
|
|
8442
|
+
// the other keeps its own.)
|
|
8443
|
+
if (l < min && d < min && Math.max(l, d) >= 3 && Math.abs(l - d) >= 0.5)
|
|
8444
|
+
return l > d ? 'light' : 'dark';
|
|
8445
|
+
return null;
|
|
8446
|
+
};
|
|
7292
8447
|
const modeOf = (/** @type {Clause} */ c) =>
|
|
7293
8448
|
c.mode && modal ? {mode: c.mode} : {};
|
|
7294
8449
|
/** @type {Draft[]} */
|
|
@@ -7548,7 +8703,8 @@ export function draftAnswer(ctx, env, question) {
|
|
|
7548
8703
|
.filter(
|
|
7549
8704
|
r =>
|
|
7550
8705
|
/^--size-/.test(r.token) &&
|
|
7551
|
-
r.props.includes('height')
|
|
8706
|
+
(r.props.includes('height') ||
|
|
8707
|
+
r.props.includes('min-height')) &&
|
|
7552
8708
|
(!size ||
|
|
7553
8709
|
r.token.endsWith(`-${size}`) ||
|
|
7554
8710
|
r.when.some(w => w.split(/[\s,]/).includes(`size=${size}`))),
|
|
@@ -7631,11 +8787,21 @@ export function draftAnswer(ctx, env, question) {
|
|
|
7631
8787
|
if (p.level) f.when = `level:${p.level}`;
|
|
7632
8788
|
const vals = C.variantValues(one(p.on));
|
|
7633
8789
|
if (!f.when && vals.size) {
|
|
7634
|
-
|
|
7635
|
-
|
|
7636
|
-
|
|
7637
|
-
|
|
7638
|
-
|
|
8790
|
+
// (A size word names the part's size only beside the part: "small
|
|
8791
|
+
// buttons", "the large inputs"; before what changes, "a small shadow
|
|
8792
|
+
// on inputs", "large padding on buttons", it is the amount.)
|
|
8793
|
+
const besidePart = (/** @type {string} */ w) =>
|
|
8794
|
+
!new RegExp(
|
|
8795
|
+
String.raw`\b(?:${w})\s+(?:shadows?|padding|radius|corners?|borders?|gaps?|spacing|text|fonts?|type|outlines?|rings?|margins?)\b`,
|
|
8796
|
+
).test(c.text);
|
|
8797
|
+
const size =
|
|
8798
|
+
/\b(small|sm)\b/.test(c.text) && besidePart('small|sm')
|
|
8799
|
+
? ['sm', 'small']
|
|
8800
|
+
: /\b(large|lg)\b/.test(c.text) && besidePart('large|lg')
|
|
8801
|
+
? ['lg', 'large']
|
|
8802
|
+
: /\b(medium|md)\b/.test(c.text) && besidePart('medium|md')
|
|
8803
|
+
? ['md', 'medium']
|
|
8804
|
+
: [];
|
|
7639
8805
|
const hit = size.find(s => vals.size.includes(s));
|
|
7640
8806
|
if (hit) f.when = `size:${hit}`;
|
|
7641
8807
|
}
|
|
@@ -7662,6 +8828,9 @@ export function draftAnswer(ctx, env, question) {
|
|
|
7662
8828
|
also && also !== st ? partState(ctx, one(p.on), `${st}+${also}`) : st;
|
|
7663
8829
|
else if (byValue && !f.when) f.when = `${byValue}:${c.state}`;
|
|
7664
8830
|
else f.noState = c.state;
|
|
8831
|
+
// (A second state the part does not have is said, never dropped:
|
|
8832
|
+
// "the selected and hovered menu items" on items with no selected.)
|
|
8833
|
+
if (st && c.alsoState && !also) f.noState = c.alsoState;
|
|
7665
8834
|
}
|
|
7666
8835
|
return f;
|
|
7667
8836
|
};
|
|
@@ -8876,6 +10045,24 @@ export function draftAnswer(ctx, env, question) {
|
|
|
8876
10045
|
// A typed color always wins over a color word.
|
|
8877
10046
|
const own = kind === 'text' ? colorsIn(ownText) : [];
|
|
8878
10047
|
if (own.length) return themeShade(c, own[0]);
|
|
10048
|
+
// ("green text on a black page": the color said with the fill's own
|
|
10049
|
+
// word is the fill, never the text's.)
|
|
10050
|
+
if (kind === 'fill' && c.colors.length > 1) {
|
|
10051
|
+
const fillWord =
|
|
10052
|
+
/(?:(?:light|dark|pale|deep)\s+)?(?:#[0-9a-f]{3,8}|[a-z]+)\s+(?:page|background|bg|surface|fill|backdrop)s?\b/i.exec(
|
|
10053
|
+
c.text,
|
|
10054
|
+
);
|
|
10055
|
+
const said = fillWord ? colorsIn(fillWord[0]) : [];
|
|
10056
|
+
if (said.length) return themeShade(c, said[0]);
|
|
10057
|
+
// (Else never the color said before "text".)
|
|
10058
|
+
const textWord =
|
|
10059
|
+
/(?:(?:light|dark|pale|deep)\s+)?(?:#[0-9a-f]{3,8}|[a-z]+)\s+(?:text|labels?|writing|words|letters)\b/i.exec(
|
|
10060
|
+
c.text,
|
|
10061
|
+
);
|
|
10062
|
+
const ink = textWord ? colorsIn(textWord[0])[0] : undefined;
|
|
10063
|
+
const other = c.colors.find(x => x !== ink);
|
|
10064
|
+
if (ink && other) return themeShade(c, other);
|
|
10065
|
+
}
|
|
8879
10066
|
if (
|
|
8880
10067
|
kind === 'fill' &&
|
|
8881
10068
|
c.colors.length &&
|
|
@@ -8982,6 +10169,94 @@ export function draftAnswer(ctx, env, question) {
|
|
|
8982
10169
|
if (steps.length) tops.push({clause: c, steps});
|
|
8983
10170
|
};
|
|
8984
10171
|
|
|
10172
|
+
// "switches: track #e5e7eb when off": a part whose only selection
|
|
10173
|
+
// state is checked draws its unchecked look at rest, so the clause is
|
|
10174
|
+
// its resting look with the checked one kept, never every state.
|
|
10175
|
+
for (let i = clauses.length - 1; i >= 0; i--) {
|
|
10176
|
+
const c = clauses[i];
|
|
10177
|
+
if (
|
|
10178
|
+
c.state !== 'unchecked' ||
|
|
10179
|
+
c.except ||
|
|
10180
|
+
!c.parts.length ||
|
|
10181
|
+
!c.parts.every(
|
|
10182
|
+
p =>
|
|
10183
|
+
statesOf(p.on).includes('checked') &&
|
|
10184
|
+
!statesOf(p.on).includes('unchecked'),
|
|
10185
|
+
)
|
|
10186
|
+
)
|
|
10187
|
+
continue;
|
|
10188
|
+
c.state = null;
|
|
10189
|
+
// (Its state words are read: the resting look, checked kept.)
|
|
10190
|
+
c.text = c.text
|
|
10191
|
+
.replace(
|
|
10192
|
+
/\b(?:unchecked|not checked|unticked|when off|turned off|toggled off|switched off|is off)\b/g,
|
|
10193
|
+
' ',
|
|
10194
|
+
)
|
|
10195
|
+
.replace(/\s+/g, ' ')
|
|
10196
|
+
.trim();
|
|
10197
|
+
clauses.splice(i + 1, 0, {
|
|
10198
|
+
...c,
|
|
10199
|
+
text: `except checked ${c.parts.map(p => p.on).join(' and ')}`,
|
|
10200
|
+
aspects: [],
|
|
10201
|
+
colors: [],
|
|
10202
|
+
lengths: [],
|
|
10203
|
+
dir: null,
|
|
10204
|
+
decl: {},
|
|
10205
|
+
state: 'checked',
|
|
10206
|
+
except: true,
|
|
10207
|
+
});
|
|
10208
|
+
}
|
|
10209
|
+
// A mode said at the end of a run of clauses on one part, joined by
|
|
10210
|
+
// "with" or "and" ("secondary buttons white with a 1px border and a
|
|
10211
|
+
// small shadow in light mode"), is the mode of the whole run, up to the
|
|
10212
|
+
// last clause that said a mode of its own; a bare color starting the
|
|
10213
|
+
// next run ("… and white with black text in dark mode") is the same
|
|
10214
|
+
// thing the first run's head colored.
|
|
10215
|
+
{
|
|
10216
|
+
const samePart = (/** @type {Clause} */ x, /** @type {Clause} */ y) =>
|
|
10217
|
+
x.parts.length > 0 &&
|
|
10218
|
+
x.parts.length === y.parts.length &&
|
|
10219
|
+
x.parts.every(
|
|
10220
|
+
(p, k) => p.on === y.parts[k].on && p.when === y.parts[k].when,
|
|
10221
|
+
);
|
|
10222
|
+
const joined = (/** @type {Clause} */ x) =>
|
|
10223
|
+
new RegExp(
|
|
10224
|
+
String.raw`\b(?:with|and)\s+${x.text.trim().replace(/[.*+?^${}()|[\]\\]/g, '\\$&')}`,
|
|
10225
|
+
).test(q);
|
|
10226
|
+
/** @type {Clause[]} */
|
|
10227
|
+
let run = [];
|
|
10228
|
+
/** @type {Clause | null} */
|
|
10229
|
+
let prevHead = null;
|
|
10230
|
+
for (const c of clauses) {
|
|
10231
|
+
if (c.except || c.neg) {
|
|
10232
|
+
run = [];
|
|
10233
|
+
continue;
|
|
10234
|
+
}
|
|
10235
|
+
if (run.length && (!joined(c) || !samePart(run[0], c))) run = [];
|
|
10236
|
+
run.push(c);
|
|
10237
|
+
if (c.mode === 'light' || c.mode === 'dark') {
|
|
10238
|
+
const others = run.slice(0, -1);
|
|
10239
|
+
if (!others.some(x => x.mode && x.mode !== c.mode)) {
|
|
10240
|
+
for (const x of others) if (!x.mode) x.mode = c.mode;
|
|
10241
|
+
const head = run[0];
|
|
10242
|
+
// (The bare color heading this run takes the thing the run
|
|
10243
|
+
// before colored first.)
|
|
10244
|
+
if (
|
|
10245
|
+
prevHead &&
|
|
10246
|
+
head !== c &&
|
|
10247
|
+
!(ownAspects.get(head) ?? []).length &&
|
|
10248
|
+
head.colors.length === 1 &&
|
|
10249
|
+
/^[a-z#0-9 ]+$/i.test(head.text.trim()) &&
|
|
10250
|
+
head.text.trim().split(/\s+/).length <= 2 &&
|
|
10251
|
+
prevHead.aspects.length
|
|
10252
|
+
)
|
|
10253
|
+
head.aspects = [...prevHead.aspects];
|
|
10254
|
+
prevHead = run[0];
|
|
10255
|
+
}
|
|
10256
|
+
run = [];
|
|
10257
|
+
}
|
|
10258
|
+
}
|
|
10259
|
+
}
|
|
8985
10260
|
for (const c of clauses) {
|
|
8986
10261
|
clauseNow = c;
|
|
8987
10262
|
// An element its place has no part of its own for: nothing is written,
|
|
@@ -9217,7 +10492,7 @@ export function draftAnswer(ctx, env, question) {
|
|
|
9217
10492
|
.filter(
|
|
9218
10493
|
w =>
|
|
9219
10494
|
!priorOn ||
|
|
9220
|
-
['small', 'large'].includes(w) ||
|
|
10495
|
+
['small', 'medium', 'large'].includes(w) ||
|
|
9221
10496
|
Object.values(
|
|
9222
10497
|
C.variantValues(one(/** @type {string} */ (priorOn))) ?? {},
|
|
9223
10498
|
)
|
|
@@ -9230,12 +10505,14 @@ export function draftAnswer(ctx, env, question) {
|
|
|
9230
10505
|
variantWords.map(variant =>
|
|
9231
10506
|
variant === 'small'
|
|
9232
10507
|
? 'size:sm'
|
|
9233
|
-
: variant === '
|
|
9234
|
-
? 'size:
|
|
9235
|
-
:
|
|
9236
|
-
|
|
9237
|
-
|
|
9238
|
-
|
|
10508
|
+
: variant === 'medium'
|
|
10509
|
+
? 'size:md'
|
|
10510
|
+
: variant === 'large'
|
|
10511
|
+
? 'size:lg'
|
|
10512
|
+
: variantKey(
|
|
10513
|
+
priorOn,
|
|
10514
|
+
variant === 'danger' ? 'destructive' : variant,
|
|
10515
|
+
),
|
|
9239
10516
|
),
|
|
9240
10517
|
),
|
|
9241
10518
|
];
|
|
@@ -9828,6 +11105,27 @@ export function draftAnswer(ctx, env, question) {
|
|
|
9828
11105
|
// to pin: said, and no command that would change it anyway.
|
|
9829
11106
|
const inGroup = (/** @type {string | undefined} */ on) =>
|
|
9830
11107
|
!on || on === p.on || (FAMILIES[on] ?? []).includes(p.on);
|
|
11108
|
+
// (A part that draws no corners at all, a heading, keeps them as
|
|
11109
|
+
// it is: nothing to keep apart.)
|
|
11110
|
+
const noCorners = (FAMILIES[p.on] ?? [p.on]).every(
|
|
11111
|
+
m =>
|
|
11112
|
+
!(C.partReads(one(m), 'corners') ?? []).length &&
|
|
11113
|
+
!Object.keys(C.MAP[one(m)]?.at?.['border-radius'] ?? {}).length,
|
|
11114
|
+
);
|
|
11115
|
+
if (
|
|
11116
|
+
noCorners &&
|
|
11117
|
+
priorSteps.some(
|
|
11118
|
+
(st, i) =>
|
|
11119
|
+
keep[i] == null &&
|
|
11120
|
+
/^(corners|border-radius|--radius-)/.test(st.thing) &&
|
|
11121
|
+
inGroup(st.on),
|
|
11122
|
+
)
|
|
11123
|
+
) {
|
|
11124
|
+
said.push(
|
|
11125
|
+
`${name} draws no corners, so the change leaves it as it is`,
|
|
11126
|
+
);
|
|
11127
|
+
continue;
|
|
11128
|
+
}
|
|
9831
11129
|
if (
|
|
9832
11130
|
priorSteps.some(
|
|
9833
11131
|
(st, i) =>
|
|
@@ -11170,7 +12468,65 @@ export function draftAnswer(ctx, env, question) {
|
|
|
11170
12468
|
prop === 'padding' && !partPropNow(sourceOn, prop)
|
|
11171
12469
|
? drawnInside(sourceOn, 'padding')
|
|
11172
12470
|
: null;
|
|
11173
|
-
|
|
12471
|
+
// (The size named on the other part, "the small inputs": its value
|
|
12472
|
+
// in that size, as its rule for that size writes it.)
|
|
12473
|
+
const srcSize = (() => {
|
|
12474
|
+
const at = lex.parts
|
|
12475
|
+
.filter(([, x]) => x.on === sourceOn)
|
|
12476
|
+
.map(([re]) => re.exec(c.text))
|
|
12477
|
+
.filter(m => m != null)
|
|
12478
|
+
.sort(
|
|
12479
|
+
(x, y) =>
|
|
12480
|
+
/** @type {RegExpExecArray} */ (y).index -
|
|
12481
|
+
/** @type {RegExpExecArray} */ (x).index,
|
|
12482
|
+
)[0];
|
|
12483
|
+
if (!at) return null;
|
|
12484
|
+
const w = /([a-z]+)\s+$/.exec(c.text.slice(0, at.index))?.[1];
|
|
12485
|
+
return (
|
|
12486
|
+
/** @type {Record<string, string>} */ ({
|
|
12487
|
+
small: 'sm',
|
|
12488
|
+
sm: 'sm',
|
|
12489
|
+
medium: 'md',
|
|
12490
|
+
md: 'md',
|
|
12491
|
+
large: 'lg',
|
|
12492
|
+
lg: 'lg',
|
|
12493
|
+
big: 'lg',
|
|
12494
|
+
})[w ?? ''] ?? null
|
|
12495
|
+
);
|
|
12496
|
+
})();
|
|
12497
|
+
const srcSized = srcSize
|
|
12498
|
+
? (Object.entries(
|
|
12499
|
+
C.MAP[one(sourceOn)]?.at?.[prop] ??
|
|
12500
|
+
C.MAP[(FAMILIES[sourceOn] ?? [])[0]]?.at?.[prop] ??
|
|
12501
|
+
{},
|
|
12502
|
+
).find(
|
|
12503
|
+
([k]) =>
|
|
12504
|
+
!k.includes(' ') && k.split(',').includes(`size=${srcSize}`),
|
|
12505
|
+
)?.[1] ?? null)
|
|
12506
|
+
: null;
|
|
12507
|
+
const srcLive = srcSized != null ? String(srcSized) : null;
|
|
12508
|
+
// (A size named that the other part writes no value for: said,
|
|
12509
|
+
// never its plain size compared in its place.)
|
|
12510
|
+
if (srcSize && srcSize !== 'md' && srcLive == null) {
|
|
12511
|
+
seenPart(subjectOn);
|
|
12512
|
+
seenPart(sourceOn);
|
|
12513
|
+
push({
|
|
12514
|
+
text: `${sourceOn} in size ${srcSize} has no ${prop} of its own that how can read (only its plain size's), so ${subjectOn} cannot take it; give the value (for example "${prop} 28px on ${subjectOn}")`,
|
|
12515
|
+
options: [],
|
|
12516
|
+
});
|
|
12517
|
+
continue;
|
|
12518
|
+
}
|
|
12519
|
+
const srcShown = srcLive
|
|
12520
|
+
? /^var\(\s*(--[a-z0-9-]+)\s*\)$/.exec(srcLive)?.[1]
|
|
12521
|
+
? (resolvedValue(
|
|
12522
|
+
/** @type {string} */ (
|
|
12523
|
+
/^var\(\s*(--[a-z0-9-]+)\s*\)$/.exec(srcLive)?.[1]
|
|
12524
|
+
),
|
|
12525
|
+
) ?? srcLive)
|
|
12526
|
+
: srcLive
|
|
12527
|
+
: null;
|
|
12528
|
+
const now =
|
|
12529
|
+
srcShown ?? partPropNow(sourceOn, prop) ?? inner?.value ?? null;
|
|
11174
12530
|
// "twice as round as inputs": that amount of the other part's;
|
|
11175
12531
|
// else the other part's own value, or the token it reads (so the
|
|
11176
12532
|
// copy follows it).
|
|
@@ -11196,7 +12552,10 @@ export function draftAnswer(ctx, env, question) {
|
|
|
11196
12552
|
? scaledBox(now, factor)
|
|
11197
12553
|
: past
|
|
11198
12554
|
? null
|
|
11199
|
-
: (
|
|
12555
|
+
: (srcLive ??
|
|
12556
|
+
partPropNow(sourceOn, prop, true) ??
|
|
12557
|
+
inner?.value ??
|
|
12558
|
+
null);
|
|
11200
12559
|
if (!value) {
|
|
11201
12560
|
// Nothing to measure against: said, never a step on both.
|
|
11202
12561
|
seenPart(subjectOn);
|
|
@@ -11766,6 +13125,16 @@ export function draftAnswer(ctx, env, question) {
|
|
|
11766
13125
|
const sizeNamed = /^size:([\w-]+)$/.exec(String(pf.when ?? ''))?.[1];
|
|
11767
13126
|
if (prop === 'height' && !pf.state && (!pf.when || sizeNamed)) {
|
|
11768
13127
|
const sized = sizeSteps(on, down ? -n : n, undefined, sizeNamed);
|
|
13128
|
+
// (A size the part's data never shows reading a control height,
|
|
13129
|
+
// a button's large size: its height now is unknown, so nothing
|
|
13130
|
+
// is written; never another size's height.)
|
|
13131
|
+
if (sizeNamed && !sized?.steps.length) {
|
|
13132
|
+
push({
|
|
13133
|
+
text: `${on}'s ${sizeNamed} size reads no control height the editor knows (its part data lists ${[...new Set((C.partReads(one(on), 'size') ?? []).filter(r => /^--size-/.test(r.token)).map(r => r.token))].join(', ') || 'none'}): nothing is written; give a height, such as min-height 40px --on ${on} --when size:${sizeNamed}`,
|
|
13134
|
+
options: [],
|
|
13135
|
+
});
|
|
13136
|
+
continue;
|
|
13137
|
+
}
|
|
11769
13138
|
if (sized?.steps.length) {
|
|
11770
13139
|
const d = {
|
|
11771
13140
|
text: `${on} ${down ? 'shorter' : 'taller'} by ${n}px: each control height it reads (${sized.toks.join(', ')}) ${down ? 'down' : 'up'} by ${n}px, on ${on} only (a part sized by its content or rows keeps its height)`,
|
|
@@ -12579,9 +13948,22 @@ export function draftAnswer(ctx, env, question) {
|
|
|
12579
13948
|
: prop === 'border-color'
|
|
12580
13949
|
? 'border'
|
|
12581
13950
|
: 'background';
|
|
12582
|
-
|
|
12583
|
-
|
|
13951
|
+
// (Read in that look itself: a look that reads only what the plain
|
|
13952
|
+
// look reads, the ghost button's fill, draws none of its own.)
|
|
13953
|
+
const all = C.partReads(one(part), group) ?? [];
|
|
13954
|
+
const token = restRead(all, w);
|
|
13955
|
+
const plain = restRead(all, '');
|
|
13956
|
+
const own0 = all.some(
|
|
13957
|
+
r =>
|
|
13958
|
+
r.token === token &&
|
|
13959
|
+
r.when.some(wn => wn.split(/\s+/).includes(w.replace(':', '='))),
|
|
13960
|
+
);
|
|
13961
|
+
if (token && (token !== plain || own0)) return `var(${token})`;
|
|
12584
13962
|
}
|
|
13963
|
+
// (A look named that draws none of that paint, the ghost button's
|
|
13964
|
+
// fill, or one the part does not have, gives nothing: never the plain
|
|
13965
|
+
// look's paint in its place.)
|
|
13966
|
+
if (when) return null;
|
|
12585
13967
|
return partPropNow(part, prop, true);
|
|
12586
13968
|
}
|
|
12587
13969
|
/**
|
|
@@ -13335,6 +14717,41 @@ export function draftAnswer(ctx, env, question) {
|
|
|
13335
14717
|
const where = on
|
|
13336
14718
|
? ` on ${on}${f.when ? ` (${f.when.replace(':', ' ')})` : ''}${f.state ? ` when ${f.state}` : ''}`
|
|
13337
14719
|
: ' for the whole theme';
|
|
14720
|
+
// A part drawn inside an overlay that paints its edge for it (a
|
|
14721
|
+
// typeahead's list, inside the popover it opens in): the shadow or the
|
|
14722
|
+
// border is the overlay's, so the answer points there, saying that a
|
|
14723
|
+
// change on it reaches every one of those overlays; nothing is written.
|
|
14724
|
+
if (on && !FAMILIES[on] && (a === 'shadow' || a === 'border')) {
|
|
14725
|
+
const props =
|
|
14726
|
+
a === 'shadow'
|
|
14727
|
+
? ['box-shadow']
|
|
14728
|
+
: ['border', 'border-color', 'border-width', 'border-style'];
|
|
14729
|
+
const rec = C.MAP[one(on)];
|
|
14730
|
+
const holder =
|
|
14731
|
+
rec && !props.some(x => rec.own?.[x] || rec.at?.[x])
|
|
14732
|
+
? Object.keys(C.MAP)
|
|
14733
|
+
.filter(
|
|
14734
|
+
k =>
|
|
14735
|
+
k !== one(on) &&
|
|
14736
|
+
(C.MAP[k].contains ?? []).includes(one(on)) &&
|
|
14737
|
+
props.some(x => C.MAP[k].own?.[x]) &&
|
|
14738
|
+
ctx.project.components[
|
|
14739
|
+
String(ctx.project.target.get(k)?.component ?? '')
|
|
14740
|
+
]?.category === 'Overlay',
|
|
14741
|
+
)
|
|
14742
|
+
.sort(
|
|
14743
|
+
(x, y) =>
|
|
14744
|
+
(C.MAP[x].contains ?? []).length -
|
|
14745
|
+
(C.MAP[y].contains ?? []).length,
|
|
14746
|
+
)[0]
|
|
14747
|
+
: undefined;
|
|
14748
|
+
if (holder)
|
|
14749
|
+
return {
|
|
14750
|
+
text: `${on} draws no ${a} of its own: the ${holder} it opens in draws it, and a change on ${holder} reaches every ${holder}; nothing is written. To change every ${holder}'s ${a}, set it --on ${holder}`,
|
|
14751
|
+
options: [],
|
|
14752
|
+
lookup: `${HOW} ${holder}`,
|
|
14753
|
+
};
|
|
14754
|
+
}
|
|
13338
14755
|
/**
|
|
13339
14756
|
* What a part has now for a property in this clause's state or variant
|
|
13340
14757
|
* ("on hover"): that scope's own setting, else the plain one.
|
|
@@ -13919,16 +15336,52 @@ export function draftAnswer(ctx, env, question) {
|
|
|
13919
15336
|
],
|
|
13920
15337
|
};
|
|
13921
15338
|
}
|
|
15339
|
+
const pageMode = pageModeOf(c, String(color));
|
|
15340
|
+
const pm = pageMode ? {mode: pageMode} : {};
|
|
15341
|
+
// (The main panel, drawn over the page with a fill of its own, shows
|
|
15342
|
+
// that fill: the second line paints it with the frame, so the page
|
|
15343
|
+
// looks the color asked.)
|
|
15344
|
+
const panelRead = C.MAP['layout-content']
|
|
15345
|
+
? restRead(C.partReads('layout-content', 'background') ?? [], '')
|
|
15346
|
+
: null;
|
|
15347
|
+
const panel =
|
|
15348
|
+
panelRead && panelRead !== '--color-background-body' ? panelRead : null;
|
|
15349
|
+
// ("green text on a black page": the text color said with the page
|
|
15350
|
+
// is the theme's text, in the page's mode, with it.)
|
|
15351
|
+
const ink = /\btext\b/.test(c.text) ? colorFor(c, 'text') : null;
|
|
15352
|
+
if (ink && ink !== color)
|
|
15353
|
+
return {
|
|
15354
|
+
text: `the page background: --color-background-body${pageModeSaid(c, pageMode)}, and the text on it: --color-text-primary`,
|
|
15355
|
+
options: [
|
|
15356
|
+
[
|
|
15357
|
+
set('--color-background-body', color, pm),
|
|
15358
|
+
set('--color-text-primary', ink, pm),
|
|
15359
|
+
],
|
|
15360
|
+
],
|
|
15361
|
+
sequence: true,
|
|
15362
|
+
};
|
|
13922
15363
|
return {
|
|
13923
|
-
text: `the page background: --color-background-body${c
|
|
15364
|
+
text: `the page background: --color-background-body${pageModeSaid(c, pageMode)}${panel ? `; the main panel (layout-content) draws ${panel} over it, so the second line paints the frame and the main panel too` : ''}`,
|
|
13924
15365
|
options: [
|
|
13925
|
-
[set('--color-background-body', color,
|
|
13926
|
-
[
|
|
15366
|
+
[set('--color-background-body', color, pm)],
|
|
15367
|
+
[
|
|
15368
|
+
set('background', color, {on: 'app-shell', ...pm}),
|
|
15369
|
+
...(panel
|
|
15370
|
+
? [set('background-color', color, {on: 'layout-content', ...pm})]
|
|
15371
|
+
: []),
|
|
15372
|
+
],
|
|
13927
15373
|
],
|
|
13928
15374
|
};
|
|
13929
15375
|
}
|
|
13930
15376
|
if (on === 'icons') {
|
|
13931
15377
|
const color = colorFor(c, 'fill');
|
|
15378
|
+
// (An icon's size is the size its own component is given; no theme
|
|
15379
|
+
// token reaches it.)
|
|
15380
|
+
if (!color && a === 'size')
|
|
15381
|
+
return {
|
|
15382
|
+
text: `an icon's size is the size its own component is given${c.container ? ` in ${c.container}` : ''}; no theme setting reaches it, so nothing is written`,
|
|
15383
|
+
options: [],
|
|
15384
|
+
};
|
|
13932
15385
|
if (!color) return null;
|
|
13933
15386
|
return {
|
|
13934
15387
|
text: 'icon colors: --color-icon-primary for most icons, --color-icon-secondary for quieter ones',
|
|
@@ -14281,6 +15734,14 @@ export function draftAnswer(ctx, env, question) {
|
|
|
14281
15734
|
k,
|
|
14282
15735
|
),
|
|
14283
15736
|
) &&
|
|
15737
|
+
// (Nor one an element inside it paints, a keyboard key's chip.)
|
|
15738
|
+
!Object.entries(C.MAP[one(on)].inside ?? {}).some(
|
|
15739
|
+
([t, ps]) =>
|
|
15740
|
+
/^--color-/.test(t) &&
|
|
15741
|
+
/** @type {string[]} */ (ps).some(x =>
|
|
15742
|
+
/^(background|background-color|color)$/.test(x),
|
|
15743
|
+
),
|
|
15744
|
+
) &&
|
|
14284
15745
|
!/\b(background|bg|fill(ed)?|gradient)\b/.test(c.text)
|
|
14285
15746
|
)
|
|
14286
15747
|
return {
|
|
@@ -14336,11 +15797,25 @@ export function draftAnswer(ctx, env, question) {
|
|
|
14336
15797
|
}
|
|
14337
15798
|
if (a === 'text') {
|
|
14338
15799
|
const color = colorFor(c, 'text');
|
|
14339
|
-
if (color)
|
|
15800
|
+
if (color) {
|
|
15801
|
+
// (One mode's page would make it unreadable: the other mode
|
|
15802
|
+
// only, as the main text is.)
|
|
15803
|
+
// (Muted text is small and quiet: held to 4.5:1, as body text
|
|
15804
|
+
// is.)
|
|
15805
|
+
const one1 = readableModeOf(c, color, 4.5);
|
|
14340
15806
|
return {
|
|
14341
|
-
text:
|
|
14342
|
-
options: [
|
|
15807
|
+
text: `the secondary text color: --color-text-secondary${one1 ? ` in ${one1} mode only: on the ${one1 === 'light' ? 'dark' : 'light'} page ${color} would not be readable` : ''}`,
|
|
15808
|
+
options: [
|
|
15809
|
+
[
|
|
15810
|
+
set(
|
|
15811
|
+
'--color-text-secondary',
|
|
15812
|
+
color,
|
|
15813
|
+
one1 ? {mode: one1} : modeOf(c),
|
|
15814
|
+
),
|
|
15815
|
+
],
|
|
15816
|
+
],
|
|
14343
15817
|
};
|
|
15818
|
+
}
|
|
14344
15819
|
}
|
|
14345
15820
|
// Anything else ("secondary text is too low contrast"): as asked of
|
|
14346
15821
|
// the whole theme, which reads the secondary text words itself.
|
|
@@ -14353,13 +15828,7 @@ export function draftAnswer(ctx, env, question) {
|
|
|
14353
15828
|
// set font --on body moves the heading font too in this release, so
|
|
14354
15829
|
// the body alone takes its token.
|
|
14355
15830
|
if (p.role === 'body' && env.bodyFontReachesHeadings) {
|
|
14356
|
-
const stack =
|
|
14357
|
-
? `${FONTS[font][0].includes(' ') ? `"${FONTS[font][0]}"` : FONTS[font][0]}, ${FONTS[font][1]}`
|
|
14358
|
-
: OPEN_FONTS[font]
|
|
14359
|
-
? `"${OPEN_FONTS[font].family}", ${OPEN_FONTS[font].fallbacks}`
|
|
14360
|
-
: /[\s,]/.test(font) && !font.includes(',')
|
|
14361
|
-
? `"${font}"`
|
|
14362
|
-
: font;
|
|
15831
|
+
const stack = presetStack(font);
|
|
14363
15832
|
return {
|
|
14364
15833
|
text: 'the body font alone: --font-family-body (font --on body also changes the headings in this release)',
|
|
14365
15834
|
options: [[set('--font-family-body', stack)]],
|
|
@@ -14530,6 +15999,28 @@ export function draftAnswer(ctx, env, question) {
|
|
|
14530
15999
|
sequence: states.length > 1,
|
|
14531
16000
|
};
|
|
14532
16001
|
}
|
|
16002
|
+
// A part that is the underline itself, asked for a color or a
|
|
16003
|
+
// thickness ("a 2px black underline" on tabs): its fill and its
|
|
16004
|
+
// height, the line Core draws, never a text decoration it has no
|
|
16005
|
+
// text for.
|
|
16006
|
+
if (!c.neg && /-indicator$/.test(one(on))) {
|
|
16007
|
+
const at = C.MAP[one(on)]?.at ?? {};
|
|
16008
|
+
const tall = ['height', 'min-height', 'block-size'].find(k => at[k]);
|
|
16009
|
+
const px = /\b(\d+(?:\.\d+)?)\s*px\b/.exec(c.text)?.[1];
|
|
16010
|
+
const color = c.colors[0];
|
|
16011
|
+
const steps = [
|
|
16012
|
+
...(color && at['background-color']
|
|
16013
|
+
? [set('background-color', color, f)]
|
|
16014
|
+
: []),
|
|
16015
|
+
...(px && tall ? [set(tall, `${px}px`, f)] : []),
|
|
16016
|
+
];
|
|
16017
|
+
if (steps.length)
|
|
16018
|
+
return {
|
|
16019
|
+
text: `the underline${where}: ${one(on)} draws it as its fill${tall ? ` and its ${tall}` : ''}`,
|
|
16020
|
+
options: [steps],
|
|
16021
|
+
sequence: steps.length > 1,
|
|
16022
|
+
};
|
|
16023
|
+
}
|
|
14533
16024
|
const value = c.neg ? 'none' : 'underline';
|
|
14534
16025
|
return {
|
|
14535
16026
|
text: `${c.neg ? 'no underline' : 'underlined'}${where}: text-decoration`,
|
|
@@ -14897,7 +16388,7 @@ export function draftAnswer(ctx, env, question) {
|
|
|
14897
16388
|
})
|
|
14898
16389
|
.filter(st => st != null);
|
|
14899
16390
|
return {
|
|
14900
|
-
text: `${soft ? 'softer' : 'stronger'} shadows everywhere: each shared shadow from its own layers, ${bigger && !c.mode ? 'its blur scaled' : `its colors' alpha ×${Math.round(k * 1000) / 1000}`}${c.mode ? ` in ${c.mode} mode only` : ' in both modes'}`,
|
|
16391
|
+
text: `${(bigger ? soft : k < 1) ? 'softer' : 'stronger'} shadows everywhere: each shared shadow from its own layers, ${bigger && !c.mode ? 'its blur scaled' : `its colors' alpha ×${Math.round(k * 1000) / 1000}`}${c.mode ? ` in ${c.mode} mode only` : ' in both modes'}`,
|
|
14901
16392
|
options: steps.length ? [/** @type {Step[]} */ (steps)] : [],
|
|
14902
16393
|
sequence: true,
|
|
14903
16394
|
...(c.mode ? {modeInValue: true} : {}),
|
|
@@ -15097,7 +16588,9 @@ export function draftAnswer(ctx, env, question) {
|
|
|
15097
16588
|
// (A shared shadow typed by name is the one asked for.)
|
|
15098
16589
|
const shared =
|
|
15099
16590
|
/\bvar\(\s*--shadow-[a-z0-9-]+\s*\)/.exec(c.text)?.[0] ??
|
|
15100
|
-
|
|
16591
|
+
// (Its size word is the rung: "a small shadow" low, "a large
|
|
16592
|
+
// shadow" high.)
|
|
16593
|
+
`var(${soft || /\b(?:small|tiny|little|slight)\s+shadows?\b/.test(c.text) ? '--shadow-low' : strong || /\blift/.test(c.text) || /\b(?:large|big|huge)\s+shadows?\b/.test(c.text) ? '--shadow-high' : '--shadow-med'})`;
|
|
15101
16594
|
// A typed color is the shadow's color: with typed offsets (in any
|
|
15102
16595
|
// order) that layer, else the shared shadow's offsets in that color.
|
|
15103
16596
|
const typedColor = !glow && !design ? c.colors[0] : undefined;
|
|
@@ -15625,7 +17118,9 @@ export function draftAnswer(ctx, env, question) {
|
|
|
15625
17118
|
!color &&
|
|
15626
17119
|
!c.lengths[0] &&
|
|
15627
17120
|
/\b(darker|lighter|darken|lighten)\b/.test(c.text) &&
|
|
15628
|
-
!/\b(thick|thin|width|wider)/.test(c.text)
|
|
17121
|
+
!/\b(thick|thin|width|wider)/.test(c.text) &&
|
|
17122
|
+
// (One side's, "the bottom edge darker", is that side's below.)
|
|
17123
|
+
!/\b(top|bottom|left|right)\b/.test(c.text)
|
|
15629
17124
|
) {
|
|
15630
17125
|
const lighter = /\blight(er|en)?\b/.test(noMode(c.text));
|
|
15631
17126
|
const amount = colorAmount(c.text, 0.2);
|
|
@@ -15775,6 +17270,56 @@ export function draftAnswer(ctx, env, question) {
|
|
|
15775
17270
|
: null);
|
|
15776
17271
|
const side = /\b(top|bottom|left|right)\b/.exec(c.text)?.[1];
|
|
15777
17272
|
const prop = side ? `border-${side}` : 'border';
|
|
17273
|
+
// "inputs should have only a bottom border": no border on the other
|
|
17274
|
+
// sides, then that side's.
|
|
17275
|
+
if (
|
|
17276
|
+
side &&
|
|
17277
|
+
(/\bonly\s+(?:a\s+|the\s+|one\s+)?(?:top|bottom|left|right)\b/.test(
|
|
17278
|
+
c.text,
|
|
17279
|
+
) ||
|
|
17280
|
+
/\b(?:top|bottom|left|right)\s+(?:border|edge|line)\s+only\b/.test(
|
|
17281
|
+
c.text,
|
|
17282
|
+
))
|
|
17283
|
+
)
|
|
17284
|
+
return {
|
|
17285
|
+
text: `only a ${side} border${where}: no border on its other sides, then the ${side} one`,
|
|
17286
|
+
options: [
|
|
17287
|
+
[
|
|
17288
|
+
set('border', 'none', f),
|
|
17289
|
+
set(
|
|
17290
|
+
prop,
|
|
17291
|
+
`${width ?? '1px'} ${style ?? 'solid'} ${color ?? keptColor}`,
|
|
17292
|
+
f,
|
|
17293
|
+
),
|
|
17294
|
+
],
|
|
17295
|
+
],
|
|
17296
|
+
sequence: true,
|
|
17297
|
+
};
|
|
17298
|
+
// "a slightly darker bottom edge": that side's color only, its own
|
|
17299
|
+
// line color mixed darker (or lighter), in every mode.
|
|
17300
|
+
if (side && !color && !c.lengths.length) {
|
|
17301
|
+
const darker = /\bdarker\b/.test(c.text);
|
|
17302
|
+
const lighter = /\blighter\b/.test(c.text);
|
|
17303
|
+
if (darker || lighter) {
|
|
17304
|
+
const share = /\b(slightly|a bit|a little|a touch)\b/.test(c.text)
|
|
17305
|
+
? 85
|
|
17306
|
+
: /\b(much|way|a lot)\b/.test(c.text)
|
|
17307
|
+
? 60
|
|
17308
|
+
: 75;
|
|
17309
|
+
return {
|
|
17310
|
+
text: `a ${darker ? 'darker' : 'lighter'} ${side} border${where}: the line color it reads (${keptColor}) mixed ${100 - share}% toward ${darker ? 'black' : 'white'} on that side only, in every mode`,
|
|
17311
|
+
options: [
|
|
17312
|
+
[
|
|
17313
|
+
set(
|
|
17314
|
+
`border-${side}-color`,
|
|
17315
|
+
`color-mix(in srgb, ${keptColor} ${share}%, ${darker ? 'black' : 'white'})`,
|
|
17316
|
+
f,
|
|
17317
|
+
),
|
|
17318
|
+
],
|
|
17319
|
+
],
|
|
17320
|
+
};
|
|
17321
|
+
}
|
|
17322
|
+
}
|
|
15778
17323
|
// A border the part draws at rest: a width other than 0 and a style
|
|
15779
17324
|
// other than none (a button's 0px border is no line).
|
|
15780
17325
|
// (Every side's, and only the variant asked when one is.)
|
|
@@ -15971,13 +17516,17 @@ export function draftAnswer(ctx, env, question) {
|
|
|
15971
17516
|
}
|
|
15972
17517
|
if (style && !color && !width)
|
|
15973
17518
|
opts.push([set('border-style', style, f)]);
|
|
15974
|
-
|
|
15975
|
-
|
|
15976
|
-
|
|
15977
|
-
|
|
15978
|
-
|
|
15979
|
-
|
|
15980
|
-
|
|
17519
|
+
// (The shorthand writes one color for every state; when no color
|
|
17520
|
+
// is asked and a longhand answers, it would paint a checked or
|
|
17521
|
+
// error border the resting color, so it is not offered.)
|
|
17522
|
+
if (color || !opts.length)
|
|
17523
|
+
opts.push([
|
|
17524
|
+
set(
|
|
17525
|
+
prop,
|
|
17526
|
+
`${width ?? '1px'} ${style ?? 'solid'} ${color ?? keptColor}`,
|
|
17527
|
+
f,
|
|
17528
|
+
),
|
|
17529
|
+
]);
|
|
15981
17530
|
return {text: `the border${where}`, options: opts};
|
|
15982
17531
|
}
|
|
15983
17532
|
// One mode on a part that draws no line now: a border would take
|
|
@@ -16409,8 +17958,24 @@ export function draftAnswer(ctx, env, question) {
|
|
|
16409
17958
|
)?.[0];
|
|
16410
17959
|
// A step ("bolder", "a bit lighter") moves one rung from the
|
|
16411
17960
|
// headings rung the theme sets, never back to a fixed one.
|
|
16412
|
-
|
|
17961
|
+
// ("a bit lighter" with no rung set: one rung from the rung the
|
|
17962
|
+
// theme's headings show now.)
|
|
17963
|
+
const aBit = /\b(?:a bit|slightly|a little|a touch|somewhat)\b/.test(
|
|
17964
|
+
c.text,
|
|
17965
|
+
);
|
|
16413
17966
|
const rungs = Object.keys(HEADING_WEIGHTS);
|
|
17967
|
+
const ownRung =
|
|
17968
|
+
ownDial('headings') ??
|
|
17969
|
+
(aBit
|
|
17970
|
+
? rungs.find(
|
|
17971
|
+
r =>
|
|
17972
|
+
String(
|
|
17973
|
+
HEADING_WEIGHTS[
|
|
17974
|
+
/** @type {keyof typeof HEADING_WEIGHTS} */ (r)
|
|
17975
|
+
],
|
|
17976
|
+
) === String(current('--text-heading-1-weight') ?? ''),
|
|
17977
|
+
)
|
|
17978
|
+
: undefined);
|
|
16414
17979
|
const stepAsk =
|
|
16415
17980
|
!typedW &&
|
|
16416
17981
|
!c.neg &&
|
|
@@ -16454,7 +18019,12 @@ export function draftAnswer(ctx, env, question) {
|
|
|
16454
18019
|
if (innerWeight.length)
|
|
16455
18020
|
return {
|
|
16456
18021
|
text: `${rung ?? value} text${where}: ${innerWeight.join(' and ')} on ${on}, which the text inside it reads for its weight`,
|
|
16457
|
-
|
|
18022
|
+
// (On the status or variant asked, "the error banner's text".)
|
|
18023
|
+
options: [
|
|
18024
|
+
innerWeight.map(tok =>
|
|
18025
|
+
set(tok, value, {on, ...(f.when ? {when: f.when} : {})}),
|
|
18026
|
+
),
|
|
18027
|
+
],
|
|
16458
18028
|
sequence: innerWeight.length > 1,
|
|
16459
18029
|
};
|
|
16460
18030
|
return {
|
|
@@ -16482,8 +18052,11 @@ export function draftAnswer(ctx, env, question) {
|
|
|
16482
18052
|
[
|
|
16483
18053
|
set(
|
|
16484
18054
|
'font-family',
|
|
16485
|
-
// A stack given with the family ("Inter, sans-serif") whole
|
|
16486
|
-
|
|
18055
|
+
// A stack given with the family ("Inter, sans-serif") whole;
|
|
18056
|
+
// else a preset's whole stack, so a system without its first
|
|
18057
|
+
// family (ui-monospace is only on Apple systems) shows the
|
|
18058
|
+
// next one of its kind.
|
|
18059
|
+
(g => (g ? `${family}, ${g[1]}` : presetStack(font)))(
|
|
16487
18060
|
/,\s*(serif|sans-serif|monospace|system-ui|cursive)\b/.exec(
|
|
16488
18061
|
c.text,
|
|
16489
18062
|
),
|
|
@@ -17317,11 +18890,61 @@ export function draftAnswer(ctx, env, question) {
|
|
|
17317
18890
|
),
|
|
17318
18891
|
);
|
|
17319
18892
|
// (A height is never below zero.)
|
|
17320
|
-
|
|
18893
|
+
// (One size named, "the medium buttons 36px tall": that size's own
|
|
18894
|
+
// control height, on the part, never one height on every size.)
|
|
18895
|
+
{
|
|
18896
|
+
const sz = /^size:([\w-]+)$/.exec(String(f.when ?? ''))?.[1];
|
|
18897
|
+
const px = tall ? lengthPx(tall) : null;
|
|
18898
|
+
if (sz && px != null && px >= 0 && !f.state) {
|
|
18899
|
+
const sized = sizeSteps(on, 0, px, sz);
|
|
18900
|
+
if (sized?.steps.length)
|
|
18901
|
+
return {
|
|
18902
|
+
text: `the height${where}: ${sized.toks.join(', ')} ${tall}, the control height its ${sz} size reads, on ${on} only`,
|
|
18903
|
+
options: [sized.steps],
|
|
18904
|
+
};
|
|
18905
|
+
return {
|
|
18906
|
+
text: `${on}'s ${sz} size reads no control height the editor knows: nothing is written; give a height, such as min-height ${tall} --on ${on} --when size:${sz}`,
|
|
18907
|
+
options: [],
|
|
18908
|
+
};
|
|
18909
|
+
}
|
|
18910
|
+
}
|
|
18911
|
+
if (tall && /^-/.test(tall))
|
|
17321
18912
|
return {
|
|
17322
18913
|
text: `a height cannot be ${tall}: give a height of 0 or more, or say shorter by an amount`,
|
|
17323
18914
|
options: [],
|
|
17324
18915
|
};
|
|
18916
|
+
// (A group with a member sized by rows, the inputs: a minimum never
|
|
18917
|
+
// makes them shorter, so the control height they read is set on
|
|
18918
|
+
// the group, the main size at the height asked, each other size by
|
|
18919
|
+
// the same amount; the text area keeps its rows.)
|
|
18920
|
+
if (tall && rowsSized && FAMILIES[on] && !f.state && !f.when) {
|
|
18921
|
+
const px = lengthPx(tall);
|
|
18922
|
+
const sized = px != null ? sizeSteps(on, 0, px) : null;
|
|
18923
|
+
if (sized?.steps.length)
|
|
18924
|
+
return {
|
|
18925
|
+
text: `the height${where}: ${tall} for its main size, each control height it reads (${sized.toks.join(', ')}) moved by the same amount, on ${on} only (${(FAMILIES[on] ?? []).filter(m => !(C.partReads(m, 'size') ?? []).some(r => /^--size-/.test(r.token))).join(', ')} take their height from their content or rows)`,
|
|
18926
|
+
options: [sized.steps],
|
|
18927
|
+
sequence: sized.steps.length > 1,
|
|
18928
|
+
};
|
|
18929
|
+
}
|
|
18930
|
+
// (One size named with a way, "the small buttons taller": that
|
|
18931
|
+
// size's control height one step, 4px, on the part.)
|
|
18932
|
+
{
|
|
18933
|
+
const sz = /^size:([\w-]+)$/.exec(String(f.when ?? ''))?.[1];
|
|
18934
|
+
if (sz && !tall && !f.state && /\b(taller|shorter)\b/.test(c.text)) {
|
|
18935
|
+
const down = /\bshorter\b/.test(c.text);
|
|
18936
|
+
const sized = sizeSteps(on, down ? -4 : 4, undefined, sz);
|
|
18937
|
+
return sized?.steps.length
|
|
18938
|
+
? {
|
|
18939
|
+
text: `the ${sz} ${on} ${down ? 'shorter' : 'taller'}: ${sized.toks.join(', ')} ${down ? 'down' : 'up'} 4px (one step), on ${on} only`,
|
|
18940
|
+
options: [sized.steps],
|
|
18941
|
+
}
|
|
18942
|
+
: {
|
|
18943
|
+
text: `${on}'s ${sz} size reads no control height the editor knows: nothing is written`,
|
|
18944
|
+
options: [],
|
|
18945
|
+
};
|
|
18946
|
+
}
|
|
18947
|
+
}
|
|
17325
18948
|
if (tall)
|
|
17326
18949
|
return {
|
|
17327
18950
|
text: `the height${where}: min-height ${tall}${rowsSized && FAMILIES[on] ? ` (never one fixed height: ${(FAMILIES[on] ?? []).filter(m => !(C.partReads(m, 'size') ?? []).some(r => /^--size-/.test(r.token))).join(', ')} take their height from their content or rows)` : ''}`,
|
|
@@ -17498,14 +19121,14 @@ export function draftAnswer(ctx, env, question) {
|
|
|
17498
19121
|
// token (--color-text-accent) is that token, never a color to give
|
|
17499
19122
|
// the main text.
|
|
17500
19123
|
const roleWord = /\b([a-z]+) (?:text|labels?)\b/.exec(c.text)?.[1];
|
|
17501
|
-
// (Not a color word, "gray text #555", which gives the color
|
|
19124
|
+
// (Not a color word, "gray text #555", which gives the color; a
|
|
19125
|
+
// role named with the value it takes, "the accent text #0033aa",
|
|
19126
|
+
// is that role's token.)
|
|
17502
19127
|
const roleTok =
|
|
17503
19128
|
roleWord &&
|
|
17504
19129
|
Object.hasOwn(TOKENS, `--color-text-${roleWord}`) &&
|
|
17505
19130
|
!Object.hasOwn(HUES, roleWord) &&
|
|
17506
|
-
!parseColor(roleWord)
|
|
17507
|
-
!colorsIn(c.text.replace(new RegExp(`\\b${roleWord}\\b`, 'g'), ' '))
|
|
17508
|
-
.length
|
|
19131
|
+
!parseColor(roleWord)
|
|
17509
19132
|
? `--color-text-${roleWord}`
|
|
17510
19133
|
: null;
|
|
17511
19134
|
// "the text 4.5:1 against the page", "links 4.5:1 contrast": the
|
|
@@ -17566,44 +19189,62 @@ export function draftAnswer(ctx, env, question) {
|
|
|
17566
19189
|
);
|
|
17567
19190
|
/** @type {string[]} */
|
|
17568
19191
|
const missed = [];
|
|
17569
|
-
|
|
17570
|
-
|
|
17571
|
-
|
|
17572
|
-
|
|
17573
|
-
|
|
17574
|
-
|
|
17575
|
-
|
|
17576
|
-
|
|
17577
|
-
|
|
17578
|
-
|
|
17579
|
-
|
|
17580
|
-
|
|
17581
|
-
|
|
17582
|
-
|
|
17583
|
-
|
|
17584
|
-
|
|
17585
|
-
|
|
17586
|
-
|
|
17587
|
-
|
|
17588
|
-
|
|
17589
|
-
|
|
17590
|
-
|
|
17591
|
-
|
|
17592
|
-
|
|
17593
|
-
|
|
17594
|
-
|
|
17595
|
-
|
|
19192
|
+
// ("all text at least 7:1": every text color of the theme, the
|
|
19193
|
+
// main, the secondary and the accent text, each measured.)
|
|
19194
|
+
const everyText =
|
|
19195
|
+
!on &&
|
|
19196
|
+
!roleTok &&
|
|
19197
|
+
/\b(?:all|every|each)\s+(?:the\s+|of\s+the\s+)?text\b|\btext\s+everywhere\b/.test(
|
|
19198
|
+
c.text,
|
|
19199
|
+
);
|
|
19200
|
+
const reads = everyText
|
|
19201
|
+
? [
|
|
19202
|
+
'--color-text-primary',
|
|
19203
|
+
'--color-text-secondary',
|
|
19204
|
+
'--color-text-accent',
|
|
19205
|
+
]
|
|
19206
|
+
: [read];
|
|
19207
|
+
const steps = reads.flatMap(rd =>
|
|
19208
|
+
perMode(
|
|
19209
|
+
rd,
|
|
19210
|
+
everyText ? rd : thing,
|
|
19211
|
+
flags,
|
|
19212
|
+
(now, m) => {
|
|
19213
|
+
const grounds = groundTokens.map(g => String(current(g, m)));
|
|
19214
|
+
const ink = parseColor(now);
|
|
19215
|
+
const meets =
|
|
19216
|
+
ink &&
|
|
19217
|
+
grounds.every(g => {
|
|
19218
|
+
const under = parseColor(g);
|
|
19219
|
+
return (
|
|
19220
|
+
under &&
|
|
19221
|
+
ratio(
|
|
19222
|
+
/** @type {[number, number, number]} */ (
|
|
19223
|
+
compositeOver(ink, alphaOf(now), under)
|
|
19224
|
+
),
|
|
19225
|
+
under,
|
|
19226
|
+
) >= target
|
|
19227
|
+
);
|
|
19228
|
+
});
|
|
19229
|
+
if (meets) return null;
|
|
19230
|
+
const v = inkAtRatio(now, grounds, target);
|
|
19231
|
+
if (!v) missed.push(m);
|
|
19232
|
+
return v;
|
|
19233
|
+
},
|
|
19234
|
+
c,
|
|
19235
|
+
),
|
|
17596
19236
|
);
|
|
17597
19237
|
const against = groundTokens.join(' and ');
|
|
19238
|
+
const readSaid = reads.join(', ');
|
|
17598
19239
|
if (missed.length)
|
|
17599
19240
|
return {
|
|
17600
|
-
text: `no text color made from the one the text${where} reads (${
|
|
19241
|
+
text: `no text color made from the one the text${where} reads (${readSaid}) measures ${target}:1 against ${against} in ${[...new Set(missed)].join(' and ')} mode; name a color instead ("${on ?? 'text'} color #595959")`,
|
|
17601
19242
|
options: [],
|
|
17602
19243
|
};
|
|
17603
19244
|
return {
|
|
17604
19245
|
text: steps.length
|
|
17605
|
-
? `the text${where}: ${
|
|
17606
|
-
: `the text${where} (${
|
|
19246
|
+
? `the text${where}: ${readSaid} moved the least that measures ${target}:1 against ${against}${on === 'link' ? ' (the token a link reads; it also colors other accent text)' : ''}${modesSaid(steps)}${everyText ? '; the text a part draws on its own fill (a button or badge label) is measured on that fill: name the part ("button text 7:1")' : ''}`
|
|
19247
|
+
: `the text${where} (${readSaid}) already measures ${target}:1 against ${against}: nothing to change${everyText ? '; the text a part draws on its own fill (a button or badge label) is measured on that fill: name the part ("button text 7:1")' : ''}`,
|
|
17607
19248
|
options: steps.length ? [steps] : [],
|
|
17608
19249
|
sequence: steps.length > 1,
|
|
17609
19250
|
};
|
|
@@ -17652,6 +19293,32 @@ export function draftAnswer(ctx, env, question) {
|
|
|
17652
19293
|
(/\bsecondary\b/.test(c.text)
|
|
17653
19294
|
? '--color-text-secondary'
|
|
17654
19295
|
: '--color-text-primary');
|
|
19296
|
+
// "never use pure black for button text": a prohibition on a
|
|
19297
|
+
// part's text moves each variant off that color where it is that
|
|
19298
|
+
// color, never writes it.
|
|
19299
|
+
if (on && c.neg && color && /\btext\b/.test(c.text)) {
|
|
19300
|
+
const avoid = parseColor(color);
|
|
19301
|
+
const off = (/** @type {string} */ now) => {
|
|
19302
|
+
const n = parseColor(now);
|
|
19303
|
+
if (!avoid || !n || n.some((x, i) => Math.abs(x - avoid[i]) > 2))
|
|
19304
|
+
return null;
|
|
19305
|
+
return nearOff(avoid);
|
|
19306
|
+
};
|
|
19307
|
+
const own = restRead(C.partReads(one(on), 'text'), f.when);
|
|
19308
|
+
const steps =
|
|
19309
|
+
byVariant(on, 'text', 'color', 'color', f, off, c) ??
|
|
19310
|
+
(own ? perMode(own, 'color', f, off, c) : []);
|
|
19311
|
+
return steps.length
|
|
19312
|
+
? {
|
|
19313
|
+
text: `text color${where}, off ${color} where it is ${color}${modesSaid(steps)}`,
|
|
19314
|
+
options: [steps],
|
|
19315
|
+
sequence: steps.length > 1,
|
|
19316
|
+
}
|
|
19317
|
+
: {
|
|
19318
|
+
text: `the text${where} is not ${color} in any variant or mode, so nothing changes`,
|
|
19319
|
+
options: [],
|
|
19320
|
+
};
|
|
19321
|
+
}
|
|
17655
19322
|
if (!on) {
|
|
17656
19323
|
const label = `${tok === '--color-text-secondary' ? 'secondary' : tok === '--color-text-primary' ? 'main' : (roleWord ?? 'main')} text color: ${tok}`;
|
|
17657
19324
|
// "never use pure black": where the token is that color, a near
|
|
@@ -17700,11 +19367,11 @@ export function draftAnswer(ctx, env, question) {
|
|
|
17700
19367
|
!c.mode &&
|
|
17701
19368
|
modal &&
|
|
17702
19369
|
readable.length === 1 &&
|
|
17703
|
-
// Asked for every mode
|
|
19370
|
+
// Asked for every mode: as asked. (With its own page color,
|
|
19371
|
+
// which goes to the mode it suits, the text follows it there.)
|
|
17704
19372
|
!/\b(everywhere|both modes|all modes|always|in every mode)\b/.test(
|
|
17705
19373
|
q,
|
|
17706
|
-
)
|
|
17707
|
-
!/\b(bg|background|page)\b/.test(q)
|
|
19374
|
+
)
|
|
17708
19375
|
)
|
|
17709
19376
|
return {
|
|
17710
19377
|
text: `${label} in ${readable[0]} mode only: on the ${readable[0] === 'light' ? 'dark' : 'light'} page ${color} would not be readable`,
|
|
@@ -17788,11 +19455,38 @@ export function draftAnswer(ctx, env, question) {
|
|
|
17788
19455
|
[set('--color-text-accent', color, {on: c.within, ...modeOf(c)})],
|
|
17789
19456
|
],
|
|
17790
19457
|
};
|
|
17791
|
-
if (on === 'link' && color)
|
|
19458
|
+
if (on === 'link' && color) {
|
|
19459
|
+
// (A link color one mode's page would make unreadable, a dark
|
|
19460
|
+
// blue on the dark page under 2:1, is set for the other mode
|
|
19461
|
+
// only, as the text color is; said.)
|
|
19462
|
+
const rgb = parseColor(color);
|
|
19463
|
+
const readable = /** @type {Array<'light' | 'dark'>} */ ([
|
|
19464
|
+
'light',
|
|
19465
|
+
'dark',
|
|
19466
|
+
]).filter(m => {
|
|
19467
|
+
const page = parseColor(current('--color-background-body', m));
|
|
19468
|
+
return !rgb || !page || ratio(rgb, page) >= 2;
|
|
19469
|
+
});
|
|
19470
|
+
const oneMode =
|
|
19471
|
+
!c.mode &&
|
|
19472
|
+
modal &&
|
|
19473
|
+
readable.length === 1 &&
|
|
19474
|
+
!/\b(?:both|all)\s+modes\b|\beverywhere\b/i.test(question)
|
|
19475
|
+
? readable[0]
|
|
19476
|
+
: null;
|
|
17792
19477
|
return {
|
|
17793
|
-
text: `the link color: --color-text-accent, the token a link reads (it also colors other accent text)${f.state ? `; a link has no color of its own for ${f.state}, so this changes it in every state` : ''}`,
|
|
17794
|
-
options: [
|
|
19478
|
+
text: `the link color: --color-text-accent, the token a link reads (it also colors other accent text)${oneMode ? ` in ${oneMode} mode only: on the ${oneMode === 'light' ? 'dark' : 'light'} page ${color} would not be readable` : ''}${f.state ? `; a link has no color of its own for ${f.state}, so this changes it in every state` : ''}`,
|
|
19479
|
+
options: [
|
|
19480
|
+
[
|
|
19481
|
+
set(
|
|
19482
|
+
'--color-text-accent',
|
|
19483
|
+
color,
|
|
19484
|
+
oneMode ? {mode: oneMode} : modeOf(c),
|
|
19485
|
+
),
|
|
19486
|
+
],
|
|
19487
|
+
],
|
|
17795
19488
|
};
|
|
19489
|
+
}
|
|
17796
19490
|
// "card text lighter", "a bit darker": from the text color the part
|
|
17797
19491
|
// shows now (its own, else the token it reads at rest).
|
|
17798
19492
|
if (!color && c.dir && /\b(light|dark)(er)?\b/.test(c.text)) {
|
|
@@ -17924,9 +19618,18 @@ export function draftAnswer(ctx, env, question) {
|
|
|
17924
19618
|
// A title block (a dialog's): its title and subtitle set their own
|
|
17925
19619
|
// color from the text tokens, so the tokens go on the block.
|
|
17926
19620
|
if (/-title-block$/.test(one(on)) && !f.state && !f.when) {
|
|
17927
|
-
|
|
19621
|
+
// (The title alone when the words name it, its subtitle alone
|
|
19622
|
+
// when they name that; both for the block's text.)
|
|
19623
|
+
const sub = /\b(?:sub-?titles?|descriptions?)\b/.test(c.text);
|
|
19624
|
+
const title = /\b(?:titles?|headings?)\b/.test(c.text);
|
|
19625
|
+
const toks =
|
|
19626
|
+
title && !sub
|
|
19627
|
+
? ['--color-text-primary']
|
|
19628
|
+
: sub && !title
|
|
19629
|
+
? ['--color-text-secondary']
|
|
19630
|
+
: ['--color-text-primary', '--color-text-secondary'];
|
|
17928
19631
|
return {
|
|
17929
|
-
text: `text color${where}: ${toks.join(' and ')} on ${on}, the text color tokens its title and subtitle read`,
|
|
19632
|
+
text: `text color${where}: ${toks.join(' and ')} on ${on}, ${toks.length > 1 ? 'the text color tokens its title and subtitle read' : `the token its ${toks[0] === '--color-text-primary' ? 'title' : 'subtitle'} reads`}`,
|
|
17930
19633
|
options: [toks.map(tok => set(tok, color, {on, ...modeOf(c)}))],
|
|
17931
19634
|
sequence: true,
|
|
17932
19635
|
};
|
|
@@ -18226,11 +19929,21 @@ export function draftAnswer(ctx, env, question) {
|
|
|
18226
19929
|
}
|
|
18227
19930
|
if (!on) {
|
|
18228
19931
|
const color = colorFor(c, 'fill');
|
|
18229
|
-
if (color)
|
|
19932
|
+
if (color) {
|
|
19933
|
+
const pageMode = pageModeOf(c, color);
|
|
18230
19934
|
return {
|
|
18231
|
-
text: `the page background: --color-background-body${c
|
|
18232
|
-
options: [
|
|
19935
|
+
text: `the page background: --color-background-body${pageModeSaid(c, pageMode)}`,
|
|
19936
|
+
options: [
|
|
19937
|
+
[
|
|
19938
|
+
set(
|
|
19939
|
+
'--color-background-body',
|
|
19940
|
+
color,
|
|
19941
|
+
pageMode ? {mode: pageMode} : {},
|
|
19942
|
+
),
|
|
19943
|
+
],
|
|
19944
|
+
],
|
|
18233
19945
|
};
|
|
19946
|
+
}
|
|
18234
19947
|
const temp = /\b(warm(er)?|cool(er)?)\b/.exec(c.text)?.[1];
|
|
18235
19948
|
if (temp) {
|
|
18236
19949
|
const way = /^warm/.test(temp) ? 'warm' : 'cool';
|
|
@@ -18362,6 +20075,32 @@ export function draftAnswer(ctx, env, question) {
|
|
|
18362
20075
|
],
|
|
18363
20076
|
sequence: true,
|
|
18364
20077
|
};
|
|
20078
|
+
// "make the error toast calmer": the fill it shows, less saturated,
|
|
20079
|
+
// in each mode from its own value.
|
|
20080
|
+
if (!color && CALMER.test(c.text)) {
|
|
20081
|
+
const reads = C.partReads(one(on), 'background');
|
|
20082
|
+
const read = C.MAP[one(on)]
|
|
20083
|
+
? (restRead(reads, f.when) ??
|
|
20084
|
+
(FAMILIES.containers.includes(one(on))
|
|
20085
|
+
? '--color-background-card'
|
|
20086
|
+
: null))
|
|
20087
|
+
: null;
|
|
20088
|
+
const steps = read
|
|
20089
|
+
? perMode(
|
|
20090
|
+
read,
|
|
20091
|
+
'background',
|
|
20092
|
+
f,
|
|
20093
|
+
now => calmShift(now, colorAmount(c.text, 0.4)),
|
|
20094
|
+
c,
|
|
20095
|
+
)
|
|
20096
|
+
: [];
|
|
20097
|
+
if (steps.length)
|
|
20098
|
+
return {
|
|
20099
|
+
text: `a calmer background${where}, from ${read}: less saturated, at the same lightness${modesSaid(steps)}`,
|
|
20100
|
+
options: [steps],
|
|
20101
|
+
sequence: steps.length > 1,
|
|
20102
|
+
};
|
|
20103
|
+
}
|
|
18365
20104
|
if (!color && c.dir) {
|
|
18366
20105
|
const lighter = /\blight(er)?\b/.test(noMode(c.text));
|
|
18367
20106
|
const reads = C.partReads(one(on), 'background');
|
|
@@ -18753,6 +20492,15 @@ export function draftAnswer(ctx, env, question) {
|
|
|
18753
20492
|
sequence: steps.length > 1,
|
|
18754
20493
|
};
|
|
18755
20494
|
}
|
|
20495
|
+
// "a right-to-left app for Arabic": Core mirrors itself when the app
|
|
20496
|
+
// sets dir="rtl"; the theme has nothing to change.
|
|
20497
|
+
if (
|
|
20498
|
+
/\b(?:rtl|right[- ]to[- ]left|arabic|hebrew|persian|farsi|urdu)\b/.test(t)
|
|
20499
|
+
)
|
|
20500
|
+
return {
|
|
20501
|
+
text: 'right to left: Core mirrors its layout itself when the app sets dir="rtl" on its <html> element (or on any container), so the theme needs no change; nothing is written',
|
|
20502
|
+
options: [],
|
|
20503
|
+
};
|
|
18756
20504
|
if (/\b(apply|use|want|make it) (a )?dark (theme|look|ui)\b/.test(t))
|
|
18757
20505
|
return {
|
|
18758
20506
|
text:
|
|
@@ -18785,17 +20533,42 @@ export function draftAnswer(ctx, env, question) {
|
|
|
18785
20533
|
// accent darker in dark mode only" scopes an accent ask, never the
|
|
18786
20534
|
// theme's mode. (A lead before a colon, "like Linear:", is a
|
|
18787
20535
|
// reference.)
|
|
18788
|
-
|
|
18789
|
-
|
|
18790
|
-
|
|
18791
|
-
|
|
18792
|
-
|
|
18793
|
-
|
|
18794
|
-
|
|
18795
|
-
|
|
20536
|
+
// (A theme said to be dark among other words of a look, "a calm dark
|
|
20537
|
+
// theme", is still the mode; the other words are named apart.)
|
|
20538
|
+
const onlyModes =
|
|
20539
|
+
/\b(?:dark|light)-only (?:theme|look|ui|interface|design)\b/.test(t) ||
|
|
20540
|
+
!noMode(t.replace(/^[^:]*:\s*/, ''))
|
|
20541
|
+
.replace(/\bdark\b|\blight\b/g, ' ')
|
|
20542
|
+
.replace(
|
|
20543
|
+
/\b(support|supports|add|enable|want|need|needs|give|turn on|make|it|the|a|an|my|our|this|theme|app|site|please|to|also|too|with|have|has|i|we|only|both|mode|modes|by|default|defaults|always|switch|go|use|just|be|is|should|set|no|without)\b/g,
|
|
20544
|
+
' ',
|
|
20545
|
+
)
|
|
20546
|
+
.replace(/[^a-z]+/g, ' ')
|
|
20547
|
+
.trim();
|
|
20548
|
+
// "the app opens in dark mode by default": the mode the app shows
|
|
20549
|
+
// first is set where it renders the theme; the theme keeps both.
|
|
20550
|
+
if (
|
|
20551
|
+
/\b(?:opens?|starts?|launch(?:es)?|loads?|boots?)\s+(?:up\s+)?in\s+(dark|light)(?:\s+mode)?\b|\b(dark|light)(?:\s+mode)?\s+by\s+default\b|\bdefaults?\s+to\s+(dark|light)\b/.test(
|
|
20552
|
+
t,
|
|
20553
|
+
) &&
|
|
20554
|
+
!c.parts.length &&
|
|
20555
|
+
!c.colors.length
|
|
20556
|
+
) {
|
|
20557
|
+
const w =
|
|
20558
|
+
/\b(dark|light)\b/.exec(
|
|
20559
|
+
t.replace(
|
|
20560
|
+
/^.*?\b(?=(?:opens?|starts?|launch|loads?|boots?|dark|light|defaults?)\b)/,
|
|
20561
|
+
'',
|
|
20562
|
+
),
|
|
20563
|
+
)?.[1] ?? 'dark';
|
|
20564
|
+
return {
|
|
20565
|
+
text: `the mode the app shows first is set where it renders the theme: <Theme mode="${w}"> (its default, "system", follows the device), and the theme keeps both modes for the switch; for a theme that is only ever ${w}, the line below: mode ${w}-only`,
|
|
20566
|
+
options: [[set('mode', `${w}-only`)]],
|
|
20567
|
+
};
|
|
20568
|
+
}
|
|
18796
20569
|
if (
|
|
18797
20570
|
onlyModes &&
|
|
18798
|
-
/\bdark[- ]?(mode|theme)? only\b|\bonly dark\b|\bdark-only\b|\bdark by default\b|\bdefault(s)? to dark\b|\balways dark\b/.test(
|
|
20571
|
+
/\bdark[- ]?(mode|theme)? only\b|\bonly dark\b|\bdark-only\b|\bdark by default\b|\bdefault(s)? to dark\b|\balways dark\b|\b(?:no|without (?:a )?)light mode\b/.test(
|
|
18799
20572
|
t,
|
|
18800
20573
|
) &&
|
|
18801
20574
|
// "in dark mode only, cards #111111": the mode scopes the other ask.
|
|
@@ -18817,7 +20590,7 @@ export function draftAnswer(ctx, env, question) {
|
|
|
18817
20590
|
};
|
|
18818
20591
|
if (
|
|
18819
20592
|
onlyModes &&
|
|
18820
|
-
/\blight[- ]?(mode|theme)? only\b|\bonly light\b|\blight-only\b/.test(
|
|
20593
|
+
/\blight[- ]?(mode|theme)? only\b|\bonly light\b|\blight-only\b|\b(?:no|without (?:a )?)dark mode\b/.test(
|
|
18821
20594
|
t,
|
|
18822
20595
|
) &&
|
|
18823
20596
|
// "light only" removes dark mode only when the ask is about the
|
|
@@ -18889,7 +20662,12 @@ export function draftAnswer(ctx, env, question) {
|
|
|
18889
20662
|
/\bless (desaturat\w*|muted|dull|washed|pastel|gr[ae]y\w*)\b/.test(t)
|
|
18890
20663
|
? false
|
|
18891
20664
|
: dim.test(t) || (/\bless\b/.test(t) && !/\bmore\b/.test(t));
|
|
18892
|
-
|
|
20665
|
+
// (A number said is the vibrancy itself: "vibrancy 0", grayscale.)
|
|
20666
|
+
const said = /\bvibrancy\s+(\d{1,3})\b/.exec(t)?.[1];
|
|
20667
|
+
const step = set(
|
|
20668
|
+
'vibrancy',
|
|
20669
|
+
said != null && Number(said) <= 100 ? said : less ? 'less' : 'more',
|
|
20670
|
+
);
|
|
18893
20671
|
const colored = (/** @type {string} */ v) => !isGraySeed(seedOf(v));
|
|
18894
20672
|
// A color dial counts when the step changes the shades made from it
|
|
18895
20673
|
// (a warm gray has a little hue to take out), as set measures it.
|
|
@@ -18913,6 +20691,20 @@ export function draftAnswer(ctx, env, question) {
|
|
|
18913
20691
|
mode: null,
|
|
18914
20692
|
saturation: less ? 'less' : 'more',
|
|
18915
20693
|
});
|
|
20694
|
+
if (hasColor && said != null) {
|
|
20695
|
+
const vibNow = Number(
|
|
20696
|
+
[...env.data.settings].reverse().find(x => x.thing === 'vibrancy')
|
|
20697
|
+
?.value ?? 50,
|
|
20698
|
+
);
|
|
20699
|
+
return {
|
|
20700
|
+
text: `${help}: vibrancy ${said}${Number(said) === 0 ? ', every generated color a gray' : ''}.`,
|
|
20701
|
+
options: [[step]],
|
|
20702
|
+
intent: {
|
|
20703
|
+
...vibIntent,
|
|
20704
|
+
saturation: Number(said) < vibNow ? 'less' : 'more',
|
|
20705
|
+
},
|
|
20706
|
+
};
|
|
20707
|
+
}
|
|
18916
20708
|
if (hasColor)
|
|
18917
20709
|
return {
|
|
18918
20710
|
text: `${help}; ${less ? 'less' : 'more'} steps it by 10.`,
|
|
@@ -18980,11 +20772,15 @@ export function draftAnswer(ctx, env, question) {
|
|
|
18980
20772
|
}
|
|
18981
20773
|
// No color to change, and none was asked for: never pick one.
|
|
18982
20774
|
return {
|
|
18983
|
-
text:
|
|
18984
|
-
|
|
18985
|
-
|
|
20775
|
+
text:
|
|
20776
|
+
less || (said != null && Number(said) === 0)
|
|
20777
|
+
? `${help}, and every color ${env.slug} has is a gray, so there is no color to take out.`
|
|
20778
|
+
: `${help}, and every color ${env.slug} has is a gray, so there is nothing to saturate yet. Set a color first: how accent shows how.`,
|
|
18986
20779
|
options: [],
|
|
18987
|
-
lookup:
|
|
20780
|
+
lookup:
|
|
20781
|
+
less || (said != null && Number(said) === 0)
|
|
20782
|
+
? `${HOW} colors`
|
|
20783
|
+
: `${HOW} accent`,
|
|
18988
20784
|
};
|
|
18989
20785
|
}
|
|
18990
20786
|
if (
|
|
@@ -19350,6 +21146,24 @@ export function draftAnswer(ctx, env, question) {
|
|
|
19350
21146
|
lookup: `${HOW} ${dial}`,
|
|
19351
21147
|
};
|
|
19352
21148
|
color = shift(seedNow, lighter ? 0.2 : -0.2);
|
|
21149
|
+
// ("darker so it reads on the page": on, step by step, until the
|
|
21150
|
+
// color stands 3:1 against the light page, as a mark must.)
|
|
21151
|
+
if (/\breadable\b/.test(c.text) && color && !lighter) {
|
|
21152
|
+
const page = parseColor(
|
|
21153
|
+
String(current('--color-background-body', 'light') ?? '#ffffff'),
|
|
21154
|
+
);
|
|
21155
|
+
let k = 0.2;
|
|
21156
|
+
while (
|
|
21157
|
+
page &&
|
|
21158
|
+
color &&
|
|
21159
|
+
parseColor(color) &&
|
|
21160
|
+
ratio(/** @type {number[]} */ (parseColor(color)), page) < 3 &&
|
|
21161
|
+
k < 0.9
|
|
21162
|
+
) {
|
|
21163
|
+
k += 0.1;
|
|
21164
|
+
color = shift(seedNow, -k);
|
|
21165
|
+
}
|
|
21166
|
+
}
|
|
19353
21167
|
// The dark half the editor generates from that seed can move the
|
|
19354
21168
|
// other way; the dark token is stepped the asked way from its own
|
|
19355
21169
|
// value, in the same answer.
|
|
@@ -19389,7 +21203,7 @@ export function draftAnswer(ctx, env, question) {
|
|
|
19389
21203
|
)
|
|
19390
21204
|
: color;
|
|
19391
21205
|
return {
|
|
19392
|
-
text: `${dial}: the editor makes its light and dark shades from ${color}${darkStep ? `, and the dark ${token} steps from its own value the same way` : ''}`,
|
|
21206
|
+
text: `${dial}: the editor makes its light and dark shades from ${color}${darkStep ? `, and the dark ${token} steps from its own value the same way` : `; or, the second line, only ${token} itself${tokenAlpha < 1 ? `, kept at its own ${Math.round(tokenAlpha * 100)}% strength (a wash)` : ''}, leaving the other ${dial} shades as they are`}`,
|
|
19393
21207
|
options: darkStep
|
|
19394
21208
|
? [[set(dial, color), darkStep]]
|
|
19395
21209
|
: [[set(dial, color)], [set(token, exactToken)]],
|
|
@@ -19418,7 +21232,8 @@ export function draftAnswer(ctx, env, question) {
|
|
|
19418
21232
|
// how cannot name: said, never the whole theme or the part before.
|
|
19419
21233
|
// (Only a noun after a determiner: "the zorp", "from the blorp".)
|
|
19420
21234
|
const DET = String.raw`(?:the|my|our|all|every|each|its|their)\s+`;
|
|
19421
|
-
|
|
21235
|
+
// (A part's piece after it, "the card zorp title", holds the slot too.)
|
|
21236
|
+
const THING = String.raw`(?:padding|spacing|shadows?|borders?|corners?|radius|background|fill|text|font|colou?r|outline|gap|size|height|width|titles?|headings?|headers?|footers?)`;
|
|
19422
21237
|
// (Between a part and the thing changed, "the card zorp border": a
|
|
19423
21238
|
// word there that is no part, state, variant, aspect, color or known
|
|
19424
21239
|
// modifier is read nowhere, so the change is not guessed at.)
|
|
@@ -19529,30 +21344,6 @@ export function draftAnswer(ctx, env, question) {
|
|
|
19529
21344
|
return null;
|
|
19530
21345
|
}
|
|
19531
21346
|
|
|
19532
|
-
/**
|
|
19533
|
-
* Whether a later clause's own subject is the whole theme's: a role color
|
|
19534
|
-
* or a dial ("the accent darker", "the spacing tighter") or the theme's
|
|
19535
|
-
* text said as a subject ("the text bigger"); such a clause takes no part
|
|
19536
|
-
* from the clause before.
|
|
19537
|
-
* @param {Clause} c
|
|
19538
|
-
*/
|
|
19539
|
-
function themeSubject(c) {
|
|
19540
|
-
// (The subject alone, before its way or value: "accent text" and
|
|
19541
|
-
// "font-weight 500" name a part's own text color and weight.)
|
|
19542
|
-
const m = /^(?:the\s+|my\s+|our\s+)?([a-z]+)\b(?!-)(?:\s+([a-z-]+))?/.exec(
|
|
19543
|
-
c.text,
|
|
19544
|
-
);
|
|
19545
|
-
const subject = m?.[1] ?? '';
|
|
19546
|
-
const next = m?.[2] ?? '';
|
|
19547
|
-
const bare = !next || /^colou?r$/.test(next) || !aspectsOf(next).length;
|
|
19548
|
-
return (
|
|
19549
|
-
(bare && (ROLE_WORDS.test(subject) || Object.hasOwn(DIALS, subject))) ||
|
|
19550
|
-
// ("and the shadows softer", "and the corners rounder": the
|
|
19551
|
-
// theme's, said as their own subject.)
|
|
19552
|
-
/^the\s+(?:text|shadows|corners)\b(?!-)/.test(c.text)
|
|
19553
|
-
);
|
|
19554
|
-
}
|
|
19555
|
-
|
|
19556
21347
|
/** @param {string} text */
|
|
19557
21348
|
function unknownPart(text) {
|
|
19558
21349
|
const m =
|
|
@@ -19640,6 +21431,8 @@ export function draftAnswer(ctx, env, question) {
|
|
|
19640
21431
|
const last = new Map();
|
|
19641
21432
|
/** @type {Array<[Step, Step]>} */
|
|
19642
21433
|
const clashes = [];
|
|
21434
|
+
/** (A step toward a rung said beside the rung.) @type {Step[]} */
|
|
21435
|
+
const relDropped = [];
|
|
19643
21436
|
for (const {clause, steps} of tops)
|
|
19644
21437
|
for (const [k, st] of steps.entries()) {
|
|
19645
21438
|
// A step one clause repeats ("2 steps rounder": the dial stepped
|
|
@@ -19649,6 +21442,38 @@ export function draftAnswer(ctx, env, question) {
|
|
|
19649
21442
|
.filter(o => idOf(o) === idOf(st) && o.value === st.value).length;
|
|
19650
21443
|
const key = again ? `${idOf(st)}#${again}` : idOf(st);
|
|
19651
21444
|
const prior = last.get(key);
|
|
21445
|
+
// ("sharper corners, almost square": a step toward a rung and the
|
|
21446
|
+
// rung itself say one thing, the rung.)
|
|
21447
|
+
const rel = (/** @type {Step} */ x) =>
|
|
21448
|
+
/^(?:more|less)$/.test(String(x.value));
|
|
21449
|
+
// (A rung by name; a length said beside a step is an example. The
|
|
21450
|
+
// step goes the rung's way: "sharper … almost square", never
|
|
21451
|
+
// "rounder but square", which contradicts.)
|
|
21452
|
+
const rung = (/** @type {Step} */ x) => /^[a-z]+$/.test(String(x.value));
|
|
21453
|
+
const LOW = /^(?:square|small|tight|compact|light|thin|regular)$/;
|
|
21454
|
+
const HIGH = /^(?:large|round|pill|roomy|spacious|bold|heavy)$/;
|
|
21455
|
+
const sameWay = (/** @type {Step} */ r, /** @type {Step} */ a) =>
|
|
21456
|
+
(r.value === 'less' && LOW.test(String(a.value))) ||
|
|
21457
|
+
(r.value === 'more' && HIGH.test(String(a.value)));
|
|
21458
|
+
if (
|
|
21459
|
+
prior &&
|
|
21460
|
+
prior.clause !== clause &&
|
|
21461
|
+
!st.on &&
|
|
21462
|
+
rel(prior.step) !== rel(st) &&
|
|
21463
|
+
rung(prior.step) &&
|
|
21464
|
+
rung(st) &&
|
|
21465
|
+
(rel(st) ? sameWay(st, prior.step) : sameWay(prior.step, st)) &&
|
|
21466
|
+
(prior.clause.mode ?? '') === (clause.mode ?? '')
|
|
21467
|
+
) {
|
|
21468
|
+
relDropped.push(rel(st) ? st : prior.step);
|
|
21469
|
+
if (rel(st)) {
|
|
21470
|
+
steps.splice(k, 1, prior.step);
|
|
21471
|
+
continue;
|
|
21472
|
+
}
|
|
21473
|
+
last.delete(key);
|
|
21474
|
+
last.set(key, {step: st, clause});
|
|
21475
|
+
continue;
|
|
21476
|
+
}
|
|
19652
21477
|
if (
|
|
19653
21478
|
prior &&
|
|
19654
21479
|
prior.clause !== clause &&
|
|
@@ -20255,16 +22080,26 @@ export function draftAnswer(ctx, env, question) {
|
|
|
20255
22080
|
// "What color is the page / the header / the primary button": a part
|
|
20256
22081
|
// that is a surface (it paints, or holds other parts) is its fill; a part
|
|
20257
22082
|
// that is only text, or words that name the text, its text color.
|
|
22083
|
+
// (The part the question is about, as the clause reads it: "the card
|
|
22084
|
+
// title" is the heading inside the card, "the card's secondary text" the
|
|
22085
|
+
// card's text; else the first part named.)
|
|
22086
|
+
const clauseOwn = (() => {
|
|
22087
|
+
if (clauses.length !== 1) return null;
|
|
22088
|
+
const ps = clauses[0].parts.filter(x => x.on !== 'body');
|
|
22089
|
+
return ps.length === 1 && ps[0].on ? ps[0].on : null;
|
|
22090
|
+
})();
|
|
20258
22091
|
const asked = (() => {
|
|
20259
22092
|
const v = valueAsked(question);
|
|
20260
22093
|
if (v !== 'color' || /\btext\b/i.test(question)) return v;
|
|
20261
|
-
const first =
|
|
20262
|
-
|
|
20263
|
-
|
|
20264
|
-
|
|
20265
|
-
|
|
20266
|
-
|
|
20267
|
-
|
|
22094
|
+
const first =
|
|
22095
|
+
clauseOwn ??
|
|
22096
|
+
lex.parts
|
|
22097
|
+
.map(([re, x]) => ({
|
|
22098
|
+
at: re.exec(question.toLowerCase())?.index ?? -1,
|
|
22099
|
+
on: x.on,
|
|
22100
|
+
}))
|
|
22101
|
+
.filter(x => x.at >= 0)
|
|
22102
|
+
.sort((x, y) => x.at - y.at)[0]?.on;
|
|
20268
22103
|
if (!first || textOnlyPart(first)) return v;
|
|
20269
22104
|
const m = C.MAP[one(first)];
|
|
20270
22105
|
return !m || m.at?.['background-color'] || (m.contains ?? []).length
|
|
@@ -20308,15 +22143,19 @@ export function draftAnswer(ctx, env, question) {
|
|
|
20308
22143
|
if (asked) {
|
|
20309
22144
|
// ("the focus ring of inputs" asks about the inputs: the ring is what
|
|
20310
22145
|
// is asked, never the focus-ring part.)
|
|
20311
|
-
const named =
|
|
20312
|
-
|
|
20313
|
-
|
|
20314
|
-
|
|
20315
|
-
|
|
20316
|
-
|
|
20317
|
-
|
|
20318
|
-
|
|
20319
|
-
|
|
22146
|
+
const named =
|
|
22147
|
+
(clauseOwn && !(asked === 'focus-ring' && clauseOwn === 'focus-ring')
|
|
22148
|
+
? clauseOwn
|
|
22149
|
+
: null) ??
|
|
22150
|
+
lex.parts
|
|
22151
|
+
.map(([re, x]) => ({
|
|
22152
|
+
at: re.exec(question.toLowerCase())?.index ?? -1,
|
|
22153
|
+
on: x.on,
|
|
22154
|
+
}))
|
|
22155
|
+
.filter(
|
|
22156
|
+
x => x.at >= 0 && !(asked === 'focus-ring' && x.on === 'focus-ring'),
|
|
22157
|
+
)
|
|
22158
|
+
.sort((x, y) => x.at - y.at)[0]?.on;
|
|
20320
22159
|
// A token set on the part itself (or on its group), as the theme saves
|
|
20321
22160
|
// it, is what the part shows: "how thick are dividers" after
|
|
20322
22161
|
// `--border-width 3px --on divider` is 3px, never the theme's own.
|
|
@@ -20877,11 +22716,21 @@ export function draftAnswer(ctx, env, question) {
|
|
|
20877
22716
|
}
|
|
20878
22717
|
: asked === 'color' &&
|
|
20879
22718
|
/\b(?:text|writing|words)\b/.test(qWords)
|
|
20880
|
-
?
|
|
20881
|
-
|
|
20882
|
-
|
|
20883
|
-
|
|
20884
|
-
|
|
22719
|
+
? // (The secondary, muted or fainter
|
|
22720
|
+
// text is its own token.)
|
|
22721
|
+
/\b(?:secondary|muted|faint|fainter|subtle|subdued)\s+(?:text|labels?|copy)\b/.test(
|
|
22722
|
+
qWords,
|
|
22723
|
+
)
|
|
22724
|
+
? {
|
|
22725
|
+
token: '--color-text-secondary',
|
|
22726
|
+
what: 'the secondary text color',
|
|
22727
|
+
example: 'secondary text #4b5563',
|
|
22728
|
+
}
|
|
22729
|
+
: {
|
|
22730
|
+
token: '--color-text-primary',
|
|
22731
|
+
what: 'the main text color',
|
|
22732
|
+
example: 'text #111827',
|
|
22733
|
+
}
|
|
20885
22734
|
: null;
|
|
20886
22735
|
if (themeAsk?.tokens && !unshown) {
|
|
20887
22736
|
const listed = themeAsk.tokens
|
|
@@ -20921,6 +22770,30 @@ export function draftAnswer(ctx, env, question) {
|
|
|
20921
22770
|
// (A value the theme set on the part itself is what it has now, before
|
|
20922
22771
|
// any token or variant it reads: "how round are the cards now?" after
|
|
20923
22772
|
// a card radius of 20px is 20px.)
|
|
22773
|
+
// ("what color is the card's secondary text?": the secondary text
|
|
22774
|
+
// token the part's text reads, set on it or the theme's.)
|
|
22775
|
+
const secondaryNow = () => {
|
|
22776
|
+
if (
|
|
22777
|
+
asked !== 'color' ||
|
|
22778
|
+
!/\b(?:secondary|muted|faint|fainter|subtle|subdued)\s+(?:text|labels?|copy)\b/i.test(
|
|
22779
|
+
question,
|
|
22780
|
+
)
|
|
22781
|
+
)
|
|
22782
|
+
return null;
|
|
22783
|
+
const tok = '--color-text-secondary';
|
|
22784
|
+
const shown = (/** @type {'light' | 'dark'} */ m) =>
|
|
22785
|
+
partNow(tok, m) ?? null;
|
|
22786
|
+
const l = shown('light');
|
|
22787
|
+
const d = shown('dark');
|
|
22788
|
+
if (!l && !d) return null;
|
|
22789
|
+
const said =
|
|
22790
|
+
qMode || readMode
|
|
22791
|
+
? shown(/** @type {'light' | 'dark'} */ (qMode ?? readMode))
|
|
22792
|
+
: l === d || !d
|
|
22793
|
+
? l
|
|
22794
|
+
: `${l} in light mode, ${d} in dark mode`;
|
|
22795
|
+
return `${said}${qModeSaid} (${tok}, its secondary text)`;
|
|
22796
|
+
};
|
|
20924
22797
|
const ownNow = () => {
|
|
20925
22798
|
if (!named || stateWord || vWord) return null;
|
|
20926
22799
|
const v = partValue(named, asked);
|
|
@@ -20929,6 +22802,7 @@ export function draftAnswer(ctx, env, question) {
|
|
|
20929
22802
|
const now =
|
|
20930
22803
|
named && !unshown
|
|
20931
22804
|
? (pageNow() ??
|
|
22805
|
+
secondaryNow() ??
|
|
20932
22806
|
ringNow() ??
|
|
20933
22807
|
ownNow() ??
|
|
20934
22808
|
conditionNow() ??
|
|
@@ -20973,8 +22847,333 @@ export function draftAnswer(ctx, env, question) {
|
|
|
20973
22847
|
});
|
|
20974
22848
|
return {parts: partsSeen, aspects: aspectsSeen, drafts: result};
|
|
20975
22849
|
}
|
|
22850
|
+
// The light/dark color rule (the mode half of the clause-scope reader):
|
|
22851
|
+
// on a theme that draws both modes, a color one mode cannot carry is not
|
|
22852
|
+
// written to it. A clearly light fill on a part whose dark-mode text
|
|
22853
|
+
// would not read on it ("white cards", "secondary buttons: background
|
|
22854
|
+
// #f6f8fa", "the info banner subtle gray") is the light mode's; a
|
|
22855
|
+
// clearly dark fill on a panel that sits on the page ("cards #0f1011")
|
|
22856
|
+
// the dark mode's, its own text with it; a clearly light border or line
|
|
22857
|
+
// color ("cards: 1px border #e5e7eb", "borders #e3e8ee") the light
|
|
22858
|
+
// mode's. Said, with the other mode's line. A color word said for the
|
|
22859
|
+
// one mode it cannot carry ("subtle gray in dark mode") is that hue's
|
|
22860
|
+
// tone for the mode. A one-mode theme, or an ask that says both modes,
|
|
22861
|
+
// writes it as asked.
|
|
22862
|
+
{
|
|
22863
|
+
const bothAsked =
|
|
22864
|
+
/\b(?:(?:in\s+)?(?:both|all)\s+modes|every\s+mode|everywhere|light\s+and\s+dark|dark\s+and\s+light)\b/i.test(
|
|
22865
|
+
question,
|
|
22866
|
+
);
|
|
22867
|
+
const clear = (/** @type {string} */ v) => {
|
|
22868
|
+
const rgb = parseColor(v);
|
|
22869
|
+
if (!rgb || alphaOf(v) < 1) return null;
|
|
22870
|
+
return ratio(rgb, [0, 0, 0]) >= 12
|
|
22871
|
+
? 'light'
|
|
22872
|
+
: ratio(rgb, [255, 255, 255]) >= 12
|
|
22873
|
+
? 'dark'
|
|
22874
|
+
: null;
|
|
22875
|
+
};
|
|
22876
|
+
/**
|
|
22877
|
+
* The text color a part (in a variant, when one is named) draws in a
|
|
22878
|
+
* mode.
|
|
22879
|
+
* @param {string} on
|
|
22880
|
+
* @param {string | undefined} when
|
|
22881
|
+
* @param {'light' | 'dark'} mode
|
|
22882
|
+
*/
|
|
22883
|
+
const inkOf = (on, when, mode) => {
|
|
22884
|
+
const reads = (C.partReads(one(on), 'text') ?? []).filter(r =>
|
|
22885
|
+
/^--color-/.test(r.token),
|
|
22886
|
+
);
|
|
22887
|
+
const v = when ? /^variant:([\w-]+)$/.exec(when)?.[1] : null;
|
|
22888
|
+
const r =
|
|
22889
|
+
(v && reads.find(x => x.when.some(w => w.trim() === `variant=${v}`))) ||
|
|
22890
|
+
reads.find(x => x.when.includes('')) ||
|
|
22891
|
+
reads[0];
|
|
22892
|
+
// (A part with no text color of its own that holds others, a card:
|
|
22893
|
+
// the main text the parts inside it read; one that holds none, a
|
|
22894
|
+
// switch, draws no text to keep readable.)
|
|
22895
|
+
if (
|
|
22896
|
+
!r &&
|
|
22897
|
+
!(C.MAP[one(on)]?.contains ?? []).some(
|
|
22898
|
+
x => (C.partReads(x, 'text') ?? []).length > 0,
|
|
22899
|
+
)
|
|
22900
|
+
)
|
|
22901
|
+
return null;
|
|
22902
|
+
return parseColor(
|
|
22903
|
+
String(current(r?.token ?? '--color-text-primary', mode) ?? ''),
|
|
22904
|
+
);
|
|
22905
|
+
};
|
|
22906
|
+
/** @param {Step} x @param {Step} st */
|
|
22907
|
+
const ownText = (x, st) =>
|
|
22908
|
+
x !== st &&
|
|
22909
|
+
x.on === st.on &&
|
|
22910
|
+
(x.thing === 'color' || /^--color-text-/.test(x.thing));
|
|
22911
|
+
/** A color typed in the question, never a color word read. */
|
|
22912
|
+
const typed = (/** @type {string} */ v) =>
|
|
22913
|
+
question.toLowerCase().includes(String(v).toLowerCase());
|
|
22914
|
+
/**
|
|
22915
|
+
* A light color word's tone for the dark mode: the hue's dark shade,
|
|
22916
|
+
* else the color taken well down.
|
|
22917
|
+
* @param {string} v
|
|
22918
|
+
*/
|
|
22919
|
+
const darkTone = v => {
|
|
22920
|
+
const hue = Object.keys(SHADED.light ?? {})
|
|
22921
|
+
.concat(Object.keys(SHADED.pale ?? {}))
|
|
22922
|
+
.find(w => SHADED.light?.[w] === v || SHADED.pale?.[w] === v);
|
|
22923
|
+
return (hue && SHADED.dark?.[hue]) || shiftKeepAlpha(v, -0.6) || null;
|
|
22924
|
+
};
|
|
22925
|
+
for (const d of result) {
|
|
22926
|
+
/** @type {Set<string>} */
|
|
22927
|
+
const notes = new Set();
|
|
22928
|
+
for (const o of d.options)
|
|
22929
|
+
for (const st of o) {
|
|
22930
|
+
if (!st.on && !/^--color-border(?:-[a-z]+)?$/.test(st.thing))
|
|
22931
|
+
continue;
|
|
22932
|
+
// (A fill token set on the part, "--color-accent-muted on
|
|
22933
|
+
// table-row when selected", is its fill too.)
|
|
22934
|
+
const fill =
|
|
22935
|
+
/^background(?:-color)?$/.test(st.thing) ||
|
|
22936
|
+
(!!st.on &&
|
|
22937
|
+
/^--color-(?:background-[a-z-]+|[a-z]+-muted)$/.test(st.thing));
|
|
22938
|
+
const line =
|
|
22939
|
+
st.thing === 'border' ||
|
|
22940
|
+
st.thing === 'border-color' ||
|
|
22941
|
+
/^--color-border(?:-[a-z]+)?$/.test(st.thing);
|
|
22942
|
+
if (!fill && !line) continue;
|
|
22943
|
+
const v =
|
|
22944
|
+
st.thing === 'border'
|
|
22945
|
+
? (/#[0-9a-f]{3,8}\b/i.exec(String(st.value ?? ''))?.[0] ?? '')
|
|
22946
|
+
: String(st.value ?? '');
|
|
22947
|
+
const kind = clear(v);
|
|
22948
|
+
if (!kind || !modal) continue;
|
|
22949
|
+
// A color word said for the one mode it cannot carry: the hue's
|
|
22950
|
+
// tone for that mode.
|
|
22951
|
+
if (
|
|
22952
|
+
fill &&
|
|
22953
|
+
st.on &&
|
|
22954
|
+
st.mode === 'dark' &&
|
|
22955
|
+
kind === 'light' &&
|
|
22956
|
+
!typed(v)
|
|
22957
|
+
) {
|
|
22958
|
+
const ink = inkOf(st.on, st.when, 'dark');
|
|
22959
|
+
const rgb = parseColor(v);
|
|
22960
|
+
const tone = darkTone(v);
|
|
22961
|
+
if (ink && rgb && ratio(rgb, ink) < 3 && tone && parseColor(tone)) {
|
|
22962
|
+
st.value = tone;
|
|
22963
|
+
notes.add(
|
|
22964
|
+
`(in dark mode, ${v} would leave ${one(st.on)}'s text unreadable, so the dark mode takes the hue's dark tone, ${tone})`,
|
|
22965
|
+
);
|
|
22966
|
+
}
|
|
22967
|
+
continue;
|
|
22968
|
+
}
|
|
22969
|
+
if (st.mode || bothAsked) continue;
|
|
22970
|
+
if (line) {
|
|
22971
|
+
if (kind !== 'light' || /light-dark\(/.test(String(st.value)))
|
|
22972
|
+
continue;
|
|
22973
|
+
// (A border shorthand keeps its width in both modes: only its
|
|
22974
|
+
// color is the light mode's, the dark mode keeping the theme's
|
|
22975
|
+
// border color.)
|
|
22976
|
+
if (st.thing === 'border')
|
|
22977
|
+
st.value = String(st.value).replace(
|
|
22978
|
+
v,
|
|
22979
|
+
`light-dark(${v}, var(--color-border))`,
|
|
22980
|
+
);
|
|
22981
|
+
else st.mode = 'light';
|
|
22982
|
+
notes.add(
|
|
22983
|
+
`(a light ${st.on ? 'border' : 'border color'}, in light mode only: on the dark page it would be a glaring edge, so the dark mode keeps its own; for the dark mode too, set a dark color with --mode dark, or say "in both modes")`,
|
|
22984
|
+
);
|
|
22985
|
+
continue;
|
|
22986
|
+
}
|
|
22987
|
+
if (!st.on) continue;
|
|
22988
|
+
// (A fill whose own text the same answer sets is that look in
|
|
22989
|
+
// every mode: "a navy header with white text".)
|
|
22990
|
+
if (
|
|
22991
|
+
result.some(e =>
|
|
22992
|
+
e.options.some(oo => oo.some(x => !x.mode && ownText(x, st))),
|
|
22993
|
+
)
|
|
22994
|
+
)
|
|
22995
|
+
continue;
|
|
22996
|
+
const rgb = parseColor(v);
|
|
22997
|
+
const other = kind === 'light' ? 'dark' : 'light';
|
|
22998
|
+
const ink = inkOf(st.on, st.when, other);
|
|
22999
|
+
if (!rgb || !ink || ratio(rgb, ink) >= 3) continue;
|
|
23000
|
+
// (A dark fill only on a panel that sits on the page, a card's,
|
|
23001
|
+
// a popover's: a dark header or sidebar in light mode is chrome
|
|
23002
|
+
// asked for as it is.)
|
|
23003
|
+
if (
|
|
23004
|
+
kind === 'dark' &&
|
|
23005
|
+
!(C.partReads(one(st.on), 'background') ?? []).some(r =>
|
|
23006
|
+
/^--color-background-(?:card|popover|elevated)$/.test(r.token),
|
|
23007
|
+
)
|
|
23008
|
+
)
|
|
23009
|
+
continue;
|
|
23010
|
+
st.mode = kind;
|
|
23011
|
+
notes.add(
|
|
23012
|
+
`(in ${kind} mode only: a ${kind} fill, and the ${other} mode keeps its own so its text stays readable; for the ${other} mode too, set a ${other} color with --mode ${other}, or say "in both modes")`,
|
|
23013
|
+
);
|
|
23014
|
+
}
|
|
23015
|
+
for (const n of notes) if (!d.text.includes(n)) d.text += ` ${n}`;
|
|
23016
|
+
}
|
|
23017
|
+
}
|
|
23018
|
+
// A fill given to every variant of a part ("navy buttons"): a variant
|
|
23019
|
+
// whose own text would barely show on it (a secondary button's dark
|
|
23020
|
+
// label on navy, under 3:1) keeps its fill; the others take it, each by
|
|
23021
|
+
// name, and the answer says which kept theirs.
|
|
23022
|
+
for (const d of result)
|
|
23023
|
+
for (const o of d.options) {
|
|
23024
|
+
for (let i = o.length - 1; i >= 0; i--) {
|
|
23025
|
+
const st = o[i];
|
|
23026
|
+
if (
|
|
23027
|
+
!st.on ||
|
|
23028
|
+
st.when ||
|
|
23029
|
+
st.state ||
|
|
23030
|
+
st.only ||
|
|
23031
|
+
!/^background(?:-color)?$/.test(st.thing) ||
|
|
23032
|
+
FAMILIES[st.on]
|
|
23033
|
+
)
|
|
23034
|
+
continue;
|
|
23035
|
+
const fill = parseColor(String(st.value ?? ''));
|
|
23036
|
+
if (!fill || alphaOf(String(st.value)) < 1) continue;
|
|
23037
|
+
// (Its text given in the same answer: the ask's own look.)
|
|
23038
|
+
if (
|
|
23039
|
+
o.some(
|
|
23040
|
+
x =>
|
|
23041
|
+
x !== st &&
|
|
23042
|
+
x.on === st.on &&
|
|
23043
|
+
(x.thing === 'color' || /^--color-(?:text|on)-/.test(x.thing)),
|
|
23044
|
+
)
|
|
23045
|
+
)
|
|
23046
|
+
continue;
|
|
23047
|
+
const variants = C.variantValues(one(st.on)).variant ?? [];
|
|
23048
|
+
// (Role variants only, a part with a main variant, a button's
|
|
23049
|
+
// primary: a tone family, a badge's statuses, each pairs its text
|
|
23050
|
+
// with its own fill and is recolored as a whole.)
|
|
23051
|
+
if (variants.length < 2 || !variants.includes('primary')) continue;
|
|
23052
|
+
/** @type {Map<string, string>} */
|
|
23053
|
+
const ink = new Map();
|
|
23054
|
+
for (const r of C.partReads(one(st.on), 'text') ?? []) {
|
|
23055
|
+
if (!/^--color-/.test(r.token)) continue;
|
|
23056
|
+
for (const w of r.when) {
|
|
23057
|
+
const m = /^variant=([\w-]+)$/.exec(w.trim());
|
|
23058
|
+
if (m && !ink.has(m[1])) ink.set(m[1], r.token);
|
|
23059
|
+
}
|
|
23060
|
+
}
|
|
23061
|
+
const mode = /** @type {'light' | 'dark'} */ (st.mode ?? 'light');
|
|
23062
|
+
const lost = variants.filter(v => {
|
|
23063
|
+
const t = ink.get(v);
|
|
23064
|
+
const rgb = t ? parseColor(String(current(t, mode) ?? '')) : null;
|
|
23065
|
+
return rgb != null && ratio(fill, rgb) < 3;
|
|
23066
|
+
});
|
|
23067
|
+
if (!lost.length || lost.length === variants.length) continue;
|
|
23068
|
+
o.splice(
|
|
23069
|
+
i,
|
|
23070
|
+
1,
|
|
23071
|
+
...variants
|
|
23072
|
+
.filter(v => !lost.includes(v))
|
|
23073
|
+
.map(v => ({...st, when: `variant:${v}`})),
|
|
23074
|
+
);
|
|
23075
|
+
if (!/keep their own fill|keeps its own fill/.test(d.text))
|
|
23076
|
+
d.text += ` (${lost.join(', ')} ${lost.length > 1 ? 'keep their own fill' : 'keeps its own fill'}: ${lost.length > 1 ? 'their' : 'its'} text would barely show on ${st.value}; give ${lost.length > 1 ? 'them' : 'it'} a text color too to change ${lost.length > 1 ? 'them' : 'it'})`;
|
|
23077
|
+
}
|
|
23078
|
+
}
|
|
23079
|
+
// A fill given to a part that holds others ("a navy header"): a part
|
|
23080
|
+
// inside it whose own resting fill would sit at nearly the same color
|
|
23081
|
+
// (a primary button navy on navy) is named, so the answer never hides
|
|
23082
|
+
// it unsaid.
|
|
23083
|
+
for (const d of result)
|
|
23084
|
+
for (const o of d.options.slice(0, 1))
|
|
23085
|
+
for (const st of o) {
|
|
23086
|
+
if (
|
|
23087
|
+
!st.on ||
|
|
23088
|
+
st.state ||
|
|
23089
|
+
st.when ||
|
|
23090
|
+
!/^background(?:-color)?$/.test(st.thing)
|
|
23091
|
+
)
|
|
23092
|
+
continue;
|
|
23093
|
+
const fill = parseColor(String(st.value ?? ''));
|
|
23094
|
+
if (!fill) continue;
|
|
23095
|
+
const mode = /** @type {'light' | 'dark'} */ (st.mode ?? 'light');
|
|
23096
|
+
// (Dark surfaces share their darks by design: light mode only.)
|
|
23097
|
+
if (mode === 'dark') continue;
|
|
23098
|
+
/** @type {string[]} */
|
|
23099
|
+
const lost = [];
|
|
23100
|
+
for (const inner of C.MAP[one(st.on)]?.contains ?? []) {
|
|
23101
|
+
for (const r of C.partReads(inner, 'background') ?? []) {
|
|
23102
|
+
// (A control's own fill, a button's: never a surface that
|
|
23103
|
+
// follows the page, which dark surfaces share by design.)
|
|
23104
|
+
if (
|
|
23105
|
+
!/^--color-/.test(r.token) ||
|
|
23106
|
+
/overlay|tint|^--color-background-/.test(r.token)
|
|
23107
|
+
)
|
|
23108
|
+
continue;
|
|
23109
|
+
const v = parseColor(String(current(r.token, mode) ?? ''));
|
|
23110
|
+
if (!v || alphaOf(String(current(r.token, mode))) < 0.9) continue;
|
|
23111
|
+
if (ratio(fill, v) < 2) {
|
|
23112
|
+
const which = r.when
|
|
23113
|
+
.map(w => /variant=([\w-]+)/.exec(w)?.[1])
|
|
23114
|
+
.filter(Boolean)[0];
|
|
23115
|
+
lost.push(`${which ? `${which} ` : ''}${inner}`);
|
|
23116
|
+
break;
|
|
23117
|
+
}
|
|
23118
|
+
}
|
|
23119
|
+
}
|
|
23120
|
+
if (lost.length && !/nearly the same color/.test(d.text))
|
|
23121
|
+
d.text += ` (note: ${[...new Set(lost)].slice(0, 4).join(', ')} inside ${st.on} ${lost.length > 1 ? 'have' : 'has'} nearly the same color as ${st.value}${st.mode ? ` in ${st.mode} mode` : ''}, so ${lost.length > 1 ? 'they' : 'it'} would barely show; give ${lost.length > 1 ? 'them' : 'it'} a fill of ${lost.length > 1 ? 'their' : 'its'} own too)`;
|
|
23122
|
+
}
|
|
20976
23123
|
for (const n of placeNotes)
|
|
20977
23124
|
if (!keptInPlace.has(n.c)) result.push({text: n.text, options: []});
|
|
23125
|
+
// A panel's look written for every one (a card's) reaches the panels an
|
|
23126
|
+
// app places in a layout too (cards in a carousel, a grid or a stack, as
|
|
23127
|
+
// tiles): said once, with the place to ask for to keep them apart.
|
|
23128
|
+
{
|
|
23129
|
+
const panels = new Set(FAMILIES.containers ?? []);
|
|
23130
|
+
const written = [
|
|
23131
|
+
...new Set(
|
|
23132
|
+
result.flatMap(d =>
|
|
23133
|
+
(d.options[0] ?? [])
|
|
23134
|
+
.filter(
|
|
23135
|
+
st =>
|
|
23136
|
+
st.verb === 'set' &&
|
|
23137
|
+
st.on &&
|
|
23138
|
+
(panels.has(st.on) || st.on === 'containers'),
|
|
23139
|
+
)
|
|
23140
|
+
.map(st => /** @type {string} */ (st.on)),
|
|
23141
|
+
),
|
|
23142
|
+
),
|
|
23143
|
+
];
|
|
23144
|
+
const part = written.includes('card')
|
|
23145
|
+
? 'card'
|
|
23146
|
+
: written.find(x => x !== 'containers');
|
|
23147
|
+
// (The layouts that hold it in the part data, which paint nothing of
|
|
23148
|
+
// their own: a carousel, a grid, a stack, never the page's shell.)
|
|
23149
|
+
const holders = part
|
|
23150
|
+
? Object.keys(C.MAP)
|
|
23151
|
+
.filter(
|
|
23152
|
+
k =>
|
|
23153
|
+
!k.includes('-') &&
|
|
23154
|
+
(C.MAP[k].contains ?? []).includes(part) &&
|
|
23155
|
+
!C.MAP[k].at?.['background-color'] &&
|
|
23156
|
+
!(C.MAP[k].contains ?? []).some(
|
|
23157
|
+
(/** @type {string} */ x) =>
|
|
23158
|
+
x.startsWith(`${k}-`) && /^(?:layout|app-shell)/.test(x),
|
|
23159
|
+
) &&
|
|
23160
|
+
!['layout', 'app-shell'].includes(k),
|
|
23161
|
+
)
|
|
23162
|
+
.sort()
|
|
23163
|
+
: [];
|
|
23164
|
+
if (part && holders.length)
|
|
23165
|
+
result.push({
|
|
23166
|
+
text: `${part}s placed in ${holders
|
|
23167
|
+
.map(h => `a ${h}`)
|
|
23168
|
+
.join(', ')
|
|
23169
|
+
.replace(
|
|
23170
|
+
/, ([^,]*)$/,
|
|
23171
|
+
' or $1',
|
|
23172
|
+
)} take this too; to keep them apart, ask for the ${part}s in that place ("${part}s in ${holders[0]}s …"), which writes on the ${holders[0]} only`,
|
|
23173
|
+
options: [],
|
|
23174
|
+
lookup: `${HOW} ${holders[0]}`,
|
|
23175
|
+
});
|
|
23176
|
+
}
|
|
20978
23177
|
// A lookup for a part a "match" ask already answered for adds nothing.
|
|
20979
23178
|
for (let i = result.length - 1; i >= 0; i--) {
|
|
20980
23179
|
const d = result[i];
|
|
@@ -20996,6 +23195,87 @@ export function draftAnswer(ctx, env, question) {
|
|
|
20996
23195
|
options: [],
|
|
20997
23196
|
lookup: `${HOW} ${named0.parts[0].on}`,
|
|
20998
23197
|
});
|
|
23198
|
+
// (The step toward a rung said with the rung is not offered apart.)
|
|
23199
|
+
for (const dropped of relDropped)
|
|
23200
|
+
result.splice(
|
|
23201
|
+
0,
|
|
23202
|
+
result.length,
|
|
23203
|
+
...result.filter(
|
|
23204
|
+
d =>
|
|
23205
|
+
!(
|
|
23206
|
+
d.options.length === 1 &&
|
|
23207
|
+
d.options[0].length === 1 &&
|
|
23208
|
+
d.options[0][0].thing === dropped.thing &&
|
|
23209
|
+
d.options[0][0].value === dropped.value &&
|
|
23210
|
+
!d.options[0][0].on
|
|
23211
|
+
),
|
|
23212
|
+
),
|
|
23213
|
+
);
|
|
23214
|
+
// "make the info banner navy": one status's fill on one part, or that
|
|
23215
|
+
// status's color for the whole theme (its banners, badges and toasts
|
|
23216
|
+
// together), the dial; both are offered, the part's first.
|
|
23217
|
+
for (const d of result) {
|
|
23218
|
+
const st =
|
|
23219
|
+
d.options.length === 1 && d.options[0].length === 1
|
|
23220
|
+
? d.options[0][0]
|
|
23221
|
+
: null;
|
|
23222
|
+
const role = st?.when
|
|
23223
|
+
? /^(?:status|type|variant):(info|success|warning|error|danger)$/.exec(
|
|
23224
|
+
String(st.when),
|
|
23225
|
+
)?.[1]
|
|
23226
|
+
: null;
|
|
23227
|
+
if (
|
|
23228
|
+
!st ||
|
|
23229
|
+
!role ||
|
|
23230
|
+
st.thing !== 'background-color' ||
|
|
23231
|
+
st.mode ||
|
|
23232
|
+
!/^(?:banner|badge|toast|alert|callout|status-dot|tag)$/.test(
|
|
23233
|
+
one(String(st.on ?? '')),
|
|
23234
|
+
) ||
|
|
23235
|
+
!parseColor(String(st.value ?? '')) ||
|
|
23236
|
+
!env.check([st]).ok
|
|
23237
|
+
)
|
|
23238
|
+
continue;
|
|
23239
|
+
const dial = /^(?:error|danger|destructive)$/.test(role) ? 'danger' : role;
|
|
23240
|
+
d.options.push([set(dial, String(st.value))]);
|
|
23241
|
+
d.text = `${d.text}; or, the second line, the ${dial} color for the whole theme (every ${role} banner, badge and toast follows it): set ${env.slug} ${dial} <color>`;
|
|
23242
|
+
}
|
|
23243
|
+
// "a calm, Linear-like dark theme with a violet accent": a look said as
|
|
23244
|
+
// a list of words takes each word a setting reads; the words none reads
|
|
23245
|
+
// are named, never dropped without a word.
|
|
23246
|
+
if (
|
|
23247
|
+
!gateAll &&
|
|
23248
|
+
/\b(?:theme|vibe|palette|aesthetic|branding)\b/.test(q) &&
|
|
23249
|
+
result.some(d => d.options.some(o => o.length))
|
|
23250
|
+
) {
|
|
23251
|
+
const STOP =
|
|
23252
|
+
/^(?:theme|themes|look|looks|feel|vibe|style|palette|with|give|make|want|need|have|this|that|those|these|their|ours?|your|for|and|but|the|very|really|quite|some|more|less|less|like|into|from|only|both|mode|modes|site|sites|apps?|page|pages|product|website|please|also|plus|something|kind|sort|ish|using|uses|feeling|overall|while|keep|kept|just|still|then|than|colou?rs?|them|they|those|these|what|when|where|which|lighten|darken|soften|brighten|sharpen|tone|default|brand|color|deep|rich)$/;
|
|
23253
|
+
const notTaken = [
|
|
23254
|
+
...new Set(
|
|
23255
|
+
(q.toLowerCase().match(/[a-z][a-z-]*[a-z]/g) ?? []).filter(
|
|
23256
|
+
w =>
|
|
23257
|
+
w.length >= 4 &&
|
|
23258
|
+
!STOP.test(w) &&
|
|
23259
|
+
!lex.vocab.includes(w) &&
|
|
23260
|
+
!Object.hasOwn(HUES, w) &&
|
|
23261
|
+
!lex.parts.some(([re]) => re.test(` ${w} `)) &&
|
|
23262
|
+
!aspectsOf(w).length &&
|
|
23263
|
+
stateWord(w) == null &&
|
|
23264
|
+
!colorsIn(w).length &&
|
|
23265
|
+
!/^(?:dark|light)(?:-only)?$/.test(w) &&
|
|
23266
|
+
// (A way, "softer", is read by the way readers.)
|
|
23267
|
+
!/[a-z]{3}er$/.test(w) &&
|
|
23268
|
+
!/^(?:dark|light|bright|pale|soft|subtle)$/.test(w) &&
|
|
23269
|
+
!partsSeen.some(p => w.startsWith(String(p))),
|
|
23270
|
+
),
|
|
23271
|
+
),
|
|
23272
|
+
];
|
|
23273
|
+
if (notTaken.length)
|
|
23274
|
+
result.push({
|
|
23275
|
+
text: `not taken: ${notTaken.map(w => `"${w}"`).join(', ')}: no setting reads ${notTaken.length > 1 ? 'these words' : 'this word'}; the looks how sets are colors (accent, neutral, the page, the text), mode, spacing, corners, fonts and contrast (how --list dials lists each)`,
|
|
23276
|
+
options: [],
|
|
23277
|
+
});
|
|
23278
|
+
}
|
|
20999
23279
|
const unsure = gateAll;
|
|
21000
23280
|
if (unsure && result.some(d => d.options.some(o => o.length))) {
|
|
21001
23281
|
const part = partsSeen[0];
|