Skip to content

Commit de501a8

Browse files
authored
Docs: Update Vue School Black Friday banner (vuejs#1200)
1 parent 45bb415 commit de501a8

File tree

9 files changed

+145
-207
lines changed

9 files changed

+145
-207
lines changed
Lines changed: 133 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,133 @@
1+
<template>
2+
<div
3+
class="vs-blackfriday-coins">
4+
<img
5+
v-for="coin in coins"
6+
:key="coin.id"
7+
:alt="coin.id"
8+
:src="`/images/vueschool/tech-coin-${coin.id}.png`"
9+
:class="[coin.id, coin.inverse ? inverseDirection : direction]"
10+
:style="coin.style"
11+
class="vs-blackfriday-coin">
12+
</div>
13+
</template>
14+
15+
<script>
16+
const coins = [
17+
{ id: 'js', inverse: true },
18+
{ id: 'ts' },
19+
{ id: 'vue', inverse: true },
20+
{ id: 'vuex', inverse: true },
21+
{ id: 'nuxt' }
22+
]
23+
24+
export default {
25+
data () {
26+
return {
27+
coins,
28+
xPosition: 0,
29+
direction: 'left',
30+
inverseDirection: 'right',
31+
isAnimated: false
32+
}
33+
},
34+
mounted () {
35+
if (window.innerWidth < 1024) return
36+
this.isAnimated = true
37+
this.animationTarget = document.getElementById('vs')
38+
this.animationTarget.addEventListener('mousemove', this.animate)
39+
},
40+
beforeDestroy () {
41+
if (!this.isAnimated) return
42+
this.animationTarget.removeEventListener('mousemove', this.animate)
43+
},
44+
methods: {
45+
animate (e) {
46+
this.direction = e.pageX > this.xPosition ? 'right' : 'left'
47+
this.inverseDirection = this.direction === 'left' ? 'right' : 'left'
48+
this.xPosition = e.pageX
49+
}
50+
}
51+
}
52+
</script>
53+
54+
<style>
55+
.vs-blackfriday-coins {
56+
overflow: hidden;
57+
position: absolute;
58+
bottom: 0;
59+
right: 0;
60+
top: 0;
61+
left: 0;
62+
z-index: -1;
63+
}
64+
65+
.vs-blackfriday-coin {
66+
display: none;
67+
}
68+
69+
@media (min-width: 768px) {
70+
.vs-blackfriday-coins {
71+
background-image: url(/images/vueschool/vueschool_blackfriday_background_tablet.svg);
72+
background-position: center;
73+
background-size: cover;
74+
}
75+
}
76+
77+
@media (min-width: 1024px) {
78+
.vs-blackfriday-coins {
79+
background: transparent;
80+
}
81+
82+
#vs:hover .vs-blackfriday-coin.left {
83+
transform: translateX(-600px);
84+
transition: transform 30s linear;
85+
}
86+
87+
#vs:hover .vs-blackfriday-coin.right {
88+
transform: translateX(600px);
89+
transition: transform 30s linear;
90+
}
91+
92+
.vs-blackfriday-coin {
93+
display: inline-block;
94+
position: absolute;
95+
transition-property: transform;
96+
transition-timing-function: cubic-bezier(.17, .84, .44,1);
97+
transition-duration: 75ms;
98+
transform: translateX(0);
99+
}
100+
101+
.vs-blackfriday-coin.js {
102+
width: 43px;
103+
top: 32px;
104+
left: calc(50% - 341px);
105+
}
106+
107+
.vs-blackfriday-coin.ts {
108+
top: 0;
109+
left: 0;
110+
width: 54px;
111+
left: calc(50% + 457px);
112+
}
113+
114+
.vs-blackfriday-coin.vue {
115+
top: 18px;
116+
width: 60px;
117+
left: calc(50% + 586px);
118+
}
119+
120+
.vs-blackfriday-coin.vuex {
121+
top: 23px;
122+
left: 0;
123+
width: 56px;
124+
left: calc(50% - 620px);
125+
}
126+
127+
.vs-blackfriday-coin.nuxt {
128+
top: 10px;
129+
width: 48px;
130+
left: calc(50% - 474px);
131+
}
132+
}
133+
</style>

docs/.vitepress/components/BannerTop.vue renamed to docs/.vitepress/components/VueSchool/BannerTop.vue

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
target="_blank"
66
rel="noreferrer"
77
>
8+
<BannerCoins />
89
<div class="vs-core">
910
<div class="vs-logo">
1011
<img src="/images/vueschool/vueschool_blackfriday_logo.svg">
@@ -27,6 +28,16 @@
2728
</a>
2829
</template>
2930

31+
<script>
32+
import BannerCoins from './BannerCoins.vue'
33+
34+
export default {
35+
components: {
36+
BannerCoins
37+
}
38+
}
39+
</script>
40+
3041
<style>
3142
@import url('https://fonts.googleapis.com/css2?family=Archivo:wght@400;600&display=swap');
3243
@@ -54,12 +65,6 @@
5465
#vs {
5566
height: 5rem;
5667
justify-content: center;
57-
background-image: url("/images/vueschool/vueschool_blackfriday_background_tablet.svg");
58-
}
59-
}
60-
@media (min-width: 900px) {
61-
#vs {
62-
background-image: url("/images/vueschool/vueschool_blackfriday_background_desktop.svg");
6368
}
6469
}
6570
#vs:hover .vs-core .vs-button {

docs/.vitepress/theme/Layout.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ import { defineAsyncComponent } from 'vue'
4848
import DefaultTheme from 'vitepress/dist/client/theme-default'
4949
import sponsors from '../components/sponsors.json'
5050
51-
const BannerTop = defineAsyncComponent(() => import('../components/BannerTop.vue'))
51+
const BannerTop = defineAsyncComponent(() => import('../components/VueSchool/BannerTop.vue'))
5252
5353
export default {
5454
name: 'Layout',
4.44 KB
Loading
5.29 KB
Loading
3.4 KB
Loading
4.28 KB
Loading
3.63 KB
Loading

docs/public/images/vueschool/vueschool_blackfriday_background_desktop.svg

Lines changed: 0 additions & 200 deletions
This file was deleted.

0 commit comments

Comments
 (0)