Skip to content
This repository was archived by the owner on Jan 13, 2025. It is now read-only.

Commit 649e836

Browse files
chore(demos): Add additional icon toggle examples (#94)
Minor cleanups and fixes as well [ci skip]
1 parent 8d9a549 commit 649e836

File tree

1 file changed

+100
-10
lines changed

1 file changed

+100
-10
lines changed

demos/icon-toggle.html

Lines changed: 100 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,57 @@
2222
<style>
2323
.mdc-theme--dark {
2424
background: #303030;
25+
}
26+
27+
.mdc-theme--dark:not(.demo-color-combo) {
2528
padding: 1rem;
2629
padding-top: 0;
2730
}
31+
32+
#demo-color-combos {
33+
display: flex;
34+
align-items: center;
35+
justify-content: flex-start;
36+
}
37+
38+
.demo-color-combo {
39+
width: 250px;
40+
padding: 1rem;
41+
border-radius: 4px;
42+
display: inline-flex;
43+
flex-direction: column;
44+
align-items: center;
45+
justify-content: center;
46+
margin-right: 8px;
47+
}
48+
49+
.demo-color-combo > p {
50+
margin: 0;
51+
}
52+
53+
#light-on-bg {
54+
background-color: #3e82f7;
55+
}
56+
#light-on-bg .mdc-icon-toggle {
57+
color: white;
58+
}
59+
#light-on-bg .mdc-icon-toggle.mdc-ripple-upgraded::before,
60+
#light-on-bg .mdc-icon-toggle.mdc-ripple-upgraded::after {
61+
background-color: rgba(255, 255, 255, .3);
62+
}
63+
64+
#dark-on-bg {
65+
background-color: #00bcd6;
66+
}
67+
68+
#custom-on-dark .mdc-icon-toggle {
69+
color: #de442c;
70+
}
71+
#custom-on-dark .mdc-icon-toggle.mdc-ripple-upgraded::before,
72+
#custom-on-dark .mdc-icon-toggle.mdc-ripple-upgraded::after {
73+
/* #de442c - opacity .16 */
74+
background-color: rgba(222, 68, 44, .26);
75+
}
2876
</style>
2977
<script src="assets/material-components-web.css.js" charset="utf-8"></script>
3078
</head>
@@ -61,8 +109,7 @@ <h2>Using Font Awesome</h2>
61109
</section>
62110
<section class="mdc-theme--dark">
63111
<h2 class="mdc-theme--text-primary-on-dark">Dark Theme</h2>
64-
<i id="add-to-favorites"
65-
class="mdc-icon-toggle material-icons"
112+
<i class="mdc-icon-toggle material-icons"
66113
role="button"
67114
aria-label="Add to favorites"
68115
aria-pressed="false"
@@ -74,8 +121,7 @@ <h2 class="mdc-theme--text-primary-on-dark">Dark Theme</h2>
74121
</section>
75122
<section>
76123
<h2>Primary Colored Icons</h2>
77-
<i id="add-to-favorites"
78-
class="mdc-icon-toggle mdc-icon-toggle--primary material-icons"
124+
<i class="mdc-icon-toggle mdc-icon-toggle--primary material-icons"
79125
role="button"
80126
aria-label="Add to favorites"
81127
aria-pressed="false"
@@ -87,8 +133,7 @@ <h2>Primary Colored Icons</h2>
87133
</section>
88134
<section>
89135
<h2>Accent Colored Icons</h2>
90-
<i id="add-to-favorites"
91-
class="mdc-icon-toggle mdc-icon-toggle--accent material-icons"
136+
<i class="mdc-icon-toggle mdc-icon-toggle--accent material-icons"
92137
role="button"
93138
aria-label="Add to favorites"
94139
aria-pressed="false"
@@ -100,8 +145,7 @@ <h2>Accent Colored Icons</h2>
100145
</section>
101146
<section>
102147
<h2>Disabled Icons</h2>
103-
<i id="add-to-favorites"
104-
class="mdc-icon-toggle mdc-icon-toggle--disabled material-icons"
148+
<i class="mdc-icon-toggle mdc-icon-toggle--disabled material-icons"
105149
role="button"
106150
aria-label="Add to favorites"
107151
aria-pressed="false"
@@ -112,8 +156,7 @@ <h2>Disabled Icons</h2>
112156
favorite_border
113157
</i>
114158
<div class="mdc-theme--dark">
115-
<i id="add-to-favorites"
116-
class="mdc-icon-toggle mdc-icon-toggle--disabled material-icons"
159+
<i class="mdc-icon-toggle mdc-icon-toggle--disabled material-icons"
117160
role="button"
118161
aria-label="Add to favorites"
119162
aria-pressed="false"
@@ -125,6 +168,53 @@ <h2>Disabled Icons</h2>
125168
</i>
126169
</div>
127170
</section>
171+
<section>
172+
<h2>Additional Color Combinations</h2>
173+
<div id="demo-color-combos">
174+
<div id="light-on-bg" class="demo-color-combo">
175+
<div>
176+
<i class="mdc-icon-toggle material-icons mdc-theme--text-primary-on-primary"
177+
role="button"
178+
aria-label="Add to favorites"
179+
aria-pressed="false"
180+
tabindex="0"
181+
data-toggle-on='{"content": "favorite", "label": "Remove From Favorites"}'
182+
data-toggle-off='{"content": "favorite_border", "label": "Add to Favorites"}'>
183+
favorite_border
184+
</i>
185+
</div>
186+
<p class="mdc-theme--text-primary-on-primary">Light icon on background</p>
187+
</div>
188+
<div id="dark-on-bg" class="demo-color-combo">
189+
<div class="mdc-theme--primary">
190+
<i class="mdc-icon-toggle material-icons"
191+
role="button"
192+
aria-label="Add to favorites"
193+
aria-pressed="false"
194+
tabindex="0"
195+
data-toggle-on='{"content": "favorite", "label": "Remove From Favorites"}'
196+
data-toggle-off='{"content": "favorite_border", "label": "Add to Favorites"}'>
197+
favorite_border
198+
</i>
199+
</div>
200+
<p>Dark icon on background</p>
201+
</div>
202+
<div id="custom-on-dark" class="demo-color-combo mdc-theme--dark">
203+
<div>
204+
<i class="mdc-icon-toggle material-icons"
205+
role="button"
206+
aria-label="Add to favorites"
207+
aria-pressed="false"
208+
tabindex="0"
209+
data-toggle-on='{"content": "favorite", "label": "Remove From Favorites"}'
210+
data-toggle-off='{"content": "favorite_border", "label": "Add to Favorites"}'>
211+
favorite_border
212+
</i>
213+
</div>
214+
<p class="mdc-theme--text-primary-on-dark">Custom color on dark background</p>
215+
</div>
216+
</div>
217+
</section>
128218
</main>
129219
<script src="assets/material-components-web.js" charset="utf-8"></script>
130220
<script>

0 commit comments

Comments
 (0)