-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Support for
mask
CSS shorthand property (#1711)
* Add `mask-*` longhands * Add tests for mask-mode * Add tests for mask-origin * Add tests for mask-repeat * Move types from coord-box.ts to box.ts * Extract API * Fix knip warnings * Implement mask-repeat * Extract common function * Remove empty test files * Handle layers in mask-composite * Update TODO and fix link * Handle layers in mask-mode * Handle layers in mask-origin * Add mask-size * Add mask-position * Remove unused imports * Extract API * Implement mask-position * Extract API * Implement shorthand `mask` * Extract API * Add `mask` to shorthands * Extract API * Add test of shorthand as well as clean up and minor fixes * Update few-clouds-play.md * Rename file * Update mask-layers.ts * Update packages/alfa-style/src/property/helpers/mask-layers.ts Co-authored-by: Jean-Yves Moyen <[email protected]> * Update packages/alfa-style/src/property/mask.ts Co-authored-by: Jean-Yves Moyen <[email protected]> * Add method for cutting or repeating an `alfa-css` `List` * Move layering logic * Align with existing code structure * Extract API * Make the returned layers resolver typed * Extract API * Use `Tuple` in `mask-repeat` * Use `Tuple` in `mask-size` * Add note about discrepancy with spec in position computation * Extract API --------- Co-authored-by: github-actions <41898282+github-actions[bot]@users.noreply.github.com> Co-authored-by: Jean-Yves Moyen <[email protected]>
- Loading branch information
1 parent
092e524
commit 3a3e6e5
Showing
32 changed files
with
1,913 additions
and
163 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,5 @@ | ||
--- | ||
"@siteimprove/alfa-style": minor | ||
--- | ||
|
||
**Added:** CSS shorthand property `mask` and corresponding longhand properties are now supported. |
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:** `List#cutOrExtend` is now available. |
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:** `List#size` is now available. |
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
Large diffs are not rendered by default.
Oops, something went wrong.
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
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
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,41 @@ | ||
import { Parser } from "@siteimprove/alfa-parser"; | ||
import { Box, Keyword, List } from "@siteimprove/alfa-css"; | ||
|
||
import { Longhand } from "../longhand.js"; | ||
import { Resolver } from "../resolver.js"; | ||
|
||
const { either } = Parser; | ||
|
||
type Specified = List<Specified.Item>; | ||
|
||
/** | ||
* @internal | ||
*/ | ||
export namespace Specified { | ||
export type Item = Box.CoordBox | Keyword<"no-clip">; | ||
} | ||
|
||
type Computed = Specified; | ||
|
||
/** | ||
* @internal | ||
*/ | ||
export const parse = either(Box.parseCoordBox, Keyword.parse("no-clip")); | ||
|
||
const parseList = List.parseCommaSeparated(parse); | ||
|
||
/** | ||
* @internal | ||
*/ | ||
export const initialItem = Keyword.of("border-box"); | ||
|
||
/** | ||
* {@link https://developer.mozilla.org/en-US/docs/Web/CSS/mask-clip} | ||
* | ||
* @internal | ||
*/ | ||
export default Longhand.of<Specified, Computed>( | ||
List.of([initialItem]), | ||
parseList, | ||
(value, style) => value.map(Resolver.layers(style, "mask-image")), | ||
); |
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,42 @@ | ||
import { Keyword, List } from "@siteimprove/alfa-css"; | ||
|
||
import { Longhand } from "../longhand.js"; | ||
import { Resolver } from "../resolver.js"; | ||
|
||
type Specified = List<Specified.Item>; | ||
|
||
/** | ||
* @internal | ||
*/ | ||
export namespace Specified { | ||
export type Item = | ||
| Keyword<"add"> | ||
| Keyword<"subtract"> | ||
| Keyword<"intersect"> | ||
| Keyword<"exclude">; | ||
} | ||
|
||
type Computed = Specified; | ||
|
||
/** | ||
* @internal | ||
*/ | ||
export const parse = Keyword.parse("add", "subtract", "intersect", "exclude"); | ||
|
||
const parseList = List.parseCommaSeparated(parse); | ||
|
||
/** | ||
* @internal | ||
*/ | ||
export const initialItem = Keyword.of("add"); | ||
|
||
/** | ||
* {@link https://developer.mozilla.org/en-US/docs/Web/CSS/mask-composite} | ||
* | ||
* @internal | ||
*/ | ||
export default Longhand.of<Specified, Computed>( | ||
List.of([initialItem], ", "), | ||
parseList, | ||
(value, style) => value.map(Resolver.layers(style, "mask-image")), | ||
); |
Oops, something went wrong.