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

Add properties container-type, mix-blend-mode and isolation #1675

Merged
merged 9 commits into from
Sep 23, 2024
5 changes: 5 additions & 0 deletions .changeset/great-dodos-cheer.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@siteimprove/alfa-style": minor
---

**Added:** Style properties `container-type`, `mix-blend-mode` and `isolation` were added.
rcj-siteimprove marked this conversation as resolved.
Show resolved Hide resolved
228 changes: 117 additions & 111 deletions docs/review/api/alfa-style.api.md

Large diffs are not rendered by default.

6 changes: 6 additions & 0 deletions packages/alfa-style/src/longhands.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ import BoxShadow from "./property/box-shadow.js";
import Clip from "./property/clip.js";
import ClipPath from "./property/clip-path.js";
import Color from "./property/color.js";
import ContainerType from "./property/container-type.js";
import Cursor from "./property/cursor.js";
import Display from "./property/display.js";
import FlexDirection from "./property/flex-direction.js";
Expand All @@ -73,6 +74,7 @@ import InsetBlockEnd from "./property/inset-block-end.js";
import InsetBlockStart from "./property/inset-block-start.js";
import InsetInlineEnd from "./property/inset-inline-end.js";
import InsetInlineStart from "./property/inset-inline-start.js";
import Isolation from "./property/isolation.js";
import Left from "./property/left.js";
import LetterSpacing from "./property/letter-spacing.js";
import LineHeight from "./property/line-height.js";
Expand All @@ -82,6 +84,7 @@ import MarginRight from "./property/margin-right.js";
import MarginTop from "./property/margin-top.js";
import MinHeight from "./property/min-height.js";
import MinWidth from "./property/min-width.js";
import MixBlendMode from "./property/mix-blend-mode.js";
import Opacity from "./property/opacity.js";
import OutlineColor from "./property/outline-color.js";
import OutlineOffset from "./property/outline-offset.js";
Expand Down Expand Up @@ -230,6 +233,7 @@ export namespace Longhands {
"clip-path": ClipPath,
clip: Clip,
color: Color,
"container-type": ContainerType,
cursor: Cursor,
display: Display,
"flex-direction": FlexDirection,
Expand All @@ -250,6 +254,7 @@ export namespace Longhands {
"inset-block-start": InsetBlockStart,
"inset-inline-end": InsetInlineEnd,
"inset-inline-start": InsetInlineStart,
isolation: Isolation,
left: Left,
"letter-spacing": LetterSpacing,
"line-height": LineHeight,
Expand All @@ -259,6 +264,7 @@ export namespace Longhands {
"margin-top": MarginTop,
"min-height": MinHeight,
"min-width": MinWidth,
"mix-blend-mode": MixBlendMode,
opacity: Opacity,
"outline-color": OutlineColor,
"outline-offset": OutlineOffset,
Expand Down
12 changes: 12 additions & 0 deletions packages/alfa-style/src/property/container-type.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import { Longhand } from "../longhand.js";

/**
* {@link https://developer.mozilla.org/en-US/docs/Web/CSS/container-type}
* @internal
*/
export default Longhand.fromKeywords(
{ inherits: false },
"normal",
"size",
"inline-size",
);
7 changes: 7 additions & 0 deletions packages/alfa-style/src/property/isolation.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import { Longhand } from "../longhand.js";

/**
* {@link https://developer.mozilla.org/en-US/docs/Web/CSS/isolation}
* @internal
*/
export default Longhand.fromKeywords({ inherits: false }, "auto", "isolate");
27 changes: 27 additions & 0 deletions packages/alfa-style/src/property/mix-blend-mode.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
import { Longhand } from "../longhand.js";

/**
* {@link https://developer.mozilla.org/en-US/docs/Web/CSS/mix-blend-mode}
* @internal
*/
export default Longhand.fromKeywords(
{ inherits: false },
"normal",
"multiply",
"screen",
"overlay",
"darken",
"lighten",
"color-dodge",
"color-burn",
"hard-light",
"soft-light",
"difference",
"exclusion",
"hue",
"saturation",
"color",
"luminosity",
"plus-darker",
"plus-lighter",
);
3 changes: 3 additions & 0 deletions packages/alfa-style/src/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,7 @@
"./property/clip.ts",
"./property/clip-path.ts",
"./property/color.ts",
"./property/container-type.ts",
"./property/cursor.ts",
"./property/display.ts",
"./property/flex-direction.ts",
Expand All @@ -136,6 +137,7 @@
"./property/inset-inline.ts",
"./property/inset-inline-end.ts",
"./property/inset-inline-start.ts",
"./property/isolation.ts",
"./property/left.ts",
"./property/letter-spacing.ts",
"./property/line-height.ts",
Expand All @@ -146,6 +148,7 @@
"./property/margin-top.ts",
"./property/min-height.ts",
"./property/min-width.ts",
"./property/mix-blend-mode.ts",
"./property/opacity.ts",
"./property/outline.ts",
"./property/outline-color.ts",
Expand Down
59 changes: 59 additions & 0 deletions packages/alfa-style/test/property/container-type.spec.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
import { h } from "@siteimprove/alfa-dom/h";
import { test } from "@siteimprove/alfa-test";

import { Device } from "@siteimprove/alfa-device";

import { Style } from "../../dist/style.js";

const device = Device.standard();

test("initial value is `normal`", (t) => {
const element = <div>Hello</div>;

const style = Style.from(element, device);

t.deepEqual(style.computed("container-type").toJSON(), {
value: { type: "keyword", value: "normal" },
source: null,
});
});

test("property is not inherited", (t) => {
const element = <div>Hello</div>;

h.document(
[<div class="container">{element}</div>],
[
h.sheet([
h.rule.style(".container", [h.declaration("container-type", "size")]),
]),
],
);
const style = Style.from(element, device);

t.deepEqual(style.computed("container-type").toJSON(), {
value: { type: "keyword", value: "normal" },
source: null,
});
});

test("#computed() parses the keywords", (t) => {
for (const kw of ["normal", "size", "inline-size"] as const) {
const element = <div class="container">Hello</div>;

h.document(
[element],
[
h.sheet([
h.rule.style(".container", [h.declaration("container-type", kw)]),
]),
],
);
const style = Style.from(element, device);

t.deepEqual(style.computed("container-type").toJSON(), {
value: { type: "keyword", value: kw },
source: h.declaration("container-type", kw).toJSON(),
});
}
});
55 changes: 55 additions & 0 deletions packages/alfa-style/test/property/isolation.spec.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
import { h } from "@siteimprove/alfa-dom/h";
import { test } from "@siteimprove/alfa-test";

import { Device } from "@siteimprove/alfa-device";

import { Style } from "../../dist/style.js";

const device = Device.standard();

test("initial value is `auto`", (t) => {
const element = <div>Hello</div>;

const style = Style.from(element, device);

t.deepEqual(style.computed("isolation").toJSON(), {
value: { type: "keyword", value: "auto" },
source: null,
});
});

test("property is not inherited", (t) => {
const element = <div>Hello</div>;

h.document(
[<div class="container">{element}</div>],
[
h.sheet([
h.rule.style(".container", [h.declaration("isolation", "isolate")]),
]),
],
);
const style = Style.from(element, device);

t.deepEqual(style.computed("isolation").toJSON(), {
value: { type: "keyword", value: "auto" },
source: null,
});
});

test("#computed() parses the keywords", (t) => {
for (const kw of ["auto", "isolate"] as const) {
const element = <div class="container">Hello</div>;

h.document(
[element],
[h.sheet([h.rule.style(".container", [h.declaration("isolation", kw)])])],
);
const style = Style.from(element, device);

t.deepEqual(style.computed("isolation").toJSON(), {
value: { type: "keyword", value: kw },
source: h.declaration("isolation", kw).toJSON(),
});
}
});
80 changes: 80 additions & 0 deletions packages/alfa-style/test/property/mix-blend-mode.spec.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
import { h } from "@siteimprove/alfa-dom/h";
import { test } from "@siteimprove/alfa-test";

import { Device } from "@siteimprove/alfa-device";

import { Style } from "../../dist/style.js";

const device = Device.standard();

test("initial value is `normal`", (t) => {
const element = <div>Hello</div>;

const style = Style.from(element, device);

t.deepEqual(style.computed("mix-blend-mode").toJSON(), {
value: { type: "keyword", value: "normal" },
source: null,
});
});

test("property is not inherited", (t) => {
const element = <div>Hello</div>;

h.document(
[<div class="container">{element}</div>],
[
h.sheet([
h.rule.style(".container", [
h.declaration("mix-blend-mode", "multiply"),
]),
]),
],
);
const style = Style.from(element, device);

t.deepEqual(style.computed("mix-blend-mode").toJSON(), {
value: { type: "keyword", value: "normal" },
source: null,
});
});

test("#computed() parses the keywords", (t) => {
for (const kw of [
"normal",
"multiply",
"screen",
"overlay",
"darken",
"lighten",
"color-dodge",
"color-burn",
"hard-light",
"soft-light",
"difference",
"exclusion",
"hue",
"saturation",
"color",
"luminosity",
"plus-darker",
"plus-lighter",
] as const) {
const element = <div class="container">Hello</div>;

h.document(
[element],
[
h.sheet([
h.rule.style(".container", [h.declaration("mix-blend-mode", kw)]),
]),
],
);
const style = Style.from(element, device);

t.deepEqual(style.computed("mix-blend-mode").toJSON(), {
value: { type: "keyword", value: kw },
source: h.declaration("mix-blend-mode", kw).toJSON(),
});
}
});
3 changes: 3 additions & 0 deletions packages/alfa-style/test/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -40,15 +40,18 @@
"./property/border-image-width.spec.tsx",
"./property/box-shadow.spec.tsx",
"./property/clip.spec.tsx",
"./property/container-type.spec.tsx",
"./property/cursor.spec.tsx",
"./property/display.spec.tsx",
"./property/font.spec.tsx",
"./property/font-family.spec.tsx",
"./property/font-size.spec.tsx",
"./property/font-variant.spec.tsx",
"./property/inset-block.spec.tsx",
"./property/isolation.spec.tsx",
"./property/line-height.spec.tsx",
"./property/margin.spec.tsx",
"./property/mix-blend-mode.spec.tsx",
"./property/opacity.spec.tsx",
"./property/outline.spec.tsx",
"./property/rotate.spec.tsx",
Expand Down