docs: update header style

This commit is contained in:
chenjiahan 2020-12-01 19:18:45 +08:00
parent b33737ef77
commit aadb03cec5
5 changed files with 38 additions and 39 deletions

View File

@ -15,7 +15,7 @@
<script> <script>
import VanDoc from './components'; import VanDoc from './components';
import { config, packageVersion } from 'site-desktop-shared'; import { config } from 'site-desktop-shared';
import { setLang } from '../common/locales'; import { setLang } from '../common/locales';
import { scrollToAnchor } from './utils'; import { scrollToAnchor } from './utils';
@ -28,7 +28,6 @@ export default {
const path = location.pathname.replace(/\/index(\.html)?/, '/'); const path = location.pathname.replace(/\/index(\.html)?/, '/');
return { return {
packageVersion,
simulator: `${path}mobile.html${location.hash}`, simulator: `${path}mobile.html${location.hash}`,
}; };
}, },
@ -58,11 +57,7 @@ export default {
}, },
versions() { versions() {
if (config.site.versions) { return config.site.versions || null;
return [{ label: packageVersion }, ...config.site.versions];
}
return null;
}, },
}, },

View File

@ -13,12 +13,11 @@
:key="index" :key="index"
class="van-doc-header__top-nav-item" class="van-doc-header__top-nav-item"
> >
<a <a class="van-doc-header__link" target="_blank" :href="item.url">
class="van-doc-header__logo-link" <img v-if="item.logo" :src="item.logo" />
target="_blank" <span v-else-if="item.text">
:href="item.url" {{ item.text }}
> </span>
<img :src="item.logo" />
</a> </a>
</li> </li>
@ -31,7 +30,7 @@
class="van-doc-header__cube van-doc-header__version" class="van-doc-header__cube van-doc-header__version"
@click="toggleVersionPop" @click="toggleVersionPop"
> >
{{ versions[0].label }} {{ packageVersion }}
<transition name="van-doc-dropdown"> <transition name="van-doc-dropdown">
<div v-if="showVersionPop" class="van-doc-header__version-pop"> <div v-if="showVersionPop" class="van-doc-header__version-pop">
<div <div
@ -64,6 +63,7 @@
<script> <script>
import SearchInput from './SearchInput'; import SearchInput from './SearchInput';
import { packageVersion } from 'site-desktop-shared';
export default { export default {
name: 'van-doc-header', name: 'van-doc-header',
@ -81,6 +81,7 @@ export default {
data() { data() {
return { return {
packageVersion,
showVersionPop: false, showVersionPop: false,
}; };
}, },
@ -153,7 +154,6 @@ export default {
align-items: center; align-items: center;
height: @van-doc-header-top-height; height: @van-doc-header-top-height;
padding: 0 @van-doc-padding; padding: 0 @van-doc-padding;
line-height: @van-doc-header-top-height;
&-nav { &-nav {
flex: 1; flex: 1;
@ -167,7 +167,7 @@ export default {
} }
&-item { &-item {
margin-left: 20px; margin-left: 16px;
} }
&-title { &-title {
@ -183,7 +183,7 @@ export default {
padding: 0 12px; padding: 0 12px;
color: #fff; color: #fff;
font-size: 14px; font-size: 14px;
line-height: 24px; line-height: 28px;
text-align: center; text-align: center;
border: 1px solid rgba(255, 255, 255, 0.7); border: 1px solid rgba(255, 255, 255, 0.7);
border-radius: 20px; border-radius: 20px;
@ -196,8 +196,8 @@ export default {
&::after { &::after {
position: absolute; position: absolute;
top: 7px; top: 9px;
right: 7px; right: 9px;
width: 5px; width: 5px;
height: 5px; height: 5px;
color: rgba(255, 255, 255, 0.9); color: rgba(255, 255, 255, 0.9);
@ -209,15 +209,16 @@ export default {
&-pop { &-pop {
position: absolute; position: absolute;
top: 30px; top: 34px;
right: 0;
left: 0; left: 0;
width: 100px;
z-index: 99; z-index: 99;
color: #333; color: #333;
line-height: 36px; line-height: 36px;
text-align: left; text-align: left;
overflow: hidden;
background-color: #fff; background-color: #fff;
border-radius: @van-doc-border-radius; border-radius: 8px;
box-shadow: 0 4px 12px #ebedf0; box-shadow: 0 4px 12px #ebedf0;
transform-origin: top; transform-origin: top;
transition: 0.2s cubic-bezier(0.215, 0.61, 0.355, 1); transition: 0.2s cubic-bezier(0.215, 0.61, 0.355, 1);
@ -228,6 +229,7 @@ export default {
&:hover { &:hover {
color: @van-doc-blue; color: @van-doc-blue;
background-color: #f7f8fa;
} }
} }
} }
@ -243,8 +245,8 @@ export default {
} }
img { img {
width: 24px; width: 28px;
margin-right: 10px; margin-right: 12px;
} }
span { span {
@ -253,11 +255,16 @@ export default {
} }
} }
&__logo-link { &__link {
span {
color: #fff;
font-size: 16px;
}
img { img {
display: block; display: block;
width: 26px; width: 28px;
height: 26px; height: 28px;
transition: 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275); transition: 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
&:hover { &:hover {

View File

@ -47,4 +47,8 @@ export default {
display: inline-block; display: inline-block;
vertical-align: middle; vertical-align: middle;
} }
.DocSearch-Button {
height: 32px;
}
</style> </style>

View File

@ -7,7 +7,7 @@ module.exports = {
themeConfig: { themeConfig: {
nav: [ nav: [
{ {
text: 'Github', text: 'GitHub',
link: 'https://github.com/youzan/vant/tree/next/packages/vant-use', link: 'https://github.com/youzan/vant/tree/next/packages/vant-use',
}, },
], ],

View File

@ -15,8 +15,9 @@ module.exports = {
site: { site: {
defaultLang: 'en-US', defaultLang: 'en-US',
versions: [ versions: [
{ label: '1.x', link: '/vant/1.x/' }, { label: 'Vant 1.x', link: '/vant/1.x/' },
{ label: '2.x', link: '/vant/' }, { label: 'Vant 2.x', link: '/vant/' },
{ label: 'Vant Weapp', link: '/vant-weapp/' },
], ],
baiduAnalytics: { baiduAnalytics: {
seed: 'ad6b5732c36321f2dafed737ac2da92f', seed: 'ad6b5732c36321f2dafed737ac2da92f',
@ -28,10 +29,6 @@ module.exports = {
logo: 'https://img.yzcdn.cn/vant/logo.png', logo: 'https://img.yzcdn.cn/vant/logo.png',
langLabel: '中文', langLabel: '中文',
links: [ links: [
{
logo: 'https://b.yzcdn.cn/vant/logo/weapp.svg',
url: '/vant-weapp',
},
{ {
logo: 'https://b.yzcdn.cn/vant/logo/github.svg', logo: 'https://b.yzcdn.cn/vant/logo/github.svg',
url: 'https://github.com/youzan/vant', url: 'https://github.com/youzan/vant',
@ -404,12 +401,8 @@ module.exports = {
title: 'Vant', title: 'Vant',
description: 'Mobile UI Components built on Vue', description: 'Mobile UI Components built on Vue',
logo: 'https://img.yzcdn.cn/vant/logo.png', logo: 'https://img.yzcdn.cn/vant/logo.png',
langLabel: 'En', langLabel: 'EN',
links: [ links: [
{
logo: 'https://b.yzcdn.cn/vant/logo/weapp.svg',
url: '/vant-weapp',
},
{ {
logo: 'https://b.yzcdn.cn/vant/logo/github.svg', logo: 'https://b.yzcdn.cn/vant/logo/github.svg',
url: 'https://github.com/youzan/vant', url: 'https://github.com/youzan/vant',