Skip to content

Commit

Permalink
docs(docs): Update Vue School summer banner (#1457)
Browse files Browse the repository at this point in the history
  • Loading branch information
nicodevs authored Jul 25, 2022
1 parent 154fa3b commit 1a39d4f
Show file tree
Hide file tree
Showing 4 changed files with 258 additions and 139 deletions.
106 changes: 77 additions & 29 deletions packages/docs/.vitepress/components/Banner.vue
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,26 @@
<div class="vs-backpack">
<img src="/images/vueschool/vs-backpack.png" alt="Backpack">
</div>
<div class="vs-slogan">
<span class="vs-slogan-light">Summer Sale:</span> Get the 3 months plan for only <span style="text-decoration: line-through">$75</span> $50
<div class="vs-slogan-wrapper">
<div class="vs-slogan">
Learn Vue this summer and <span class="vs-slogan-light">save 40%</span>
</div>
<div class="vs-subline">
<span
v-if="isExtended"
:style="{ fontWeight: 'bold', marginRight: '8px' }">
Extended!
</span>
<span
v-else>
Limited time offer
</span>
<BannerCountdown
v-bind="{ remaining }" />
</div>
</div>
<div class="vs-button">
Get 33% OFF
Get Offer
</div>
</div>
<div
Expand All @@ -32,16 +47,30 @@
</template>

<script>
import BannerCountdown from './BannerCountdown.vue'
export default {
components: {
BannerCountdown
},
data () {
return {
isVisible: false
isActive: null,
isExtended: null,
isVisible: false,
remaining: 0
}
},
mounted () {
const now = new Date()
const end = new Date('2022-07-23T00:00:00+02:00')
this.isVisible = !localStorage.getItem('VS_SUMMER_22') && (now < end)
const extension = new Date('2022-07-27T00:00:00+02:00')
const end = new Date('2022-07-29T00:00:00+02:00')
this.isActive = now < end
this.isExtended = now > extension && now < end
this.remaining = (this.isExtended ? end : extension) - now
this.isVisible = !localStorage.getItem('VS_SUMMER_22') && this.remaining > 0
if (this.isVisible) document.body.classList.add('has-top-banner')
},
methods: {
Expand Down Expand Up @@ -71,26 +100,32 @@ export default {
height: 5rem;
display: flex;
}
#vs:hover {
text-decoration: none;
}
@media (min-width: 680px) {
#vs {
height: 5rem;
}
}
#vs:hover .vs-core .vs-button {
background: #f22606;
}
#vs .vs-iso {
position: absolute;
left: 20px;
height: 26px;
display: none;
}
#vs .vs-iso img {
height: 26px;
}
@media (min-width: 680px) {
#vs .vs-iso {
left: 40px;
Expand All @@ -101,71 +136,80 @@ export default {
height: 40px;
}
}
@media (min-width: 900px) {
#vs .vs-iso {
display: none;
}
}
#vs .vs-logo {
position: absolute;
display: none;
left: 40px;
}
@media (min-width: 900px) {
#vs .vs-logo {
display: block;
}
}
#vs .vs-core {
display: flex;
align-items: center;
}
#vs .vs-core .vs-backpack {
margin-right: 14px;
margin-right: 26px;
}
#vs .vs-core .vs-backpack img {
height: 38px;
}
@media (min-width: 900px) {
#vs .vs-core .vs-backpack img {
height: 50px;
}
height: 44px;
}
@media (min-width: 900px) {
#vs .vs-core .vs-backpack img {
height: 74px;
}
#vs .vs-core .vs-slogan-wrapper {
margin-right: 26px;
}
#vs .vs-core .vs-slogan {
color: #FFF;
font-weight: bold;
font-size: 14px;
margin-right: 26px;
font-size: 16px;
text-align: center;
}
@media (min-width: 680px) {
#vs .vs-core .vs-slogan {
margin-right: 0;
font-size: 16px;
}
}
@media (min-width: 900px) {
#vs .vs-core .vs-slogan {
font-size: 20px;
font-size: 18px;
}
}
#vs .vs-core .vs-slogan > .vs-slogan-light {
color: #ff5338;
color: #00b5ff;
display: block;
text-align: left;
}
#vs .vs-core .vs-slogan-wrapper .vs-subline {
color: #FFF;
text-align: center;
font-size: 12px;
}
@media (min-width: 680px) {
#vs .vs-core .vs-slogan-wrapper .vs-subline {
font-size: 16px;
}
}
@media (min-width: 900px) {
#vs .vs-core .vs-slogan > .vs-slogan-light {
text-align: center;
display: inline;
}
}
#vs .vs-core .vs-button {
margin-left: 43px;
color: #fff;
padding: 13px 24px;
border-radius: 40px;
Expand All @@ -174,21 +218,25 @@ export default {
font-weight: bold;
text-transform: uppercase;
}
@media (min-width: 680px) {
#vs .vs-core .vs-button {
display: inline-block;
}
}
#vs .vs-close {
right: 10px;
position: absolute;
padding: 10px;
}
@media (min-width: 680px) {
#vs .vs-close {
right: 20px;
}
}
#vs .vs-close:hover {
color: #56d8ff;
}
Expand Down
55 changes: 55 additions & 0 deletions packages/docs/.vitepress/components/BannerCountdown.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
<template>
<ClientOnly>
<VueCountdown
v-if="remaining"
:time="remaining"
v-slot="data">
<span
v-for="part in ['days', 'hours', 'minutes', 'seconds']"
:key="part">
{{ data[part] }}{{ part[0].toLowerCase() }}
<span
v-if="part !== 'seconds'"
class="px-1 text-xl font-bold">
:
</span>
</span>
</VueCountdown>
</ClientOnly>
</template>

<script>
import VueCountdown from '@chenfengyuan/vue-countdown'
const countdownTransform = (props) => {
Object.entries(props).forEach(([key, value]) => {
const digits = value < 10 ? `0${value}` : value
props[key] = digits
})
return props
}
export default {
components: {
VueCountdown
},
props: {
remaining: {
type: Number,
default: 0
}
},
computed: {
isVisible () {
return this.remaining > 0
}
}
}
</script>

<style scoped>
span {
color: #ff5338;
font-weight: bold;
}
</style>
1 change: 1 addition & 0 deletions packages/docs/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
"docs:build": "vitepress build ."
},
"dependencies": {
"@chenfengyuan/vue-countdown": "2",
"@vueuse/core": "^8.9.4",
"pinia": "^2.0.0",
"vitepress": "^0.22.2"
Expand Down
Loading

0 comments on commit 1a39d4f

Please sign in to comment.