Skip to content

Commit cf060d6

Browse files
committed
feat: button icons disabled state
1 parent 94688d0 commit cf060d6

File tree

3 files changed

+48
-0
lines changed

3 files changed

+48
-0
lines changed

docs/index.html.ejs

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -167,6 +167,19 @@
167167
</p>
168168

169169
<%- example(`<button[[ class="focused"]]>I am focused</button>`) %>
170+
171+
<p>
172+
Images and elements with <code>[role=img]</code> inside the button will get disabled state when the button is disabled.
173+
</p>
174+
175+
<%- example(`
176+
<button style="height: auto; padding: 16px;">
177+
<img style="width: 32px;height: 32px;" src="mail-icon.png" alt="icon"/>
178+
</button>
179+
<button style="height: auto; padding: 16px;" disabled>
180+
<img style="width: 32px;height: 32px;" src="mail-icon.png" alt="icon"/>
181+
</button>
182+
`) %>
170183
</div>
171184
</section>
172185

@@ -987,5 +1000,28 @@
9871000
subscribing to more fun things on <a href="https://twitter.com/jdan">my twitter</a>. 👋
9881001
</p>
9891002
</main>
1003+
1004+
<svg id="filters-98css">
1005+
<defs>
1006+
<filter id="disabled-filter-98css">
1007+
<feColorMatrix
1008+
type="matrix"
1009+
values="1 0 0 0 0
1010+
0 1 0 0 0
1011+
0 0 1 0 0
1012+
-21.25 -71.54 -7.21 40 0"
1013+
result="color-matrix"
1014+
></feColorMatrix>
1015+
<feFlood flood-color="grey" result="color" ></feFlood>
1016+
<feComposite in="color" in2="color-matrix" operator="in" ></feComposite>
1017+
<feDropShadow
1018+
dx="1"
1019+
dy="1"
1020+
stdDeviation="0"
1021+
flood-color="white"
1022+
></feDropShadow>
1023+
</filter>
1024+
</defs>
1025+
</svg>
9901026
</body>
9911027
</html>

docs/mail-icon.png

1.25 KB
Loading

style.css

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -200,6 +200,11 @@ input[type="reset"]:disabled,
200200
text-shadow: 1px 1px 0 var(--button-highlight);
201201
}
202202

203+
button:disabled img,
204+
button:disabled [role="img"] {
205+
filter: url("#disabled-filter-98css");
206+
}
207+
203208
.window {
204209
box-shadow: var(--border-window-outer), var(--border-window-inner);
205210
background: var(--surface);
@@ -885,3 +890,10 @@ table > tbody > tr > * {
885890
padding: 0 var(--grouped-element-spacing);
886891
height: 14px;
887892
}
893+
894+
#filters-98css {
895+
position: absolute;
896+
pointer-events: none;
897+
top: 0;
898+
left: 0;
899+
}

0 commit comments

Comments
 (0)