Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Introduce calculatable numeric types #1432

Merged
merged 34 commits into from
Jun 21, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
34 commits
Select commit Hold shift + click to select a range
045a646
Add calculalted Numeric abstraction
Jym77 Jun 13, 2023
2c33caa
Add calculated Number type
Jym77 Jun 13, 2023
ab1a14d
Add some Number tests
Jym77 Jun 13, 2023
c92e5fb
Typo
Jym77 Jun 13, 2023
af24dcc
Scaffold for calculated interger
Jym77 Jun 13, 2023
d79f623
Merge branch 'main' into calculated-numeric-types
Jym77 Jun 13, 2023
40b2cee
Accept broader refinements in Selective.if()
Jym77 Jun 13, 2023
9203fa5
Replace CSS Number by (fixed) calculatable ones
Jym77 Jun 13, 2023
76f0fef
Clean up parser
Jym77 Jun 13, 2023
547dee5
Use (fixed) calculated Integers
Jym77 Jun 14, 2023
cc11701
Remove and infer redundant second parameter of dimensions
Jym77 Jun 14, 2023
1f1ccf6
Make calculatable length inherits from calculatable dimensions
Jym77 Jun 14, 2023
f134f99
Add some angle parsing tests
Jym77 Jun 14, 2023
5f9a477
Build calculatable Angle abstraction
Jym77 Jun 15, 2023
8629c7c
Spread usage of calculatable Angles
Jym77 Jun 15, 2023
ebb2e7e
Streamline expressions reducing
Jym77 Jun 15, 2023
f168e47
Introduce calculatable percentage abstraction
Jym77 Jun 15, 2023
6c91bfa
Remove NumberPercentage
Jym77 Jun 15, 2023
555894f
Use calculatable percentages
Jym77 Jun 15, 2023
7cf970b
Streamline percentage resolusion
Jym77 Jun 15, 2023
58f1bf7
Clean up
Jym77 Jun 15, 2023
d8b5dc7
Extract API
github-actions[bot] Jun 15, 2023
db5a352
Clean up
Jym77 Jun 15, 2023
fae8e9c
Clean up
Jym77 Jun 15, 2023
c9d3521
Extract API
github-actions[bot] Jun 15, 2023
3289d48
Strip down base numerics used in calculations
Jym77 Jun 15, 2023
abb0a37
Remove Math inheritance from Value
Jym77 Jun 15, 2023
434dbfe
Move value.ts back in the value directory
Jym77 Jun 15, 2023
b7865d7
Mark temporary helpers as internal
Jym77 Jun 15, 2023
565e2ae
Extract API
github-actions[bot] Jun 15, 2023
6b35945
Introduce Foo.Canonical abstraction
Jym77 Jun 16, 2023
ac80ec0
Extract API
github-actions[bot] Jun 16, 2023
81640c1
Merge branch 'main' into calculated-numeric-types
Jym77 Jun 16, 2023
b5feffa
Typo
Jym77 Jun 21, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions .changeset/brown-countries-applaud.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
---
"@siteimprove/alfa-style": minor
"@siteimprove/alfa-css": minor
---

**Breaking:** New abstractions for calculatable numeric values (numbers, percentages, dimensions) are introduced and used in style properties. Currently, style properties only accept non-calculated numeric (except for some properties that already accepted calculated lengths or length-percentages and keep doing so).

These abstractions are now exported from `@siteimprove/alfa-css` instead of the old abstractions which didn't accept calculations. In order to keep the functionalities of the old abstractions, replace `Foo` (`Number`, `Length`, …) with `Foo.Fixed`.

The new abstractions come with a `#resolve()` method which resolve any remaining calculation and returns a `Fixed` value. These methods need various resolvers argument depending on the precise abstraction (e.g. `Length#resolve` needs to know how to resolve relative lengths into `px`).
5 changes: 5 additions & 0 deletions .changeset/cold-tables-sing.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@siteimprove/alfa-css": minor
---

**Breaking:** Math expression converters (`.toLength`, …) now return a `Result<T, string>` instead of an `option<T>`.
5 changes: 5 additions & 0 deletions .changeset/fair-needles-compare.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@siteimprove/alfa-css": minor
---

**Breaking:** The redundant second type parameter (Unit category) of Dimensions has been removed and is now automatically inferred from the first parameter (type string representation).
7 changes: 2 additions & 5 deletions .changeset/gold-pens-shave.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,7 @@
"@siteimprove/alfa-css": minor
---

**Breaking:** `Math.resolve` has been renamed `Math.resolve2`.
This is a temporary change to accommodate for the new `resolve` method on parent class `Value`.

**Breaking:** `Math.resolve2` now returns a `Result<Numeric, string>` instead of an `Option`.
**Breaking:** `Math.resolve` now returns a `Result<Numeric, string>` instead of an `Option`.
Invalid expressions return an error message.

**Breaking:** No resolver is needed for `Math.resolve2` on `Number` expressions.
**Breaking:** No resolver is needed for `Math.resolve` on `Number` expressions.
5 changes: 5 additions & 0 deletions .changeset/hip-baboons-applaud.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@siteimprove/alfa-css": minor
---

**Added:** Most CSS value types now export a `Foo.Canonical` type which is the canonical representation of the type with calculation resolved, relative values absolutized, and dimensions converted to their canonical units. The `Canonical` type is normally the one used to represent conputed values of style propreties.
7 changes: 7 additions & 0 deletions .changeset/odd-dancers-rush.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
"@siteimprove/alfa-selective": minor
---

**Added:** `Selective.if()` now accepts any refinement and will refine to the intersection of its result and the value in the associated right side.

This allows use cases like `Selective.of<A | B>(foo).if(isBOrC, bar => …)` to correctly refine `bar` to a `B` instead of defaulting to the `Predicate` overload that wouldn't refine anything.
5 changes: 5 additions & 0 deletions .changeset/rotten-birds-pay.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@siteimprove/alfa-style": minor
---

**Breaking:** the `NumberPercentage` abstraction, which doesn't exist in CSS, has been removed.
5 changes: 5 additions & 0 deletions .changeset/serious-snails-switch.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@siteimprove/alfa-style": minor
---

**Breaking:** The `Resolver.percentage` helper has been removed. Instead, the `Percentage#resolve(base)` method (from `@siteimprove/alfa-css`) provides the same functionality.
Loading