Skip to content

Commit

Permalink
feat(global): create menu
Browse files Browse the repository at this point in the history
  • Loading branch information
pablosirera committed Jul 17, 2020
1 parent 6c28703 commit 75f7d76
Show file tree
Hide file tree
Showing 7 changed files with 128 additions and 18 deletions.
6 changes: 6 additions & 0 deletions assets/css/global.css
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,12 @@ html {
-webkit-font-smoothing: antialiased;
}

body::-webkit-scrollbar {
display: none;
-ms-overflow-style: none;
scrollbar-width: none;
}

* {
box-sizing: border-box;
}
Expand Down
95 changes: 95 additions & 0 deletions components/ui/Menu.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,95 @@
<template>
<div class="menu">
<span @click="toggleMenu">
<img
class="w-8 cursor-pointer"
src="/images/icons/menu.svg"
:alt="$t('general.openMenu')"
/>
</span>
<transition name="slide-fade">
<div
v-if="showMenu"
class="menu-body bg-primary h-screen w-full absolute top-0 left-0 z-10"
>
<span
class="close flex justify-end text-white p-3 font-bold text-2xl cursor-pointer"
@click="toggleMenu"
>
<img
class="w-6"
src="/images/icons/cross.svg"
:alt="$t('general.closeMenu')"
/>
</span>
<div class="menu-content">
<div class="text-center flex flex-col p-5">
<a
v-for="(link, index) in links"
:key="index"
class="link font-bold text-2xl text-blue-main-800 rounded p-4 cursor-pointer"
@click="navigateTo(link.url)"
>
{{ link.name }}
</a>
</div>
</div>
</div>
</transition>
</div>
</template>

<script>
import { NAV_LINKS } from '@/constants/navLinks'
export default {
name: 'Menu',
data: () => ({
showMenu: false,
}),
computed: {
links() {
return NAV_LINKS
},
},
methods: {
toggleMenu() {
this.showMenu = !this.showMenu
},
navigateTo(url) {
this.toggleMenu()
this.$router.push(url)
},
},
}
</script>

<style lang="scss" scoped>
$heightClose: 60px;
.close {
height: $heightClose;
}
.menu-content {
height: calc(100% - 120px);
@apply flex justify-center items-center;
.link:hover {
background: rgba(0, 0, 0, 0.2);
}
}
.slide-fade-enter-active {
transition: all 0.3s ease;
}
.slide-fade-leave-active {
transition: all 0.3s cubic-bezier(1, 0.5, 0.8, 1);
}
.slide-fade-enter,
.slide-fade-leave-to {
transform: translateX(10px);
opacity: 0;
}
</style>
25 changes: 8 additions & 17 deletions components/ui/TheHeader.vue
Original file line number Diff line number Diff line change
Expand Up @@ -23,38 +23,29 @@
</nuxt-link>
</li>
</ul>
<Menu class="block sm:hidden" />
</div>
</header>
</template>

<script>
import { NAV_LINKS } from '@/constants/navLinks'
import Logo from '~/components/Logo'
export default {
name: 'TheHeader',
components: {
Logo,
},
data: () => ({
links: [
{
url: '/blog',
name: 'Blog',
},
{
url: '/projects',
name: 'Projects',
},
{
url: '/about',
name: 'About',
},
],
}),
computed: {
links() {
return NAV_LINKS
},
},
}
</script>

<style scoped>
<style lang="scss" scoped>
.links:last-child {
border: 0;
}
Expand Down
14 changes: 14 additions & 0 deletions constants/navLinks.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
export const NAV_LINKS = [
{
url: '/blog',
name: 'Blog',
},
{
url: '/projects',
name: 'Projects',
},
{
url: '/about',
name: 'About',
},
]
4 changes: 3 additions & 1 deletion locales/es.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
{
"general": {
"altLogo": "Pablo Sirera, desarrollador web frontend | Javascript, Vue y Nuxt"
"altLogo": "Pablo Sirera, desarrollador web frontend | Javascript, Vue y Nuxt",
"closeMenu": "Cerrar menú",
"openMenu": "Abrir menú"
},
"months": {
"april": "Abril",
Expand Down
1 change: 1 addition & 0 deletions static/images/icons/cross.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions static/images/icons/menu.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 75f7d76

Please sign in to comment.