Skip to content

Commit

Permalink
feat: add support for static light/dark images for logo (#874)
Browse files Browse the repository at this point in the history
  • Loading branch information
bdrtsky authored Apr 10, 2023
1 parent 7cd18d2 commit 3e79992
Show file tree
Hide file tree
Showing 6 changed files with 54 additions and 60 deletions.
15 changes: 0 additions & 15 deletions .docs/public/logo-dark.svg

This file was deleted.

15 changes: 0 additions & 15 deletions .docs/public/logo-light.svg

This file was deleted.

14 changes: 0 additions & 14 deletions assets/css/main.css
Original file line number Diff line number Diff line change
@@ -1,17 +1,3 @@
.light-img {
display: block;
@dark {
display: hidden;
}
}

.dark-img {
display: hidden;
@dark {
display: block;
}
}

/* Base */

:root {
Expand Down
43 changes: 33 additions & 10 deletions components/app/AppHeaderLogo.vue
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,17 @@ const title = computed(() => config.value.header?.title || config.value.title)
<template>
<NuxtLink class="navbar-logo" to="/" :aria-label="title">
<!-- Only Logo -->
<component :is="logo" v-if="logo && typeof logo === 'string'" />
<Logo v-else-if="logo" />
<span class="logo" v-if="logo">
<component :is="logo" v-if="typeof logo === 'string'" />
<template v-else-if="logo.light && logo.dark">
<img :src="logo.light" alt="" class="light-img">
<img :src="logo.dark" alt="" class="dark-img">
</template>
<Logo v-else-if="logo" />
</span>

<!-- Only title -->
<span v-else>
<span class="title" v-else>
{{ title }}
</span>
</NuxtLink>
Expand All @@ -24,15 +30,32 @@ css({
alignItems: 'center',
flex: 'none',
span: {
fontSize: '{fontSize.xl}',
fontWeight: '{fontWeight.bold}',
color: '{color.gray.900}',
'@dark': {
color: '{color.gray.100}',
'.logo': {
height: '{docus.header.logo.height}',
width: 'auto',
'img, svg': {
height: 'inherit',
},
'.light-img': {
display: 'block',
'@dark': {
display: 'none'
}
},
'.dark-img': {
display: 'none',
'@dark': {
display: 'block'
}
},
},
'.title': {
fontSize: '{docus.header.title.fontSize}',
fontWeight: '{docus.header.title.fontWeight}',
color: '{docus.header.title.color.static}',
'&:hover': {
color: '{color.gray.500}',
color: '{docus.header.title.color.hover}',
}
}
}
Expand Down
6 changes: 1 addition & 5 deletions components/app/Logo.vue
Original file line number Diff line number Diff line change
Expand Up @@ -55,14 +55,10 @@
css({
svg: {
color: '{color.gray.900}',
height: '{space.6}',
width: 'auto',
height: 'inherit',
'@dark': {
color: '{color.gray.100}'
},
'@sm': {
height: '{space.7}'
}
}
})
</style>
21 changes: 20 additions & 1 deletion tokens.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,26 @@ export default defineTheme({
},
fontFamily: '{font.sans}'
},
header: { height: '64px' },
header: {
height: '64px',
logo: {
height: {
initial: '{space.6}',
sm: '{space.7}'
}
},
title: {
fontSize: '{fontSize.2xl}',
fontWeight: '{fontWeight.bold}',
color: {
static: {
initial: '{color.gray.900}',
dark: '{color.gray.100}',
},
hover: '{color.primary.500}',
}
}
},
footer: { height: { initial: '145px', sm: '100px' }, padding: '{space.4} 0' },
readableLine: '78ch',
loadingBar: {
Expand Down

0 comments on commit 3e79992

Please sign in to comment.