feat: a bit of the search bar and improvements to the menu

This commit is contained in:
Filipe Medeiros 2021-10-10 20:52:13 +01:00
parent 328ecd43b6
commit dd6bb30532
7 changed files with 75 additions and 24 deletions

View File

@ -8,7 +8,7 @@
<main <main
class="uk-container uk-container-expand" class="uk-container uk-container-expand"
style="height: 100vh; overflow: scroll;" style="height: 100vh; overflow: scroll;"
:style="[{ background: backgroundColor, colour: foregroundColor }]" :style="{ background: backgroundColor, colour: foregroundColor, marginTop: isMobile ? '70px' : 0 }"
:class="{ 'uk-light': darkMode }" :class="{ 'uk-light': darkMode }"
> >
<router-view v-slot="{ Component }"> <router-view v-slot="{ Component }">
@ -33,10 +33,17 @@
<script> <script>
import Menu from "@/components/Menu"; import Menu from "@/components/Menu";
import { useIsMobile } from "./store";
export default { export default {
components: { components: {
Menu, Menu,
}, },
setup() {
const isMobile = useIsMobile();
return { isMobile };
},
data() { data() {
return { menuCollapsed: false }; return { menuCollapsed: false };
}, },
@ -85,7 +92,7 @@ export default {
}; };
</script> </script>
<style lang="scss"> <style>
h1, h1,
p, p,
a, a,

View File

@ -1,28 +1,26 @@
<template> <template>
<MenuDesktop v-if="!isMobile" /> <MenuDesktop :collapsed="collapsed" :toggleCollapsed="toggleCollapsed" v-if="!isMobile" />
<MenuMobile v-else /> <MenuMobile :collapsed="collapsed" :toggleCollapsed="toggleCollapsed" v-else />
</template> </template>
<script> <script>
import MenuDesktop from "./MenuDesktop.vue"; import MenuDesktop from "./MenuDesktop.vue";
import MenuMobile from "./MenuMobile.vue"; import MenuMobile from "./MenuMobile.vue";
import { useIsMobile } from "../store";
export default { export default {
components: { components: {
MenuDesktop, MenuDesktop,
MenuMobile, MenuMobile,
}, },
data() { props: {
return { isMobile: false }; collapsed: Boolean,
}, toggleCollapse: Function,
mounted() {
this.updateMenu();
window.addEventListener("resize", this.updateMenu);
},
methods: {
updateMenu() {
this.isMobile = window.matchMedia("screen and (max-width: 800px)").matches;
}, },
setup() {
const isMobile = useIsMobile();
return { isMobile };
}, },
}; };
</script> </script>

View File

@ -17,7 +17,7 @@
<div <div
class="uk-flex uk-flex-middle" class="uk-flex uk-flex-middle"
style="gap: 16px; transition: transform 300ms, gap 300ms;" style="gap: 16px; transition: transform 300ms, gap 300ms;"
:style="collapseText ? 'transform: scale(0); gap: 0;' : 'transition-delay: 150ms'" :style="collapseText ? 'transform: scale(0); gap: 0;' : 'transition-delay: 170ms'"
v-if="!hideText" v-if="!hideText"
> >
<img src="/img/pipedPlay.svg" :class="{ 'piped-play': !hideText }" /> <img src="/img/pipedPlay.svg" :class="{ 'piped-play': !hideText }" />
@ -147,7 +147,8 @@ export default {
} }
.piped-play { .piped-play {
animation: bump 300ms ease-in-out 600ms; animation: bump 300ms ease-in-out;
animation-delay: 700ms !important;
} }
@media (prefers-reduced-motion) { @media (prefers-reduced-motion) {
.piped-play { .piped-play {
@ -191,6 +192,6 @@ export default {
color: #fff; color: #fff;
} }
.router-link-active { .router-link-active {
background: linear-gradient(#da22ff, #9733ee); background: linear-gradient(to right, #da22ff, #9733ee);
} }
</style> </style>

View File

@ -1,12 +1,15 @@
<template> <template>
<div <div
class="uk-flex uk-flex-column uk-flex-middle uk-position-fixed uk-position-top" class="uk-flex uk-flex-column uk-flex-middle uk-position-fixed uk-position-top"
:class="{ 'uk-height-viewport': collapsed }" :class="{ 'uk-height-viewport': !collapsed }"
style="padding: 24px 12px; width: 100vw; box-sizing: border-box; z-index: 9999; transition: min-height 40ms, height 400ms; overflow: hidden;" style="padding: 24px 12px; width: 100vw; box-sizing: border-box; z-index: 9999; transition: min-height 40ms, height 400ms; overflow: hidden;"
:style="{ backgroundColor: secondaryBackgroundColor, minHeight: 0, height: collapsed ? '70px' : '100vh' }" :style="{ backgroundColor: secondaryBackgroundColor, minHeight: 0, height: !collapsed ? '70px' : '100vh' }"
> >
<div class="uk-width-1-1 uk-flex uk-flex-middle" style="margin-bottom: 100px; padding: 0 14px; gap: 32px;"> <div class="uk-width-1-1 uk-flex uk-flex-middle" style="margin-bottom: 100px; padding: 0 14px; gap: 32px;">
<div style="transition: padding 500ms;"> <div
style="transition: padding 500ms, transform 500ms;"
:style="collapsed ? 'transform: rotate(90deg)' : {}"
>
<font-awesome-icon class="button highlight" @click="toggleCollapsed()" icon="bars" /> <font-awesome-icon class="button highlight" @click="toggleCollapsed()" icon="bars" />
</div> </div>
<div class="uk-flex uk-flex-middle" style="gap: 12px;" v-if="!hideText"> <div class="uk-flex uk-flex-middle" style="gap: 12px;" v-if="!hideText">
@ -72,6 +75,12 @@ export default {
props: { props: {
collapsed: Boolean, collapsed: Boolean,
toggleCollapsed: Function, toggleCollapsed: Function,
searchText: String,
onKeyUp: Function,
onInputFocus: Function,
onInputBlur: Function,
onSearchTextChange: Function,
}, },
methods: { methods: {
logout() { logout() {
@ -158,6 +167,6 @@ export default {
color: #fff; color: #fff;
} }
.router-link-active { .router-link-active {
background: linear-gradient(#da22ff, #9733ee); background: linear-gradient(to right, #da22ff, #9733ee);
} }
</style> </style>

View File

@ -1,10 +1,22 @@
<template> <template>
<h1
v-if="isMobile"
v-t="'titles.trending'"
style="margin-bottom: 0; padding-top: 34px; font-weight: bold;"
class="uk-heading-small"
/>
<div class="uk-flex uk-flex-middle uk-flex-between uk-flex-row-reverse" style="padding: 34px 0"> <div class="uk-flex uk-flex-middle uk-flex-between uk-flex-row-reverse" style="padding: 34px 0">
<form class="uk-search"> <form
class="uk-search"
:style="{
width: isMobile ? '100%' : '35ch',
}"
>
<div class="uk-position-relative"> <div class="uk-position-relative">
<input <input
class="uk-search-input" class="uk-search-input"
style="border-radius: 9999px; padding: 12px 18px 12px 40px; width: 35ch;" style="border-radius: 9999px; padding: 12px 18px 12px 40px;"
:style="{ backgroundColor: secondaryBackgroundColor }" :style="{ backgroundColor: secondaryBackgroundColor }"
type="search" type="search"
:placeholder="$t('actions.search')" :placeholder="$t('actions.search')"
@ -18,6 +30,7 @@
</form> </form>
<div <div
v-if="!isMobile"
class="uk-flex uk-flex-middle" class="uk-flex uk-flex-middle"
style="gap: 16px; transition: transform 400ms; transform-origin: left;" style="gap: 16px; transition: transform 400ms; transform-origin: left;"
:style="!menuCollapsed ? 'transform: scale(0);' : {}" :style="!menuCollapsed ? 'transform: scale(0);' : {}"
@ -32,7 +45,7 @@
v-for="video in videos" v-for="video in videos"
:key="video.url" :key="video.url"
:style="[{ background: backgroundColor }]" :style="[{ background: backgroundColor }]"
class="uk-width-1-2 uk-width-1-3@s uk-width-1-4@m uk-width-1-5@l uk-width-1-6@xl" class="uk-width-1-1 uk-width-1-2@s uk-width-1-4@m uk-width-1-5@l uk-width-1-6@xl"
> >
<VideoItem :video="video" height="118" width="210" /> <VideoItem :video="video" height="118" width="210" />
</div> </div>
@ -42,6 +55,8 @@
<script> <script>
import VideoItem from "@/components/VideoItem.vue"; import VideoItem from "@/components/VideoItem.vue";
import { useIsMobile } from "../store";
export default { export default {
components: { components: {
VideoItem, VideoItem,
@ -49,6 +64,10 @@ export default {
props: { props: {
menuCollapsed: Boolean, menuCollapsed: Boolean,
}, },
setup() {
const isMobile = useIsMobile();
return { isMobile };
},
data() { data() {
return { return {
videos: [], videos: [],

View File

@ -232,6 +232,12 @@ const mixin = {
} }
return "en"; return "en";
}, },
data() {
return { isMobile: false };
},
isMobile() {
return window.matchMedia("screen and (max-width: 800px)").matches;
},
}, },
}; };

11
src/store.js Normal file
View File

@ -0,0 +1,11 @@
import { ref } from "vue";
const isMobile = ref(false);
export function useIsMobile() {
isMobile.value = window.matchMedia("screen and (max-width: 800px)").matches;
window.addEventListener("resize", () => {
isMobile.value = window.matchMedia("screen and (max-width: 800px)").matches;
});
return isMobile;
}