refactor: improve css treeshaking + avoid layout shift on async components

pull/198/head
Evan You 4 years ago
parent b9c9e79cda
commit 3e85b46727

@ -1,9 +1,8 @@
import { App } from 'vue' import { App, defineAsyncComponent } from 'vue'
import { joinPath } from './utils' import { joinPath } from './utils'
import { SiteDataRef } from './composables/siteData' import { SiteDataRef } from './composables/siteData'
import { PageDataRef } from './composables/pageData' import { PageDataRef } from './composables/pageData'
import { Content } from './components/Content' import { Content } from './components/Content'
import Debug from './components/Debug.vue'
import { ClientOnly } from './components/ClientOnly' import { ClientOnly } from './components/ClientOnly'
export function mixinGlobalComputed( export function mixinGlobalComputed(
@ -70,5 +69,10 @@ export function mixinGlobalComponents(app: App) {
app.component('Content', Content) app.component('Content', Content)
app.component('ClientOnly', ClientOnly) app.component('ClientOnly', ClientOnly)
app.component('Debug', isProd ? () => null : Debug) app.component(
'Debug',
isProd
? () => null
: defineAsyncComponent(() => import('./components/Debug.vue'))
)
} }

@ -76,6 +76,7 @@ import type { DefaultTheme } from './config'
import NavBar from './components/NavBar.vue' import NavBar from './components/NavBar.vue'
import SideBar from './components/SideBar.vue' import SideBar from './components/SideBar.vue'
import Page from './components/Page.vue' import Page from './components/Page.vue'
const Home = defineAsyncComponent(() => import('./components/Home.vue')) const Home = defineAsyncComponent(() => import('./components/Home.vue'))
const NoopComponent = () => null const NoopComponent = () => null

@ -139,6 +139,7 @@ function initialize(userOptions: any) {
@media (min-width: 720px) { @media (min-width: 720px) {
.algolia-search-box { .algolia-search-box {
padding-left: 8px; padding-left: 8px;
min-width: 176.3px; /* avoid layout shift */
} }
} }

@ -28,6 +28,7 @@ onMounted(() => {
max-width: 280px; max-width: 280px;
font-size: .75rem; font-size: .75rem;
background-color: rgba(255, 255, 255, .8); background-color: rgba(255, 255, 255, .8);
min-height: 105.38px; /* avoid layout shift on mobile */
} }
.carbon-ads::after { .carbon-ads::after {
@ -46,6 +47,7 @@ onMounted(() => {
padding: 8px; padding: 8px;
width: 146px; width: 146px;
max-width: 100%; max-width: 100%;
min-height: 200px;
} }
} }
@ -60,7 +62,7 @@ onMounted(() => {
} }
} }
.carbon-ads ::v-deep(.carbon-img) { .carbon-ads :deep(.carbon-img) {
float: left; float: left;
margin-right: .75rem; margin-right: .75rem;
max-width: 100px; max-width: 100px;
@ -68,7 +70,7 @@ onMounted(() => {
} }
@media (min-width: 420px) { @media (min-width: 420px) {
.carbon-ads ::v-deep(.carbon-img) { .carbon-ads :deep(.carbon-img) {
float: none; float: none;
display: block; display: block;
margin-right: 0; margin-right: 0;
@ -76,24 +78,24 @@ onMounted(() => {
} }
} }
.carbon-ads ::v-deep(.carbon-img img) { .carbon-ads :deep(.carbon-img img) {
display: block; display: block;
width: 100%; width: 100%;
} }
@media (min-width: 420px) { @media (min-width: 420px) {
.carbon-ads ::v-deep(.carbon-text) { .carbon-ads :deep(.carbon-text) {
padding-top: 8px; padding-top: 8px;
} }
} }
.carbon-ads ::v-deep(.carbon-text) { .carbon-ads :deep(.carbon-text) {
display: block; display: block;
font-weight: 400; font-weight: 400;
color: var(--c-text-light); color: var(--c-text-light);
} }
.carbon-ads ::v-deep(.carbon-poweredby) { .carbon-ads :deep(.carbon-poweredby) {
display: block; display: block;
padding-top: 2px; padding-top: 2px;
font-weight: 400; font-weight: 400;

Loading…
Cancel
Save