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

Change base-select icon from background-image to svg elements #46152

Merged
merged 1 commit into from
May 13, 2024
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -51,10 +51,6 @@
}

.stylable-select-button-icon {
background-image: url(data:image/svg+xml,%3Csvg%20width%3D%2220%22%20height%3D%2214%22%20viewBox%3D%220%200%2020%2016%22%20fill%3D%22none%22%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%3E%3Cpath%20d%3D%22M4%206%20L10%2012%20L%2016%206%22%20stroke%3D%22WindowText%22%20stroke-width%3D%223%22%20stroke-linejoin%3D%22round%22%2F%3E%3C%2Fsvg%3E);
background-origin: content-box;
background-repeat: no-repeat;
background-size: contain;
opacity: 1;
outline: none;
margin-inline-start: 0.25em;
Expand All @@ -65,6 +61,11 @@
min-inline-size: 1.2em;
max-inline-size: 1.2em;
display: block;

color: light-dark(black, white);
stroke: currentColor;
stroke-width: 3;
stroke-linejoin: round;
}

.stylable-select-selectedoption {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
function populateFallbackButtonIcon() {
document.querySelectorAll('.stylable-select-button-icon').forEach(element => {
element.innerHTML =
`<svg viewBox="0 0 20 16" fill="none" xmlns="http://www.w3.org/2000/svg">
<path d="M4 6 L10 12 L 16 6"></path>
</svg>`;
});
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
<!DOCTYPE html>
<link rel=stylesheet href="resources/stylable-select-styles.css">
<script src="resources/stylable-select-utils.js"></script>

<style>
:root {
color-scheme: dark;
}
</style>

<div id=container class=stylable-select-container>
<button class=stylable-select-button popovertarget=popover id=button>
<span class=stylable-select-selectedoption>one</span>
<div class=stylable-select-button-icon></div>
</button>
<div id=popover popover=auto anchor=container class=stylable-select-datalist>
<div class=stylable-select-option>one</div>
<div class=stylable-select-option>two</div>
</div>
</div>

<script>
populateFallbackButtonIcon();
document.getElementById('popover').showPopover();
</script>
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
<!DOCTYPE html>
<html class=reftest-wait>
<link rel=author href="mailto:jarhar@chromium.org">
<link rel=help href="https://github.com/whatwg/html/issues/9799">
<link rel=match href="select-appearance-dark-mode-ref.html">
<script src="/resources/testdriver.js"></script>
<script src="/resources/testdriver-vendor.js"></script>

<style>
:root {
color-scheme: dark;
}
</style>

<select style="appearance:base-select">
<option>one</option>
<option>two</option>
</select>

<script>
(async () => {
await test_driver.bless();
document.querySelector('select').showPicker();
document.documentElement.classList.remove('reftest-wait');
})();
</script>
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
<!DOCTYPE html>
<link rel=stylesheet href="resources/stylable-select-styles.css">
<script src="resources/stylable-select-utils.js"></script>

<div id=container class=stylable-select-container>
<button class=stylable-select-button popovertarget=popover id=button>
Expand All @@ -13,5 +14,6 @@
</div>

<script>
populateFallbackButtonIcon();
document.getElementById('popover').showPopover();
</script>
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
<!DOCTYPE html>
<link rel=stylesheet href="resources/stylable-select-styles.css">
<script src="resources/stylable-select-utils.js"></script>

<style>
html {
Expand All @@ -19,5 +20,6 @@
</div>

<script>
populateFallbackButtonIcon();
document.getElementById('popover').showPopover();
</script>
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
<!DOCTYPE html>
<link rel=stylesheet href="resources/stylable-select-styles.css">
<script src="resources/stylable-select-utils.js"></script>

<style>
html {
Expand All @@ -19,5 +20,6 @@
</div>

<script>
populateFallbackButtonIcon();
document.getElementById('popover').showPopover();
</script>
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
<!DOCTYPE html>
<link rel=stylesheet href="resources/stylable-select-styles.css">
<script src="resources/stylable-select-utils.js"></script>

<style>
.stylable-select-button-icon svg {
stroke: red !important;
}
</style>

<div class=stylable-select-container>
<button class=stylable-select-button popovertarget=popover id=button>
<span class=stylable-select-selectedoption>option</span>
<div class=stylable-select-button-icon></div>
</button>
</div>

<script>
populateFallbackButtonIcon();
</script>
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<!DOCTYPE html>
<link rel=author href="mailto:jarhar@chromium.org">
<link rel=help href="https://github.com/openui/open-ui/issues/881">
<link rel=match href="select-icon-color-ref.html">

<style>
select {
appearance: base-select;
}
select::select-fallback-button-icon {
stroke: red;
}
</style>

<select>
<option>option</option>
</select>