Skip to content

Commit 57fe6fa

Browse files
Change base-select icon from background-image to svg elements
Putting the svg in a data url for background-image was not as customizable in CSS for developers, but using an actual svg element is: openui/open-ui#881 Bug: 40146374 Fixed: 337904202 Change-Id: If1528b3df97e31de5b86b27a6aa935223ff0f0a4
1 parent 6813062 commit 57fe6fa

7 files changed

+55
-4
lines changed

html/semantics/forms/the-select-element/stylable-select/resources/stylable-select-styles.css

+4-4
Original file line numberDiff line numberDiff line change
@@ -51,10 +51,6 @@
5151
}
5252

5353
.stylable-select-button-icon {
54-
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);
55-
background-origin: content-box;
56-
background-repeat: no-repeat;
57-
background-size: contain;
5854
opacity: 1;
5955
outline: none;
6056
margin-inline-start: 0.25em;
@@ -65,6 +61,10 @@
6561
min-inline-size: 1.2em;
6662
max-inline-size: 1.2em;
6763
display: block;
64+
65+
stroke: black;
66+
stroke-width: 3;
67+
stroke-linejoin: round;
6868
}
6969

7070
.stylable-select-selectedoption {
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
function populateFallbackButtonIcon() {
2+
document.querySelectorAll('.stylable-select-button-icon').forEach(element => {
3+
element.innerHTML =
4+
`<svg viewBox="0 0 20 16" fill="none" xmlns="http://www.w3.org/2000/svg">
5+
<path d="M4 6 L10 12 L 16 6"></path>
6+
</svg>`;
7+
});
8+
}

html/semantics/forms/the-select-element/stylable-select/select-appearance-no-button-no-datalist-ref.html

+2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
<!DOCTYPE html>
22
<link rel=stylesheet href="resources/stylable-select-styles.css">
3+
<script src="resources/stylable-select-utils.js"></script>
34

45
<div id=container class=stylable-select-container>
56
<button class=stylable-select-button popovertarget=popover id=button>
@@ -13,5 +14,6 @@
1314
</div>
1415

1516
<script>
17+
populateFallbackButtonIcon();
1618
document.getElementById('popover').showPopover();
1719
</script>

html/semantics/forms/the-select-element/stylable-select/select-appearance-writing-mode-vertical-lr-ref.html

+2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
<!DOCTYPE html>
22
<link rel=stylesheet href="resources/stylable-select-styles.css">
3+
<script src="resources/stylable-select-utils.js"></script>
34

45
<style>
56
html {
@@ -19,5 +20,6 @@
1920
</div>
2021

2122
<script>
23+
populateFallbackButtonIcon();
2224
document.getElementById('popover').showPopover();
2325
</script>

html/semantics/forms/the-select-element/stylable-select/select-appearance-writing-mode-vertical-rl-ref.html

+2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
<!DOCTYPE html>
22
<link rel=stylesheet href="resources/stylable-select-styles.css">
3+
<script src="resources/stylable-select-utils.js"></script>
34

45
<style>
56
html {
@@ -19,5 +20,6 @@
1920
</div>
2021

2122
<script>
23+
populateFallbackButtonIcon();
2224
document.getElementById('popover').showPopover();
2325
</script>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
<!DOCTYPE html>
2+
<link rel=stylesheet href="resources/stylable-select-styles.css">
3+
<script src="resources/stylable-select-utils.js"></script>
4+
5+
<style>
6+
.stylable-select-button-icon svg {
7+
stroke: red !important;
8+
}
9+
</style>
10+
11+
<div class=stylable-select-container>
12+
<button class=stylable-select-button popovertarget=popover id=button>
13+
<span class=stylable-select-selectedoption>option</span>
14+
<div class=stylable-select-button-icon></div>
15+
</button>
16+
</div>
17+
18+
<script>
19+
populateFallbackButtonIcon();
20+
</script>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
<!DOCTYPE html>
2+
<link rel=author href="mailto:[email protected]">
3+
<link rel=help href="https://github.com/openui/open-ui/issues/881">
4+
<link rel=match href="select-icon-color-ref.html">
5+
6+
<style>
7+
select {
8+
appearance: base-select;
9+
}
10+
select::select-fallback-button-icon {
11+
stroke: red;
12+
}
13+
</style>
14+
15+
<select>
16+
<option>option</option>
17+
</select>

0 commit comments

Comments
 (0)