Skip to content

Commit 367ca03

Browse files
committed
feat(theme): add support for custom themes
1 parent 5983935 commit 367ca03

File tree

8 files changed

+67
-31
lines changed

8 files changed

+67
-31
lines changed

src/components/docker-registry-ui.riot

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
4141
filter-results="{ state.filter }"
4242
on-authentication="{ onAuthentication }"
4343
show-catalog-nb-tags="{ truthy(props.showCatalogNbTags) }"
44-
/>
44+
></catalog>
4545
</route>
4646
<route path="{baseRoute}taglist/(.*)">
4747
<tag-list
@@ -84,7 +84,9 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
8484
</main>
8585
<footer>
8686
<material-footer mini="true">
87-
<a class="material-footer-logo" href="https://joxit.github.io/docker-registry-ui/">Docker Registry UI { version }</a>
87+
<a class="material-footer-logo" href="https://joxit.github.io/docker-registry-ui/">
88+
Docker Registry UI { version }
89+
</a>
8890
<ul>
8991
<li>
9092
<a href="https://github.com/Joxit/docker-registry-ui">Contribute on GitHub</a>
@@ -105,6 +107,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
105107
import SearchBar from './search-bar.riot';
106108
import { stripHttps, getRegistryServers, setRegistryServers, truthy, stringToArray } from '../scripts/utils';
107109
import router from '../scripts/router';
110+
import { loadTheme } from '../scripts/theme';
108111
109112
export default {
110113
components: {
@@ -138,6 +141,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
138141
this.state.catalogElementsLimit = props.catalogElementsLimit || 100000;
139142
this.state.pullUrl = this.pullUrl(this.state.registryUrl, props.pullUrl);
140143
this.state.useControlCacheHeader = props.useControlCacheHeader;
144+
loadTheme(props, this.root.style);
141145
},
142146
onServerChange(registryUrl) {
143147
this.update({
@@ -200,10 +204,15 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
200204
};
201205
</script>
202206
<style>
207+
:host {
208+
display: block;
209+
background-color: var(--background);
210+
color: var(--primary-text);
211+
}
203212
material-navbar {
204213
height: 64px;
205214
}
206-
215+
207216
material-navbar .menu {
208217
display: flex;
209218
}

src/components/tag-history/tag-history.riot

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,12 +18,13 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
1818
<material-card>
1919
<div class="material-card-title-action">
2020
<material-button
21-
color="#777"
21+
text-color="var(--neutral-text)"
22+
color="inherit"
23+
waves-color="var(--hover-background)"
2224
waves-center="true"
2325
rounded="true"
2426
waves-color="#ddd"
2527
href="{ toTaglist() }"
26-
inverted
2728
icon
2829
>
2930
<i class="material-icons">arrow_back</i>

src/components/tag-list/copy-to-clipboard.riot

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,9 @@
1818
<div class="copy-to-clipboard">
1919
<input style="display: none; width: 1px; height: 1px" value="{ getDockerCmd(props) }" />
2020
<material-button
21-
color="rgba(0,0,0,0)"
22-
text-color="#777"
23-
waves-color="#ddd"
21+
text-color="var(--neutral-text)"
22+
color="var(--background)"
23+
waves-color="var(--hover-background)"
2424
waves-center="true"
2525
onClick="{ copy }"
2626
title="Copy pull command."

src/components/tag-list/remove-image.riot

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,9 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
1616
-->
1717
<remove-image>
1818
<material-button
19-
color="rgba(0,0,0,0)"
20-
text-color="#777"
21-
waves-color="#ddd"
19+
text-color="var(--neutral-text)"
20+
color="var(--background)"
21+
waves-color="var(--hover-background)"
2222
waves-center="true"
2323
title="This will delete the image."
2424
if="{ !props.multiDelete }"

src/components/tag-list/tag-history-button.riot

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,9 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
1717
<tag-history-button>
1818
<material-button
1919
title="{ buttonTittle() }"
20-
color="rgba(0,0,0,0)"
21-
text-color="#777"
22-
waves-color="#ddd"
20+
text-color="var(--neutral-text)"
21+
color="var(--background)"
22+
waves-color="var(--hover-background)"
2323
waves-center="true"
2424
href="{ routeToHistory() }"
2525
disabled="{ props.image.ociImage }"

src/components/tag-list/tag-list.riot

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,12 +18,12 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
1818
<material-card class="header">
1919
<div class="material-card-title-action">
2020
<material-button
21-
color="#777"
22-
waves-color="#ddd"
21+
text-color="var(--neutral-text)"
22+
color="var(--background)"
23+
waves-color="var(--hover-background)"
2324
waves-center="true"
2425
href="{ router.home() }"
2526
icon
26-
inverted
2727
>
2828
<i class="material-icons">arrow_back</i>
2929
</material-button>

src/scripts/theme.js

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
const LIGHT_THEME = {
2+
'primary-text': '#25313b',
3+
'neutral-text': '#777',
4+
'background': '#fff',
5+
'hover-background': '#eee',
6+
};
7+
const DARK_THEME = {
8+
'primary-text': '#8A9EBA',
9+
'neutral-text': '#36527A',
10+
'background': '#22272e',
11+
'hover-background': '#30404D',
12+
};
13+
14+
let THEME;
15+
16+
const normalizeKey = (k) =>
17+
k
18+
.replace(/([A-Z])/g, '-$1')
19+
.toLowerCase()
20+
.replace(/^theme-/, '');
21+
22+
export const loadTheme = (props, style) => {
23+
THEME = props.theme == 'dark' ? DARK_THEME : LIGHT_THEME;
24+
Object.entries(props)
25+
.filter(([k, v]) => v && /^theme[A-Z]/.test(k))
26+
.map(([k, v]) => [normalizeKey(k), v])
27+
.forEach(([k, v]) => (THEME[k] = v));
28+
Object.entries(THEME).forEach(([k, v]) => style.setProperty(`--${k}`, v));
29+
};

src/style.scss

Lines changed: 11 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,9 @@ body {
6060
text-decoration: none;
6161
font-weight: inherit;
6262
}
63-
63+
material-card {
64+
background-color: var(--background);
65+
}
6466
material-card,
6567
material-tabs,
6668
pagination .container {
@@ -141,7 +143,7 @@ h2 {
141143
}
142144

143145
.list.highlight:hover {
144-
background-color: #eee;
146+
background-color: var(--hover-background);
145147
cursor: pointer;
146148
}
147149

@@ -165,7 +167,7 @@ docker-registry-ui material-button > :first-child .content i.material-icons.mate
165167
height: 24px;
166168
width: 24px;
167169
box-sizing: border-box;
168-
color: #757575;
170+
color: var(--neutral-text);
169171
}
170172

171173
.list > span .right i.material-icons.animated {
@@ -230,7 +232,6 @@ material-card table {
230232
border-collapse: collapse;
231233
white-space: nowrap;
232234
font-size: 13px;
233-
background-color: #fff;
234235
border: none;
235236
}
236237

@@ -239,7 +240,7 @@ material-card table th {
239240
vertical-align: bottom;
240241
line-height: 24px;
241242
height: 48px;
242-
color: rgba(0, 0, 0, 0.54);
243+
color: var(--neutral-text);
243244
box-sizing: border-box;
244245
padding: 0 18px 12px 18px;
245246
text-align: right;
@@ -249,10 +250,10 @@ material-card table th {
249250
text-align: left;
250251
}
251252

252-
material-button:hover > :first-child[inverted='true'],
253+
material-button:hover > :first-child,
253254
material-card .material-card-title-action material-button:hover button,
254255
material-card table tbody tr:hover {
255-
background-color: #eee !important;
256+
background-color: rgba(0, 0, 0, 0.12) !important;
256257
}
257258

258259
material-button > :first-child[inverted='true'],
@@ -308,7 +309,7 @@ material-card table th.material-card-th-sorted-descending:before {
308309

309310
material-button .content i.material-icons,
310311
.material-icons {
311-
color: #777;
312+
color: var(--neutral-text);
312313
}
313314

314315
material-button[disabled] .content i.material-icons,
@@ -320,10 +321,6 @@ material-snackbar .toast {
320321
height: auto;
321322
}
322323

323-
material-popup material-button:hover material-waves {
324-
background-color: hsla(0, 0%, 75%, 0.2);
325-
}
326-
327324
material-popup .popup > .content {
328325
padding: 1em;
329326
max-width: 450px;
@@ -452,9 +449,9 @@ material-checkbox.indeterminate .checkbox.checked .checkmark {
452449
}
453450

454451
material-checkbox .checkbox {
455-
border-color: #777;
452+
border-color: var(--neutral-text);
456453
}
457454

458455
material-checkbox .checkbox.checked {
459-
background-color: #777;
456+
background-color: var(--neutral-text);
460457
}

0 commit comments

Comments
 (0)