From 6fb9fe7f29c86c77424f393cb4f1caabc90954e2 Mon Sep 17 00:00:00 2001 From: Andre Torgal Date: Sun, 23 Feb 2025 01:14:53 +0100 Subject: [PATCH 1/2] Rename "space" models, values and primitives to "size" --- .../Values/Types/SizeValue.mdx | 38 +++++++++++ .../Values/Types/SpaceValue.mdx | 29 -------- .../cli-helpers/formatDecisionStatus.mdx | 6 +- .../{SpaceVizName.mdx => SizeVizName.mdx} | 12 ++-- .../src/content/docs/examples/space.mdx | 38 +++++------ .../docs/guides/10-decisions-as-data.mdx | 14 ++-- .../docs/guides/20-loading-and-validating.mdx | 28 ++++---- .../42-documenting-decisions.mdx | 6 +- .../integrations/Astro/Composable/types.mdx | 10 ++- .../integrations/Astro/Composable/values.mdx | 16 ++--- .../Astro/Composable/visualizations.mdx | 32 ++++----- .../docs/integrations/Astro/ShowDecision.mdx | 6 +- .../integrations/Astro/ShowDecisionCard.mdx | 4 +- .../_partials/TableDecisionComponents.astro | 16 ++--- .../content/docs/integrations/Astro/props.mdx | 4 +- .../resources/data/demo/space/space.json | 38 +++++------ .../samples/space/space-scale-anchored.json | 4 +- .../samples/space/space-scale-bounded.json | 4 +- .../samples/space/space-scale-explicit.json | 4 +- .../samples/space/space-value-explicit.json | 9 ++- .../src/constants/decisions.ts | 6 +- .../domains/decisionTypeAssertions.test.ts | 18 ++--- .../src/decision/domains/space/index.ts | 4 +- .../domains/space/isSizeScaleDecision.ts | 8 +++ .../domains/space/isSizeValueDecision.ts | 8 +++ .../domains/space/isSpaceScaleDecision.ts | 8 --- .../domains/space/isSpaceValueDecision.ts | 8 --- .../src/decision/domains/space/types/scale.ts | 4 +- .../src/decision/domains/space/types/value.ts | 4 +- .../src/errors/serializeErrorData.ts | 4 +- .../src/inputs/types/models/space/set.ts | 22 +++--- .../src/inputs/types/models/space/value.ts | 8 +-- .../inputs/types/primitives/space/index.ts | 2 +- .../src/inputs/types/primitives/space/size.ts | 13 ++++ .../inputs/types/primitives/space/space.ts | 23 ------- .../src/meta/domains/space/index.ts | 2 +- .../src/meta/domains/space/size.ts | 58 ++++++++++++++++ .../src/meta/domains/space/space.ts | 59 ---------------- .../libs/designer-decisions/src/meta/index.ts | 4 +- .../src/models/space/index.ts | 4 +- .../createSizeScaleAnchoredModel.test.ts} | 12 ++-- .../createSizeScaleAnchoredModel.ts | 31 +++++++++ .../createSizeScaleBoundedModel.test.ts} | 12 ++-- .../size-scale/createSizeScaleBoundedModel.ts | 32 +++++++++ .../createSizeScaleExplicitModel.test.ts} | 12 ++-- .../createSizeScaleExplicitModel.ts | 20 ++++++ .../src/models/space/size-scale/index.ts | 4 ++ .../createSizeValueExplicitModel.test.ts} | 12 ++-- .../createSizeValueExplicitModel.ts | 15 ++++ .../{space-value => size-value}/index.ts | 2 +- .../createSpaceScaleAnchoredModel.ts | 31 --------- .../createSpaceScaleBoundedModel.ts | 32 --------- .../createSpaceScaleExplicitModel.ts | 20 ------ .../src/models/space/space-scale/index.ts | 4 -- .../createSpaceValueExplicitModel.ts | 15 ---- .../src/values/domains/space/constants.ts | 2 +- .../values/domains/space/helpers/constants.ts | 3 - .../space/helpers/isValidSpaceWithUnits.ts | 21 ------ .../src/values/domains/space/index.ts | 5 +- .../domains/space/scale/createSpaceScale.ts | 7 -- .../createSizeScale.test.ts} | 10 +-- .../space/size-scale/createSizeScale.ts | 7 ++ .../space/{scale => size-scale}/index.ts | 2 +- .../createSizeValue.test.ts} | 67 +++++++++--------- .../space/size-value/createSizeValue.ts | 37 ++++++++++ .../space/{value => size-value}/index.ts | 6 +- .../space/size-value/private/constants.ts | 6 ++ .../{value => size-value}/private/index.ts | 0 .../resolveSizeValue.test.ts} | 48 ++++++------- .../resolveSizeValue.ts} | 16 ++--- .../resolveSizeValueRef.test.ts} | 68 +++++++++---------- .../resolveSizeValueRef.ts} | 14 ++-- .../src/values/domains/space/types.ts | 20 +++--- .../domains/space/value/createSpaceValue.ts | 37 ---------- .../domains/space/value/private/constants.ts | 6 -- .../functions/resolveSetRefDecision.test.ts | 12 ++-- .../src/values/primitives/index.ts | 1 + .../values/primitives/size/createSize.test.ts | 21 ++++++ .../src/values/primitives/size/createSize.ts | 13 ++++ .../primitives/size/helpers/constants.ts | 3 + .../size}/helpers/index.ts | 2 +- .../helpers/isValidSizeObjectLiteral.test.ts} | 17 +++-- .../size/helpers/isValidSizeObjectLiteral.ts | 21 ++++++ .../src/values/primitives/size/index.ts | 4 ++ .../src/values/primitives/size/types/index.ts | 2 + .../src/values/primitives/size/types/size.ts | 7 ++ .../src/astro/meta/getDecisionComponent.ts | 8 +-- .../src/astro/meta/getSizeVizComponent.ts | 17 +++++ .../src/astro/meta/getSpaceVizComponent.ts | 17 ----- .../designer-shows/src/astro/meta/index.ts | 2 +- .../designer-shows/src/astro/styles/base.css | 6 +- .../designer-shows/src/astro/types/index.ts | 32 ++++----- ...owSpaceValue.astro => ShowSizeValue.astro} | 12 ++-- .../src/astro/values/space/ShowSizeViz.astro | 18 +++++ .../src/astro/values/space/ShowSpaceViz.astro | 18 ----- .../src/astro/values/space/index.ts | 4 +- ...aceCircleViz.astro => SizeCircleViz.astro} | 20 +++--- ...arViz.astro => SizeHorizontalBarViz.astro} | 22 +++--- ...aceSquareViz.astro => SizeSquareViz.astro} | 22 +++--- ...lBarViz.astro => SizeVerticalBarViz.astro} | 20 +++--- .../src/astro/viz/space/index.ts | 8 +-- 101 files changed, 802 insertions(+), 748 deletions(-) create mode 100644 docs/designer-decisions/src/content/docs/api/designer-decisions/Values/Types/SizeValue.mdx delete mode 100644 docs/designer-decisions/src/content/docs/api/designer-decisions/Values/Types/SpaceValue.mdx rename docs/designer-decisions/src/content/docs/api/designer-shows/Types/{SpaceVizName.mdx => SizeVizName.mdx} (69%) create mode 100644 packages/libs/designer-decisions/src/decision/domains/space/isSizeScaleDecision.ts create mode 100644 packages/libs/designer-decisions/src/decision/domains/space/isSizeValueDecision.ts delete mode 100644 packages/libs/designer-decisions/src/decision/domains/space/isSpaceScaleDecision.ts delete mode 100644 packages/libs/designer-decisions/src/decision/domains/space/isSpaceValueDecision.ts create mode 100644 packages/libs/designer-decisions/src/inputs/types/primitives/space/size.ts delete mode 100644 packages/libs/designer-decisions/src/inputs/types/primitives/space/space.ts create mode 100644 packages/libs/designer-decisions/src/meta/domains/space/size.ts delete mode 100644 packages/libs/designer-decisions/src/meta/domains/space/space.ts rename packages/libs/designer-decisions/src/models/space/{space-scale/createSpaceScaleAnchoredModel.test.ts => size-scale/createSizeScaleAnchoredModel.test.ts} (82%) create mode 100644 packages/libs/designer-decisions/src/models/space/size-scale/createSizeScaleAnchoredModel.ts rename packages/libs/designer-decisions/src/models/space/{space-scale/createSpaceScaleBoundedModel.test.ts => size-scale/createSizeScaleBoundedModel.test.ts} (79%) create mode 100644 packages/libs/designer-decisions/src/models/space/size-scale/createSizeScaleBoundedModel.ts rename packages/libs/designer-decisions/src/models/space/{space-scale/createSpaceScaleExplicitModel.test.ts => size-scale/createSizeScaleExplicitModel.test.ts} (80%) create mode 100644 packages/libs/designer-decisions/src/models/space/size-scale/createSizeScaleExplicitModel.ts create mode 100644 packages/libs/designer-decisions/src/models/space/size-scale/index.ts rename packages/libs/designer-decisions/src/models/space/{space-value/createSpaceValueExplicitModel.test.ts => size-value/createSizeValueExplicitModel.test.ts} (68%) create mode 100644 packages/libs/designer-decisions/src/models/space/size-value/createSizeValueExplicitModel.ts rename packages/libs/designer-decisions/src/models/space/{space-value => size-value}/index.ts (73%) delete mode 100644 packages/libs/designer-decisions/src/models/space/space-scale/createSpaceScaleAnchoredModel.ts delete mode 100644 packages/libs/designer-decisions/src/models/space/space-scale/createSpaceScaleBoundedModel.ts delete mode 100644 packages/libs/designer-decisions/src/models/space/space-scale/createSpaceScaleExplicitModel.ts delete mode 100644 packages/libs/designer-decisions/src/models/space/space-scale/index.ts delete mode 100644 packages/libs/designer-decisions/src/models/space/space-value/createSpaceValueExplicitModel.ts delete mode 100644 packages/libs/designer-decisions/src/values/domains/space/helpers/constants.ts delete mode 100644 packages/libs/designer-decisions/src/values/domains/space/helpers/isValidSpaceWithUnits.ts delete mode 100644 packages/libs/designer-decisions/src/values/domains/space/scale/createSpaceScale.ts rename packages/libs/designer-decisions/src/values/domains/space/{scale/createSpaceScale.test.ts => size-scale/createSizeScale.test.ts} (67%) create mode 100644 packages/libs/designer-decisions/src/values/domains/space/size-scale/createSizeScale.ts rename packages/libs/designer-decisions/src/values/domains/space/{scale => size-scale}/index.ts (79%) rename packages/libs/designer-decisions/src/values/domains/space/{value/createSpaceValue.test.ts => size-value/createSizeValue.test.ts} (57%) create mode 100644 packages/libs/designer-decisions/src/values/domains/space/size-value/createSizeValue.ts rename packages/libs/designer-decisions/src/values/domains/space/{value => size-value}/index.ts (55%) create mode 100644 packages/libs/designer-decisions/src/values/domains/space/size-value/private/constants.ts rename packages/libs/designer-decisions/src/values/domains/space/{value => size-value}/private/index.ts (100%) rename packages/libs/designer-decisions/src/values/domains/space/{value/resolveSpaceValue.test.ts => size-value/resolveSizeValue.test.ts} (54%) rename packages/libs/designer-decisions/src/values/domains/space/{value/resolveSpaceValue.ts => size-value/resolveSizeValue.ts} (63%) rename packages/libs/designer-decisions/src/values/domains/space/{value/resolveSpaceValueRef.test.ts => size-value/resolveSizeValueRef.test.ts} (61%) rename packages/libs/designer-decisions/src/values/domains/space/{value/resolveSpaceValueRef.ts => size-value/resolveSizeValueRef.ts} (58%) delete mode 100644 packages/libs/designer-decisions/src/values/domains/space/value/createSpaceValue.ts delete mode 100644 packages/libs/designer-decisions/src/values/domains/space/value/private/constants.ts create mode 100644 packages/libs/designer-decisions/src/values/primitives/size/createSize.test.ts create mode 100644 packages/libs/designer-decisions/src/values/primitives/size/createSize.ts create mode 100644 packages/libs/designer-decisions/src/values/primitives/size/helpers/constants.ts rename packages/libs/designer-decisions/src/values/{domains/space => primitives/size}/helpers/index.ts (79%) rename packages/libs/designer-decisions/src/values/{domains/space/helpers/isValidSpaceWithUnits.test.ts => primitives/size/helpers/isValidSizeObjectLiteral.test.ts} (60%) create mode 100644 packages/libs/designer-decisions/src/values/primitives/size/helpers/isValidSizeObjectLiteral.ts create mode 100644 packages/libs/designer-decisions/src/values/primitives/size/index.ts create mode 100644 packages/libs/designer-decisions/src/values/primitives/size/types/index.ts create mode 100644 packages/libs/designer-decisions/src/values/primitives/size/types/size.ts create mode 100644 packages/libs/designer-shows/src/astro/meta/getSizeVizComponent.ts delete mode 100644 packages/libs/designer-shows/src/astro/meta/getSpaceVizComponent.ts rename packages/libs/designer-shows/src/astro/values/space/{ShowSpaceValue.astro => ShowSizeValue.astro} (58%) create mode 100644 packages/libs/designer-shows/src/astro/values/space/ShowSizeViz.astro delete mode 100644 packages/libs/designer-shows/src/astro/values/space/ShowSpaceViz.astro rename packages/libs/designer-shows/src/astro/viz/space/{SpaceCircleViz.astro => SizeCircleViz.astro} (60%) rename packages/libs/designer-shows/src/astro/viz/space/{SpaceHorizontalBarViz.astro => SizeHorizontalBarViz.astro} (65%) rename packages/libs/designer-shows/src/astro/viz/space/{SpaceSquareViz.astro => SizeSquareViz.astro} (56%) rename packages/libs/designer-shows/src/astro/viz/space/{SpaceVerticalBarViz.astro => SizeVerticalBarViz.astro} (62%) diff --git a/docs/designer-decisions/src/content/docs/api/designer-decisions/Values/Types/SizeValue.mdx b/docs/designer-decisions/src/content/docs/api/designer-decisions/Values/Types/SizeValue.mdx new file mode 100644 index 00000000..8b383569 --- /dev/null +++ b/docs/designer-decisions/src/content/docs/api/designer-decisions/Values/Types/SizeValue.mdx @@ -0,0 +1,38 @@ +--- +title: SizeValue +slug: api/designer-decisions/Values/Types/SizeValue +sidebar: + order: 0 +--- + +Extends `BaseValue` + +```ts +export type SizeRaw = string | number; + +export type SizeAbsoluteUnits = 'px' | 'rem'; + +export type SizeObjectLiteral = { + value: number; + units: SizeAbsoluteUnits; +}; +export type SizeLiteral = SizeRaw | SizeObjectLiteral; + +export type Size = { + value: number; + units: SizeAbsoluteUnits; + toString: () => string; +}; + +export type SizeFormatOptions = { + quantize?: number; +}; + +export type SizeValue = { + get: () => Size; + raw: () => number; + quantized: (quantize?: number) => number; + toString: (options?: SizeFormatOptions) => string; + toObject: (options?: SizeFormatOptions) => SizeObjectLiteral; +}; +``` diff --git a/docs/designer-decisions/src/content/docs/api/designer-decisions/Values/Types/SpaceValue.mdx b/docs/designer-decisions/src/content/docs/api/designer-decisions/Values/Types/SpaceValue.mdx deleted file mode 100644 index 07c416c2..00000000 --- a/docs/designer-decisions/src/content/docs/api/designer-decisions/Values/Types/SpaceValue.mdx +++ /dev/null @@ -1,29 +0,0 @@ ---- -title: SpaceValue -slug: api/designer-decisions/Values/Types/SpaceValue -sidebar: - order: 0 ---- - -Extends `BaseValue` - -```ts -export type SpaceUnits = 'px' | 'em' | 'rem'; - -export type SpaceWithUnits = { - value: number; - units: SpaceUnits; -}; - -export type SpaceValueFormatOptions = { - quantize?: number; -}; - -export type SpaceValue = { - get: () => number; - raw: () => number; - quantized: (quantize?: number) => number; - toString: (options?: SpaceValueFormatOptions) => string; - toObject: (options?: SpaceValueFormatOptions) => SpaceWithUnits; -}; -``` diff --git a/docs/designer-decisions/src/content/docs/api/designer-functions/cli-helpers/formatDecisionStatus.mdx b/docs/designer-decisions/src/content/docs/api/designer-functions/cli-helpers/formatDecisionStatus.mdx index abb4faa9..12b0c991 100644 --- a/docs/designer-decisions/src/content/docs/api/designer-functions/cli-helpers/formatDecisionStatus.mdx +++ b/docs/designer-decisions/src/content/docs/api/designer-functions/cli-helpers/formatDecisionStatus.mdx @@ -53,10 +53,10 @@ produced.decisions().forEach(status => console.info(formatDecisionStatus(status) Returns one decision per line, with nested value errors. ``` -🟨 | Sizing Scale | space-scale/bounded | [0px, 0px, 0px, 0px, 0px, 0px] | 2 warnings +🟨 | Sizing Scale | size-scale/bounded | [0px, 0px, 0px, 0px, 0px, 0px] | 2 warnings - > 🟨 Ref (SpaceValue) {"$name":"Size Smallest"} not found. - > 🟨 Ref (SpaceValue) {"$name":"Brand Black"} matched "color-value". + > 🟨 Ref (SizeValue) {"$name":"Size Smallest"} not found. + > 🟨 Ref (SizeValue) {"$name":"Brand Black"} matched "color-value". ``` Using `formatDecisionStatus(status, ['status-colors', 'name', 'value'])` diff --git a/docs/designer-decisions/src/content/docs/api/designer-shows/Types/SpaceVizName.mdx b/docs/designer-decisions/src/content/docs/api/designer-shows/Types/SizeVizName.mdx similarity index 69% rename from docs/designer-decisions/src/content/docs/api/designer-shows/Types/SpaceVizName.mdx rename to docs/designer-decisions/src/content/docs/api/designer-shows/Types/SizeVizName.mdx index b57a18f8..34968af4 100644 --- a/docs/designer-decisions/src/content/docs/api/designer-shows/Types/SpaceVizName.mdx +++ b/docs/designer-decisions/src/content/docs/api/designer-shows/Types/SizeVizName.mdx @@ -1,27 +1,27 @@ --- -title: SpaceVizName -slug: api/designer-shows/Types/SpaceVizName +title: SizeVizName +slug: api/designer-shows/Types/SizeVizName --- import { ShowDecision } from '@noodlestan/designer-shows/astro'; -Available visualizations for [Space Values](/integrations/Astro/Composable/Values/#showspacevalue) +Available visualizations for [Space Values](/integrations/Astro/Composable/Values/#showsizevalue) ```ts -type SpaceVizName = 'bar-h' | 'bar-v' | 'square' | 'circle'; +type SizeVizName = 'bar-h' | 'bar-v' | 'square' | 'circle'; ``` When rendering decisions you can chose a different visualization by setting the [viz prop](/integrations/Astro/Props#-viz-true-boolean--string) to one of these. ```mdx - + ``` ## Type Values ### `bar-h` (default) - + ### `bar-v` diff --git a/docs/designer-decisions/src/content/docs/examples/space.mdx b/docs/designer-decisions/src/content/docs/examples/space.mdx index 501c45c5..8f997406 100644 --- a/docs/designer-decisions/src/content/docs/examples/space.mdx +++ b/docs/designer-decisions/src/content/docs/examples/space.mdx @@ -13,36 +13,36 @@ import { ShowDecisionCard, } from '@noodlestan/designer-shows/astro'; -## Space values +## Size values
-SpaceValue +SizeValue ```mdx - + ```
- + -## Space scales +## Size scales
-SpaceScale (default viz / xs size) +SizeScale (default viz / xs size) ```mdx - + ```
- +
-SpaceScale (vertical bar viz) +SizeScale (vertical bar viz) ```mdx @@ -53,18 +53,18 @@ import {
-SpaceScale (square viz vs circle viz) +SizeScale (square viz vs circle viz) ```mdx - - + + ```
- - + + ## Cards @@ -73,23 +73,23 @@ import { SpaceValue (DecisionCard / model and params shown) ```mdx - + ```
- +
-SpaceScale (DecisionCard / column layout) +SizeScale (DecisionCard / column layout) ```mdx - + ```
- + ## See also diff --git a/docs/designer-decisions/src/content/docs/guides/10-decisions-as-data.mdx b/docs/designer-decisions/src/content/docs/guides/10-decisions-as-data.mdx index c18525a0..78b50ff1 100644 --- a/docs/designer-decisions/src/content/docs/guides/10-decisions-as-data.mdx +++ b/docs/designer-decisions/src/content/docs/guides/10-decisions-as-data.mdx @@ -65,22 +65,22 @@ When declaring decisions in JSON files you are encouraged to organize them in sm You can reuse decision values and avoid repetition by referencing them in other decisions. -The following example defines an explicit [Space Value](/models/decision-types/space-value) decision called "Space Unit" and a [Space Scale](/models/decision-types/space-scale#anchored) anchored on the value of the first one. +The following example defines an explicit [Size Value](/models/decision-types/size-value) decision called "Size Unit" and a [Size Scale](/models/decision-types/size-scale#anchored) anchored on the value of the first one. ```json [ { - "type": "space-value/explicit", - "name": "Space Unit", + "type": "size-value/explicit", + "name": "Size Unit", "params": { "value": "8" } }, { - "type": "space-scale/anchored", + "type": "size-scale/anchored", "name": "Sizing Scale", "params": { - "anchor": { "$name": "Space Unit" }, + "anchor": { "$name": "Size Unit" }, "after": { "steps": 5, "modifier": { "mode": "gemetric", "by": 1.5 } @@ -92,12 +92,12 @@ The following example defines an explicit [Space Value](/models/decision-types/s You can also reference items of a decision set set or scale by adding the index to the reference. -In the following example we are creating a [Space Value](/models/decision-types/space-value) decision based on the second element of the "Sizing Scale" declared before. +In the following example we are creating a [Size Value](/models/decision-types/size-value) decision based on the second element of the "Sizing Scale" declared before. ```json [ { - "type": "space-value/explicit", + "type": "size-value/explicit", "name": "Default Size", "params": { "value": { "$name": "Sizing Scale", "index": 3 } diff --git a/docs/designer-decisions/src/content/docs/guides/20-loading-and-validating.mdx b/docs/designer-decisions/src/content/docs/guides/20-loading-and-validating.mdx index 919f7a4e..c7f940bd 100644 --- a/docs/designer-decisions/src/content/docs/guides/20-loading-and-validating.mdx +++ b/docs/designer-decisions/src/content/docs/guides/20-loading-and-validating.mdx @@ -131,10 +131,10 @@ If no errors occur, the output should look something like: ``` ... -Sizing Space Scale space-scale/anchored -Card Thumb Minimum Size space-value/explicit -Avatar Minimum Size space-value/explicit -Avatar Sizes space-scale/anchored +Sizing Scale size-scale/anchored +Card Thumb Minimum Size size-value/explicit +Avatar Minimum Size size-value/explicit +Avatar Sizes size-scale/anchored 🐘 67 records ``` @@ -182,8 +182,8 @@ If you run `node scripts/validate-decisions.js` again, you will see two new deci ``` ... -Avatar Minimum Size space-value/explicit -Avatar Sizes space-scale/anchored +Avatar Minimum Size size-value/explicit +Avatar Sizes size-scale/anchored Warm Color color-value/explicit Cold Color color-value/explicit 🐘 68 records @@ -317,19 +317,19 @@ Without any errors, the output will now display the decision status, the name an ``` ... -🟩 | Textarea Maximum Height | space-value/explicit | 300 | -🟩 | Card Thumb Minimum Size | space-value/explicit | 175 | -🟩 | Avatar Minimum Size | space-value/explicit | 50 | -🟩 | Avatar Sizes | space-scale/anchored | [50, 100, 150, 200] | +🟩 | Textarea Maximum Height | size-value/explicit | 300 | +🟩 | Card Thumb Minimum Size | size-value/explicit | 175 | +🟩 | Avatar Minimum Size | size-value/explicit | 50 | +🟩 | Avatar Sizes | size-scale/anchored | [50, 100, 150, 200] | ``` If we introduce a validation issue in one of the items, as in the previous example, the output will also include details about the error. ``` ... -🟩 | Card Thumb Minimum Size | space-value/explicit | 175 | -🟩 | Avatar Minimum Size | space-value/explicit | 50 | -🟩 | Avatar Sizes | space-scale/anchored | [50, 100, 150, 200] | +🟩 | Card Thumb Minimum Size | size-value/explicit | 175 | +🟩 | Avatar Minimum Size | size-value/explicit | 50 | +🟩 | Avatar Sizes | size-scale/anchored | [50, 100, 150, 200] | 🟨 | Warm Color | color-value/explicit | #000000 | 1 errors, 1 warnings > 🟨 Decision "Warm Color" /params (required) must have required property 'value' > 🟨 Invalid input data for a ColorValue in {"$name":"Warm Color"}: undefined @@ -374,7 +374,7 @@ loadDecisions(); You can use it to summarize all counts in one line. ``` -🟨 Decision "Sizing Space Scale" /params/after (required) must have required property 'steps' +🟨 Decision "Sizing Scale" /params/after (required) must have required property 'steps' 🐘 59 records, 0 errors, 1 warnings ``` diff --git a/docs/designer-decisions/src/content/docs/guides/Generating Docs/42-documenting-decisions.mdx b/docs/designer-decisions/src/content/docs/guides/Generating Docs/42-documenting-decisions.mdx index 176f20bc..8d95d058 100644 --- a/docs/designer-decisions/src/content/docs/guides/Generating Docs/42-documenting-decisions.mdx +++ b/docs/designer-decisions/src/content/docs/guides/Generating Docs/42-documenting-decisions.mdx @@ -22,12 +22,12 @@ This guide explains how to document design decisions and tokens in your document ```mdx - + ``` - + ## Setup @@ -220,7 +220,7 @@ Some decision types can be rendered using different visualizations. The `viz` prop is passed down to value components to determine which visualization is used. -For instance, the [ShowSpaceViz](/integrations/Astro/Composable/Visualizations/#showspaceviz) component can represent a space value with a few different shapes. +For instance, the [ShowSizeViz](/integrations/Astro/Composable/Visualizations/#showsizeviz) component can represent a size value with a few different shapes. ```mdx diff --git a/docs/designer-decisions/src/content/docs/integrations/Astro/Composable/types.mdx b/docs/designer-decisions/src/content/docs/integrations/Astro/Composable/types.mdx index bedd50dc..35f0549e 100644 --- a/docs/designer-decisions/src/content/docs/integrations/Astro/Composable/types.mdx +++ b/docs/designer-decisions/src/content/docs/integrations/Astro/Composable/types.mdx @@ -11,16 +11,16 @@ import { Aside } from '@astrojs/starlight/components'; import { createColorValue, createValueContext, - createSpaceValue, + createSizeValue, } from '@noodlestan/designer-decisions'; import { integrationAPI } from '@noodlestan/designer-integration-astro'; -import { ShowColorValue, ShowSpaceValue } from '@noodlestan/designer-shows/astro'; +import { ShowColorValue, ShowSizeValue } from '@noodlestan/designer-shows/astro'; import { TableDecisionComponents } from '../_partials'; export const store = await integrationAPI.build(); export const colorValue = createColorValue(store.createValueContext(), '#ff0000'); -export const spaceValue = createSpaceValue(store.createValueContext(), 12); +export const sizeValue = createSizeValue(store.createValueContext(), 12); These components render a decision's visualization directly. @@ -42,3 +42,7 @@ The following table lists all decision types and which component is used interna ### Color + +### Typography + + diff --git a/docs/designer-decisions/src/content/docs/integrations/Astro/Composable/values.mdx b/docs/designer-decisions/src/content/docs/integrations/Astro/Composable/values.mdx index 6b7bb4aa..655a2df0 100644 --- a/docs/designer-decisions/src/content/docs/integrations/Astro/Composable/values.mdx +++ b/docs/designer-decisions/src/content/docs/integrations/Astro/Composable/values.mdx @@ -12,19 +12,19 @@ import { createColorValue, createOklabHueValue, createValueContext, - createSpaceValue, + createSizeValue, } from '@noodlestan/designer-decisions'; import { integrationAPI } from '@noodlestan/designer-integration-astro'; import { ShowColorChannelValue, ShowColorValue, - ShowSpaceValue, + ShowSizeValue, } from '@noodlestan/designer-shows/astro'; export const store = await integrationAPI.build(); export const colorValue = createColorValue(store.createValueContext(), '#ff0000'); export const colorChannelValue = createOklabHueValue(store.createValueContext(), 123); -export const spaceValue = createSpaceValue(store.createValueContext(), 12); +export const sizeValue = createSizeValue(store.createValueContext(), 12); These components render a decision's value directly. @@ -91,9 +91,9 @@ export const colorChannelValue = createOklabHueValue(context, 123); Space related components. -### ShowSpaceValue +### ShowSizeValue -#### ༶ `v`: [SpaceValue](/api/designer-decisions/Values/Types/SpaceValue) +#### ༶ `v`: [SizeValue](/api/designer-decisions/Values/Types/SizeValue) #### ༶ `value`: - @@ -102,9 +102,9 @@ This prop has no effect on this component. #### Example ```mdx -export const spaceValue = createSpaceValue(context, 12); +export const sizeValue = createSizeValue(context, 12); - + ``` - + diff --git a/docs/designer-decisions/src/content/docs/integrations/Astro/Composable/visualizations.mdx b/docs/designer-decisions/src/content/docs/integrations/Astro/Composable/visualizations.mdx index b36aee33..fffa6215 100644 --- a/docs/designer-decisions/src/content/docs/integrations/Astro/Composable/visualizations.mdx +++ b/docs/designer-decisions/src/content/docs/integrations/Astro/Composable/visualizations.mdx @@ -12,13 +12,13 @@ import { createColorValue, createOklabHueValue, createValueContext, - createSpaceValue, + createSizeValue, } from '@noodlestan/designer-decisions'; import { LayoutGrid, ShowColorChannelViz, ShowColorViz, - ShowSpaceViz, + ShowSizeViz, } from '@noodlestan/designer-shows/astro'; import { integrationAPI } from '@noodlestan/designer-integration-astro'; @@ -26,7 +26,7 @@ import { integrationAPI } from '@noodlestan/designer-integration-astro'; export const store = await integrationAPI.build(); export const colorValue = createColorValue(store.createValueContext(), '#009955'); export const colorChannelValue = createOklabHueValue(store.createValueContext(), 123); -export const spaceValue = createSpaceValue(store.createValueContext(), 100); +export const sizeValue = createSizeValue(store.createValueContext(), 100); These components render a decision's visualization directly. @@ -115,28 +115,28 @@ export const colorChannelValue = createOklabHueValue(context, 123); Space related components. -### ShowSpaceViz +### ShowSizeViz -#### ༶ `v`: [SpaceValue](/api/designer-decisions/Values/Types/SpaceValue) +#### ༶ `v`: [SizeValue](/api/designer-decisions/Values/Types/SizeValue) -#### ༶ `viz`: [SpaceVizName](/api/designer-shows/Types/SpaceVizName/) +#### ༶ `viz`: [SizeVizName](/api/designer-shows/Types/SizeVizName/) -Which space visualization to show. +Which size visualization to show. #### Example ```mdx -export const spaceValue = createSpaceValue(context, 100); +export const sizeValue = createSizeValue(context, 100); - - - - + + + + ``` - - - - + + + + diff --git a/docs/designer-decisions/src/content/docs/integrations/Astro/ShowDecision.mdx b/docs/designer-decisions/src/content/docs/integrations/Astro/ShowDecision.mdx index 66229779..8186a488 100644 --- a/docs/designer-decisions/src/content/docs/integrations/Astro/ShowDecision.mdx +++ b/docs/designer-decisions/src/content/docs/integrations/Astro/ShowDecision.mdx @@ -14,15 +14,15 @@ import { ShowDecision } from '@noodlestan/designer-shows/astro'; Renders the appropriate visualization according to the decision type. -In the following two examples we use the `` to render both a [Color Value](/models/decision-types/color-value) decision and a [Space Scale](/models/decision-types/space-scale) decision. +In the following two examples we use the `` to render both a [Color Value](/models/decision-types/color-value) decision and a [Size Scale](/models/decision-types/size-scale) decision. ```mdx - + ``` - + ## Composes diff --git a/docs/designer-decisions/src/content/docs/integrations/Astro/ShowDecisionCard.mdx b/docs/designer-decisions/src/content/docs/integrations/Astro/ShowDecisionCard.mdx index 6621881a..1d091ea9 100644 --- a/docs/designer-decisions/src/content/docs/integrations/Astro/ShowDecisionCard.mdx +++ b/docs/designer-decisions/src/content/docs/integrations/Astro/ShowDecisionCard.mdx @@ -75,10 +75,10 @@ Refer to the table on [Composable Types](/integrations/Astro/Composable/Types) f Provide this flag to hide the decision's name. ```mdx - + ``` - + ### ༶ `description` (true): boolean diff --git a/docs/designer-decisions/src/content/docs/integrations/Astro/_partials/TableDecisionComponents.astro b/docs/designer-decisions/src/content/docs/integrations/Astro/_partials/TableDecisionComponents.astro index d2ae6b14..98dffc25 100644 --- a/docs/designer-decisions/src/content/docs/integrations/Astro/_partials/TableDecisionComponents.astro +++ b/docs/designer-decisions/src/content/docs/integrations/Astro/_partials/TableDecisionComponents.astro @@ -9,16 +9,16 @@ const { domain } = Astro.props; const types = [ { - name: 'SpaceValue', - type: 'space-value', - viz: 'ShowSpaceViz', - value: 'ShowSpaceValue', + name: 'SizeValue', + type: 'size-value', + viz: 'ShowSizeViz', + value: 'ShowSizeValue', }, { - name: 'SpaceScale', - type: 'space-scale', - viz: 'ShowSpaceViz', - value: 'ShowSpaceValue', + name: 'SizeScale', + type: 'size-scale', + viz: 'ShowSizeViz', + value: 'ShowSizeValue', }, { name: 'ColorValue', diff --git a/docs/designer-decisions/src/content/docs/integrations/Astro/props.mdx b/docs/designer-decisions/src/content/docs/integrations/Astro/props.mdx index f597b98e..9bc2e5dd 100644 --- a/docs/designer-decisions/src/content/docs/integrations/Astro/props.mdx +++ b/docs/designer-decisions/src/content/docs/integrations/Astro/props.mdx @@ -116,12 +116,12 @@ Constrains the visualization to a specific size. ```mdx - + ``` - + Refer to [ShowVizSize](/api/designer-shows/Types/ShowVizSize) for available sizes. diff --git a/packages/libs/designer-decisions/resources/data/demo/space/space.json b/packages/libs/designer-decisions/resources/data/demo/space/space.json index 7bd6aa18..cc7f8b33 100644 --- a/packages/libs/designer-decisions/resources/data/demo/space/space.json +++ b/packages/libs/designer-decisions/resources/data/demo/space/space.json @@ -1,18 +1,18 @@ [ { - "model": "space-value/explicit", - "name": "Space Unit", - "description": "Base unit for space scales", + "model": "size-value/explicit", + "name": "Size Unit", + "description": "Base unit for size scales", "params": { "value": 8 } }, { - "model": "space-scale/anchored", - "name": "Layout Space Scale", - "description": "Space scale for padding and gaps in small layouts", + "model": "size-scale/anchored", + "name": "Layout Gap Scale", + "description": "Scale for padding and gaps in small layouts", "params": { - "anchor": { "$name": "Space Unit" }, + "anchor": { "$name": "Size Unit" }, "after": { "steps": 4, "modifier": { "mode": "geometric", "by": 2 } @@ -20,11 +20,11 @@ } }, { - "model": "space-scale/anchored", + "model": "size-scale/anchored", "name": "Layout Rhythm Scale", - "description": "Space scale for vertical spacing between sections or page-wide layouts", + "description": "Scale for vertical spacing between sections or page-wide layouts", "params": { - "anchor": { "$name": "Layout Space Scale", "index": 2 }, + "anchor": { "$name": "Layout Gap Scale", "index": 2 }, "after": { "steps": 3, "modifier": { "mode": "geometric", "by": 1.5 } @@ -32,11 +32,11 @@ } }, { - "model": "space-scale/anchored", - "name": "Sizing Space Scale", - "description": "Space scale for component sizing", + "model": "size-scale/anchored", + "name": "Sizing Scale", + "description": "Scale for component sizing", "params": { - "anchor": { "$name": "Layout Space Scale", "index": 2 }, + "anchor": { "$name": "Layout Gap Scale", "index": 2 }, "after": { "steps": 3, "modifier": { "mode": "geometric", "by": 1.5 } @@ -44,7 +44,7 @@ } }, { - "model": "space-value/explicit", + "model": "size-value/explicit", "name": "Textarea Maximum Height", "description": "Max height for textarea components", "params": { @@ -52,7 +52,7 @@ } }, { - "model": "space-value/explicit", + "model": "size-value/explicit", "name": "Card Thumb Minimum Size", "description": "Minimum size of thumb area in cards", "params": { @@ -60,7 +60,7 @@ } }, { - "model": "space-value/explicit", + "model": "size-value/explicit", "name": "Avatar Minimum Size", "description": "Minimum size for avatar components", "params": { @@ -68,9 +68,9 @@ } }, { - "model": "space-scale/anchored", + "model": "size-scale/anchored", "name": "Avatar Sizes", - "description": "Space scale for avatar sizes", + "description": "Scale for avatar sizes", "params": { "anchor": 50, "after": { diff --git a/packages/libs/designer-decisions/resources/data/samples/space/space-scale-anchored.json b/packages/libs/designer-decisions/resources/data/samples/space/space-scale-anchored.json index 0f348f4d..9c9272cb 100644 --- a/packages/libs/designer-decisions/resources/data/samples/space/space-scale-anchored.json +++ b/packages/libs/designer-decisions/resources/data/samples/space/space-scale-anchored.json @@ -1,7 +1,7 @@ [ { - "model": "space-scale/anchored", - "name": "Space Scale Anchored Sample", + "model": "size-scale/anchored", + "name": "Size Scale Anchored Sample", "params": { "anchor": 30, "before": { diff --git a/packages/libs/designer-decisions/resources/data/samples/space/space-scale-bounded.json b/packages/libs/designer-decisions/resources/data/samples/space/space-scale-bounded.json index ba5d2466..815b4080 100644 --- a/packages/libs/designer-decisions/resources/data/samples/space/space-scale-bounded.json +++ b/packages/libs/designer-decisions/resources/data/samples/space/space-scale-bounded.json @@ -1,7 +1,7 @@ [ { - "model": "space-scale/bounded", - "name": "Space Scale Bounded Sample", + "model": "size-scale/bounded", + "name": "Size Scale Bounded Sample", "params": { "from": 25, "to": 200, diff --git a/packages/libs/designer-decisions/resources/data/samples/space/space-scale-explicit.json b/packages/libs/designer-decisions/resources/data/samples/space/space-scale-explicit.json index 7e258d81..b319bde1 100644 --- a/packages/libs/designer-decisions/resources/data/samples/space/space-scale-explicit.json +++ b/packages/libs/designer-decisions/resources/data/samples/space/space-scale-explicit.json @@ -1,7 +1,7 @@ [ { - "model": "space-scale/explicit", - "name": "Space Scale Explicit Sample", + "model": "size-scale/explicit", + "name": "Size Scale Explicit Sample", "params": { "values": [5, 10, 15, 20, 30, 50] } diff --git a/packages/libs/designer-decisions/resources/data/samples/space/space-value-explicit.json b/packages/libs/designer-decisions/resources/data/samples/space/space-value-explicit.json index 89ac43e9..490cc1f8 100644 --- a/packages/libs/designer-decisions/resources/data/samples/space/space-value-explicit.json +++ b/packages/libs/designer-decisions/resources/data/samples/space/space-value-explicit.json @@ -1,9 +1,12 @@ [ { - "model": "space-value/explicit", - "name": "Space Value Explicit Sample", + "model": "size-value/explicit", + "name": "Size Value Explicit Sample", "params": { - "value": 5 + "value": { + "value": 12, + "units": "rem" + } } } ] diff --git a/packages/libs/designer-decisions/src/constants/decisions.ts b/packages/libs/designer-decisions/src/constants/decisions.ts index e2fdd348..34d3bd6b 100644 --- a/packages/libs/designer-decisions/src/constants/decisions.ts +++ b/packages/libs/designer-decisions/src/constants/decisions.ts @@ -13,8 +13,8 @@ export const DECISION_COLOR_SRGB_LIGHTNESS_SCALE = 'color-srgb-lightness-scale'; export const DECISION_COLOR_SRGB_SATURATION_VALUE = 'color-srgb-saturation-value'; export const DECISION_COLOR_SRGB_SATURATION_SCALE = 'color-srgb-saturation-scale'; -export const DECISION_SPACE_SCALE = 'space-scale'; -export const DECISION_SPACE_VALUE = 'space-value'; +export const DECISION_SIZE_SCALE = 'size-scale'; +export const DECISION_SIZE_VALUE = 'size-value'; export const DECISION_TYPEFACE_VALUE = 'typeface-value'; @@ -26,5 +26,5 @@ export const SET_DECISION_TYPES = [ DECISION_COLOR_SRGB_HUE_SET, DECISION_COLOR_SRGB_LIGHTNESS_SCALE, DECISION_COLOR_SRGB_SATURATION_SCALE, - DECISION_SPACE_SCALE, + DECISION_SIZE_SCALE, ]; diff --git a/packages/libs/designer-decisions/src/decision/domains/decisionTypeAssertions.test.ts b/packages/libs/designer-decisions/src/decision/domains/decisionTypeAssertions.test.ts index 24fab8ba..434ae78c 100644 --- a/packages/libs/designer-decisions/src/decision/domains/decisionTypeAssertions.test.ts +++ b/packages/libs/designer-decisions/src/decision/domains/decisionTypeAssertions.test.ts @@ -15,8 +15,8 @@ import { DECISION_COLOR_SRGB_SATURATION_SCALE, DECISION_COLOR_SRGB_SATURATION_VALUE, DECISION_COLOR_VALUE, - DECISION_SPACE_SCALE, - DECISION_SPACE_VALUE, + DECISION_SIZE_SCALE, + DECISION_SIZE_VALUE, DECISION_TYPEFACE_VALUE, } from '../../constants'; import type { DecisionUnknown } from '../types'; @@ -37,7 +37,7 @@ import { isColorSetDecision, isColorValueDecision, } from './color'; -import { isSpaceScaleDecision, isSpaceValueDecision } from './space'; +import { isSizeScaleDecision, isSizeValueDecision } from './space'; import { isTypefaceValueDecision } from './typography'; const testCases = [ @@ -112,14 +112,14 @@ const testCases = [ type: DECISION_COLOR_VALUE, }, { - name: 'isSpaceScaleDecision', - fn: isSpaceScaleDecision, - type: DECISION_SPACE_SCALE, + name: 'isSizeScaleDecision', + fn: isSizeScaleDecision, + type: DECISION_SIZE_SCALE, }, { - name: 'isSpaceValueDecision', - fn: isSpaceValueDecision, - type: DECISION_SPACE_VALUE, + name: 'isSizeValueDecision', + fn: isSizeValueDecision, + type: DECISION_SIZE_VALUE, }, { name: 'isTypefaceValueDecision', diff --git a/packages/libs/designer-decisions/src/decision/domains/space/index.ts b/packages/libs/designer-decisions/src/decision/domains/space/index.ts index b1da4147..c72e3aea 100644 --- a/packages/libs/designer-decisions/src/decision/domains/space/index.ts +++ b/packages/libs/designer-decisions/src/decision/domains/space/index.ts @@ -1,4 +1,4 @@ // @index(['./*.ts', '!./*.test.ts', './!(private|mocks|functions)*/index.ts'], f => `export * from '${f.path.replace(/\/index$/, '')}';`) -export * from './isSpaceScaleDecision'; -export * from './isSpaceValueDecision'; +export * from './isSizeScaleDecision'; +export * from './isSizeValueDecision'; export * from './types'; diff --git a/packages/libs/designer-decisions/src/decision/domains/space/isSizeScaleDecision.ts b/packages/libs/designer-decisions/src/decision/domains/space/isSizeScaleDecision.ts new file mode 100644 index 00000000..14fdd59d --- /dev/null +++ b/packages/libs/designer-decisions/src/decision/domains/space/isSizeScaleDecision.ts @@ -0,0 +1,8 @@ +import { DECISION_SIZE_SCALE } from '../../../constants'; +import type { DecisionUnknown } from '../../types'; + +import type { SizeScaleDecision } from './types'; + +export const isSizeScaleDecision = (decision: DecisionUnknown): decision is SizeScaleDecision => { + return decision.type() === DECISION_SIZE_SCALE; +}; diff --git a/packages/libs/designer-decisions/src/decision/domains/space/isSizeValueDecision.ts b/packages/libs/designer-decisions/src/decision/domains/space/isSizeValueDecision.ts new file mode 100644 index 00000000..eaabcf07 --- /dev/null +++ b/packages/libs/designer-decisions/src/decision/domains/space/isSizeValueDecision.ts @@ -0,0 +1,8 @@ +import { DECISION_SIZE_VALUE } from '../../../constants'; +import type { DecisionUnknown } from '../../types'; + +import type { SizeValueDecision } from './types'; + +export const isSizeValueDecision = (decision: DecisionUnknown): decision is SizeValueDecision => { + return decision.type() === DECISION_SIZE_VALUE; +}; diff --git a/packages/libs/designer-decisions/src/decision/domains/space/isSpaceScaleDecision.ts b/packages/libs/designer-decisions/src/decision/domains/space/isSpaceScaleDecision.ts deleted file mode 100644 index 6841ff44..00000000 --- a/packages/libs/designer-decisions/src/decision/domains/space/isSpaceScaleDecision.ts +++ /dev/null @@ -1,8 +0,0 @@ -import { DECISION_SPACE_SCALE } from '../../../constants'; -import type { DecisionUnknown } from '../../types'; - -import type { SpaceScaleDecision } from './types'; - -export const isSpaceScaleDecision = (decision: DecisionUnknown): decision is SpaceScaleDecision => { - return decision.type() === DECISION_SPACE_SCALE; -}; diff --git a/packages/libs/designer-decisions/src/decision/domains/space/isSpaceValueDecision.ts b/packages/libs/designer-decisions/src/decision/domains/space/isSpaceValueDecision.ts deleted file mode 100644 index f01a34d6..00000000 --- a/packages/libs/designer-decisions/src/decision/domains/space/isSpaceValueDecision.ts +++ /dev/null @@ -1,8 +0,0 @@ -import { DECISION_SPACE_VALUE } from '../../../constants'; -import type { DecisionUnknown } from '../../types'; - -import type { SpaceValueDecision } from './types'; - -export const isSpaceValueDecision = (decision: DecisionUnknown): decision is SpaceValueDecision => { - return decision.type() === DECISION_SPACE_VALUE; -}; diff --git a/packages/libs/designer-decisions/src/decision/domains/space/types/scale.ts b/packages/libs/designer-decisions/src/decision/domains/space/types/scale.ts index a165a377..51491467 100644 --- a/packages/libs/designer-decisions/src/decision/domains/space/types/scale.ts +++ b/packages/libs/designer-decisions/src/decision/domains/space/types/scale.ts @@ -1,4 +1,4 @@ -import type { SpaceScale } from '../../../../values'; +import type { SizeScale } from '../../../../values'; import type { Decision } from '../../../types'; -export type SpaceScaleDecision = Decision; +export type SizeScaleDecision = Decision; diff --git a/packages/libs/designer-decisions/src/decision/domains/space/types/value.ts b/packages/libs/designer-decisions/src/decision/domains/space/types/value.ts index 21a433d2..ebb1d605 100644 --- a/packages/libs/designer-decisions/src/decision/domains/space/types/value.ts +++ b/packages/libs/designer-decisions/src/decision/domains/space/types/value.ts @@ -1,4 +1,4 @@ -import type { SpaceValue } from '../../../../values'; +import type { SizeValue } from '../../../../values'; import type { Decision } from '../../../types'; -export type SpaceValueDecision = Decision; +export type SizeValueDecision = Decision; diff --git a/packages/libs/designer-decisions/src/errors/serializeErrorData.ts b/packages/libs/designer-decisions/src/errors/serializeErrorData.ts index 1165076b..db5bb555 100644 --- a/packages/libs/designer-decisions/src/errors/serializeErrorData.ts +++ b/packages/libs/designer-decisions/src/errors/serializeErrorData.ts @@ -1,6 +1,6 @@ -export function serializeErrorData(data: unknown, space: number = 2): string { +export function serializeErrorData(data: unknown, spaces: number = 2): string { const type = typeof data; - const str = JSON.stringify(data, undefined, space) || ''; + const str = JSON.stringify(data, undefined, spaces) || ''; const truncated = str.length > 200 ? str.substring(0, 200) + '\n ... (truncated)' : str; return `[${type}] ${truncated}`; } diff --git a/packages/libs/designer-decisions/src/inputs/types/models/space/set.ts b/packages/libs/designer-decisions/src/inputs/types/models/space/set.ts index d776a093..92853682 100644 --- a/packages/libs/designer-decisions/src/inputs/types/models/space/set.ts +++ b/packages/libs/designer-decisions/src/inputs/types/models/space/set.ts @@ -1,26 +1,26 @@ -import type { AnchoredNumberSeriesParams, DecisionInput, SpaceValueInput } from '../../primitives'; +import type { AnchoredNumberSeriesParams, DecisionInput, SizeValueInput } from '../../primitives'; -export type SpaceScaleExplicitInput = DecisionInput & { - model: 'space-scale/explicit'; +export type SizeScaleExplicitInput = DecisionInput & { + model: 'size-scale/explicit'; params: { - values: SpaceValueInput[]; + values: SizeValueInput[]; quantize?: number; }; }; -export type SpaceScaleBoundedInput = DecisionInput & { - model: 'space-scale/bounded'; +export type SizeScaleBoundedInput = DecisionInput & { + model: 'size-scale/bounded'; params: { - from: SpaceValueInput; - to: SpaceValueInput; + from: SizeValueInput; + to: SizeValueInput; steps: number; quantize?: number; }; }; -export type SpaceScaleAnchoredInput = DecisionInput & { - model: 'space-scale/anchored'; +export type SizeScaleAnchoredInput = DecisionInput & { + model: 'size-scale/anchored'; params: { - anchor: SpaceValueInput; + anchor: SizeValueInput; } & AnchoredNumberSeriesParams; }; diff --git a/packages/libs/designer-decisions/src/inputs/types/models/space/value.ts b/packages/libs/designer-decisions/src/inputs/types/models/space/value.ts index 81c2902a..8122b723 100644 --- a/packages/libs/designer-decisions/src/inputs/types/models/space/value.ts +++ b/packages/libs/designer-decisions/src/inputs/types/models/space/value.ts @@ -1,9 +1,9 @@ -import type { DecisionInput, SpaceValueInput } from '../../primitives'; +import type { DecisionInput, SizeValueInput } from '../../primitives'; -export type SpaceValueExplicitInput = DecisionInput & { - model: 'space-value/explicit'; +export type SizeValueExplicitInput = DecisionInput & { + model: 'size-value/explicit'; params: { - value: SpaceValueInput; + value: SizeValueInput; quantize?: number; }; }; diff --git a/packages/libs/designer-decisions/src/inputs/types/primitives/space/index.ts b/packages/libs/designer-decisions/src/inputs/types/primitives/space/index.ts index b77c54c2..3eb035dd 100644 --- a/packages/libs/designer-decisions/src/inputs/types/primitives/space/index.ts +++ b/packages/libs/designer-decisions/src/inputs/types/primitives/space/index.ts @@ -1,2 +1,2 @@ // @index(['./*.ts', '!./*.test.ts', './!(private|mocks|functions)*/index.ts'], f => `export * from '${f.path.replace(/\/index$/, '')}';`) -export * from './space'; +export * from './size'; diff --git a/packages/libs/designer-decisions/src/inputs/types/primitives/space/size.ts b/packages/libs/designer-decisions/src/inputs/types/primitives/space/size.ts new file mode 100644 index 00000000..1fd62b07 --- /dev/null +++ b/packages/libs/designer-decisions/src/inputs/types/primitives/space/size.ts @@ -0,0 +1,13 @@ +import type { DecisionRef } from '../ref'; + +export type SizeRaw = string | number; + +export type SizeAbsoluteUnits = 'px' | 'rem'; + +export type SizeObjectLiteral = { + value: number; + units: SizeAbsoluteUnits; +}; +export type SizeLiteral = SizeRaw | SizeObjectLiteral; + +export type SizeValueInput = DecisionRef | SizeLiteral; diff --git a/packages/libs/designer-decisions/src/inputs/types/primitives/space/space.ts b/packages/libs/designer-decisions/src/inputs/types/primitives/space/space.ts deleted file mode 100644 index dfe11b3d..00000000 --- a/packages/libs/designer-decisions/src/inputs/types/primitives/space/space.ts +++ /dev/null @@ -1,23 +0,0 @@ -/** space */ - -import type { DecisionRef } from '../ref'; - -export type SpaceScaleRef = DecisionRef & { - $subset: - | number[] - | { - start: number; - count: number; - }; -}; - -export type SpaceRaw = string | number; - -export type SpaceUnits = 'px' | 'em' | 'rem'; - -export type SpaceWithUnits = { - value: number; - units: SpaceUnits; -}; - -export type SpaceValueInput = DecisionRef | SpaceRaw | SpaceWithUnits; diff --git a/packages/libs/designer-decisions/src/meta/domains/space/index.ts b/packages/libs/designer-decisions/src/meta/domains/space/index.ts index b77c54c2..3eb035dd 100644 --- a/packages/libs/designer-decisions/src/meta/domains/space/index.ts +++ b/packages/libs/designer-decisions/src/meta/domains/space/index.ts @@ -1,2 +1,2 @@ // @index(['./*.ts', '!./*.test.ts', './!(private|mocks|functions)*/index.ts'], f => `export * from '${f.path.replace(/\/index$/, '')}';`) -export * from './space'; +export * from './size'; diff --git a/packages/libs/designer-decisions/src/meta/domains/space/size.ts b/packages/libs/designer-decisions/src/meta/domains/space/size.ts new file mode 100644 index 00000000..df59142d --- /dev/null +++ b/packages/libs/designer-decisions/src/meta/domains/space/size.ts @@ -0,0 +1,58 @@ +import { DECISION_SIZE_SCALE, DECISION_SIZE_VALUE } from '../../../constants'; +import { + MODEL_TYPE_ANCHORED, + MODEL_TYPE_BOUNDED, + MODEL_TYPE_EXPLICIT, + createSizeScaleAnchoredModel, + createSizeScaleBoundedModel, + createSizeScaleExplicitModel, + createSizeValueExplicitModel, +} from '../../../models'; +import { castFactory } from '../../functions'; +import type { DecisionType } from '../../types'; + +export const SizeDecisionTypes: DecisionType[] = [ + { + type: DECISION_SIZE_VALUE, + name: 'Size Value', + category: 'value', + domain: 'space', + description: 'A decision to define a size value.', + models: [ + { + model: MODEL_TYPE_EXPLICIT, + name: 'Explicit value', + description: 'Defines a size value explicitly.', + factory: castFactory(createSizeValueExplicitModel), + }, + ], + }, + { + type: DECISION_SIZE_SCALE, + name: 'Size Scale', + category: 'scale', + domain: 'space', + description: 'A decision to define a size scale.', + models: [ + { + model: MODEL_TYPE_EXPLICIT, + name: 'Explicit value', + description: 'Defines a size scale with arbitrary size values.', + factory: castFactory(createSizeScaleExplicitModel), + }, + { + model: MODEL_TYPE_BOUNDED, + name: 'Bounded', + description: 'Defines a size scale interpolating linearly between two size values.', + factory: castFactory(createSizeScaleBoundedModel), + }, + { + model: MODEL_TYPE_ANCHORED, + name: 'Anchored', + description: + 'Defines a size scale from an anchor value applying modifiers to generate items before and/or after the anchor .', + factory: castFactory(createSizeScaleAnchoredModel), + }, + ], + }, +]; diff --git a/packages/libs/designer-decisions/src/meta/domains/space/space.ts b/packages/libs/designer-decisions/src/meta/domains/space/space.ts deleted file mode 100644 index 4ce2939d..00000000 --- a/packages/libs/designer-decisions/src/meta/domains/space/space.ts +++ /dev/null @@ -1,59 +0,0 @@ -import { DECISION_SPACE_SCALE, DECISION_SPACE_VALUE } from '../../../constants'; -import { - MODEL_TYPE_ANCHORED, - MODEL_TYPE_BOUNDED, - MODEL_TYPE_EXPLICIT, - createSpaceScaleAnchoredModel, - createSpaceScaleBoundedModel, - createSpaceScaleExplicitModel, - createSpaceValueExplicitModel, -} from '../../../models'; -import { castFactory } from '../../functions'; -import type { DecisionType } from '../../types'; - -export const SpaceDecisionTypes: DecisionType[] = [ - { - type: DECISION_SPACE_VALUE, - name: 'Space Value', - category: 'value', - domain: 'space', - description: 'A decision to define a space value.', - models: [ - { - model: MODEL_TYPE_EXPLICIT, - name: 'Explicit value', - description: 'Defines a space value explicitly.', - factory: castFactory(createSpaceValueExplicitModel), - }, - ], - }, - { - type: DECISION_SPACE_SCALE, - name: 'Space Scale', - category: 'scale', - domain: 'space', - description: 'A decision to define a space scale.', - models: [ - { - model: MODEL_TYPE_EXPLICIT, - name: 'Explicit value', - description: 'Defines a space scale with arbitrary space values.', - factory: castFactory(createSpaceScaleExplicitModel), - }, - { - model: MODEL_TYPE_BOUNDED, - name: 'Bounded', - description: - 'Defines a space scale interpolating linearly between two space values.', - factory: castFactory(createSpaceScaleBoundedModel), - }, - { - model: MODEL_TYPE_ANCHORED, - name: 'Anchored', - description: - 'Defines a space scale from an anchor value applying modifiers to generate items before and/or after the anchor .', - factory: castFactory(createSpaceScaleAnchoredModel), - }, - ], - }, -]; diff --git a/packages/libs/designer-decisions/src/meta/index.ts b/packages/libs/designer-decisions/src/meta/index.ts index eb7abe65..9147f224 100644 --- a/packages/libs/designer-decisions/src/meta/index.ts +++ b/packages/libs/designer-decisions/src/meta/index.ts @@ -1,11 +1,11 @@ -import { ColorDecisionTypes, SpaceDecisionTypes, TypeDecisionTypes } from './domains'; +import { ColorDecisionTypes, SizeDecisionTypes, TypeDecisionTypes } from './domains'; import { createDecisionModelMetas, createDecisionTypeMeta } from './functions'; export * from './data'; export * from './schemas'; export * from './types'; -export const DECISION_TYPES = [...ColorDecisionTypes, ...SpaceDecisionTypes, ...TypeDecisionTypes]; +export const DECISION_TYPES = [...ColorDecisionTypes, ...SizeDecisionTypes, ...TypeDecisionTypes]; export const DECISION_TYPE_METAS = DECISION_TYPES.map(createDecisionTypeMeta); export const DECISION_MODEL_METAS = DECISION_TYPES.flatMap(createDecisionModelMetas); diff --git a/packages/libs/designer-decisions/src/models/space/index.ts b/packages/libs/designer-decisions/src/models/space/index.ts index b26bd9b4..22487612 100644 --- a/packages/libs/designer-decisions/src/models/space/index.ts +++ b/packages/libs/designer-decisions/src/models/space/index.ts @@ -1,3 +1,3 @@ // @index(['./*.ts', '!./*.test.ts', './!(private|mocks|functions)*/index.ts'], f => `export * from '${f.path.replace(/\/index$/, '')}';`) -export * from './space-scale'; -export * from './space-value'; +export * from './size-scale'; +export * from './size-value'; diff --git a/packages/libs/designer-decisions/src/models/space/space-scale/createSpaceScaleAnchoredModel.test.ts b/packages/libs/designer-decisions/src/models/space/size-scale/createSizeScaleAnchoredModel.test.ts similarity index 82% rename from packages/libs/designer-decisions/src/models/space/space-scale/createSpaceScaleAnchoredModel.test.ts rename to packages/libs/designer-decisions/src/models/space/size-scale/createSizeScaleAnchoredModel.test.ts index f8391776..81025c01 100644 --- a/packages/libs/designer-decisions/src/models/space/space-scale/createSpaceScaleAnchoredModel.test.ts +++ b/packages/libs/designer-decisions/src/models/space/size-scale/createSizeScaleAnchoredModel.test.ts @@ -1,17 +1,17 @@ import { describe, expect, it } from 'vitest'; -import type { SpaceScaleAnchoredInput } from '../../../inputs'; +import type { SizeScaleAnchoredInput } from '../../../inputs'; import { createValueContextMock } from '../../../mocks'; -import { createSpaceScaleAnchoredModel } from './createSpaceScaleAnchoredModel'; +import { createSizeScaleAnchoredModel } from './createSizeScaleAnchoredModel'; -describe('createSpaceScaleAnchoredModel()', () => { - const model = createSpaceScaleAnchoredModel(); +describe('createSizeScaleAnchoredModel()', () => { + const model = createSizeScaleAnchoredModel(); describe('Given a context and params', () => { const [mockContext] = createValueContextMock(); const expectedLength = 6; - const params: SpaceScaleAnchoredInput['params'] = { + const params: SizeScaleAnchoredInput['params'] = { anchor: 50, before: { steps: 2, @@ -41,7 +41,7 @@ describe('createSpaceScaleAnchoredModel()', () => { describe('Given a quantize param', () => { const [mockContext] = createValueContextMock(); - const params: SpaceScaleAnchoredInput['params'] = { + const params: SizeScaleAnchoredInput['params'] = { anchor: 50, before: { steps: 2, diff --git a/packages/libs/designer-decisions/src/models/space/size-scale/createSizeScaleAnchoredModel.ts b/packages/libs/designer-decisions/src/models/space/size-scale/createSizeScaleAnchoredModel.ts new file mode 100644 index 00000000..c8c11ca1 --- /dev/null +++ b/packages/libs/designer-decisions/src/models/space/size-scale/createSizeScaleAnchoredModel.ts @@ -0,0 +1,31 @@ +import type { SizeScaleAnchoredInput } from '../../../inputs'; +import { + type SizeScale, + createSizeScale, + createSizeValue, + generateAnchoredSeries, +} from '../../../values'; +import type { DecisionModelFactory } from '../../types'; + +export const createSizeScaleAnchoredModel: DecisionModelFactory< + SizeScale, + SizeScaleAnchoredInput +> = () => { + return { + produce: (context, params) => { + const { quantize } = params; + + const anchorValue = createSizeValue(context.nestedContext(), params.anchor, { + quantize, + }); + const { value: anchor } = anchorValue.toObject(); + + const series = generateAnchoredSeries(anchor, params); + const values = series.map(size => + createSizeValue(context.nestedContext(), size, { quantize }), + ); + + return createSizeScale(context, values); + }, + }; +}; diff --git a/packages/libs/designer-decisions/src/models/space/space-scale/createSpaceScaleBoundedModel.test.ts b/packages/libs/designer-decisions/src/models/space/size-scale/createSizeScaleBoundedModel.test.ts similarity index 79% rename from packages/libs/designer-decisions/src/models/space/space-scale/createSpaceScaleBoundedModel.test.ts rename to packages/libs/designer-decisions/src/models/space/size-scale/createSizeScaleBoundedModel.test.ts index a6c5a3d7..a4ad85fa 100644 --- a/packages/libs/designer-decisions/src/models/space/space-scale/createSpaceScaleBoundedModel.test.ts +++ b/packages/libs/designer-decisions/src/models/space/size-scale/createSizeScaleBoundedModel.test.ts @@ -1,17 +1,17 @@ import { describe, expect, it } from 'vitest'; -import type { SpaceScaleBoundedInput } from '../../../inputs'; +import type { SizeScaleBoundedInput } from '../../../inputs'; import { createValueContextMock } from '../../../mocks'; -import { createSpaceScaleBoundedModel } from './createSpaceScaleBoundedModel'; +import { createSizeScaleBoundedModel } from './createSizeScaleBoundedModel'; -describe('createSpaceScaleBoundedModel()', () => { - const model = createSpaceScaleBoundedModel(); +describe('createSizeScaleBoundedModel()', () => { + const model = createSizeScaleBoundedModel(); describe('Given a context and params', () => { const [mockContext] = createValueContextMock(); const expectedLength = 3; - const params: SpaceScaleBoundedInput['params'] = { + const params: SizeScaleBoundedInput['params'] = { from: 10, to: 12.25, steps: expectedLength - 2, @@ -35,7 +35,7 @@ describe('createSpaceScaleBoundedModel()', () => { describe('Given a quantize param', () => { const [mockContext] = createValueContextMock(); - const params: SpaceScaleBoundedInput['params'] = { + const params: SizeScaleBoundedInput['params'] = { from: 10, to: 12.25, steps: 1, diff --git a/packages/libs/designer-decisions/src/models/space/size-scale/createSizeScaleBoundedModel.ts b/packages/libs/designer-decisions/src/models/space/size-scale/createSizeScaleBoundedModel.ts new file mode 100644 index 00000000..058ab8b4 --- /dev/null +++ b/packages/libs/designer-decisions/src/models/space/size-scale/createSizeScaleBoundedModel.ts @@ -0,0 +1,32 @@ +import type { SizeScaleBoundedInput } from '../../../inputs'; +import { + type SizeScale, + createSizeScale, + createSizeValue, + generateBoundedSeries, +} from '../../../values'; +import type { DecisionModelFactory } from '../../types'; + +export const createSizeScaleBoundedModel: DecisionModelFactory< + SizeScale, + SizeScaleBoundedInput +> = () => { + return { + produce: (context, params) => { + const { quantize } = params; + + const fromValue = createSizeValue(context.nestedContext(), params.from, { quantize }); + const toValue = createSizeValue(context.nestedContext(), params.to, { quantize }); + + const { value: from } = fromValue.toObject(); + const { value: to } = toValue.toObject(); + + const series = generateBoundedSeries(from, to, params.steps); + const values = series + .slice(1, series.length - 1) + .map(item => createSizeValue(context.nestedContext(), item, { quantize })); + + return createSizeScale(context, [fromValue, ...values, toValue]); + }, + }; +}; diff --git a/packages/libs/designer-decisions/src/models/space/space-scale/createSpaceScaleExplicitModel.test.ts b/packages/libs/designer-decisions/src/models/space/size-scale/createSizeScaleExplicitModel.test.ts similarity index 80% rename from packages/libs/designer-decisions/src/models/space/space-scale/createSpaceScaleExplicitModel.test.ts rename to packages/libs/designer-decisions/src/models/space/size-scale/createSizeScaleExplicitModel.test.ts index 87047a19..9d14c39d 100644 --- a/packages/libs/designer-decisions/src/models/space/space-scale/createSpaceScaleExplicitModel.test.ts +++ b/packages/libs/designer-decisions/src/models/space/size-scale/createSizeScaleExplicitModel.test.ts @@ -1,16 +1,16 @@ import { describe, expect, it } from 'vitest'; -import type { SpaceScaleExplicitInput } from '../../../inputs'; +import type { SizeScaleExplicitInput } from '../../../inputs'; import { createValueContextMock } from '../../../mocks'; -import { createSpaceScaleExplicitModel } from './createSpaceScaleExplicitModel'; +import { createSizeScaleExplicitModel } from './createSizeScaleExplicitModel'; -describe('createSpaceScaleExplicitModel()', () => { - const model = createSpaceScaleExplicitModel(); +describe('createSizeScaleExplicitModel()', () => { + const model = createSizeScaleExplicitModel(); describe('Given a context and params', () => { const [mockContext] = createValueContextMock(); - const params: SpaceScaleExplicitInput['params'] = { + const params: SizeScaleExplicitInput['params'] = { values: [32.111, 64, 128], }; @@ -32,7 +32,7 @@ describe('createSpaceScaleExplicitModel()', () => { describe('Given a quantize param', () => { const [mockContext] = createValueContextMock(); - const params: SpaceScaleExplicitInput['params'] = { + const params: SizeScaleExplicitInput['params'] = { values: [32.111, 63, 127], quantize: 2, }; diff --git a/packages/libs/designer-decisions/src/models/space/size-scale/createSizeScaleExplicitModel.ts b/packages/libs/designer-decisions/src/models/space/size-scale/createSizeScaleExplicitModel.ts new file mode 100644 index 00000000..dab34453 --- /dev/null +++ b/packages/libs/designer-decisions/src/models/space/size-scale/createSizeScaleExplicitModel.ts @@ -0,0 +1,20 @@ +import type { SizeScaleExplicitInput } from '../../../inputs'; +import { type SizeScale, createSizeScale, createSizeValue } from '../../../values'; +import type { DecisionModelFactory } from '../../types'; + +export const createSizeScaleExplicitModel: DecisionModelFactory< + SizeScale, + SizeScaleExplicitInput +> = () => { + return { + produce: (context, params) => { + const { quantize } = params; + + const values = params.values.map(value => + createSizeValue(context.nestedContext(), value, { quantize }), + ); + + return createSizeScale(context, values); + }, + }; +}; diff --git a/packages/libs/designer-decisions/src/models/space/size-scale/index.ts b/packages/libs/designer-decisions/src/models/space/size-scale/index.ts new file mode 100644 index 00000000..bda6db70 --- /dev/null +++ b/packages/libs/designer-decisions/src/models/space/size-scale/index.ts @@ -0,0 +1,4 @@ +// @index(['./*.ts', '!./*.test.ts', './!(private|mocks|functions)*/index.ts'], f => `export * from '${f.path.replace(/\/index$/, '')}';`) +export * from './createSizeScaleAnchoredModel'; +export * from './createSizeScaleBoundedModel'; +export * from './createSizeScaleExplicitModel'; diff --git a/packages/libs/designer-decisions/src/models/space/space-value/createSpaceValueExplicitModel.test.ts b/packages/libs/designer-decisions/src/models/space/size-value/createSizeValueExplicitModel.test.ts similarity index 68% rename from packages/libs/designer-decisions/src/models/space/space-value/createSpaceValueExplicitModel.test.ts rename to packages/libs/designer-decisions/src/models/space/size-value/createSizeValueExplicitModel.test.ts index 397d0cf3..d16680c9 100644 --- a/packages/libs/designer-decisions/src/models/space/space-value/createSpaceValueExplicitModel.test.ts +++ b/packages/libs/designer-decisions/src/models/space/size-value/createSizeValueExplicitModel.test.ts @@ -1,16 +1,16 @@ import { describe, expect, it } from 'vitest'; -import type { SpaceValueExplicitInput } from '../../../inputs'; +import type { SizeValueExplicitInput } from '../../../inputs'; import { createValueContextMock } from '../../../mocks'; -import { createSpaceValueExplicitModel } from './createSpaceValueExplicitModel'; +import { createSizeValueExplicitModel } from './createSizeValueExplicitModel'; -describe('createSpaceValueExplicitModel()', () => { - const model = createSpaceValueExplicitModel(); +describe('createSizeValueExplicitModel()', () => { + const model = createSizeValueExplicitModel(); describe('Given a context and params', () => { const [mockContext] = createValueContextMock(); - const params: SpaceValueExplicitInput['params'] = { + const params: SizeValueExplicitInput['params'] = { value: 2.111, }; @@ -23,7 +23,7 @@ describe('createSpaceValueExplicitModel()', () => { describe('Given a quantize param', () => { const [mockContext] = createValueContextMock(); - const params: SpaceValueExplicitInput['params'] = { + const params: SizeValueExplicitInput['params'] = { value: 2.111, quantize: 4, }; diff --git a/packages/libs/designer-decisions/src/models/space/size-value/createSizeValueExplicitModel.ts b/packages/libs/designer-decisions/src/models/space/size-value/createSizeValueExplicitModel.ts new file mode 100644 index 00000000..26bc078b --- /dev/null +++ b/packages/libs/designer-decisions/src/models/space/size-value/createSizeValueExplicitModel.ts @@ -0,0 +1,15 @@ +import type { SizeValueExplicitInput } from '../../../inputs'; +import { type SizeValue, createSizeValue } from '../../../values'; +import type { DecisionModelFactory } from '../../types'; + +export const createSizeValueExplicitModel: DecisionModelFactory< + SizeValue, + SizeValueExplicitInput +> = () => { + return { + produce: (context, params) => { + const { quantize } = params; + return createSizeValue(context, params.value, { quantize }); + }, + }; +}; diff --git a/packages/libs/designer-decisions/src/models/space/space-value/index.ts b/packages/libs/designer-decisions/src/models/space/size-value/index.ts similarity index 73% rename from packages/libs/designer-decisions/src/models/space/space-value/index.ts rename to packages/libs/designer-decisions/src/models/space/size-value/index.ts index 945fa379..63661425 100644 --- a/packages/libs/designer-decisions/src/models/space/space-value/index.ts +++ b/packages/libs/designer-decisions/src/models/space/size-value/index.ts @@ -1,2 +1,2 @@ // @index(['./*.ts', '!./*.test.ts', './!(private|mocks|functions)*/index.ts'], f => `export * from '${f.path.replace(/\/index$/, '')}';`) -export * from './createSpaceValueExplicitModel'; +export * from './createSizeValueExplicitModel'; diff --git a/packages/libs/designer-decisions/src/models/space/space-scale/createSpaceScaleAnchoredModel.ts b/packages/libs/designer-decisions/src/models/space/space-scale/createSpaceScaleAnchoredModel.ts deleted file mode 100644 index 324fe466..00000000 --- a/packages/libs/designer-decisions/src/models/space/space-scale/createSpaceScaleAnchoredModel.ts +++ /dev/null @@ -1,31 +0,0 @@ -import type { SpaceScaleAnchoredInput } from '../../../inputs'; -import { - type SpaceScale, - createSpaceScale, - createSpaceValue, - generateAnchoredSeries, -} from '../../../values'; -import type { DecisionModelFactory } from '../../types'; - -export const createSpaceScaleAnchoredModel: DecisionModelFactory< - SpaceScale, - SpaceScaleAnchoredInput -> = () => { - return { - produce: (context, params) => { - const { quantize } = params; - - const anchorValue = createSpaceValue(context.nestedContext(), params.anchor, { - quantize, - }); - const { value: anchor } = anchorValue.toObject(); - - const series = generateAnchoredSeries(anchor, params); - const values = series.map(space => - createSpaceValue(context.nestedContext(), space, { quantize }), - ); - - return createSpaceScale(context, values); - }, - }; -}; diff --git a/packages/libs/designer-decisions/src/models/space/space-scale/createSpaceScaleBoundedModel.ts b/packages/libs/designer-decisions/src/models/space/space-scale/createSpaceScaleBoundedModel.ts deleted file mode 100644 index 3a2695b3..00000000 --- a/packages/libs/designer-decisions/src/models/space/space-scale/createSpaceScaleBoundedModel.ts +++ /dev/null @@ -1,32 +0,0 @@ -import type { SpaceScaleBoundedInput } from '../../../inputs'; -import { - type SpaceScale, - createSpaceScale, - createSpaceValue, - generateBoundedSeries, -} from '../../../values'; -import type { DecisionModelFactory } from '../../types'; - -export const createSpaceScaleBoundedModel: DecisionModelFactory< - SpaceScale, - SpaceScaleBoundedInput -> = () => { - return { - produce: (context, params) => { - const { quantize } = params; - - const fromValue = createSpaceValue(context.nestedContext(), params.from, { quantize }); - const toValue = createSpaceValue(context.nestedContext(), params.to, { quantize }); - - const { value: from } = fromValue.toObject(); - const { value: to } = toValue.toObject(); - - const series = generateBoundedSeries(from, to, params.steps); - const values = series - .slice(1, series.length - 1) - .map(item => createSpaceValue(context.nestedContext(), item, { quantize })); - - return createSpaceScale(context, [fromValue, ...values, toValue]); - }, - }; -}; diff --git a/packages/libs/designer-decisions/src/models/space/space-scale/createSpaceScaleExplicitModel.ts b/packages/libs/designer-decisions/src/models/space/space-scale/createSpaceScaleExplicitModel.ts deleted file mode 100644 index ecc543ee..00000000 --- a/packages/libs/designer-decisions/src/models/space/space-scale/createSpaceScaleExplicitModel.ts +++ /dev/null @@ -1,20 +0,0 @@ -import type { SpaceScaleExplicitInput } from '../../../inputs'; -import { type SpaceScale, createSpaceScale, createSpaceValue } from '../../../values'; -import type { DecisionModelFactory } from '../../types'; - -export const createSpaceScaleExplicitModel: DecisionModelFactory< - SpaceScale, - SpaceScaleExplicitInput -> = () => { - return { - produce: (context, params) => { - const { quantize } = params; - - const values = params.values.map(value => - createSpaceValue(context.nestedContext(), value, { quantize }), - ); - - return createSpaceScale(context, values); - }, - }; -}; diff --git a/packages/libs/designer-decisions/src/models/space/space-scale/index.ts b/packages/libs/designer-decisions/src/models/space/space-scale/index.ts deleted file mode 100644 index 9a2c17a2..00000000 --- a/packages/libs/designer-decisions/src/models/space/space-scale/index.ts +++ /dev/null @@ -1,4 +0,0 @@ -// @index(['./*.ts', '!./*.test.ts', './!(private|mocks|functions)*/index.ts'], f => `export * from '${f.path.replace(/\/index$/, '')}';`) -export * from './createSpaceScaleAnchoredModel'; -export * from './createSpaceScaleBoundedModel'; -export * from './createSpaceScaleExplicitModel'; diff --git a/packages/libs/designer-decisions/src/models/space/space-value/createSpaceValueExplicitModel.ts b/packages/libs/designer-decisions/src/models/space/space-value/createSpaceValueExplicitModel.ts deleted file mode 100644 index 9a166d16..00000000 --- a/packages/libs/designer-decisions/src/models/space/space-value/createSpaceValueExplicitModel.ts +++ /dev/null @@ -1,15 +0,0 @@ -import type { SpaceValueExplicitInput } from '../../../inputs'; -import { type SpaceValue, createSpaceValue } from '../../../values'; -import type { DecisionModelFactory } from '../../types'; - -export const createSpaceValueExplicitModel: DecisionModelFactory< - SpaceValue, - SpaceValueExplicitInput -> = () => { - return { - produce: (context, params) => { - const { quantize } = params; - return createSpaceValue(context, params.value, { quantize }); - }, - }; -}; diff --git a/packages/libs/designer-decisions/src/values/domains/space/constants.ts b/packages/libs/designer-decisions/src/values/domains/space/constants.ts index 65facde3..411bc72b 100644 --- a/packages/libs/designer-decisions/src/values/domains/space/constants.ts +++ b/packages/libs/designer-decisions/src/values/domains/space/constants.ts @@ -1 +1 @@ -export const SPACE_VALUE_QUANTIZE = 0.1; +export const SIZE_VALUE_QUANTIZE = 0.1; diff --git a/packages/libs/designer-decisions/src/values/domains/space/helpers/constants.ts b/packages/libs/designer-decisions/src/values/domains/space/helpers/constants.ts deleted file mode 100644 index b30d9b16..00000000 --- a/packages/libs/designer-decisions/src/values/domains/space/helpers/constants.ts +++ /dev/null @@ -1,3 +0,0 @@ -import type { SpaceUnits } from '../../../../inputs'; - -export const VALID_UNITS: SpaceUnits[] = ['px', 'em', 'rem']; diff --git a/packages/libs/designer-decisions/src/values/domains/space/helpers/isValidSpaceWithUnits.ts b/packages/libs/designer-decisions/src/values/domains/space/helpers/isValidSpaceWithUnits.ts deleted file mode 100644 index e83a5ef2..00000000 --- a/packages/libs/designer-decisions/src/values/domains/space/helpers/isValidSpaceWithUnits.ts +++ /dev/null @@ -1,21 +0,0 @@ -import type { SpaceWithUnits } from '../../../../inputs'; - -import { VALID_UNITS } from './constants'; - -export const isValidSpaceWithUnits = (input: unknown): input is SpaceWithUnits => { - if (typeof input !== 'object' || input === null) { - return false; - } - - const { value, units } = input as Partial; - - if (typeof value !== 'number' || isNaN(value)) { - return false; - } - - if (typeof units !== 'string' || !VALID_UNITS.includes(units)) { - return false; - } - - return true; -}; diff --git a/packages/libs/designer-decisions/src/values/domains/space/index.ts b/packages/libs/designer-decisions/src/values/domains/space/index.ts index 61001d6e..983f0b22 100644 --- a/packages/libs/designer-decisions/src/values/domains/space/index.ts +++ b/packages/libs/designer-decisions/src/values/domains/space/index.ts @@ -1,6 +1,5 @@ // @index(['./*.ts', '!./*.test.ts', './!(private|mocks|functions)*/index.ts'], f => `export * from '${f.path.replace(/\/index$/, '')}';`) export * from './constants'; -export * from './helpers'; -export * from './scale'; +export * from './size-scale'; export * from './types'; -export * from './value'; +export * from './size-value'; diff --git a/packages/libs/designer-decisions/src/values/domains/space/scale/createSpaceScale.ts b/packages/libs/designer-decisions/src/values/domains/space/scale/createSpaceScale.ts deleted file mode 100644 index d5f6fcd1..00000000 --- a/packages/libs/designer-decisions/src/values/domains/space/scale/createSpaceScale.ts +++ /dev/null @@ -1,7 +0,0 @@ -import type { ValueContext } from '../../../../value'; -import { createBaseSet } from '../../../base'; -import type { SpaceScale, SpaceValue } from '../types'; - -export const createSpaceScale = (context: ValueContext, input: SpaceValue[]): SpaceScale => { - return createBaseSet(context, input); -}; diff --git a/packages/libs/designer-decisions/src/values/domains/space/scale/createSpaceScale.test.ts b/packages/libs/designer-decisions/src/values/domains/space/size-scale/createSizeScale.test.ts similarity index 67% rename from packages/libs/designer-decisions/src/values/domains/space/scale/createSpaceScale.test.ts rename to packages/libs/designer-decisions/src/values/domains/space/size-scale/createSizeScale.test.ts index 78bc77c9..9b64b89b 100644 --- a/packages/libs/designer-decisions/src/values/domains/space/scale/createSpaceScale.test.ts +++ b/packages/libs/designer-decisions/src/values/domains/space/size-scale/createSizeScale.test.ts @@ -2,14 +2,14 @@ import { beforeEach, describe, expect, it, vi } from 'vitest'; import { type ValueContext } from '../../../../value'; import { createBaseSet } from '../../../base'; -import { SpaceValue } from '../types'; +import { SizeValue } from '../types'; -import { createSpaceScale } from './createSpaceScale'; +import { createSizeScale } from './createSizeScale'; vi.mock('../../../base'); -describe('createSpaceScale()', () => { - const mockInputs: SpaceValue[] = []; +describe('createSizeScale()', () => { + const mockInputs: SizeValue[] = []; const mockContext = {} as ValueContext; beforeEach(() => { @@ -17,7 +17,7 @@ describe('createSpaceScale()', () => { }); it('should call createBaseSet() with the correct arguments', () => { - createSpaceScale(mockContext, mockInputs); + createSizeScale(mockContext, mockInputs); expect(createBaseSet).toHaveBeenCalledWith(mockContext, mockInputs); }); }); diff --git a/packages/libs/designer-decisions/src/values/domains/space/size-scale/createSizeScale.ts b/packages/libs/designer-decisions/src/values/domains/space/size-scale/createSizeScale.ts new file mode 100644 index 00000000..7232dab4 --- /dev/null +++ b/packages/libs/designer-decisions/src/values/domains/space/size-scale/createSizeScale.ts @@ -0,0 +1,7 @@ +import type { ValueContext } from '../../../../value'; +import { createBaseSet } from '../../../base'; +import type { SizeScale, SizeValue } from '../types'; + +export const createSizeScale = (context: ValueContext, input: SizeValue[]): SizeScale => { + return createBaseSet(context, input); +}; diff --git a/packages/libs/designer-decisions/src/values/domains/space/scale/index.ts b/packages/libs/designer-decisions/src/values/domains/space/size-scale/index.ts similarity index 79% rename from packages/libs/designer-decisions/src/values/domains/space/scale/index.ts rename to packages/libs/designer-decisions/src/values/domains/space/size-scale/index.ts index c941c414..ce09f0b1 100644 --- a/packages/libs/designer-decisions/src/values/domains/space/scale/index.ts +++ b/packages/libs/designer-decisions/src/values/domains/space/size-scale/index.ts @@ -1,2 +1,2 @@ // @index(['./*.ts', '!./*.test.ts', './!(private|mocks|functions)*/index.ts'], f => `export * from '${f.path.replace(/\/index$/, '')}';`) -export * from './createSpaceScale'; +export * from './createSizeScale'; diff --git a/packages/libs/designer-decisions/src/values/domains/space/value/createSpaceValue.test.ts b/packages/libs/designer-decisions/src/values/domains/space/size-value/createSizeValue.test.ts similarity index 57% rename from packages/libs/designer-decisions/src/values/domains/space/value/createSpaceValue.test.ts rename to packages/libs/designer-decisions/src/values/domains/space/size-value/createSizeValue.test.ts index 28d2c280..978413ec 100644 --- a/packages/libs/designer-decisions/src/values/domains/space/value/createSpaceValue.test.ts +++ b/packages/libs/designer-decisions/src/values/domains/space/size-value/createSizeValue.test.ts @@ -1,12 +1,12 @@ import { beforeEach, describe, expect, it } from 'vitest'; -import type { SpaceValueInput } from '../../../../inputs'; +import type { SizeValueInput } from '../../../../inputs'; import { createDecisionContextMock } from '../../../../mocks'; import { type ValueContext, createValueContext } from '../../../../value'; -import { createSpaceValue } from './createSpaceValue'; +import { createSizeValue } from './createSizeValue'; -describe('createSpaceValue()', () => { +describe('createSizeValue()', () => { const [mockDecisionContext] = createDecisionContextMock(); let valueContext: ValueContext; @@ -16,46 +16,47 @@ describe('createSpaceValue()', () => { }); describe('Given a value', () => { - const input = { value: 123.371, units: 'rem' } as SpaceValueInput; + const input = { value: 123.371, units: 'rem' } as SizeValueInput; it('should have the provided context', () => { - const result = createSpaceValue(valueContext, input); + const result = createSizeValue(valueContext, input); expect(result.context()).toBe(valueContext); }); it('should consume the input', () => { - createSpaceValue(valueContext, input); + createSizeValue(valueContext, input); expect(valueContext.valueInput()).toEqual(input); }); it('should expose the resolved value via .get()', () => { - const result = createSpaceValue(valueContext, input); + const result = createSizeValue(valueContext, input); - expect(result.get()).toEqual(123.4); + expect(result.get().value).toEqual(123.4); + expect(result.get().units).toEqual('rem'); }); it('should expose the raw value via .raw()', () => { - const result = createSpaceValue(valueContext, input); + const result = createSizeValue(valueContext, input); expect(result.raw()).toEqual(123.371); }); it('should expose the quantized value via .quantized()', () => { - const result = createSpaceValue(valueContext, input); + const result = createSizeValue(valueContext, input); expect(result.quantized()).toEqual(123.4); }); it('should (re)quantize the value', () => { - const result = createSpaceValue(valueContext, input); + const result = createSizeValue(valueContext, input); expect(result.quantized(2)).toEqual(124); }); - it('should expose the value as SpaceWithUnits ', () => { - const result = createSpaceValue(valueContext, input); + it('should expose the value as SizeObjectLiteral ', () => { + const result = createSizeValue(valueContext, input); expect(result.toObject()).toEqual({ value: 123.4, @@ -63,8 +64,8 @@ describe('createSpaceValue()', () => { }); }); - it('should quantize the SpaceWithUnits ', () => { - const result = createSpaceValue(valueContext, input); + it('should quantize the SizeObjectLiteral ', () => { + const result = createSizeValue(valueContext, input); expect(result.toObject({ quantize: 0.5 })).toEqual({ value: 123.5, @@ -73,53 +74,53 @@ describe('createSpaceValue()', () => { }); it('should expose the value as a string', () => { - const result = createSpaceValue(valueContext, input); + const result = createSizeValue(valueContext, input); expect(result.toString()).toEqual('123.4rem'); }); it('should quantize the string value', () => { - const result = createSpaceValue(valueContext, input); + const result = createSizeValue(valueContext, input); expect(result.toString({ quantize: 0.5 })).toEqual('123.5rem'); }); }); describe('Given a quantize param', () => { - const input = { value: 123.371, units: 'rem' } as SpaceValueInput; + const input = { value: 123.371, units: 'rem' } as SizeValueInput; it('should expose the quantized value via .get()', () => { - const result = createSpaceValue(valueContext, input, { quantize: 0.02 }); + const result = createSizeValue(valueContext, input, { quantize: 0.02 }); - expect(result.get()).toEqual(123.38); + expect(result.get().value).toEqual(123.38); }); it('should expose the raw value via .raw()', () => { - const result = createSpaceValue(valueContext, input, { quantize: 0.02 }); + const result = createSizeValue(valueContext, input, { quantize: 0.02 }); expect(result.raw()).toEqual(123.371); }); it('should expose the quantized value', () => { - const result = createSpaceValue(valueContext, input, { quantize: 0.02 }); + const result = createSizeValue(valueContext, input, { quantize: 0.02 }); expect(result.quantized()).toEqual(123.38); }); it('should expose the (un)quantized value (given q is 0)', () => { - const result = createSpaceValue(valueContext, input, { quantize: 0.02 }); + const result = createSizeValue(valueContext, input, { quantize: 0.02 }); expect(result.quantized(0)).toEqual(123.371); }); it('should (re)quantize the value', () => { - const result = createSpaceValue(valueContext, input, { quantize: 0.02 }); + const result = createSizeValue(valueContext, input, { quantize: 0.02 }); expect(result.quantized(0.5)).toEqual(123.5); }); - it('should expose the quantized value as SpaceWithUnits ', () => { - const result = createSpaceValue(valueContext, input, { quantize: 0.02 }); + it('should expose the quantized value as SizeObjectLiteral ', () => { + const result = createSizeValue(valueContext, input, { quantize: 0.02 }); expect(result.toObject()).toEqual({ value: 123.38, @@ -127,14 +128,14 @@ describe('createSpaceValue()', () => { }); }); - it('should expose the (un)quantized value as SpaceWithUnits (given q is 0', () => { - const result = createSpaceValue(valueContext, input, { quantize: 0.02 }); + it('should expose the (un)quantized value as SizeObjectLiteral (given q is 0', () => { + const result = createSizeValue(valueContext, input, { quantize: 0.02 }); expect(result.toObject({ quantize: 0 })).toEqual(input); }); - it('should (re)quantize the SpaceWithUnits ', () => { - const result = createSpaceValue(valueContext, input, { quantize: 0.02 }); + it('should (re)quantize the SizeObjectLiteral ', () => { + const result = createSizeValue(valueContext, input, { quantize: 0.02 }); expect(result.toObject({ quantize: 5 })).toEqual({ value: 125, @@ -143,19 +144,19 @@ describe('createSpaceValue()', () => { }); it('should expose the quantized value as a string', () => { - const result = createSpaceValue(valueContext, input, { quantize: 0.02 }); + const result = createSizeValue(valueContext, input, { quantize: 0.02 }); expect(result.toString()).toEqual('123.38rem'); }); it('should expose the (un)quantized value as a string (given q is 0', () => { - const result = createSpaceValue(valueContext, input, { quantize: 0.02 }); + const result = createSizeValue(valueContext, input, { quantize: 0.02 }); expect(result.toString({ quantize: 0 })).toEqual('123.371rem'); }); it('should (re)quantize the string value', () => { - const result = createSpaceValue(valueContext, input, { quantize: 0.02 }); + const result = createSizeValue(valueContext, input, { quantize: 0.02 }); expect(result.toString({ quantize: 0.5 })).toEqual('123.5rem'); }); diff --git a/packages/libs/designer-decisions/src/values/domains/space/size-value/createSizeValue.ts b/packages/libs/designer-decisions/src/values/domains/space/size-value/createSizeValue.ts new file mode 100644 index 00000000..eacaf43f --- /dev/null +++ b/packages/libs/designer-decisions/src/values/domains/space/size-value/createSizeValue.ts @@ -0,0 +1,37 @@ +import type { SizeValueInput } from '../../../../inputs'; +import type { ValueContext } from '../../../../value'; +import { createBaseValue } from '../../../base'; +import { createNumericValue, createSize } from '../../../primitives'; +import { SIZE_VALUE_QUANTIZE } from '../constants'; +import type { SizeFormatOptions, SizeValue } from '../types'; + +import { resolveSizeValue } from './resolveSizeValue'; + +export const createSizeValue = ( + context: ValueContext, + input: SizeValueInput, + options: SizeFormatOptions = {}, +): SizeValue => { + const baseValue = createBaseValue(context, input); + + const { quantize = SIZE_VALUE_QUANTIZE } = options; + const { value, units } = resolveSizeValue(context, input); + + const { get: getValue, raw, quantized } = createNumericValue(value, { quantize }); + + return { + ...baseValue, + get: () => createSize({ value: getValue(), units }), + raw, + quantized, + toString: ({ quantize: q }: SizeFormatOptions = {}) => { + return String(quantized(q ?? quantize)) + units; + }, + toObject: ({ quantize: q }: SizeFormatOptions = {}) => { + return { + value: quantized(q ?? quantize), + units, + }; + }, + }; +}; diff --git a/packages/libs/designer-decisions/src/values/domains/space/value/index.ts b/packages/libs/designer-decisions/src/values/domains/space/size-value/index.ts similarity index 55% rename from packages/libs/designer-decisions/src/values/domains/space/value/index.ts rename to packages/libs/designer-decisions/src/values/domains/space/size-value/index.ts index ed25f8a2..0e4ad45f 100644 --- a/packages/libs/designer-decisions/src/values/domains/space/value/index.ts +++ b/packages/libs/designer-decisions/src/values/domains/space/size-value/index.ts @@ -1,4 +1,4 @@ // @index(['./*.ts', '!./*.test.ts', './!(private|mocks|functions)*/index.ts'], f => `export * from '${f.path.replace(/\/index$/, '')}';`) -export * from './createSpaceValue'; -export * from './resolveSpaceValue'; -export * from './resolveSpaceValueRef'; +export * from './createSizeValue'; +export * from './resolveSizeValue'; +export * from './resolveSizeValueRef'; diff --git a/packages/libs/designer-decisions/src/values/domains/space/size-value/private/constants.ts b/packages/libs/designer-decisions/src/values/domains/space/size-value/private/constants.ts new file mode 100644 index 00000000..269c9ff1 --- /dev/null +++ b/packages/libs/designer-decisions/src/values/domains/space/size-value/private/constants.ts @@ -0,0 +1,6 @@ +import { DECISION_SIZE_SCALE, DECISION_SIZE_VALUE } from '../../../../../constants'; +import type { SizeObjectLiteral } from '../../../../../inputs'; + +export const VALUE_NAME = DECISION_SIZE_VALUE; +export const FALLBACK_VALUE: SizeObjectLiteral = { value: 0, units: 'px' }; +export const REF_CHECKED_TYPES = [DECISION_SIZE_VALUE, DECISION_SIZE_SCALE]; diff --git a/packages/libs/designer-decisions/src/values/domains/space/value/private/index.ts b/packages/libs/designer-decisions/src/values/domains/space/size-value/private/index.ts similarity index 100% rename from packages/libs/designer-decisions/src/values/domains/space/value/private/index.ts rename to packages/libs/designer-decisions/src/values/domains/space/size-value/private/index.ts diff --git a/packages/libs/designer-decisions/src/values/domains/space/value/resolveSpaceValue.test.ts b/packages/libs/designer-decisions/src/values/domains/space/size-value/resolveSizeValue.test.ts similarity index 54% rename from packages/libs/designer-decisions/src/values/domains/space/value/resolveSpaceValue.test.ts rename to packages/libs/designer-decisions/src/values/domains/space/size-value/resolveSizeValue.test.ts index 93650773..38a69459 100644 --- a/packages/libs/designer-decisions/src/values/domains/space/value/resolveSpaceValue.test.ts +++ b/packages/libs/designer-decisions/src/values/domains/space/size-value/resolveSizeValue.test.ts @@ -1,18 +1,18 @@ import { beforeEach, describe, expect, it, vi } from 'vitest'; -import type { SpaceValueInput, SpaceWithUnits } from '../../../../inputs'; +import type { SizeObjectLiteral, SizeValueInput } from '../../../../inputs'; import { createValueContextMock } from '../../../../mocks'; import type { ValueInputError } from '../../../../value'; import { FALLBACK_VALUE } from './private'; -import { resolveSpaceValue } from './resolveSpaceValue'; -import { resolveSpaceValueRef } from './resolveSpaceValueRef'; +import { resolveSizeValue } from './resolveSizeValue'; +import { resolveSizeValueRef } from './resolveSizeValueRef'; -vi.mock('./resolveSpaceValueRef'); +vi.mock('./resolveSizeValueRef'); -const resolveSpaceValueRefMock = vi.mocked(resolveSpaceValueRef); +const resolveSizeValueRefMock = vi.mocked(resolveSizeValueRef); -describe('resolveSpaceValue()', () => { +describe('resolveSizeValue()', () => { const [mockContext, { addErrorSpy }] = createValueContextMock(); beforeEach(() => { @@ -21,21 +21,21 @@ describe('resolveSpaceValue()', () => { describe('When input is a DecisionRef', () => { const mockInput = { $uuid: 'mock-uuid' }; - const resolvedValue: SpaceWithUnits = { value: 42, units: 'px' }; + const resolvedValue: SizeObjectLiteral = { value: 42, units: 'px' }; beforeEach(() => { - resolveSpaceValueRefMock.mockReturnValue(resolvedValue); + resolveSizeValueRefMock.mockReturnValue(resolvedValue); }); - it('should call resolveSpaceValueRef with the correct arguments', () => { - resolveSpaceValue(mockContext, mockInput); + it('should call resolveSizeValueRef with the correct arguments', () => { + resolveSizeValue(mockContext, mockInput); - expect(resolveSpaceValueRefMock).toHaveBeenCalledOnce(); - expect(resolveSpaceValueRefMock).toHaveBeenCalledWith(mockContext, mockInput); + expect(resolveSizeValueRefMock).toHaveBeenCalledOnce(); + expect(resolveSizeValueRefMock).toHaveBeenCalledWith(mockContext, mockInput); }); - it('should return the value resolved by resolveSpaceValueRef', () => { - const result = resolveSpaceValue(mockContext, mockInput); + it('should return the value resolved by resolveSizeValueRef', () => { + const result = resolveSizeValue(mockContext, mockInput); expect(result).toEqual(resolvedValue); }); }); @@ -43,8 +43,8 @@ describe('resolveSpaceValue()', () => { describe('When input is a string', () => { const mockInput = '24'; - it('should return a SpaceWithUnits object with the value parsed as a number and "px" as the units', () => { - const result = resolveSpaceValue(mockContext, mockInput); + it('should return a SizeObjectLiteral object with the value parsed as a number and "px" as the units', () => { + const result = resolveSizeValue(mockContext, mockInput); expect(result).toEqual({ value: 24, units: 'px' }); }); }); @@ -52,17 +52,17 @@ describe('resolveSpaceValue()', () => { describe('When input is a number', () => { const mockInput = 12; - it('should return a SpaceWithUnits object with the value and "px" as the units', () => { - const result = resolveSpaceValue(mockContext, mockInput); + it('should return a SizeObjectLiteral object with the value and "px" as the units', () => { + const result = resolveSizeValue(mockContext, mockInput); expect(result).toEqual({ value: 12, units: 'px' }); }); }); - describe('When input is already a SpaceWithUnits object', () => { - const mockInput: SpaceWithUnits = { value: 10, units: 'em' }; + describe('When input is already a SizeObjectLiteral object', () => { + const mockInput: SizeObjectLiteral = { value: 10, units: 'px' }; it('should return the input as-is', () => { - const result = resolveSpaceValue(mockContext, mockInput); + const result = resolveSizeValue(mockContext, mockInput); expect(result).toEqual(mockInput); }); }); @@ -74,7 +74,7 @@ describe('resolveSpaceValue()', () => { true, false, { value: 'not-a-number', units: 'px' }, - { value: 12, units: 'invalid-unit' }, + { value: 12, units: 'em' }, { units: 'px' }, { value: 10 }, 'invalid-string', @@ -83,14 +83,14 @@ describe('resolveSpaceValue()', () => { it.each(invalidInputs)( 'should return the fallback value for invalid input: %s', invalidInput => { - const result = resolveSpaceValue(mockContext, invalidInput as SpaceValueInput); + const result = resolveSizeValue(mockContext, invalidInput as SizeValueInput); expect(result).toEqual(FALLBACK_VALUE); }, ); it.each(invalidInputs)( 'should add an error to the context for invalid input: %s', invalidInput => { - resolveSpaceValue(mockContext, invalidInput as SpaceValueInput); + resolveSizeValue(mockContext, invalidInput as SizeValueInput); expect(addErrorSpy).toHaveBeenCalledOnce(); const error = addErrorSpy.mock.calls[0][0] as ValueInputError; diff --git a/packages/libs/designer-decisions/src/values/domains/space/value/resolveSpaceValue.ts b/packages/libs/designer-decisions/src/values/domains/space/size-value/resolveSizeValue.ts similarity index 63% rename from packages/libs/designer-decisions/src/values/domains/space/value/resolveSpaceValue.ts rename to packages/libs/designer-decisions/src/values/domains/space/size-value/resolveSizeValue.ts index 5a861e71..d4b3f73b 100644 --- a/packages/libs/designer-decisions/src/values/domains/space/value/resolveSpaceValue.ts +++ b/packages/libs/designer-decisions/src/values/domains/space/size-value/resolveSizeValue.ts @@ -1,16 +1,16 @@ -import { type SpaceValueInput, type SpaceWithUnits, isDecisionRef } from '../../../../inputs'; +import { type SizeObjectLiteral, type SizeValueInput, isDecisionRef } from '../../../../inputs'; import { type ValueContext, createValueInputError } from '../../../../value'; -import { isValidSpaceWithUnits } from '../helpers'; +import { isValidSizeObjectLiteral } from '../../../primitives/size/helpers'; import { FALLBACK_VALUE as fallback, VALUE_NAME as valueName } from './private'; -import { resolveSpaceValueRef } from './resolveSpaceValueRef'; +import { resolveSizeValueRef } from './resolveSizeValueRef'; -export const resolveSpaceValue = ( +export const resolveSizeValue = ( context: ValueContext, - input: SpaceValueInput, -): SpaceWithUnits => { + input: SizeValueInput, +): SizeObjectLiteral => { if (isDecisionRef(input)) { - return resolveSpaceValueRef(context, input); + return resolveSizeValueRef(context, input); } if (typeof input === 'string') { @@ -26,7 +26,7 @@ export const resolveSpaceValue = ( return { value: input, units: 'px' }; } - if (!isValidSpaceWithUnits(input)) { + if (!isValidSizeObjectLiteral(input)) { context.addError(createValueInputError({ context, valueName, input })); return fallback; } diff --git a/packages/libs/designer-decisions/src/values/domains/space/value/resolveSpaceValueRef.test.ts b/packages/libs/designer-decisions/src/values/domains/space/size-value/resolveSizeValueRef.test.ts similarity index 61% rename from packages/libs/designer-decisions/src/values/domains/space/value/resolveSpaceValueRef.test.ts rename to packages/libs/designer-decisions/src/values/domains/space/size-value/resolveSizeValueRef.test.ts index d7762e8e..f2e6228e 100644 --- a/packages/libs/designer-decisions/src/values/domains/space/value/resolveSpaceValueRef.test.ts +++ b/packages/libs/designer-decisions/src/values/domains/space/size-value/resolveSizeValueRef.test.ts @@ -1,7 +1,7 @@ import { beforeEach, describe, expect, it, vi } from 'vitest'; -import { DECISION_SPACE_VALUE } from '../../../../constants'; -import type { DecisionInput, DecisionRef, SpaceWithUnits } from '../../../../inputs'; +import { DECISION_SIZE_VALUE } from '../../../../constants'; +import type { DecisionInput, DecisionRef, SizeObjectLiteral } from '../../../../inputs'; import { createStaticDecisionMock, createValueContextMock, @@ -9,11 +9,11 @@ import { } from '../../../../mocks'; import type { ValueRefNotFoundError } from '../../../../value'; import { resolveSetRefDecision } from '../../../functions'; -import type { SpaceScale, SpaceValue } from '../types'; +import type { SizeScale, SizeValue } from '../types'; -import { createSpaceValue } from './createSpaceValue'; +import { createSizeValue } from './createSizeValue'; import { FALLBACK_VALUE } from './private'; -import { resolveSpaceValueRef } from './resolveSpaceValueRef'; +import { resolveSizeValueRef } from './resolveSizeValueRef'; vi.mock('../../../functions', async importOriginal => { return { @@ -24,7 +24,7 @@ vi.mock('../../../functions', async importOriginal => { const resolveSetRefDecisionMocked = vi.mocked(resolveSetRefDecision); -describe('resolveSpaceValueRef()', () => { +describe('resolveSizeValueRef()', () => { describe('When the decision cannot be resolved', () => { const mockRef: DecisionRef = { $uuid: 'mock-uuid' }; const [mockValueContext, { addErrorSpy }] = createValueContextWithResolveMock(); @@ -34,51 +34,51 @@ describe('resolveSpaceValueRef()', () => { }); it('should return the fallback value', () => { - const result = resolveSpaceValueRef(mockValueContext, mockRef); + const result = resolveSizeValueRef(mockValueContext, mockRef); expect(result).toEqual(FALLBACK_VALUE); }); it('should add an error to the context', () => { - resolveSpaceValueRef(mockValueContext, mockRef); + resolveSizeValueRef(mockValueContext, mockRef); expect(addErrorSpy).toHaveBeenCalledOnce(); const error = addErrorSpy.mock.calls[0][0] as ValueRefNotFoundError; expect(error.message()).toContain('not found'); expect(error.context).toBe(mockValueContext); expect(error.ref).toBe(mockRef); - expect(error.valueName).toBe(DECISION_SPACE_VALUE); + expect(error.valueName).toBe(DECISION_SIZE_VALUE); }); }); - describe('When it resolves to a SpaceScale with a quantized value and the item is resolved', () => { + describe('When it resolves to a SizeScale with a quantized value and the item is resolved', () => { const mockRef: DecisionRef = { $uuid: 'mock-uuid' }; - const mockInput = { model: 'space-scale/foo' } as DecisionInput; - const [, mockDecision] = createStaticDecisionMock([mockInput]); + const mockInput = { model: 'size-scale/foo' } as DecisionInput; + const [, mockDecision] = createStaticDecisionMock([mockInput]); const [mockValueContext] = createValueContextWithResolveMock([undefined, mockDecision]); - const spaceWithUnits: SpaceWithUnits = { value: 3.33, units: 'px' }; - const spaceValue = createSpaceValue(createValueContextMock()[0], spaceWithUnits, { + const SizeObjectLiteral: SizeObjectLiteral = { value: 3.33, units: 'px' }; + const sizeValue = createSizeValue(createValueContextMock()[0], SizeObjectLiteral, { quantize: 5, }); beforeEach(() => { vi.clearAllMocks(); - resolveSetRefDecisionMocked.mockReturnValue(spaceValue); + resolveSetRefDecisionMocked.mockReturnValue(sizeValue); }); it('should call resolveSetRefDecision() with the correct arguments', () => { - resolveSpaceValueRef(mockValueContext, mockRef); + resolveSizeValueRef(mockValueContext, mockRef); expect(resolveSetRefDecisionMocked).toHaveBeenCalledOnce(); expect(resolveSetRefDecisionMocked).toHaveBeenCalledWith( mockDecision, mockValueContext, - DECISION_SPACE_VALUE, + DECISION_SIZE_VALUE, mockRef, ); }); - it('should return the resolved (quantized) SpaceValue', () => { - const result = resolveSpaceValueRef(mockValueContext, mockRef); + it('should return the resolved (quantized) SizeValue', () => { + const result = resolveSizeValueRef(mockValueContext, mockRef); expect(result).toEqual({ value: 5, units: 'px', @@ -86,10 +86,10 @@ describe('resolveSpaceValueRef()', () => { }); }); - describe('When it resolves to a SpaceScale decision and the item is not resolved', () => { + describe('When it resolves to a SizeScale decision and the item is not resolved', () => { const mockRef: DecisionRef = { $uuid: 'mock-uuid' }; - const mockInput = { model: 'space-scale/foo' } as DecisionInput; - const [, mockDecision] = createStaticDecisionMock([mockInput]); + const mockInput = { model: 'size-scale/foo' } as DecisionInput; + const [, mockDecision] = createStaticDecisionMock([mockInput]); const [mockValueContext] = createValueContextWithResolveMock([undefined, mockDecision]); beforeEach(() => { @@ -98,20 +98,20 @@ describe('resolveSpaceValueRef()', () => { }); it('should return the fallback value', () => { - const result = resolveSpaceValueRef(mockValueContext, mockRef); + const result = resolveSizeValueRef(mockValueContext, mockRef); expect(result).toEqual(FALLBACK_VALUE); }); }); - describe('When it resolves to a SpaceValue decision', () => { + describe('When it resolves to a SizeValue decision', () => { const mockRef: DecisionRef = { $uuid: 'mock-uuid' }; - const mockInput = { model: 'space-value/foo' } as DecisionInput; - const spaceWithUnits: SpaceWithUnits = { value: 3.33, units: 'px' }; - const spaceValue = createSpaceValue(createValueContextMock()[0], spaceWithUnits, { + const mockInput = { model: 'size-value/foo' } as DecisionInput; + const SizeObjectLiteral: SizeObjectLiteral = { value: 3.33, units: 'px' }; + const SizeValue = createSizeValue(createValueContextMock()[0], SizeObjectLiteral, { quantize: 5, }); - const [, mockDecision] = createStaticDecisionMock([mockInput], { - toObject: spaceValue.toObject, + const [, mockDecision] = createStaticDecisionMock([mockInput], { + toObject: SizeValue.toObject, }); const [mockValueContext] = createValueContextWithResolveMock([undefined, mockDecision]); @@ -119,8 +119,8 @@ describe('resolveSpaceValueRef()', () => { vi.clearAllMocks(); }); - it('should return the (quantized) SpaceValue produced by the decision', () => { - const result = resolveSpaceValueRef(mockValueContext, mockRef); + it('should return the (quantized) SizeValue produced by the decision', () => { + const result = resolveSizeValueRef(mockValueContext, mockRef); expect(result).toEqual({ value: 5, units: 'px', @@ -142,16 +142,16 @@ describe('resolveSpaceValueRef()', () => { }); it('should return the fallback value', () => { - const result = resolveSpaceValueRef(mockValueContext, mockRef); + const result = resolveSizeValueRef(mockValueContext, mockRef); expect(result).toEqual(FALLBACK_VALUE); }); it('should add an error to the context', () => { - resolveSpaceValueRef(mockValueContext, mockRef); + resolveSizeValueRef(mockValueContext, mockRef); expect(addErrorSpy).toHaveBeenCalledOnce(); const error = addErrorSpy.mock.calls[0][0] as ValueRefNotFoundError; - expect(error.message()).toContain('matched "unexpected-type", expected space-value'); + expect(error.message()).toContain('matched "unexpected-type", expected size-value'); }); }); }); diff --git a/packages/libs/designer-decisions/src/values/domains/space/value/resolveSpaceValueRef.ts b/packages/libs/designer-decisions/src/values/domains/space/size-value/resolveSizeValueRef.ts similarity index 58% rename from packages/libs/designer-decisions/src/values/domains/space/value/resolveSpaceValueRef.ts rename to packages/libs/designer-decisions/src/values/domains/space/size-value/resolveSizeValueRef.ts index 4d0692e8..55a29fcf 100644 --- a/packages/libs/designer-decisions/src/values/domains/space/value/resolveSpaceValueRef.ts +++ b/packages/libs/designer-decisions/src/values/domains/space/size-value/resolveSizeValueRef.ts @@ -1,12 +1,12 @@ -import { isSpaceScaleDecision, isSpaceValueDecision } from '../../../../decision'; -import type { DecisionRef, SpaceWithUnits } from '../../../../inputs'; +import { isSizeScaleDecision, isSizeValueDecision } from '../../../../decision'; +import type { DecisionRef, SizeObjectLiteral } from '../../../../inputs'; import type { ValueContext } from '../../../../value'; import { handleDecisionNotFound, handleRefMismatchError, resolveSetRefDecision, } from '../../../functions'; -import type { SpaceValue } from '../types'; +import type { SizeValue } from '../types'; import { REF_CHECKED_TYPES as accepted, @@ -14,7 +14,7 @@ import { VALUE_NAME as valueName, } from './private'; -export const resolveSpaceValueRef = (context: ValueContext, ref: DecisionRef): SpaceWithUnits => { +export const resolveSizeValueRef = (context: ValueContext, ref: DecisionRef): SizeObjectLiteral => { const [, decision] = context.resolve(ref); if (!decision) { @@ -22,12 +22,12 @@ export const resolveSpaceValueRef = (context: ValueContext, ref: DecisionRef): S return fallback; } - if (isSpaceScaleDecision(decision)) { - const value = resolveSetRefDecision(decision, context, valueName, ref); + if (isSizeScaleDecision(decision)) { + const value = resolveSetRefDecision(decision, context, valueName, ref); return value?.toObject() ?? fallback; } - if (isSpaceValueDecision(decision)) { + if (isSizeValueDecision(decision)) { return decision.produce(context).toObject(); } diff --git a/packages/libs/designer-decisions/src/values/domains/space/types.ts b/packages/libs/designer-decisions/src/values/domains/space/types.ts index 46f7d306..73e11367 100644 --- a/packages/libs/designer-decisions/src/values/domains/space/types.ts +++ b/packages/libs/designer-decisions/src/values/domains/space/types.ts @@ -1,14 +1,16 @@ -import type { SpaceWithUnits } from '../../../inputs'; -import type { BaseSet } from '../../base'; -import type { BaseNumericValue, NumberValueOptions } from '../../primitives'; +import type { SizeObjectLiteral } from '../../../inputs'; +import type { BaseSet, BaseValue } from '../../base'; +import type { NumberValueOptions, Size } from '../../primitives'; -export type SpaceValueOptions = NumberValueOptions; +export type SizeValueOptions = NumberValueOptions; -export type SpaceValueFormatOptions = SpaceValueOptions; +export type SizeFormatOptions = NumberValueOptions; -export type SpaceValue = BaseNumericValue & { - toString(options?: SpaceValueFormatOptions): string; - toObject(options?: SpaceValueFormatOptions): SpaceWithUnits; +export type SizeValue = BaseValue & { + raw(): number; + quantized: (quantize?: number) => number; + toString(options?: SizeFormatOptions): string; + toObject(options?: SizeFormatOptions): SizeObjectLiteral; }; -export type SpaceScale = BaseSet; +export type SizeScale = BaseSet; diff --git a/packages/libs/designer-decisions/src/values/domains/space/value/createSpaceValue.ts b/packages/libs/designer-decisions/src/values/domains/space/value/createSpaceValue.ts deleted file mode 100644 index a89cd9b6..00000000 --- a/packages/libs/designer-decisions/src/values/domains/space/value/createSpaceValue.ts +++ /dev/null @@ -1,37 +0,0 @@ -import type { SpaceValueInput } from '../../../../inputs'; -import type { ValueContext } from '../../../../value'; -import { createBaseValue } from '../../../base'; -import { createNumericValue } from '../../../primitives'; -import { SPACE_VALUE_QUANTIZE } from '../constants'; -import type { SpaceValue, SpaceValueFormatOptions, SpaceValueOptions } from '../types'; - -import { resolveSpaceValue } from './resolveSpaceValue'; - -export const createSpaceValue = ( - context: ValueContext, - input: SpaceValueInput, - options: SpaceValueOptions = {}, -): SpaceValue => { - const baseValue = createBaseValue(context, input); - - const { quantize = SPACE_VALUE_QUANTIZE } = options; - const { value, units } = resolveSpaceValue(context, input); - - const { get, raw, quantized } = createNumericValue(value, { quantize }); - - return { - ...baseValue, - get, - raw, - quantized, - toString: ({ quantize: q }: SpaceValueFormatOptions = {}) => { - return String(quantized(q ?? quantize)) + units; - }, - toObject: ({ quantize: q }: SpaceValueFormatOptions = {}) => { - return { - value: quantized(q ?? quantize), - units, - }; - }, - }; -}; diff --git a/packages/libs/designer-decisions/src/values/domains/space/value/private/constants.ts b/packages/libs/designer-decisions/src/values/domains/space/value/private/constants.ts deleted file mode 100644 index 10874f0f..00000000 --- a/packages/libs/designer-decisions/src/values/domains/space/value/private/constants.ts +++ /dev/null @@ -1,6 +0,0 @@ -import { DECISION_SPACE_SCALE, DECISION_SPACE_VALUE } from '../../../../../constants'; -import type { SpaceWithUnits } from '../../../../../inputs'; - -export const VALUE_NAME = DECISION_SPACE_VALUE; -export const FALLBACK_VALUE: SpaceWithUnits = { value: 0, units: 'px' }; -export const REF_CHECKED_TYPES = [DECISION_SPACE_VALUE, DECISION_SPACE_SCALE]; diff --git a/packages/libs/designer-decisions/src/values/functions/resolveSetRefDecision.test.ts b/packages/libs/designer-decisions/src/values/functions/resolveSetRefDecision.test.ts index 0818fe7a..2b8cc7c8 100644 --- a/packages/libs/designer-decisions/src/values/functions/resolveSetRefDecision.test.ts +++ b/packages/libs/designer-decisions/src/values/functions/resolveSetRefDecision.test.ts @@ -11,11 +11,11 @@ import { resolveSetRefDecision } from './resolveSetRefDecision'; describe('resolveSetRefDecision()', () => { const [mockContext, { addErrorSpy }] = createValueContextMock(); const mockValueName = 'mock-scale'; - const mockSpace1 = { value: 10, units: 'px' }; - const mockSpace2 = { value: 12, units: 'px' }; + const mockSize1 = { value: 10, units: 'px' }; + const mockSize2 = { value: 12, units: 'px' }; - const itemSet = createItemSet([mockSpace1, mockSpace2]); - const [, decisionMock] = createStaticDecisionMock>([], { + const itemSet = createItemSet([mockSize1, mockSize2]); + const [, decisionMock] = createStaticDecisionMock>([], { get: () => itemSet, }); @@ -28,7 +28,7 @@ describe('resolveSetRefDecision()', () => { const ref: DecisionRef = { $uuid: 'test-uuid', index: 1 }; const result = resolveSetRefDecision(decisionMock, mockContext, mockValueName, ref); - expect(result).toEqual(mockSpace2); + expect(result).toEqual(mockSize2); }); }); @@ -55,7 +55,7 @@ describe('resolveSetRefDecision()', () => { const ref: DecisionRef = { $uuid: 'test-uuid' }; const result = resolveSetRefDecision(decisionMock, mockContext, mockValueName, ref); - expect(result).toEqual(mockSpace1); + expect(result).toEqual(mockSize1); }); }); }); diff --git a/packages/libs/designer-decisions/src/values/primitives/index.ts b/packages/libs/designer-decisions/src/values/primitives/index.ts index 489db32e..943b726f 100644 --- a/packages/libs/designer-decisions/src/values/primitives/index.ts +++ b/packages/libs/designer-decisions/src/values/primitives/index.ts @@ -2,3 +2,4 @@ export * from './color'; export * from './number'; export * from './set'; +export * from './size'; diff --git a/packages/libs/designer-decisions/src/values/primitives/size/createSize.test.ts b/packages/libs/designer-decisions/src/values/primitives/size/createSize.test.ts new file mode 100644 index 00000000..0e9e2e1a --- /dev/null +++ b/packages/libs/designer-decisions/src/values/primitives/size/createSize.test.ts @@ -0,0 +1,21 @@ +import { describe, expect, it } from 'vitest'; + +import type { SizeObjectLiteral } from '../../../inputs'; + +import { createSize } from './createSize'; + +describe('createSize()', () => { + describe('Given a SizeObjectLiteral', () => { + const sizeLiteral: SizeObjectLiteral = { value: 32, units: 'px' }; + const size = createSize(sizeLiteral); + + it('should return the expected value', () => { + expect(size.value).toEqual(32); + expect(size.units).toEqual('px'); + }); + + it('should format toString()', () => { + expect(size.toString()).toEqual('32px'); + }); + }); +}); diff --git a/packages/libs/designer-decisions/src/values/primitives/size/createSize.ts b/packages/libs/designer-decisions/src/values/primitives/size/createSize.ts new file mode 100644 index 00000000..8c63df48 --- /dev/null +++ b/packages/libs/designer-decisions/src/values/primitives/size/createSize.ts @@ -0,0 +1,13 @@ +import type { SizeObjectLiteral } from '../../../inputs'; + +import type { Size } from './types'; + +export function createSize(input: SizeObjectLiteral): Size { + const { value, units } = input; + + return { + value, + units, + toString: () => `${value}${units}`, + }; +} diff --git a/packages/libs/designer-decisions/src/values/primitives/size/helpers/constants.ts b/packages/libs/designer-decisions/src/values/primitives/size/helpers/constants.ts new file mode 100644 index 00000000..b4b676d9 --- /dev/null +++ b/packages/libs/designer-decisions/src/values/primitives/size/helpers/constants.ts @@ -0,0 +1,3 @@ +import type { SizeAbsoluteUnits } from '../../../../inputs'; + +export const SIZE_ABSOLUtE_UNITS: SizeAbsoluteUnits[] = ['px', 'rem']; diff --git a/packages/libs/designer-decisions/src/values/domains/space/helpers/index.ts b/packages/libs/designer-decisions/src/values/primitives/size/helpers/index.ts similarity index 79% rename from packages/libs/designer-decisions/src/values/domains/space/helpers/index.ts rename to packages/libs/designer-decisions/src/values/primitives/size/helpers/index.ts index 490837e6..a950ce8b 100644 --- a/packages/libs/designer-decisions/src/values/domains/space/helpers/index.ts +++ b/packages/libs/designer-decisions/src/values/primitives/size/helpers/index.ts @@ -1,3 +1,3 @@ // @index(['./*.ts', '!./*.test.ts', './!(private|mocks|functions)*/index.ts'], f => `export * from '${f.path.replace(/\/index$/, '')}';`) export * from './constants'; -export * from './isValidSpaceWithUnits'; +export * from './isValidSizeObjectLiteral'; diff --git a/packages/libs/designer-decisions/src/values/domains/space/helpers/isValidSpaceWithUnits.test.ts b/packages/libs/designer-decisions/src/values/primitives/size/helpers/isValidSizeObjectLiteral.test.ts similarity index 60% rename from packages/libs/designer-decisions/src/values/domains/space/helpers/isValidSpaceWithUnits.test.ts rename to packages/libs/designer-decisions/src/values/primitives/size/helpers/isValidSizeObjectLiteral.test.ts index f11e4bce..4973bd92 100644 --- a/packages/libs/designer-decisions/src/values/domains/space/helpers/isValidSpaceWithUnits.test.ts +++ b/packages/libs/designer-decisions/src/values/primitives/size/helpers/isValidSizeObjectLiteral.test.ts @@ -1,20 +1,19 @@ import { describe, expect, it } from 'vitest'; -import type { SpaceWithUnits } from '../../../../inputs'; +import type { SizeObjectLiteral } from '../../../../inputs'; -import { isValidSpaceWithUnits } from './isValidSpaceWithUnits'; +import { isValidSizeObjectLiteral } from './isValidSizeObjectLiteral'; -describe('isValidSpaceWithUnits()', () => { +describe('isValidSizeObjectLiteral()', () => { describe('When input is valid', () => { - const validInputs: SpaceWithUnits[] = [ + const validInputs: SizeObjectLiteral[] = [ { value: 10, units: 'px' }, - { value: 0, units: 'em' }, { value: 42.5, units: 'rem' }, ]; - it('should return true for valid SpaceWithUnits objects', () => { + it('should return true for valid SizeObjectLiteral objects', () => { validInputs.forEach(input => { - expect(isValidSpaceWithUnits(input)).toBe(true); + expect(isValidSizeObjectLiteral(input)).toBe(true); }); }); }); @@ -29,7 +28,7 @@ describe('isValidSpaceWithUnits()', () => { 123, { value: 'not-a-number', units: 'px' }, { value: NaN, units: 'px' }, - { value: 10, units: 'invalid-unit' }, + { value: 10, units: 'em' }, { value: 10 }, { units: 'px' }, {}, @@ -37,7 +36,7 @@ describe('isValidSpaceWithUnits()', () => { it('should return false for invalid inputs', () => { invalidInputs.forEach(input => { - expect(isValidSpaceWithUnits(input)).toBe(false); + expect(isValidSizeObjectLiteral(input)).toBe(false); }); }); }); diff --git a/packages/libs/designer-decisions/src/values/primitives/size/helpers/isValidSizeObjectLiteral.ts b/packages/libs/designer-decisions/src/values/primitives/size/helpers/isValidSizeObjectLiteral.ts new file mode 100644 index 00000000..0950dbe3 --- /dev/null +++ b/packages/libs/designer-decisions/src/values/primitives/size/helpers/isValidSizeObjectLiteral.ts @@ -0,0 +1,21 @@ +import type { SizeObjectLiteral } from '../../../../inputs'; + +import { SIZE_ABSOLUtE_UNITS } from './constants'; + +export const isValidSizeObjectLiteral = (input: unknown): input is SizeObjectLiteral => { + if (typeof input !== 'object' || input === null) { + return false; + } + + const { value, units } = input as Partial; + + if (typeof value !== 'number' || isNaN(value)) { + return false; + } + + if (typeof units !== 'string' || !SIZE_ABSOLUtE_UNITS.includes(units)) { + return false; + } + + return true; +}; diff --git a/packages/libs/designer-decisions/src/values/primitives/size/index.ts b/packages/libs/designer-decisions/src/values/primitives/size/index.ts new file mode 100644 index 00000000..ee84a4cc --- /dev/null +++ b/packages/libs/designer-decisions/src/values/primitives/size/index.ts @@ -0,0 +1,4 @@ +// @index(['./*.ts', '!./*.test.ts', './!(private|mocks|functions)*/index.ts'], f => `export * from '${f.path.replace(/\/index$/, '')}';`) +export * from './createSize'; +export * from './helpers'; +export * from './types'; diff --git a/packages/libs/designer-decisions/src/values/primitives/size/types/index.ts b/packages/libs/designer-decisions/src/values/primitives/size/types/index.ts new file mode 100644 index 00000000..3eb035dd --- /dev/null +++ b/packages/libs/designer-decisions/src/values/primitives/size/types/index.ts @@ -0,0 +1,2 @@ +// @index(['./*.ts', '!./*.test.ts', './!(private|mocks|functions)*/index.ts'], f => `export * from '${f.path.replace(/\/index$/, '')}';`) +export * from './size'; diff --git a/packages/libs/designer-decisions/src/values/primitives/size/types/size.ts b/packages/libs/designer-decisions/src/values/primitives/size/types/size.ts new file mode 100644 index 00000000..b1e46b13 --- /dev/null +++ b/packages/libs/designer-decisions/src/values/primitives/size/types/size.ts @@ -0,0 +1,7 @@ +import type { SizeAbsoluteUnits } from '../../../../inputs'; + +export type Size = { + value: number; + units: SizeAbsoluteUnits; + toString: () => string; +}; diff --git a/packages/libs/designer-shows/src/astro/meta/getDecisionComponent.ts b/packages/libs/designer-shows/src/astro/meta/getDecisionComponent.ts index 93975efc..7c3b2a30 100644 --- a/packages/libs/designer-shows/src/astro/meta/getDecisionComponent.ts +++ b/packages/libs/designer-shows/src/astro/meta/getDecisionComponent.ts @@ -12,8 +12,8 @@ import { ShowColorChannelViz, ShowColorValue, ShowColorViz, - ShowSpaceValue, - ShowSpaceViz, + ShowSizeValue, + ShowSizeViz, ShowTypefaceValue, ShowTypefaceViz, } from '../values'; @@ -81,8 +81,8 @@ export const getDecisionComponentMap = ( 'color-srgb-saturation-scale': channelCs(ShowSetDecision), 'color-set': defaultCs(ShowSetDecision, valueC(ShowColorValue), vizC(ShowColorViz)), 'color-value': defaultCs(ShowValueDecision, valueC(ShowColorValue), vizC(ShowColorViz)), - 'space-value': defaultCs(ShowValueDecision, valueC(ShowSpaceValue), vizC(ShowSpaceViz)), - 'space-scale': defaultCs(ShowSetDecision, valueC(ShowSpaceValue), vizC(ShowSpaceViz)), + 'size-value': defaultCs(ShowValueDecision, valueC(ShowSizeValue), vizC(ShowSizeViz)), + 'size-scale': defaultCs(ShowSetDecision, valueC(ShowSizeValue), vizC(ShowSizeViz)), 'typeface-value': defaultCs( ShowValueDecision, valueC(ShowTypefaceValue), diff --git a/packages/libs/designer-shows/src/astro/meta/getSizeVizComponent.ts b/packages/libs/designer-shows/src/astro/meta/getSizeVizComponent.ts new file mode 100644 index 00000000..66f2831e --- /dev/null +++ b/packages/libs/designer-shows/src/astro/meta/getSizeVizComponent.ts @@ -0,0 +1,17 @@ +import type { SizeVizComponent, SizeVizName } from '../types'; +import { SizeCircleViz, SizeHorizontalBarViz, SizeSquareViz, SizeVerticalBarViz } from '../viz'; + +export const getSizeVizComponent = (viz?: string | boolean): SizeVizComponent => { + // WIP we would rather have this in a constants.ts file but it looks like + // component function references are not available in the unit scope + const SIZE_VIZ_COMPONENT_MAP: Record = { + square: SizeSquareViz, + circle: SizeCircleViz, + 'bar-h': SizeHorizontalBarViz, + 'bar-v': SizeVerticalBarViz, + }; + + const mapped = typeof viz === 'string' && SIZE_VIZ_COMPONENT_MAP[viz as SizeVizName]; + + return mapped || SizeHorizontalBarViz; +}; diff --git a/packages/libs/designer-shows/src/astro/meta/getSpaceVizComponent.ts b/packages/libs/designer-shows/src/astro/meta/getSpaceVizComponent.ts deleted file mode 100644 index 434c9dba..00000000 --- a/packages/libs/designer-shows/src/astro/meta/getSpaceVizComponent.ts +++ /dev/null @@ -1,17 +0,0 @@ -import type { SpaceVizComponent, SpaceVizName } from '../types'; -import { SpaceCircleViz, SpaceHorizontalBarViz, SpaceSquareViz, SpaceVerticalBarViz } from '../viz'; - -export const getSpaceVizComponent = (viz?: string | boolean): SpaceVizComponent => { - // WIP we would rather have this in a constants.ts file but it looks like - // component function references are not available in the unit scope - const SPACE_VIZ_COMPONENT_MAP: Record = { - square: SpaceSquareViz, - circle: SpaceCircleViz, - 'bar-h': SpaceHorizontalBarViz, - 'bar-v': SpaceVerticalBarViz, - }; - - const mapped = typeof viz === 'string' && SPACE_VIZ_COMPONENT_MAP[viz as SpaceVizName]; - - return mapped || SpaceHorizontalBarViz; -}; diff --git a/packages/libs/designer-shows/src/astro/meta/index.ts b/packages/libs/designer-shows/src/astro/meta/index.ts index c2eb0018..2a5b5fad 100644 --- a/packages/libs/designer-shows/src/astro/meta/index.ts +++ b/packages/libs/designer-shows/src/astro/meta/index.ts @@ -1,4 +1,4 @@ // @index(['./*.ts', '!./*.test.ts', './!(private|mocks|functions)*/index.ts'], f => `export * from '${f.path.replace(/\/index$/, '')}';`) export * from './getColorVizComponent'; export * from './getDecisionComponent'; -export * from './getSpaceVizComponent'; +export * from './getSizeVizComponent'; diff --git a/packages/libs/designer-shows/src/astro/styles/base.css b/packages/libs/designer-shows/src/astro/styles/base.css index fcabf20e..6ea19787 100644 --- a/packages/libs/designer-shows/src/astro/styles/base.css +++ b/packages/libs/designer-shows/src/astro/styles/base.css @@ -81,9 +81,9 @@ --dd-viz-size-l: var(--dd-size-l); --dd-viz-size-xl: var(--dd-size-xl); - --dd-space-viz-color: var(--dd-color-max); - --dd-space-viz-border: none; - --dd-space-viz-border-radius: 0; + --dd-size-viz-color: var(--dd-color-max); + --dd-size-viz-border: none; + --dd-size-viz-border-radius: 0; --dd-color-viz-border: 1px solid var(--sl-color-gray-3); --dd-color-viz-border-radius: 5px; diff --git a/packages/libs/designer-shows/src/astro/types/index.ts b/packages/libs/designer-shows/src/astro/types/index.ts index 47803cba..84ce2b73 100644 --- a/packages/libs/designer-shows/src/astro/types/index.ts +++ b/packages/libs/designer-shows/src/astro/types/index.ts @@ -1,4 +1,4 @@ -import type { ColorValue, SpaceValue, TypefaceValue } from '@noodlestan/designer-decisions'; +import type { ColorValue, SizeValue, TypefaceValue } from '@noodlestan/designer-decisions'; import type { Store } from '@noodlestan/designer-functions'; import type { LayoutDynamicProps } from '../layouts'; @@ -43,23 +43,13 @@ export type DecisionVizComponent = (props: ShowVizPro /* space */ -export type SpaceVizName = 'square' | 'circle' | 'bar-h' | 'bar-v'; +export type SizeVizName = 'square' | 'circle' | 'bar-h' | 'bar-v'; -export type SpaceVizProps = ShowVizProps & { - viz?: boolean | SpaceVizName; - v?: SpaceValue; +export type SizeVizProps = ShowVizProps & { + viz?: boolean | SizeVizName; + v?: SizeValue; }; -export type SpaceVizComponent = (props: SpaceVizProps) => unknown; - -/* space */ - -export type TypeVizName = 'short-text'; - -export type TypeVizProps = ShowVizProps & { - viz?: boolean | TypeVizName; - v?: TypefaceValue; // WIP : this will have to be a TypeStyleValue -}; -export type TypeVizComponent = (props: TypeVizProps) => unknown; +export type SizeVizComponent = (props: SizeVizProps) => unknown; /* color */ @@ -79,3 +69,13 @@ export type ColorVizProps = ShowVizProps & { options?: ColorVizOptions; }; export type ColorVizComponent = (props: ColorVizProps) => unknown; + +/* typography */ + +export type TypeVizName = 'short-text'; + +export type TypeVizProps = ShowVizProps & { + viz?: boolean | TypeVizName; + v?: TypefaceValue; // WIP : this will have to be a TypeStyleValue +}; +export type TypeVizComponent = (props: TypeVizProps) => unknown; diff --git a/packages/libs/designer-shows/src/astro/values/space/ShowSpaceValue.astro b/packages/libs/designer-shows/src/astro/values/space/ShowSizeValue.astro similarity index 58% rename from packages/libs/designer-shows/src/astro/values/space/ShowSpaceValue.astro rename to packages/libs/designer-shows/src/astro/values/space/ShowSizeValue.astro index b59515c4..d4a92244 100644 --- a/packages/libs/designer-shows/src/astro/values/space/ShowSpaceValue.astro +++ b/packages/libs/designer-shows/src/astro/values/space/ShowSizeValue.astro @@ -1,23 +1,23 @@ --- -import { type SpaceValue } from '@noodlestan/designer-decisions'; +import { type SizeValue } from '@noodlestan/designer-decisions'; import { DecisionValueContainer, ShowError } from '../../atoms'; import { LayoutStack } from '../../layouts'; import type { ShowValueProps } from '../../types'; type Props = ShowValueProps & { - v?: SpaceValue; + v?: SizeValue; }; -const { v: spaceValue, value = true, muteErrors } = Astro.props; +const { v: sizeValue, value = true, muteErrors } = Astro.props; -const { value: v, units } = spaceValue?.toObject() || {}; +const { value: v, units } = sizeValue?.toObject() || {}; const vWithUnits = `${v}${units}`; -const showErrors = !muteErrors && spaceValue?.context().hasErrors(); +const showErrors = !muteErrors && sizeValue?.context().hasErrors(); --- { - value && spaceValue !== undefined && ( + value && sizeValue !== undefined && ( {showErrors && } diff --git a/packages/libs/designer-shows/src/astro/values/space/ShowSizeViz.astro b/packages/libs/designer-shows/src/astro/values/space/ShowSizeViz.astro new file mode 100644 index 00000000..9632916f --- /dev/null +++ b/packages/libs/designer-shows/src/astro/values/space/ShowSizeViz.astro @@ -0,0 +1,18 @@ +--- +import { type SizeValue } from '@noodlestan/designer-decisions'; + +import { getSizeVizComponent } from '../../meta'; +import type { ShowVizProps } from '../../types'; + +type Props = ShowVizProps & { + v?: SizeValue; +}; + +const { v: sizeValue, viz = true, size = 'auto', options } = Astro.props; + +const Viz = getSizeVizComponent(viz); + +const opt = options || {}; +--- + +{viz && } diff --git a/packages/libs/designer-shows/src/astro/values/space/ShowSpaceViz.astro b/packages/libs/designer-shows/src/astro/values/space/ShowSpaceViz.astro deleted file mode 100644 index 4c78fd7b..00000000 --- a/packages/libs/designer-shows/src/astro/values/space/ShowSpaceViz.astro +++ /dev/null @@ -1,18 +0,0 @@ ---- -import { type SpaceValue } from '@noodlestan/designer-decisions'; - -import { getSpaceVizComponent } from '../../meta'; -import type { ShowVizProps } from '../../types'; - -type Props = ShowVizProps & { - v?: SpaceValue; -}; - -const { v: spaceValue, viz = true, size = 'auto', options } = Astro.props; - -const Viz = getSpaceVizComponent(viz); - -const opt = options || {}; ---- - -{viz && } diff --git a/packages/libs/designer-shows/src/astro/values/space/index.ts b/packages/libs/designer-shows/src/astro/values/space/index.ts index 757dabf9..06744411 100644 --- a/packages/libs/designer-shows/src/astro/values/space/index.ts +++ b/packages/libs/designer-shows/src/astro/values/space/index.ts @@ -1,3 +1,3 @@ // @index(['./*.astro','./!(private|functions)*/index.ts}'], f => `export { default as ${f.name.replace(/\/index$/, '')} } from '${f.path}.astro';`) -export { default as ShowSpaceValue } from './ShowSpaceValue.astro'; -export { default as ShowSpaceViz } from './ShowSpaceViz.astro'; +export { default as ShowSizeValue } from './ShowSizeValue.astro'; +export { default as ShowSizeViz } from './ShowSizeViz.astro'; diff --git a/packages/libs/designer-shows/src/astro/viz/space/SpaceCircleViz.astro b/packages/libs/designer-shows/src/astro/viz/space/SizeCircleViz.astro similarity index 60% rename from packages/libs/designer-shows/src/astro/viz/space/SpaceCircleViz.astro rename to packages/libs/designer-shows/src/astro/viz/space/SizeCircleViz.astro index 645601a5..30e7e642 100644 --- a/packages/libs/designer-shows/src/astro/viz/space/SpaceCircleViz.astro +++ b/packages/libs/designer-shows/src/astro/viz/space/SizeCircleViz.astro @@ -1,23 +1,23 @@ --- import { ShowError } from '../../atoms'; -import type { SpaceVizProps } from '../../types'; +import type { SizeVizProps } from '../../types'; -type Props = SpaceVizProps; +type Props = SizeVizProps; -const { v: space, muteErrors } = Astro.props; +const { v: sizeValue, muteErrors } = Astro.props; -const { value: v, units } = space?.toObject() || {}; +const { value: v, units } = sizeValue?.get() || {}; const vWithUnits = `${v}${units}`; -const showErrors = !muteErrors && space?.context().hasErrors(); +const showErrors = !muteErrors && sizeValue?.context().hasErrors(); --- -
+
{showErrors && }
diff --git a/packages/libs/designer-shows/src/astro/viz/space/SpaceHorizontalBarViz.astro b/packages/libs/designer-shows/src/astro/viz/space/SizeHorizontalBarViz.astro similarity index 65% rename from packages/libs/designer-shows/src/astro/viz/space/SpaceHorizontalBarViz.astro rename to packages/libs/designer-shows/src/astro/viz/space/SizeHorizontalBarViz.astro index c525643e..7bf2e0a2 100644 --- a/packages/libs/designer-shows/src/astro/viz/space/SpaceHorizontalBarViz.astro +++ b/packages/libs/designer-shows/src/astro/viz/space/SizeHorizontalBarViz.astro @@ -1,23 +1,23 @@ --- import { ShowError } from '../../atoms'; -import type { SpaceVizProps } from '../../types'; +import type { SizeVizProps } from '../../types'; -type Props = SpaceVizProps; +type Props = SizeVizProps; -const { v: space, size = 'auto', muteErrors } = Astro.props; +const { v: sizeValue, size = 'auto', muteErrors } = Astro.props; -const { value: v, units } = space?.toObject() || {}; +const { value: v, units } = sizeValue?.get() || {}; const vWithUnits = `${v}${units}`; -const showErrors = !muteErrors && space?.context().hasErrors(); +const showErrors = !muteErrors && sizeValue?.context().hasErrors(); --- -
+
{showErrors && }
diff --git a/packages/libs/designer-shows/src/astro/viz/space/SpaceSquareViz.astro b/packages/libs/designer-shows/src/astro/viz/space/SizeSquareViz.astro similarity index 56% rename from packages/libs/designer-shows/src/astro/viz/space/SpaceSquareViz.astro rename to packages/libs/designer-shows/src/astro/viz/space/SizeSquareViz.astro index 1f70ef88..1890fe16 100644 --- a/packages/libs/designer-shows/src/astro/viz/space/SpaceSquareViz.astro +++ b/packages/libs/designer-shows/src/astro/viz/space/SizeSquareViz.astro @@ -1,23 +1,23 @@ --- import { ShowError } from '../../atoms'; -import type { SpaceVizProps } from '../../types'; +import type { SizeVizProps } from '../../types'; -type Props = SpaceVizProps; +type Props = SizeVizProps; -const { v: space, muteErrors } = Astro.props; +const { v: sizeValue, muteErrors } = Astro.props; -const { value: v, units } = space?.toObject() || {}; +const { value: v, units } = sizeValue?.get() || {}; const vWithUnits = `${v}${units}`; -const showErrors = !muteErrors && space?.context().hasErrors(); +const showErrors = !muteErrors && sizeValue?.context().hasErrors(); --- -
+
{showErrors && }
diff --git a/packages/libs/designer-shows/src/astro/viz/space/SpaceVerticalBarViz.astro b/packages/libs/designer-shows/src/astro/viz/space/SizeVerticalBarViz.astro similarity index 62% rename from packages/libs/designer-shows/src/astro/viz/space/SpaceVerticalBarViz.astro rename to packages/libs/designer-shows/src/astro/viz/space/SizeVerticalBarViz.astro index 859aaf40..8c4f9d8a 100644 --- a/packages/libs/designer-shows/src/astro/viz/space/SpaceVerticalBarViz.astro +++ b/packages/libs/designer-shows/src/astro/viz/space/SizeVerticalBarViz.astro @@ -1,23 +1,23 @@ --- import { ShowError } from '../../atoms'; -import type { SpaceVizProps } from '../../types'; +import type { SizeVizProps } from '../../types'; -type Props = SpaceVizProps; +type Props = SizeVizProps; -const { v: space, size = 'auto', muteErrors } = Astro.props; +const { v: sizeValue, size = 'auto', muteErrors } = Astro.props; -const { value: v, units } = space?.toObject() || {}; +const { value: v, units } = sizeValue?.get() || {}; const vWithUnits = `${v}${units}`; -const showErrors = !muteErrors && space?.context().hasErrors(); +const showErrors = !muteErrors && sizeValue?.context().hasErrors(); --- -
+
{showErrors && }
diff --git a/packages/libs/designer-shows/src/astro/viz/space/index.ts b/packages/libs/designer-shows/src/astro/viz/space/index.ts index 391922e0..9cb1176b 100644 --- a/packages/libs/designer-shows/src/astro/viz/space/index.ts +++ b/packages/libs/designer-shows/src/astro/viz/space/index.ts @@ -1,5 +1,5 @@ // @index(['./*.astro','./!(private|functions)*/index.ts}'], f => `export { default as ${f.name.replace(/\/index$/, '')} } from '${f.path}.astro';`) -export { default as SpaceCircleViz } from './SpaceCircleViz.astro'; -export { default as SpaceHorizontalBarViz } from './SpaceHorizontalBarViz.astro'; -export { default as SpaceSquareViz } from './SpaceSquareViz.astro'; -export { default as SpaceVerticalBarViz } from './SpaceVerticalBarViz.astro'; +export { default as SizeCircleViz } from './SizeCircleViz.astro'; +export { default as SizeHorizontalBarViz } from './SizeHorizontalBarViz.astro'; +export { default as SizeSquareViz } from './SizeSquareViz.astro'; +export { default as SizeVerticalBarViz } from './SizeVerticalBarViz.astro'; From b6d76082606328ebca2a5692a10b470d2f8ad4e6 Mon Sep 17 00:00:00 2001 From: Andre Torgal Date: Sun, 23 Feb 2025 01:26:44 +0100 Subject: [PATCH 2/2] Rename "space" models, values and primitives to "size" --- .../api/designer-shows/Types/SizeVizName.mdx | 2 +- .../_partials/TableDecisionComponents.astro | 29 +++++++++++++++++-- ...anchored.json => size-scale-anchored.json} | 0 ...e-bounded.json => size-scale-bounded.json} | 0 ...explicit.json => size-scale-explicit.json} | 0 ...explicit.json => size-value-explicit.json} | 0 .../models/color/{set.ts => color-set.ts} | 0 .../models/color/{color.ts => color-value.ts} | 0 .../src/inputs/types/models/color/index.ts | 4 +-- ...{chroma.ts => color-oklab-chroma-scale.ts} | 8 ----- .../color/oklab/color-oklab-chroma-value.ts | 9 ++++++ .../oklab/{hue.ts => color-oklab-hue-set.ts} | 8 ----- .../color/oklab/color-oklab-hue-value.ts | 9 ++++++ ...ness.ts => color-oklab-lightness-scale.ts} | 8 ----- .../oklab/color-oklab-lightness-value.ts | 9 ++++++ .../inputs/types/models/color/oklab/index.ts | 9 ++++-- .../srgb/{hue.ts => color-srgb-hue-set.ts} | 8 ----- .../models/color/srgb/color-srgb-hue-value.ts | 9 ++++++ ...tness.ts => color-srgb-lightness-scale.ts} | 8 ----- .../color/srgb/color-srgb-lightness-value.ts | 9 ++++++ ...tion.ts => color-srgb-saturation-scale.ts} | 8 ----- .../color/srgb/color-srgb-saturation-value.ts | 9 ++++++ .../inputs/types/models/color/srgb/index.ts | 9 ++++-- .../src/inputs/types/models/space/index.ts | 4 +-- .../models/space/{set.ts => size-scale.ts} | 0 .../models/space/{value.ts => size-value.ts} | 0 .../inputs/types/models/typography/index.ts | 2 +- .../{value.ts => typeface-value.ts} | 0 .../primitives/size/helpers/constants.ts | 2 +- .../size/helpers/isValidSizeObjectLiteral.ts | 4 +-- 30 files changed, 101 insertions(+), 66 deletions(-) rename packages/libs/designer-decisions/resources/data/samples/space/{space-scale-anchored.json => size-scale-anchored.json} (100%) rename packages/libs/designer-decisions/resources/data/samples/space/{space-scale-bounded.json => size-scale-bounded.json} (100%) rename packages/libs/designer-decisions/resources/data/samples/space/{space-scale-explicit.json => size-scale-explicit.json} (100%) rename packages/libs/designer-decisions/resources/data/samples/space/{space-value-explicit.json => size-value-explicit.json} (100%) rename packages/libs/designer-decisions/src/inputs/types/models/color/{set.ts => color-set.ts} (100%) rename packages/libs/designer-decisions/src/inputs/types/models/color/{color.ts => color-value.ts} (100%) rename packages/libs/designer-decisions/src/inputs/types/models/color/oklab/{chroma.ts => color-oklab-chroma-scale.ts} (79%) create mode 100644 packages/libs/designer-decisions/src/inputs/types/models/color/oklab/color-oklab-chroma-value.ts rename packages/libs/designer-decisions/src/inputs/types/models/color/oklab/{hue.ts => color-oklab-hue-set.ts} (79%) create mode 100644 packages/libs/designer-decisions/src/inputs/types/models/color/oklab/color-oklab-hue-value.ts rename packages/libs/designer-decisions/src/inputs/types/models/color/oklab/{lightness.ts => color-oklab-lightness-scale.ts} (79%) create mode 100644 packages/libs/designer-decisions/src/inputs/types/models/color/oklab/color-oklab-lightness-value.ts rename packages/libs/designer-decisions/src/inputs/types/models/color/srgb/{hue.ts => color-srgb-hue-set.ts} (79%) create mode 100644 packages/libs/designer-decisions/src/inputs/types/models/color/srgb/color-srgb-hue-value.ts rename packages/libs/designer-decisions/src/inputs/types/models/color/srgb/{lightness.ts => color-srgb-lightness-scale.ts} (79%) create mode 100644 packages/libs/designer-decisions/src/inputs/types/models/color/srgb/color-srgb-lightness-value.ts rename packages/libs/designer-decisions/src/inputs/types/models/color/srgb/{saturation.ts => color-srgb-saturation-scale.ts} (79%) create mode 100644 packages/libs/designer-decisions/src/inputs/types/models/color/srgb/color-srgb-saturation-value.ts rename packages/libs/designer-decisions/src/inputs/types/models/space/{set.ts => size-scale.ts} (100%) rename packages/libs/designer-decisions/src/inputs/types/models/space/{value.ts => size-value.ts} (100%) rename packages/libs/designer-decisions/src/inputs/types/models/typography/{value.ts => typeface-value.ts} (100%) diff --git a/docs/designer-decisions/src/content/docs/api/designer-shows/Types/SizeVizName.mdx b/docs/designer-decisions/src/content/docs/api/designer-shows/Types/SizeVizName.mdx index 34968af4..74fa0014 100644 --- a/docs/designer-decisions/src/content/docs/api/designer-shows/Types/SizeVizName.mdx +++ b/docs/designer-decisions/src/content/docs/api/designer-shows/Types/SizeVizName.mdx @@ -5,7 +5,7 @@ slug: api/designer-shows/Types/SizeVizName import { ShowDecision } from '@noodlestan/designer-shows/astro'; -Available visualizations for [Space Values](/integrations/Astro/Composable/Values/#showsizevalue) +Available visualizations for [Size Values](/integrations/Astro/Composable/Values/#showsizevalue) ```ts type SizeVizName = 'bar-h' | 'bar-v' | 'square' | 'circle'; diff --git a/docs/designer-decisions/src/content/docs/integrations/Astro/_partials/TableDecisionComponents.astro b/docs/designer-decisions/src/content/docs/integrations/Astro/_partials/TableDecisionComponents.astro index 98dffc25..788349a7 100644 --- a/docs/designer-decisions/src/content/docs/integrations/Astro/_partials/TableDecisionComponents.astro +++ b/docs/designer-decisions/src/content/docs/integrations/Astro/_partials/TableDecisionComponents.astro @@ -11,102 +11,125 @@ const types = [ { name: 'SizeValue', type: 'size-value', + domain: 'space', viz: 'ShowSizeViz', value: 'ShowSizeValue', }, { name: 'SizeScale', type: 'size-scale', + domain: 'space', viz: 'ShowSizeViz', value: 'ShowSizeValue', }, { name: 'ColorValue', type: 'color-value', + domain: 'color', viz: 'ShowColorViz', value: 'ShowColorValue', }, { name: 'ColorSet', type: 'color-set', + domain: 'color', viz: 'ShowColorViz', value: 'ShowColorValue', }, { name: 'Color Oklab Hue Value', type: 'color-oklab-hue-value', + domain: 'color', viz: 'ShowColorChannelViz', value: 'ShowColorChannelValue', }, { name: 'Color Oklab Hue Set', type: 'color-oklab-hue-set', + domain: 'color', viz: 'ShowColorChannelViz', value: 'ShowColorChannelValue', }, { name: 'Color Oklab Chroma Value', type: 'color-oklab-chroma-value', + domain: 'color', viz: 'ShowColorChannelViz', value: 'ShowColorChannelValue', }, { name: 'Color Oklab Chroma Scale', type: 'color-oklab-chroma-scale', + domain: 'color', viz: 'ShowColorChannelViz', value: 'ShowColorChannelValue', }, { name: 'Color Oklab Lightness Value', type: 'color-oklab-lightness-value', + domain: 'color', viz: 'ShowColorChannelViz', value: 'ShowColorChannelValue', }, { name: 'Color Oklab Lightness Scale', type: 'color-oklab-lightness-scale', + domain: 'color', viz: 'ShowColorChannelViz', value: 'ShowColorChannelValue', }, { name: 'Color sRGB Hue Value', type: 'color-srgb-hue-value', + domain: 'color', viz: 'ShowColorChannelViz', value: 'ShowColorChannelValue', }, { name: 'Color sRGB Hue Set', type: 'color-srgb-hue-set', + domain: 'color', viz: 'ShowColorChannelViz', value: 'ShowColorChannelValue', }, { name: 'Color sRGB Saturation Value', type: 'color-srgb-saturation-value', + domain: 'color', viz: 'ShowColorChannelViz', value: 'ShowColorChannelValue', }, { name: 'Color sRGB Saturation Scale', type: 'color-srgb-saturation-scale', + domain: 'color', viz: 'ShowColorChannelViz', value: 'ShowColorChannelValue', }, { name: 'Color sRGB Lightness Value', type: 'color-srgb-lightness-value', + domain: 'color', viz: 'ShowColorChannelViz', value: 'ShowColorChannelValue', }, { - name: 'Color sRGB Lightness Scale ', - type: 'color-srgb-lightness-scale ', + name: 'Color sRGB Lightness Scale', + type: 'color-srgb-lightness-scale', + domain: 'color', viz: 'ShowColorChannelViz', value: 'ShowColorChannelValue', }, + { + name: 'Typeface Value ', + type: 'typeface-value', + domain: 'typography', + viz: 'ShowTypeViz', + value: 'ShowTypeValue', + }, ]; -const items = domain ? types.filter(({ type }) => type.startsWith(domain)) : types; +const items = domain ? types.filter(({ domain: d }) => d === domain) : types; --- diff --git a/packages/libs/designer-decisions/resources/data/samples/space/space-scale-anchored.json b/packages/libs/designer-decisions/resources/data/samples/space/size-scale-anchored.json similarity index 100% rename from packages/libs/designer-decisions/resources/data/samples/space/space-scale-anchored.json rename to packages/libs/designer-decisions/resources/data/samples/space/size-scale-anchored.json diff --git a/packages/libs/designer-decisions/resources/data/samples/space/space-scale-bounded.json b/packages/libs/designer-decisions/resources/data/samples/space/size-scale-bounded.json similarity index 100% rename from packages/libs/designer-decisions/resources/data/samples/space/space-scale-bounded.json rename to packages/libs/designer-decisions/resources/data/samples/space/size-scale-bounded.json diff --git a/packages/libs/designer-decisions/resources/data/samples/space/space-scale-explicit.json b/packages/libs/designer-decisions/resources/data/samples/space/size-scale-explicit.json similarity index 100% rename from packages/libs/designer-decisions/resources/data/samples/space/space-scale-explicit.json rename to packages/libs/designer-decisions/resources/data/samples/space/size-scale-explicit.json diff --git a/packages/libs/designer-decisions/resources/data/samples/space/space-value-explicit.json b/packages/libs/designer-decisions/resources/data/samples/space/size-value-explicit.json similarity index 100% rename from packages/libs/designer-decisions/resources/data/samples/space/space-value-explicit.json rename to packages/libs/designer-decisions/resources/data/samples/space/size-value-explicit.json diff --git a/packages/libs/designer-decisions/src/inputs/types/models/color/set.ts b/packages/libs/designer-decisions/src/inputs/types/models/color/color-set.ts similarity index 100% rename from packages/libs/designer-decisions/src/inputs/types/models/color/set.ts rename to packages/libs/designer-decisions/src/inputs/types/models/color/color-set.ts diff --git a/packages/libs/designer-decisions/src/inputs/types/models/color/color.ts b/packages/libs/designer-decisions/src/inputs/types/models/color/color-value.ts similarity index 100% rename from packages/libs/designer-decisions/src/inputs/types/models/color/color.ts rename to packages/libs/designer-decisions/src/inputs/types/models/color/color-value.ts diff --git a/packages/libs/designer-decisions/src/inputs/types/models/color/index.ts b/packages/libs/designer-decisions/src/inputs/types/models/color/index.ts index bf4cfa65..7f437176 100644 --- a/packages/libs/designer-decisions/src/inputs/types/models/color/index.ts +++ b/packages/libs/designer-decisions/src/inputs/types/models/color/index.ts @@ -1,5 +1,5 @@ // @index(['./*.ts', '!./*.test.ts', './!(private|mocks|functions)*/index.ts'], f => `export * from '${f.path.replace(/\/index$/, '')}';`) -export * from './color'; +export * from './color-set'; +export * from './color-value'; export * from './oklab'; -export * from './set'; export * from './srgb'; diff --git a/packages/libs/designer-decisions/src/inputs/types/models/color/oklab/chroma.ts b/packages/libs/designer-decisions/src/inputs/types/models/color/oklab/color-oklab-chroma-scale.ts similarity index 79% rename from packages/libs/designer-decisions/src/inputs/types/models/color/oklab/chroma.ts rename to packages/libs/designer-decisions/src/inputs/types/models/color/oklab/color-oklab-chroma-scale.ts index b91725be..9e56ef91 100644 --- a/packages/libs/designer-decisions/src/inputs/types/models/color/oklab/chroma.ts +++ b/packages/libs/designer-decisions/src/inputs/types/models/color/oklab/color-oklab-chroma-scale.ts @@ -4,14 +4,6 @@ import type { DecisionInput, } from '../../../primitives'; -export type ColorOklabChromaValueExplicitInput = DecisionInput & { - model: 'color-oklab-chroma-value/explicit'; - params: { - value: ColorOklabChromaInput; - quantize?: number; - }; -}; - export type ColorOklabChromaScaleExplicitInput = DecisionInput & { model: 'color-oklab-chroma-scale/explicit'; params: { diff --git a/packages/libs/designer-decisions/src/inputs/types/models/color/oklab/color-oklab-chroma-value.ts b/packages/libs/designer-decisions/src/inputs/types/models/color/oklab/color-oklab-chroma-value.ts new file mode 100644 index 00000000..ba8493fd --- /dev/null +++ b/packages/libs/designer-decisions/src/inputs/types/models/color/oklab/color-oklab-chroma-value.ts @@ -0,0 +1,9 @@ +import type { ColorOklabChromaInput, DecisionInput } from '../../../primitives'; + +export type ColorOklabChromaValueExplicitInput = DecisionInput & { + model: 'color-oklab-chroma-value/explicit'; + params: { + value: ColorOklabChromaInput; + quantize?: number; + }; +}; diff --git a/packages/libs/designer-decisions/src/inputs/types/models/color/oklab/hue.ts b/packages/libs/designer-decisions/src/inputs/types/models/color/oklab/color-oklab-hue-set.ts similarity index 79% rename from packages/libs/designer-decisions/src/inputs/types/models/color/oklab/hue.ts rename to packages/libs/designer-decisions/src/inputs/types/models/color/oklab/color-oklab-hue-set.ts index 26d7645f..c917177a 100644 --- a/packages/libs/designer-decisions/src/inputs/types/models/color/oklab/hue.ts +++ b/packages/libs/designer-decisions/src/inputs/types/models/color/oklab/color-oklab-hue-set.ts @@ -4,14 +4,6 @@ import type { DecisionInput, } from '../../../primitives'; -export type ColorOklabHueValueExplicitInput = DecisionInput & { - model: 'color-oklab-hue-value/explicit'; - params: { - value: ColorOklabHueInput; - quantize?: number; - }; -}; - export type ColorOklabHueSetExplicitInput = DecisionInput & { model: 'color-oklab-hue-set/explicit'; params: { diff --git a/packages/libs/designer-decisions/src/inputs/types/models/color/oklab/color-oklab-hue-value.ts b/packages/libs/designer-decisions/src/inputs/types/models/color/oklab/color-oklab-hue-value.ts new file mode 100644 index 00000000..339aece3 --- /dev/null +++ b/packages/libs/designer-decisions/src/inputs/types/models/color/oklab/color-oklab-hue-value.ts @@ -0,0 +1,9 @@ +import type { ColorOklabHueInput, DecisionInput } from '../../../primitives'; + +export type ColorOklabHueValueExplicitInput = DecisionInput & { + model: 'color-oklab-hue-value/explicit'; + params: { + value: ColorOklabHueInput; + quantize?: number; + }; +}; diff --git a/packages/libs/designer-decisions/src/inputs/types/models/color/oklab/lightness.ts b/packages/libs/designer-decisions/src/inputs/types/models/color/oklab/color-oklab-lightness-scale.ts similarity index 79% rename from packages/libs/designer-decisions/src/inputs/types/models/color/oklab/lightness.ts rename to packages/libs/designer-decisions/src/inputs/types/models/color/oklab/color-oklab-lightness-scale.ts index 4bb4f841..a6b6f23c 100644 --- a/packages/libs/designer-decisions/src/inputs/types/models/color/oklab/lightness.ts +++ b/packages/libs/designer-decisions/src/inputs/types/models/color/oklab/color-oklab-lightness-scale.ts @@ -4,14 +4,6 @@ import type { DecisionInput, } from '../../../primitives'; -export type ColorOklabLightnessValueExplicitInput = DecisionInput & { - model: 'color-oklab-lightness-value/explicit'; - params: { - value: ColorOklabLightnessInput; - quantize?: number; - }; -}; - export type ColorOklabLightnessScaleExplicitInput = DecisionInput & { model: 'color-oklab-lightness-scale/explicit'; params: { diff --git a/packages/libs/designer-decisions/src/inputs/types/models/color/oklab/color-oklab-lightness-value.ts b/packages/libs/designer-decisions/src/inputs/types/models/color/oklab/color-oklab-lightness-value.ts new file mode 100644 index 00000000..f84bcfce --- /dev/null +++ b/packages/libs/designer-decisions/src/inputs/types/models/color/oklab/color-oklab-lightness-value.ts @@ -0,0 +1,9 @@ +import type { ColorOklabLightnessInput, DecisionInput } from '../../../primitives'; + +export type ColorOklabLightnessValueExplicitInput = DecisionInput & { + model: 'color-oklab-lightness-value/explicit'; + params: { + value: ColorOklabLightnessInput; + quantize?: number; + }; +}; diff --git a/packages/libs/designer-decisions/src/inputs/types/models/color/oklab/index.ts b/packages/libs/designer-decisions/src/inputs/types/models/color/oklab/index.ts index cf75235a..4cf584f1 100644 --- a/packages/libs/designer-decisions/src/inputs/types/models/color/oklab/index.ts +++ b/packages/libs/designer-decisions/src/inputs/types/models/color/oklab/index.ts @@ -1,4 +1,7 @@ // @index(['./*.ts', '!./*.test.ts', './!(private|mocks|functions)*/index.ts'], f => `export * from '${f.path.replace(/\/index$/, '')}';`) -export * from './chroma'; -export * from './hue'; -export * from './lightness'; +export * from './color-oklab-chroma-scale'; +export * from './color-oklab-chroma-value'; +export * from './color-oklab-hue-set'; +export * from './color-oklab-hue-value'; +export * from './color-oklab-lightness-scale'; +export * from './color-oklab-lightness-value'; diff --git a/packages/libs/designer-decisions/src/inputs/types/models/color/srgb/hue.ts b/packages/libs/designer-decisions/src/inputs/types/models/color/srgb/color-srgb-hue-set.ts similarity index 79% rename from packages/libs/designer-decisions/src/inputs/types/models/color/srgb/hue.ts rename to packages/libs/designer-decisions/src/inputs/types/models/color/srgb/color-srgb-hue-set.ts index e0c88dd9..38241b3a 100644 --- a/packages/libs/designer-decisions/src/inputs/types/models/color/srgb/hue.ts +++ b/packages/libs/designer-decisions/src/inputs/types/models/color/srgb/color-srgb-hue-set.ts @@ -4,14 +4,6 @@ import type { DecisionInput, } from '../../../primitives'; -export type ColorSRGBHueValueExplicitInput = DecisionInput & { - model: 'color-srgb-hue-value/explicit'; - params: { - value: ColorSRGBHueInput; - quantize?: number; - }; -}; - export type ColorSRGBHueSetExplicitInput = DecisionInput & { model: 'color-srgb-hue-set/explicit'; params: { diff --git a/packages/libs/designer-decisions/src/inputs/types/models/color/srgb/color-srgb-hue-value.ts b/packages/libs/designer-decisions/src/inputs/types/models/color/srgb/color-srgb-hue-value.ts new file mode 100644 index 00000000..53e396fe --- /dev/null +++ b/packages/libs/designer-decisions/src/inputs/types/models/color/srgb/color-srgb-hue-value.ts @@ -0,0 +1,9 @@ +import type { ColorSRGBHueInput, DecisionInput } from '../../../primitives'; + +export type ColorSRGBHueValueExplicitInput = DecisionInput & { + model: 'color-srgb-hue-value/explicit'; + params: { + value: ColorSRGBHueInput; + quantize?: number; + }; +}; diff --git a/packages/libs/designer-decisions/src/inputs/types/models/color/srgb/lightness.ts b/packages/libs/designer-decisions/src/inputs/types/models/color/srgb/color-srgb-lightness-scale.ts similarity index 79% rename from packages/libs/designer-decisions/src/inputs/types/models/color/srgb/lightness.ts rename to packages/libs/designer-decisions/src/inputs/types/models/color/srgb/color-srgb-lightness-scale.ts index 395b8735..994afe88 100644 --- a/packages/libs/designer-decisions/src/inputs/types/models/color/srgb/lightness.ts +++ b/packages/libs/designer-decisions/src/inputs/types/models/color/srgb/color-srgb-lightness-scale.ts @@ -4,14 +4,6 @@ import type { DecisionInput, } from '../../../primitives'; -export type ColorSRGBLightnessValueExplicitInput = DecisionInput & { - model: 'color-srgb-lightness-value/explicit'; - params: { - value: ColorSRGBLightnessInput; - quantize?: number; - }; -}; - export type ColorSRGBLightnessScaleExplicitInput = DecisionInput & { model: 'color-srgb-lightness-scale/explicit'; params: { diff --git a/packages/libs/designer-decisions/src/inputs/types/models/color/srgb/color-srgb-lightness-value.ts b/packages/libs/designer-decisions/src/inputs/types/models/color/srgb/color-srgb-lightness-value.ts new file mode 100644 index 00000000..e2225df0 --- /dev/null +++ b/packages/libs/designer-decisions/src/inputs/types/models/color/srgb/color-srgb-lightness-value.ts @@ -0,0 +1,9 @@ +import type { ColorSRGBLightnessInput, DecisionInput } from '../../../primitives'; + +export type ColorSRGBLightnessValueExplicitInput = DecisionInput & { + model: 'color-srgb-lightness-value/explicit'; + params: { + value: ColorSRGBLightnessInput; + quantize?: number; + }; +}; diff --git a/packages/libs/designer-decisions/src/inputs/types/models/color/srgb/saturation.ts b/packages/libs/designer-decisions/src/inputs/types/models/color/srgb/color-srgb-saturation-scale.ts similarity index 79% rename from packages/libs/designer-decisions/src/inputs/types/models/color/srgb/saturation.ts rename to packages/libs/designer-decisions/src/inputs/types/models/color/srgb/color-srgb-saturation-scale.ts index 1c7ebc74..7674f03e 100644 --- a/packages/libs/designer-decisions/src/inputs/types/models/color/srgb/saturation.ts +++ b/packages/libs/designer-decisions/src/inputs/types/models/color/srgb/color-srgb-saturation-scale.ts @@ -4,14 +4,6 @@ import type { DecisionInput, } from '../../../primitives'; -export type ColorSRGBSaturationValueExplicitInput = DecisionInput & { - model: 'color-srgb-saturation-value/explicit'; - params: { - value: ColorSRGBSaturationInput; - quantize?: number; - }; -}; - export type ColorSRGBSaturationScaleExplicitInput = DecisionInput & { model: 'color-srgb-saturation-scale/explicit'; params: { diff --git a/packages/libs/designer-decisions/src/inputs/types/models/color/srgb/color-srgb-saturation-value.ts b/packages/libs/designer-decisions/src/inputs/types/models/color/srgb/color-srgb-saturation-value.ts new file mode 100644 index 00000000..43ca5e7d --- /dev/null +++ b/packages/libs/designer-decisions/src/inputs/types/models/color/srgb/color-srgb-saturation-value.ts @@ -0,0 +1,9 @@ +import type { ColorSRGBSaturationInput, DecisionInput } from '../../../primitives'; + +export type ColorSRGBSaturationValueExplicitInput = DecisionInput & { + model: 'color-srgb-saturation-value/explicit'; + params: { + value: ColorSRGBSaturationInput; + quantize?: number; + }; +}; diff --git a/packages/libs/designer-decisions/src/inputs/types/models/color/srgb/index.ts b/packages/libs/designer-decisions/src/inputs/types/models/color/srgb/index.ts index 6bd4dcad..7857af78 100644 --- a/packages/libs/designer-decisions/src/inputs/types/models/color/srgb/index.ts +++ b/packages/libs/designer-decisions/src/inputs/types/models/color/srgb/index.ts @@ -1,4 +1,7 @@ // @index(['./*.ts', '!./*.test.ts', './!(private|mocks|functions)*/index.ts'], f => `export * from '${f.path.replace(/\/index$/, '')}';`) -export * from './hue'; -export * from './lightness'; -export * from './saturation'; +export * from './color-srgb-hue-set'; +export * from './color-srgb-hue-value'; +export * from './color-srgb-lightness-scale'; +export * from './color-srgb-lightness-value'; +export * from './color-srgb-saturation-scale'; +export * from './color-srgb-saturation-value'; diff --git a/packages/libs/designer-decisions/src/inputs/types/models/space/index.ts b/packages/libs/designer-decisions/src/inputs/types/models/space/index.ts index ccffec74..22487612 100644 --- a/packages/libs/designer-decisions/src/inputs/types/models/space/index.ts +++ b/packages/libs/designer-decisions/src/inputs/types/models/space/index.ts @@ -1,3 +1,3 @@ // @index(['./*.ts', '!./*.test.ts', './!(private|mocks|functions)*/index.ts'], f => `export * from '${f.path.replace(/\/index$/, '')}';`) -export * from './set'; -export * from './value'; +export * from './size-scale'; +export * from './size-value'; diff --git a/packages/libs/designer-decisions/src/inputs/types/models/space/set.ts b/packages/libs/designer-decisions/src/inputs/types/models/space/size-scale.ts similarity index 100% rename from packages/libs/designer-decisions/src/inputs/types/models/space/set.ts rename to packages/libs/designer-decisions/src/inputs/types/models/space/size-scale.ts diff --git a/packages/libs/designer-decisions/src/inputs/types/models/space/value.ts b/packages/libs/designer-decisions/src/inputs/types/models/space/size-value.ts similarity index 100% rename from packages/libs/designer-decisions/src/inputs/types/models/space/value.ts rename to packages/libs/designer-decisions/src/inputs/types/models/space/size-value.ts diff --git a/packages/libs/designer-decisions/src/inputs/types/models/typography/index.ts b/packages/libs/designer-decisions/src/inputs/types/models/typography/index.ts index 0e1bb6e9..d05dd6ec 100644 --- a/packages/libs/designer-decisions/src/inputs/types/models/typography/index.ts +++ b/packages/libs/designer-decisions/src/inputs/types/models/typography/index.ts @@ -1,2 +1,2 @@ // @index(['./*.ts', '!./*.test.ts', './!(private|mocks|functions)*/index.ts'], f => `export * from '${f.path.replace(/\/index$/, '')}';`) -export * from './value'; +export * from './typeface-value'; diff --git a/packages/libs/designer-decisions/src/inputs/types/models/typography/value.ts b/packages/libs/designer-decisions/src/inputs/types/models/typography/typeface-value.ts similarity index 100% rename from packages/libs/designer-decisions/src/inputs/types/models/typography/value.ts rename to packages/libs/designer-decisions/src/inputs/types/models/typography/typeface-value.ts diff --git a/packages/libs/designer-decisions/src/values/primitives/size/helpers/constants.ts b/packages/libs/designer-decisions/src/values/primitives/size/helpers/constants.ts index b4b676d9..43d11bf0 100644 --- a/packages/libs/designer-decisions/src/values/primitives/size/helpers/constants.ts +++ b/packages/libs/designer-decisions/src/values/primitives/size/helpers/constants.ts @@ -1,3 +1,3 @@ import type { SizeAbsoluteUnits } from '../../../../inputs'; -export const SIZE_ABSOLUtE_UNITS: SizeAbsoluteUnits[] = ['px', 'rem']; +export const SIZE_ABSOLUTE_UNITS: SizeAbsoluteUnits[] = ['px', 'rem']; diff --git a/packages/libs/designer-decisions/src/values/primitives/size/helpers/isValidSizeObjectLiteral.ts b/packages/libs/designer-decisions/src/values/primitives/size/helpers/isValidSizeObjectLiteral.ts index 0950dbe3..d5c5bf03 100644 --- a/packages/libs/designer-decisions/src/values/primitives/size/helpers/isValidSizeObjectLiteral.ts +++ b/packages/libs/designer-decisions/src/values/primitives/size/helpers/isValidSizeObjectLiteral.ts @@ -1,6 +1,6 @@ import type { SizeObjectLiteral } from '../../../../inputs'; -import { SIZE_ABSOLUtE_UNITS } from './constants'; +import { SIZE_ABSOLUTE_UNITS } from './constants'; export const isValidSizeObjectLiteral = (input: unknown): input is SizeObjectLiteral => { if (typeof input !== 'object' || input === null) { @@ -13,7 +13,7 @@ export const isValidSizeObjectLiteral = (input: unknown): input is SizeObjectLit return false; } - if (typeof units !== 'string' || !SIZE_ABSOLUtE_UNITS.includes(units)) { + if (typeof units !== 'string' || !SIZE_ABSOLUTE_UNITS.includes(units)) { return false; }