Skip to content

Commit

Permalink
refactor: keep carbon ads async
Browse files Browse the repository at this point in the history
  • Loading branch information
posva committed Dec 5, 2020
1 parent 618d97f commit 67e80c9
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 18 deletions.
45 changes: 40 additions & 5 deletions src/client/theme-default/Layout.vue
Original file line number Diff line number Diff line change
Expand Up @@ -36,12 +36,16 @@
<Page v-else>
<template #top>
<slot name="page-top-ads">
<CarbonAds
<div
id="ads-container"
v-if="theme.carbonAds && theme.carbonAds.carbon"
:key="'carbon' + page.relativePath"
:code="theme.carbonAds.carbon"
:placement="theme.carbonAds.placement"
/>
>
<CarbonAds
:key="'carbon' + page.relativePath"
:code="theme.carbonAds.carbon"
:placement="theme.carbonAds.placement"
/>
</div>
</slot>
<slot name="page-top" />
</template>
Expand Down Expand Up @@ -150,3 +154,34 @@ const pageClasses = computed(() => {
]
})
</script>

<style>
#ads-container {
margin: 0 auto;
}
@media (min-width: 420px) {
#ads-container {
position: relative;
right: 0;
float: right;
margin: -8px -8px 24px 24px;
width: 146px;
}
}
@media (max-width: 420px) {
#ads-container {
/* Avoid layout shift */
height: 105px;
}
}
@media (min-width: 1400px) {
#ads-container {
position: fixed;
right: 8px;
bottom: 8px;
}
}
</style>
13 changes: 0 additions & 13 deletions src/client/theme-default/components/CarbonAds.vue
Original file line number Diff line number Diff line change
Expand Up @@ -38,30 +38,17 @@ onMounted(() => {
@media (min-width: 420px) {
.carbon-ads {
position: relative;
right: -8px;
z-index: 1;
float: right;
margin: -8px -8px 24px 24px;
padding: 8px;
width: 146px;
max-width: 100%;
}
}
@media (max-width: 420px) {
.carbon-ads {
/* Avoid layout shift */
height: 105px;
}
}
@media (min-width: 1400px) {
.carbon-ads {
position: fixed;
top: auto;
right: 8px;
bottom: 8px;
float: none;
margin: 0;
}
Expand Down

0 comments on commit 67e80c9

Please sign in to comment.