Skip to content

Commit

Permalink
Correctly implement (Partially)Resolvable
Browse files Browse the repository at this point in the history
  • Loading branch information
Jym77 committed Nov 23, 2023
1 parent b8c7f57 commit 41d3074
Show file tree
Hide file tree
Showing 6 changed files with 31 additions and 9 deletions.
5 changes: 5 additions & 0 deletions .changeset/gentle-berries-decide.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@siteimprove/alfa-css": patch
---

**Added:** all `Value` subtype now correctly implement the `(Partially)Resovable` interfaces.
6 changes: 5 additions & 1 deletion packages/alfa-css/src/value/image/gradient/linear/corner.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { Parser } from "@siteimprove/alfa-parser";

import { type Parser as CSSParser, Token } from "../../../../syntax";

import { Resolvable } from "../../../resolvable";
import { Value } from "../../../value";

import { Position } from "./position";
Expand All @@ -12,7 +13,10 @@ const { map, either, pair, option, right } = Parser;
/**
* @internal
*/
export class Corner extends Value<"corner", false> {
export class Corner
extends Value<"corner", false>
implements Resolvable<Corner.Canonical, Corner.Resolver>
{
public static of(
vertical: Position.Vertical,
horizontal: Position.Horizontal,
Expand Down
6 changes: 5 additions & 1 deletion packages/alfa-css/src/value/image/gradient/linear/side.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { Parser } from "@siteimprove/alfa-parser";

import { Token } from "../../../../syntax";

import { Resolvable } from "../../../resolvable";
import { Value } from "../../../value";

import { Position } from "./position";
Expand All @@ -12,7 +13,10 @@ const { map, option, right } = Parser;
/**
* @internal
*/
export class Side extends Value<"side", false> {
export class Side
extends Value<"side", false>
implements Resolvable<Side.Canonical, Side.Resolver>
{
public static of(side: Position.Vertical | Position.Horizontal): Side {
return new Side(side);
}
Expand Down
9 changes: 5 additions & 4 deletions packages/alfa-css/src/value/image/gradient/radial/circle.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,17 +5,18 @@ import { Parser as CSSParser, Token } from "../../../../syntax";

import { Keyword } from "../../../keyword";
import { Length } from "../../../numeric";
import { Resolvable } from "../../../resolvable";
import { Value } from "../../../value";

/**
* {@link https://drafts.csswg.org/css-images/#valdef-ending-shape-circle}
*
* @internal
*/
export class Circle<R extends Length = Length> extends Value<
"circle",
Value.HasCalculation<[R]>
> {
export class Circle<R extends Length = Length>
extends Value<"circle", Value.HasCalculation<[R]>>
implements Resolvable<Circle.Canonical, Circle.Resolver>
{
public static of<R extends Length>(radius: R): Circle<R> {
return new Circle(radius);
}
Expand Down
6 changes: 5 additions & 1 deletion packages/alfa-css/src/value/image/gradient/radial/extent.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,18 @@ import { Err, Result } from "@siteimprove/alfa-result";
import { Parser as CSSParser, Token } from "../../../../syntax";

import { Keyword } from "../../../keyword";
import { Resolvable } from "../../../resolvable";
import { Value } from "../../../value";

const { map } = Parser;

/**
* @internal
*/
export class Extent extends Value<"extent", false> {
export class Extent
extends Value<"extent", false>
implements Resolvable<Extent.Canonical, Extent.Resolver>
{
public static of(
shape: Extent.Shape = Extent.Shape.Circle,
size: Extent.Size = Extent.Size.FarthestCorner,
Expand Down
8 changes: 6 additions & 2 deletions packages/alfa-css/src/value/shape/rectangle.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import { Comma, Function, type Parser as CSSParser, Token } from "../../syntax";

import { Keyword } from "../keyword";
import { Length } from "../numeric";
import { Resolvable } from "../resolvable";
import { Value } from "../value";

import { BasicShape } from "./basic-shape";
Expand All @@ -18,8 +19,11 @@ const { either, map, option, separatedList } = Parser;
* @deprecated Deprecated as of CSS Masking Module Level 1
*/
export class Rectangle<
O extends Length | Rectangle.Auto = Length | Rectangle.Auto,
> extends BasicShape<"rectangle", Value.HasCalculation<[O, O, O, O]>> {
O extends Length | Rectangle.Auto = Length | Rectangle.Auto,
>
extends BasicShape<"rectangle", Value.HasCalculation<[O, O, O, O]>>
implements Resolvable<Rectangle.Canonical, Rectangle.Resolver>
{
public static of<O extends Length | Rectangle.Auto = Length | Rectangle.Auto>(
top: O,
right: O,
Expand Down

0 comments on commit 41d3074

Please sign in to comment.