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

[WIP] Contrast color svg #240

Open
wants to merge 5 commits into
base: main
Choose a base branch
from
Open
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
35 changes: 33 additions & 2 deletions content/body/img.php
Original file line number Diff line number Diff line change
Expand Up @@ -150,8 +150,8 @@
<title id="circle-alt">A dark blue circle with text inside</title>

<rect x="0" y="0" width="200" height="163" fill="none" fill-opacity="1"></rect>
<circle cx="81" cy="85" r="75" fill="#00a" stroke="#000" stroke-width="1"></circle>
<text id="svg-text" x="81" y="85" font-size="14px" text-anchor="middle" fill="#fff">
<circle cx="81" cy="85" r="75" class="circle" stroke="#000" stroke-width="1"></circle>
<text id="svg-text" x="81" y="85" font-size="14px" text-anchor="middle" class="text">
I am text in a circle
</text>
</svg>
Expand Down Expand Up @@ -364,4 +364,35 @@
}
]
}
</script>

<h2>Use Embed to update a SVG</h2>

<?php includeStats(["isForNewBuilds" => false]); ?>

<p>
To ensure compatibility with Safari and allow dynamic color updates based on the color theme, use the <code>embed</code> HTML tag instead of the <code>img</code> tag to import SVGs. This approach facilitates greater flexibility in styling SVGs directly through CSS or JavaScript
</p>

<div id="svg-embed-example" class="enable-example">
<embed type="image/svg+xml" src="images/icons/add-embed.svg" role="presentation" title="Link SVG Image">
</div>

<?php includeShowcode("svg-embed-example"); ?>
<script type="application/json" id="svg-embed-example-props">
{
"replaceHtmlRules": {},
"steps": [
{
"label": "Add readable title",
"highlight": "title",
"notes": "Add title for accessibility"
},
{
"label": "Add role to embed",
"highlight": "role",
"notes": ""
}
]
}
</script>
12 changes: 12 additions & 0 deletions css/img.css

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

16 changes: 16 additions & 0 deletions images/icons/add-embed.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
15 changes: 15 additions & 0 deletions less/img.less
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,21 @@
}
}

#inline-svg-example{
.circle {
fill: #00a;
.enable__is-dark-mode &{
fill: #fff;
}
}
.text {
fill: #fff;
.enable__is-dark-mode &{
fill: #00a;
}
}
}

#svg-sprite-example {
p {
text-align: center;
Expand Down