Skip to content

Commit 5ecb737

Browse files
author
Alexander Classen
committed
Using the store to handle navigation with siblings, add styles, icons and font
1 parent 5ee77ca commit 5ecb737

18 files changed

+226
-59
lines changed

assets/css/styles.css

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
@layer base {
2+
@font-face {
3+
font-family: ITC Avant Garde Gothic;
4+
font-weight: 400;
5+
src: url(/fonts/itc-avant-garde-gothic-medium.otf) format('woff');
6+
}
7+
@font-face {
8+
font-family: ITC Avant Garde Gothic;
9+
font-weight: 600;
10+
src: url(/fonts/itc-avant-garde-gothic-std-bold.otf) format('woff');
11+
}
12+
}
13+
14+
@layer base {
15+
* {
16+
@apply text-white;
17+
font-size: 20px;
18+
}
19+
h1 {
20+
@apply font-bold;
21+
@apply text-6xl;
22+
}
23+
h2 {
24+
@apply font-bold;
25+
@apply text-6xl;
26+
}
27+
h3 {
28+
@apply font-bold;
29+
@apply text-5xl;
30+
}
31+
32+
ul li {
33+
@apply list-outside;
34+
@apply list-disc;
35+
}
36+
}

assets/icons/arrow.svg

Lines changed: 13 additions & 0 deletions
Loading

assets/icons/westwerk-bildmarke.svg

Lines changed: 1 addition & 0 deletions
Loading

components/arrow.vue

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,14 @@
11
<template>
2-
<div class="arrow" @click="$emit(`slide-${direction}`)">
3-
<span class="icon text-6xl cursor-pointer">{{ icon }}</span>
2+
<div
3+
class="arrow cursor-pointer w-8 h-8"
4+
@click="$emit(`slide-${direction}`)"
5+
>
6+
<img
7+
class="icon"
8+
:class="direction"
9+
src="@/assets/icons/arrow.svg"
10+
alt="Logo"
11+
/>
412
</div>
513
</template>
614

@@ -22,3 +30,8 @@ export default {
2230
},
2331
}
2432
</script>
33+
<style scoped>
34+
.icon.right {
35+
transform: rotate(180deg);
36+
}
37+
</style>

components/progress-bar.vue

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
<template>
2+
<div class="progress-bar fixed top-0 w-full">
3+
<div class="bar h-1 bg-green" :style="styleObj"></div>
4+
</div>
5+
</template>
6+
7+
<script>
8+
export default {
9+
computed: {
10+
width() {
11+
return (100 / this.$store.state.slides.length) * this.$route.params.slide
12+
},
13+
styleObj() {
14+
return { width: this.width + '%' }
15+
},
16+
},
17+
}
18+
</script>
19+
<style scoped>
20+
.progress-bar .bar {
21+
transition: width 300ms ease-in-out;
22+
}
23+
</style>

components/slide-navigation.vue

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,14 @@
11
<template>
22
<div class="slide-navigation">
33
<div class="arrwos flex">
4-
<nuxt-link v-if="navigationItems[0]" :to="navigationItems[0].slug">
4+
<nuxt-link
5+
v-if="navigationItems[0]"
6+
:to="`${navigationItems[0]}`"
7+
class="mx-2"
8+
>
59
<arrow :direction="'left'" @slide-left="$emit('slide-left')" />
610
</nuxt-link>
7-
<nuxt-link v-if="navigationItems[1]" :to="navigationItems[1].slug">
11+
<nuxt-link v-if="navigationItems[1]" :to="`${navigationItems[1]}`">
812
<arrow :direction="'right'" @slide-right="$emit('slide-right')" />
913
</nuxt-link>
1014
</div>
@@ -16,7 +20,7 @@ export default {
1620
props: {
1721
navigationItems: {
1822
default() {
19-
return [{}, {}]
23+
return []
2024
},
2125
validator(value) {
2226
return value.length === 2

content/slides/slide-1.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
title: Welcome to my Presentation
33
---
44

5-
Hello all! This is my presentation about NUXTJS.
5+
Hello all! This is my presentation about Nuxt.js.
66

77
# Hello audience!
8+
## Audience: Hello Back!

layouts/default.vue

Lines changed: 72 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,80 @@
11
<template>
2-
<main>
2+
<main class="bg-black">
3+
<progress-bar />
34
<div
45
class="container mx-auto flex justify-center items-center min-h-screen"
56
>
67
<nuxt />
78
</div>
9+
<slide-navigation
10+
v-if="siblings.length"
11+
class="fixed bottom-0 right-0 mr-3"
12+
:navigation-items="[prev, next]"
13+
@slide-left="slideLeft"
14+
@slide-right="slideRight"
15+
/>
16+
<img
17+
class="fixed logo bottom-0"
18+
src="@/assets/icons/westwerk-bildmarke.svg"
19+
alt="Logo"
20+
/>
821
</main>
922
</template>
23+
<script>
24+
export default {
25+
computed: {
26+
siblings() {
27+
return this.$store.state.siblings
28+
},
29+
slides() {
30+
return this.$store.state.slides
31+
},
32+
33+
next() {
34+
return (
35+
this.slides.findIndex((item) => item.slug === this.siblings[1]?.slug) +
36+
1
37+
)
38+
},
39+
prev() {
40+
return (
41+
this.slides.findIndex((item) => item.slug === this.siblings[0]?.slug) +
42+
1
43+
)
44+
},
45+
},
46+
mounted() {
47+
window.addEventListener('keyup', this.keyup)
48+
},
49+
beforeDestroy() {
50+
window.removeEventListener('keyup', this.keyup)
51+
},
52+
methods: {
53+
keyup({ key }) {
54+
if (key === 'ArrowLeft') this.slideLeft()
55+
if (key === 'ArrowRight') this.slideRight()
56+
if (key === 'ArrowRown') this.slideDown()
57+
if (key === 'ArrowUP') this.slideUp()
58+
},
59+
slideRight() {
60+
if (this.siblings[1]) {
61+
this.$router.push({
62+
params: { slide: this.next },
63+
})
64+
}
65+
},
66+
slideLeft() {
67+
if (this.siblings[0]) {
68+
this.$router.push({
69+
params: { slide: this.prev },
70+
})
71+
}
72+
},
73+
},
74+
}
75+
</script>
76+
<style>
77+
.logo {
78+
transform: translate(-25%, 40%);
79+
}
80+
</style>

nuxt.config.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ export default {
1818
},
1919

2020
// Global CSS (https://go.nuxtjs.dev/config-css)
21-
css: [],
21+
css: ['@/assets/css/styles.css'],
2222

2323
// Plugins to run before rendering page (https://go.nuxtjs.dev/config-plugins)
2424
plugins: [],

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
},
1818
"husky": {
1919
"hooks": {
20-
"pre-commit": "lint-staged"
20+
"pre-commit": "npm run lint"
2121
}
2222
},
2323
"dependencies": {

0 commit comments

Comments
 (0)