Skip to content

Commit 3e79992

Browse files
authored
feat: add support for static light/dark images for logo (#874)
1 parent 7cd18d2 commit 3e79992

File tree

6 files changed

+54
-60
lines changed

6 files changed

+54
-60
lines changed

.docs/public/logo-dark.svg

Lines changed: 0 additions & 15 deletions
This file was deleted.

.docs/public/logo-light.svg

Lines changed: 0 additions & 15 deletions
This file was deleted.

assets/css/main.css

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,3 @@
1-
.light-img {
2-
display: block;
3-
@dark {
4-
display: hidden;
5-
}
6-
}
7-
8-
.dark-img {
9-
display: hidden;
10-
@dark {
11-
display: block;
12-
}
13-
}
14-
151
/* Base */
162

173
:root {

components/app/AppHeaderLogo.vue

Lines changed: 33 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,17 @@ const title = computed(() => config.value.header?.title || config.value.title)
77
<template>
88
<NuxtLink class="navbar-logo" to="/" :aria-label="title">
99
<!-- Only Logo -->
10-
<component :is="logo" v-if="logo && typeof logo === 'string'" />
11-
<Logo v-else-if="logo" />
10+
<span class="logo" v-if="logo">
11+
<component :is="logo" v-if="typeof logo === 'string'" />
12+
<template v-else-if="logo.light && logo.dark">
13+
<img :src="logo.light" alt="" class="light-img">
14+
<img :src="logo.dark" alt="" class="dark-img">
15+
</template>
16+
<Logo v-else-if="logo" />
17+
</span>
1218

1319
<!-- Only title -->
14-
<span v-else>
20+
<span class="title" v-else>
1521
{{ title }}
1622
</span>
1723
</NuxtLink>
@@ -24,15 +30,32 @@ css({
2430
alignItems: 'center',
2531
flex: 'none',
2632
27-
span: {
28-
fontSize: '{fontSize.xl}',
29-
fontWeight: '{fontWeight.bold}',
30-
color: '{color.gray.900}',
31-
'@dark': {
32-
color: '{color.gray.100}',
33+
'.logo': {
34+
height: '{docus.header.logo.height}',
35+
width: 'auto',
36+
'img, svg': {
37+
height: 'inherit',
38+
},
39+
'.light-img': {
40+
display: 'block',
41+
'@dark': {
42+
display: 'none'
43+
}
3344
},
45+
'.dark-img': {
46+
display: 'none',
47+
'@dark': {
48+
display: 'block'
49+
}
50+
},
51+
},
52+
53+
'.title': {
54+
fontSize: '{docus.header.title.fontSize}',
55+
fontWeight: '{docus.header.title.fontWeight}',
56+
color: '{docus.header.title.color.static}',
3457
'&:hover': {
35-
color: '{color.gray.500}',
58+
color: '{docus.header.title.color.hover}',
3659
}
3760
}
3861
}

components/app/Logo.vue

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -55,14 +55,10 @@
5555
css({
5656
svg: {
5757
color: '{color.gray.900}',
58-
height: '{space.6}',
59-
width: 'auto',
58+
height: 'inherit',
6059
'@dark': {
6160
color: '{color.gray.100}'
6261
},
63-
'@sm': {
64-
height: '{space.7}'
65-
}
6662
}
6763
})
6864
</style>

tokens.config.ts

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,26 @@ export default defineTheme({
108108
},
109109
fontFamily: '{font.sans}'
110110
},
111-
header: { height: '64px' },
111+
header: {
112+
height: '64px',
113+
logo: {
114+
height: {
115+
initial: '{space.6}',
116+
sm: '{space.7}'
117+
}
118+
},
119+
title: {
120+
fontSize: '{fontSize.2xl}',
121+
fontWeight: '{fontWeight.bold}',
122+
color: {
123+
static: {
124+
initial: '{color.gray.900}',
125+
dark: '{color.gray.100}',
126+
},
127+
hover: '{color.primary.500}',
128+
}
129+
}
130+
},
112131
footer: { height: { initial: '145px', sm: '100px' }, padding: '{space.4} 0' },
113132
readableLine: '78ch',
114133
loadingBar: {

0 commit comments

Comments
 (0)