-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Introduce calculatable numeric types (#1432)
* Add calculalted Numeric abstraction * Add calculated Number type * Add some Number tests * Typo * Scaffold for calculated interger * Accept broader refinements in Selective.if() * Replace CSS Number by (fixed) calculatable ones * Clean up parser * Use (fixed) calculated Integers * Remove and infer redundant second parameter of dimensions * Make calculatable length inherits from calculatable dimensions * Add some angle parsing tests * Build calculatable Angle abstraction * Spread usage of calculatable Angles * Streamline expressions reducing * Introduce calculatable percentage abstraction * Remove NumberPercentage * Use calculatable percentages * Streamline percentage resolusion * Clean up * Extract API * Clean up * Clean up * Extract API * Strip down base numerics used in calculations * Remove Math inheritance from Value * Move value.ts back in the value directory * Mark temporary helpers as internal * Extract API * Introduce Foo.Canonical abstraction * Extract API * Typo Co-authored-by: Rolf Christian Jørgensen <114920418+rcj-siteimprove@users.noreply.github.com> --------- Co-authored-by: github-actions <41898282+github-actions[bot]@users.noreply.github.com> Co-authored-by: Rolf Christian Jørgensen <114920418+rcj-siteimprove@users.noreply.github.com>
- Loading branch information
1 parent
dc70915
commit f4cda0e
Showing
115 changed files
with
2,656 additions
and
1,279 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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`). |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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>`. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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). |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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. |
Oops, something went wrong.