This repository has been archived by the owner on Aug 31, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 659
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(css-prefix): image-rendering support (#1524)
- Loading branch information
Showing
5 changed files
with
82 additions
and
1 deletion.
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
30 changes: 30 additions & 0 deletions
30
internal/compiler/transforms/compile/css-handler/prefix/prefixes/image-rendering.ts
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,30 @@ | ||
import { | ||
createPrefixVisitor, | ||
prefixCSSValue, | ||
} from "@internal/compiler/transforms/compile/css-handler/prefix/utils"; | ||
|
||
function pixelatedRenamer(value: string) { | ||
if (value.startsWith("-webkit-")) { | ||
return value.replace("pixelated", "optimize-contrast"); | ||
} | ||
if (value.startsWith("-moz-")) { | ||
return value.replace("pixelated", "crisp-edges"); | ||
} | ||
return value; | ||
} | ||
|
||
// https://github.com/Fyrd/caniuse/blob/main/features-json/css-crisp-edges.json | ||
export default [ | ||
createPrefixVisitor({ | ||
name: "image-rendering/pixelated", | ||
enter(path) { | ||
return prefixCSSValue({ | ||
path, | ||
propertyName: "image-rendering", | ||
value: "pixelated", | ||
browserFeaturesKey: "css-crisp-edges", | ||
rename: pixelatedRenamer, | ||
}); | ||
}, | ||
}), | ||
]; |
3 changes: 3 additions & 0 deletions
3
...al/compiler/transforms/compile/test-fixtures/css-handler/prefix/image-rendering/input.css
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,3 @@ | ||
.style { | ||
image-rendering: pixelated; | ||
} |
32 changes: 32 additions & 0 deletions
32
...ansforms/compile/test-fixtures/css-handler/prefix/image-rendering/input.test.md
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,32 @@ | ||
# `index.test.ts` | ||
|
||
**DO NOT MODIFY**. This file has been autogenerated. Run `rome test internal/compiler/transforms/compile/index.test.ts --update-snapshots` to update. | ||
|
||
## `css-handler > prefix > image-rendering` | ||
|
||
### `Diagnostics` | ||
|
||
``` | ||
``` | ||
|
||
### `Input` | ||
|
||
```css | ||
.style { | ||
image-rendering: pixelated; | ||
} | ||
|
||
``` | ||
|
||
### `Output` | ||
|
||
```css | ||
.style { | ||
image-rendering: -moz-crisp-edges; | ||
image-rendering: -webkit-optimize-contrast; | ||
image-rendering: -o-pixelated; | ||
image-rendering: pixelated; | ||
} | ||
|
||
``` |
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,14 @@ | ||
--- | ||
title: Prefix image-rendering | ||
layout: layouts/prefix.liquid | ||
showHero: false | ||
description: MISSING DOCUMENTATION | ||
eleventyNavigation: | ||
key: css-handler/prefix/image-rendering | ||
parent: css-handler | ||
title: image-rendering | ||
--- | ||
|
||
# image-rendering | ||
|
||
MISSING DOCUMENTATION |