Skip to content
This repository has been archived by the owner on Mar 15, 2023. It is now read-only.

add desktop nav #2

Merged
merged 2 commits into from
Feb 4, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion .eslintrc
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
}
],
"object-shorthand": "warn",
"vue/html-self-closing": "warn"
"vue/html-self-closing": "warn",
"no-console": "warn"
}
}
86 changes: 42 additions & 44 deletions src/App.vue
Original file line number Diff line number Diff line change
@@ -1,58 +1,56 @@
<template>
<NavbarTop />
<div class="toolbarContainer">
<KeepAlive>
<Component
:is="activeVariant"
:options="options"
@navigate="navigate"
/>
</KeepAlive>
</div>
</template>

<script>
import NavbarTop from './components/NavbarTop.vue';
import { Breakpoints, navbarItems } from './constants';
import { windowWidthMixin } from './mixins';

//import swipe from "@/events/swipe";
import { ToolbarBack, ToolbarCalendar, ToolbarPlain } from './components';

export default {
components: { NavbarTop },
mixins: [windowWidthMixin],

data() {
return { show_appbar: false, navbarItems };
components: {
ToolbarBack,
ToolbarCalendar,
ToolbarPlain,
},

data: () => ({
layoutName: 'plain',
text: 'Твой физфак!',
}),
beforeMount() {
// вызов функции swipe с предварительными настройками
//swipe(document, { maxTime: 800, minTime: 200, maxDist: 150, minDist: 50 });
document.addEventListener('change-header-layout', e => {
this.layoutName = e.detail.layoutName;
this.options = e.detail;
});
},

methods: {
isMobile() {
return this.windowWidth < Breakpoints.SM;
},

resizeHandler(event) {
console.log(event.target);
this.windowWidth = event.target.innerWidth;
},

async captureNavigation(from, to) {
if (from === to) return;
try {
fetch(`${process.env.VUE_APP_API_MARKETING}/action`, {
method: 'POST',
cache: 'no-cache',
redirect: 'follow',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({
user_id: localStorage.getItem('marketing-id'),
action: 'route to',
path_from: from,
path_to: to,
}),
});
} catch {
//Failed, skips
computed: {
activeVariant() {
switch (this.layoutName) {
case 'calendar':
return ToolbarCalendar;
case 'back':
return ToolbarBack;
}
return ToolbarPlain;
},
},
};
</script>

<style></style>
<style scoped>
.toolbarContainer {
display: flex;
height: 100%;
align-items: center;
width: 100%;
gap: 10px;
padding: 10px 4%;
height: 56px;
background: var(--bs-primary);
}
</style>
35 changes: 35 additions & 0 deletions src/components/ButtonIcon.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
<template>
<button class="material-symbols-sharp">
{{ icon }}
</button>
</template>

<script>
export default {
props: {
icon: {
type: String,
required: true,
},
},
};
</script>

<style scoped>
button {
color: var(--bs-on-primary);
border-radius: 999px;
padding: 8px;
}

button:disabled {
opacity: 0.6;
}

button:hover {
background-color: rgba(255, 255, 255, 0.1);
}
button:active {
background-color: rgba(255, 255, 255, 0.2);
}
</style>
9 changes: 4 additions & 5 deletions src/components/DropdownMenu.vue
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
<template>
<OptionsButton
<ButtonIcon
icon="more_vert"
:disabled="disabled"
@click="showOptions = !showOptions"
/>
<div
v-if="showOptions"
v-show="showOptions"
v-click-outside="closeMenu"
class="dropdown-menu"
>
Expand All @@ -22,13 +22,13 @@

<script>
import vClickOutside from 'click-outside-vue3';
import OptionsButton from './OptionsButton';
import ButtonIcon from './ButtonIcon';

export default {
directives: {
clickOutside: vClickOutside.directive,
},
components: { OptionsButton },
components: { ButtonIcon },
props: {
menu: { type: Array, default: () => [] },
disabled: Boolean,
Expand All @@ -38,7 +38,6 @@ export default {
}),
methods: {
openMenu() {
console.log(this.menu);
this.showOptions = !this.showOptions;
},
closeMenu() {
Expand Down
58 changes: 0 additions & 58 deletions src/components/NavbarTop.vue

This file was deleted.

50 changes: 0 additions & 50 deletions src/components/NavbarTopBack.vue

This file was deleted.

38 changes: 0 additions & 38 deletions src/components/NavbarTopPlain.vue

This file was deleted.

48 changes: 0 additions & 48 deletions src/components/OptionsButton.vue

This file was deleted.

Loading