Skip to content

Commit 1a39d4f

Browse files
authored
docs(docs): Update Vue School summer banner (#1457)
1 parent 154fa3b commit 1a39d4f

File tree

4 files changed

+258
-139
lines changed

4 files changed

+258
-139
lines changed

packages/docs/.vitepress/components/Banner.vue

Lines changed: 77 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,26 @@
1515
<div class="vs-backpack">
1616
<img src="/images/vueschool/vs-backpack.png" alt="Backpack">
1717
</div>
18-
<div class="vs-slogan">
19-
<span class="vs-slogan-light">Summer Sale:</span> Get the 3 months plan for only <span style="text-decoration: line-through">$75</span> $50
18+
<div class="vs-slogan-wrapper">
19+
<div class="vs-slogan">
20+
Learn Vue this summer and <span class="vs-slogan-light">save 40%</span>
21+
</div>
22+
<div class="vs-subline">
23+
<span
24+
v-if="isExtended"
25+
:style="{ fontWeight: 'bold', marginRight: '8px' }">
26+
Extended!
27+
</span>
28+
<span
29+
v-else>
30+
Limited time offer
31+
</span>
32+
<BannerCountdown
33+
v-bind="{ remaining }" />
34+
</div>
2035
</div>
2136
<div class="vs-button">
22-
Get 33% OFF
37+
Get Offer
2338
</div>
2439
</div>
2540
<div
@@ -32,16 +47,30 @@
3247
</template>
3348

3449
<script>
50+
import BannerCountdown from './BannerCountdown.vue'
51+
3552
export default {
53+
components: {
54+
BannerCountdown
55+
},
3656
data () {
3757
return {
38-
isVisible: false
58+
isActive: null,
59+
isExtended: null,
60+
isVisible: false,
61+
remaining: 0
3962
}
4063
},
4164
mounted () {
4265
const now = new Date()
43-
const end = new Date('2022-07-23T00:00:00+02:00')
44-
this.isVisible = !localStorage.getItem('VS_SUMMER_22') && (now < end)
66+
const extension = new Date('2022-07-27T00:00:00+02:00')
67+
const end = new Date('2022-07-29T00:00:00+02:00')
68+
69+
this.isActive = now < end
70+
this.isExtended = now > extension && now < end
71+
72+
this.remaining = (this.isExtended ? end : extension) - now
73+
this.isVisible = !localStorage.getItem('VS_SUMMER_22') && this.remaining > 0
4574
if (this.isVisible) document.body.classList.add('has-top-banner')
4675
},
4776
methods: {
@@ -71,26 +100,32 @@ export default {
71100
height: 5rem;
72101
display: flex;
73102
}
103+
74104
#vs:hover {
75105
text-decoration: none;
76106
}
107+
77108
@media (min-width: 680px) {
78109
#vs {
79110
height: 5rem;
80111
}
81112
}
113+
82114
#vs:hover .vs-core .vs-button {
83115
background: #f22606;
84116
}
117+
85118
#vs .vs-iso {
86119
position: absolute;
87120
left: 20px;
88121
height: 26px;
89122
display: none;
90123
}
124+
91125
#vs .vs-iso img {
92126
height: 26px;
93127
}
128+
94129
@media (min-width: 680px) {
95130
#vs .vs-iso {
96131
left: 40px;
@@ -101,71 +136,80 @@ export default {
101136
height: 40px;
102137
}
103138
}
139+
104140
@media (min-width: 900px) {
105141
#vs .vs-iso {
106142
display: none;
107143
}
108144
}
145+
109146
#vs .vs-logo {
110147
position: absolute;
111148
display: none;
112149
left: 40px;
113150
}
151+
114152
@media (min-width: 900px) {
115153
#vs .vs-logo {
116154
display: block;
117155
}
118156
}
157+
119158
#vs .vs-core {
120159
display: flex;
121160
align-items: center;
122161
}
162+
123163
#vs .vs-core .vs-backpack {
124-
margin-right: 14px;
164+
margin-right: 26px;
125165
}
166+
126167
#vs .vs-core .vs-backpack img {
127-
height: 38px;
128-
}
129-
@media (min-width: 900px) {
130-
#vs .vs-core .vs-backpack img {
131-
height: 50px;
132-
}
168+
height: 44px;
133169
}
134-
@media (min-width: 900px) {
135-
#vs .vs-core .vs-backpack img {
136-
height: 74px;
137-
}
170+
171+
#vs .vs-core .vs-slogan-wrapper {
172+
margin-right: 26px;
138173
}
174+
139175
#vs .vs-core .vs-slogan {
140176
color: #FFF;
141177
font-weight: bold;
142-
font-size: 14px;
143-
margin-right: 26px;
178+
font-size: 16px;
179+
text-align: center;
144180
}
181+
145182
@media (min-width: 680px) {
146183
#vs .vs-core .vs-slogan {
147-
margin-right: 0;
148-
font-size: 16px;
149-
}
150-
}
151-
@media (min-width: 900px) {
152-
#vs .vs-core .vs-slogan {
153-
font-size: 20px;
184+
font-size: 18px;
154185
}
155186
}
187+
156188
#vs .vs-core .vs-slogan > .vs-slogan-light {
157-
color: #ff5338;
189+
color: #00b5ff;
158190
display: block;
159-
text-align: left;
160191
}
192+
193+
#vs .vs-core .vs-slogan-wrapper .vs-subline {
194+
color: #FFF;
195+
text-align: center;
196+
font-size: 12px;
197+
}
198+
199+
@media (min-width: 680px) {
200+
#vs .vs-core .vs-slogan-wrapper .vs-subline {
201+
font-size: 16px;
202+
}
203+
}
204+
161205
@media (min-width: 900px) {
162206
#vs .vs-core .vs-slogan > .vs-slogan-light {
163207
text-align: center;
164208
display: inline;
165209
}
166210
}
211+
167212
#vs .vs-core .vs-button {
168-
margin-left: 43px;
169213
color: #fff;
170214
padding: 13px 24px;
171215
border-radius: 40px;
@@ -174,21 +218,25 @@ export default {
174218
font-weight: bold;
175219
text-transform: uppercase;
176220
}
221+
177222
@media (min-width: 680px) {
178223
#vs .vs-core .vs-button {
179224
display: inline-block;
180225
}
181226
}
227+
182228
#vs .vs-close {
183229
right: 10px;
184230
position: absolute;
185231
padding: 10px;
186232
}
233+
187234
@media (min-width: 680px) {
188235
#vs .vs-close {
189236
right: 20px;
190237
}
191238
}
239+
192240
#vs .vs-close:hover {
193241
color: #56d8ff;
194242
}
Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
<template>
2+
<ClientOnly>
3+
<VueCountdown
4+
v-if="remaining"
5+
:time="remaining"
6+
v-slot="data">
7+
<span
8+
v-for="part in ['days', 'hours', 'minutes', 'seconds']"
9+
:key="part">
10+
{{ data[part] }}{{ part[0].toLowerCase() }}
11+
<span
12+
v-if="part !== 'seconds'"
13+
class="px-1 text-xl font-bold">
14+
:
15+
</span>
16+
</span>
17+
</VueCountdown>
18+
</ClientOnly>
19+
</template>
20+
21+
<script>
22+
import VueCountdown from '@chenfengyuan/vue-countdown'
23+
24+
const countdownTransform = (props) => {
25+
Object.entries(props).forEach(([key, value]) => {
26+
const digits = value < 10 ? `0${value}` : value
27+
props[key] = digits
28+
})
29+
return props
30+
}
31+
32+
export default {
33+
components: {
34+
VueCountdown
35+
},
36+
props: {
37+
remaining: {
38+
type: Number,
39+
default: 0
40+
}
41+
},
42+
computed: {
43+
isVisible () {
44+
return this.remaining > 0
45+
}
46+
}
47+
}
48+
</script>
49+
50+
<style scoped>
51+
span {
52+
color: #ff5338;
53+
font-weight: bold;
54+
}
55+
</style>

packages/docs/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
"docs:build": "vitepress build ."
99
},
1010
"dependencies": {
11+
"@chenfengyuan/vue-countdown": "2",
1112
"@vueuse/core": "^8.9.4",
1213
"pinia": "^2.0.0",
1314
"vitepress": "^0.22.2"

0 commit comments

Comments
 (0)