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

color <funciri> #700

Merged
merged 1 commit into from
Jan 25, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions src/options.js
Original file line number Diff line number Diff line change
Expand Up @@ -240,10 +240,14 @@ export function isEvery(values, is) {
// strictly requires that the value be a string; we might want to apply string
// coercion here, though note that d3-color instances would need to support
// valueOf to work correctly with InternMap.
// https://www.w3.org/TR/SVG11/painting.html#SpecifyingPaint
export function isColor(value) {
if (typeof value !== "string") return false;
value = value.toLowerCase();
return value === "currentcolor" || value === "none" || color(value) !== null;
value = value.toLowerCase().trim();
return value === "none"
|| value === "currentcolor"
|| (value.startsWith("url(") && value.endsWith(")")) // <funciri>, e.g. pattern or gradient
|| color(value) !== null;
}

const symbols = new Map([
Expand Down
190 changes: 190 additions & 0 deletions test/output/penguinSpeciesCheysson.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
68 changes: 68 additions & 0 deletions test/output/penguinSpeciesGradient.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 2 additions & 0 deletions test/plots/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,8 @@ export {default as penguinMassSpecies} from "./penguin-mass-species.js";
export {default as penguinSex} from "./penguin-sex.js";
export {default as penguinSexMassCulmenSpecies} from "./penguin-sex-mass-culmen-species.js";
export {default as penguinSizeSymbols} from "./penguin-size-symbols.js";
export {default as penguinSpeciesCheysson} from "./penguin-species-cheysson.js";
export {default as penguinSpeciesGradient} from "./penguin-species-gradient.js";
export {default as penguinSpeciesGroup} from "./penguin-species-group.js";
export {default as penguinSpeciesIsland} from "./penguin-species-island.js";
export {default as penguinSpeciesIslandRelative} from "./penguin-species-island-relative.js";
Expand Down
Loading