feat: add theme color and support mobile devices

This commit is contained in:
Justineo 2021-10-22 12:15:12 +08:00
parent c639dc2028
commit 9411435247
No known key found for this signature in database
GPG Key ID: B73F0979CF18A0EA
5 changed files with 128 additions and 13 deletions

View File

@ -35,11 +35,18 @@ input
font inherit font inherit
color inherit color inherit
a:focus a
outline none -webkit-tap-highlight-color transparent
&:focus
outline none
main main
line-height 1.5 line-height 1.5
.DocSearch-Container .DocSearch-Container
backdrop-filter blur(4px) backdrop-filter blur(4px)
@media (max-width 480px)
body
margin 0

View File

@ -141,6 +141,8 @@ margin-y($top, $bottom = $top)
backdrop-filter blur(4px) backdrop-filter blur(4px)
th th
position relative
&::after &::after
content "" content ""
position absolute position absolute
@ -353,3 +355,33 @@ margin-y($top, $bottom = $top)
12% 12%
80% 80%
background-color #f2f7ff background-color #f2f7ff
@media (max-width 480px)
.post
padding 30px
[data-markdown]
h1
h1&
font-size 24px
h2
h2&
font-size 20px
h3
h3&
font-size 18px
h4
h4&
font-size 16px
h5
h5&
font-size 14px
table&
display block
max-width 100%
width fit-content
overflow-x auto

View File

@ -1,9 +1,13 @@
<template> <template>
<aside class="one-nav"> <aside
v-outside="collapseMenu"
class="one-nav"
:class="{ expanded }"
>
<veui-menu <veui-menu
class="one-menu" class="one-menu"
:items="menuItems" :items="menuItems"
:expanded.sync="expanded" :expanded.sync="menuExpanded"
> >
<template #before> <template #before>
<header> <header>
@ -29,6 +33,12 @@
<section class="search"> <section class="search">
<one-search/> <one-search/>
</section> </section>
<button
class="toggle"
@click="toggleMenu"
>
<veui-icon name="hamburger"/>
</button>
</header> </header>
</template> </template>
<template #item-label="{ label, sub }"> <template #item-label="{ label, sub }">
@ -41,16 +51,23 @@
<script> <script>
import i18n from '../common/i18n' import i18n from '../common/i18n'
import OneSearch from './OneSearch' import OneSearch from './OneSearch'
import { Menu } from 'veui' import { Menu, Icon } from 'veui'
import outside from 'veui/directives/outside'
import 'veui-theme-dls-icons/hamburger'
export default { export default {
name: 'one-menu', name: 'one-menu',
directives: {
outside
},
components: { components: {
'one-search': OneSearch, 'one-search': OneSearch,
'veui-menu': Menu 'veui-menu': Menu,
'veui-icon': Icon
}, },
mixins: [i18n], mixins: [i18n],
props: { props: {
expanded: Boolean,
nav: { nav: {
type: Array, type: Array,
default () { default () {
@ -60,7 +77,7 @@ export default {
}, },
data () { data () {
return { return {
expanded: [] menuExpanded: []
} }
}, },
computed: { computed: {
@ -80,7 +97,7 @@ export default {
} }
}, },
created () { created () {
this.expanded = this.menuItems.map(({ name }) => name) this.menuExpanded = this.menuItems.map(({ name }) => name)
}, },
methods: { methods: {
getTitleDetail (title) { getTitleDetail (title) {
@ -105,6 +122,12 @@ export default {
disabled, disabled,
children: children ? children.map(child => this.normalizeItem(child, fullSlug)) : [] children: children ? children.map(child => this.normalizeItem(child, fullSlug)) : []
} }
},
toggleMenu () {
this.$emit('toggle', !this.expanded)
},
collapseMenu () {
this.$emit('toggle', false)
} }
} }
} }
@ -122,6 +145,7 @@ export default {
.one-menu .one-menu
width 100% width 100%
height 100% height 100%
background-color #fff
& >>> .veui-menu-tree-wrapper & >>> .veui-menu-tree-wrapper
display flex display flex
@ -184,11 +208,47 @@ export default {
flex-shrink 0 flex-shrink 0
.toggle .toggle
margin-right 16px display none
font-size 13px
vertical-align middle
.disabled .disabled
opacity 0.3 opacity 0.3
pointer-events none pointer-events none
@media (max-width 480px)
.one-nav
z-index 20
transition transform 0.3s
transform translateX(-100%)
&.expanded
transform translateX(0)
box-shadow 0 0 12px rgba(0, 0, 0, 0.2)
header
position relative
.toggle
display flex
align-items center
justify-content center
width 36px
height 36px
position absolute
top 80px
left 100%
border 1px solid #e2e6f0
border-top-right-radius 4px
border-bottom-right-radius 4px
background-color #fff
box-shadow 0 0 12px rgba(0, 0, 0, 0.1)
font-size 20px
&::before
content ""
position absolute
top 0
bottom 0
left -19px
width 20px
background-color #fff
</style> </style>

View File

@ -6,7 +6,11 @@
'no-links': !hasFooterLinks 'no-links': !hasFooterLinks
}" }"
> >
<one-menu :nav="nav"/> <one-menu
:nav="nav"
:expanded="expanded"
@toggle="handleToggle"
/>
<nuxt/> <nuxt/>
<one-footer <one-footer
class="footer" class="footer"
@ -42,7 +46,8 @@ export default {
hasFooterLinks: true, hasFooterLinks: true,
config: { config: {
'link.routerLink': 'nuxt-link' 'link.routerLink': 'nuxt-link'
} },
expanded: false
} }
}, },
computed: { computed: {
@ -79,6 +84,9 @@ export default {
methods: { methods: {
updateLayout ({ hasLinks }) { updateLayout ({ hasLinks }) {
this.hasFooterLinks = hasLinks this.hasFooterLinks = hasLinks
},
handleToggle (expanded) {
this.expanded = expanded
} }
} }
} }
@ -95,6 +103,11 @@ main
max-width 1346px - $sidebar-width max-width 1346px - $sidebar-width
min-width 560px min-width 560px
transition margin-left 0.5s cubic-bezier(0.785, 0.135, 0.15, 0.86) transition margin-left 0.5s cubic-bezier(0.785, 0.135, 0.15, 0.86)
@media (max-width 480px)
.content
.footer
min-width 0
</style> </style>
<style lang="stylus" src="@/assets/styles/post.styl"></style> <style lang="stylus" src="@/assets/styles/post.styl"></style>

View File

@ -24,6 +24,9 @@ module.exports = {
hid: 'description', hid: 'description',
name: 'description', name: 'description',
content: 'Website for VEUI: an enterprise component library for Vue.js.' content: 'Website for VEUI: an enterprise component library for Vue.js.'
},
{
name: 'theme-color', content: '#0052cc'
} }
], ],
link: [ link: [