@@ -101,6 +101,19 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
101
101
<li>
102
102
<a href="https://github.com/Joxit/docker-registry-ui/blob/main/LICENSE">License AGPL-3.0</a>
103
103
</li>
104
+ <li if="{ props.theme === 'auto' }">
105
+ <material-switch
106
+ on-change="{ onThemeChange }"
107
+ checked="{ state.themeSwitch }"
108
+ track-selected-color="var(--accent-text)"
109
+ outline-selected-color="var(--accent-text)"
110
+ >
111
+ <i slot="thumb-icon" class="material-icons" style="color: white; font-size: 0.75em">wb_sunny</i>
112
+ <i slot="thumb-selected-icon" class="material-icons" style="color: #79747e; font-size: 0.75em">
113
+ brightness_2
114
+ </i>
115
+ </material-switch>
116
+ </li>
104
117
</ul>
105
118
</material-footer>
106
119
</footer>
@@ -156,7 +169,8 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
156
169
this.state.catalogElementsLimit = props.catalogElementsLimit || 100000;
157
170
this.state.pullUrl = this.pullUrl(this.state.registryUrl, props.pullUrl);
158
171
this.state.useControlCacheHeader = props.useControlCacheHeader;
159
- loadTheme(props, this.root.parentNode.style);
172
+ const theme = loadTheme(props, this.root.parentNode.style);
173
+ this.state.themeSwitch = theme === 'dark';
160
174
},
161
175
onServerChange(registryUrl) {
162
176
this.update({
@@ -216,6 +230,11 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
216
230
filter: value,
217
231
});
218
232
},
233
+ onThemeChange(e) {
234
+ const theme = e.target.checked ? 'dark' : 'light';
235
+ loadTheme({ ...this.props, theme }, this.root.parentNode.style);
236
+ this.update({ themeSwitch: e.target.checked });
237
+ },
219
238
baseRoute: '([^#]*?)/(\\?[^#]*?)?(#!)?(/?)',
220
239
router,
221
240
version,
@@ -245,5 +264,9 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
245
264
material-footer .material-footer-logo {
246
265
color: var(--footer-text);
247
266
}
267
+
268
+ material-switch i {
269
+ user-select: none;
270
+ }
248
271
</style>
249
272
</docker-registry-ui>
0 commit comments