import RecentlyModified from "./RecentlyModified";
import LoadingIndicator from "./LoadingIndicator";
import Login from "./Login";
+import NavBar from "./NavBar";
import api from "../api";
import * as constants from "../constants";
import * as helpers from "../helpers";
export default {
+ name: "App",
+
components: {
Viewer,
Editor,
RecentlyModified,
LoadingIndicator,
Login,
+ NavBar,
},
data: function() {
<template>
- <div class="container h-100">
- <!-- Header -->
- <div v-if="currentView != views.login" class="mt-4 mb-4">
- <a
- href="/"
- @click.prevent="navigate('/', $event)"
- class="h1 clickable-link text-center"
- ><img src="../assets/logo.svg"
- /></a>
- </div>
+ <div class="container d-flex flex-column align-items-center h-100">
+ <!-- Nav Bar -->
+ <NavBar
+ v-if="currentView != views.login"
+ class="mt-2 w-100"
+ :show-logo="currentView != views.home"
+ @navigate-home="navigate('/')"
+ @new-note="newNote()"
+ @logout="logout()"
+ ></NavBar>
<!-- Login -->
<Login v-if="currentView == views.login"></Login>
<!-- Buttons -->
<div class="d-flex justify-content-center mb-4">
- <!-- Logout -->
- <button
- v-if="currentView == views.home"
- type="button"
- class="btn btn-sm btn-outline-dark mx-1"
- @click="logout"
- >
- Logout
- </button>
-
- <!-- New -->
- <button
- v-if="currentView == views.home"
- type="button"
- class="btn btn-sm btn-outline-primary mx-1"
- @click="newNote"
- >
- New
- </button>
-
<!-- Edit -->
<button
v-if="
</button>
</div>
- <!-- Search Input -->
- <form
- v-if="[views.search, views.home].includes(currentView)"
+ <!-- Home -->
+ <div
+ v-if="currentView == views.home"
v-on:submit.prevent="search"
+ class="home-view d-flex flex-column justify-content-center align-items-center flex-grow-1 w-100"
>
- <div class="form-group mb-4 d-flex justify-content-center">
- <input
- type="text"
- class="form-control"
- placeholder="Search"
- v-model="searchTerm"
- style="max-width: 500px"
- autofocus
- />
+ <div class="mb-3">
+ <img src="../assets/logo.svg" />
</div>
- </form>
+ <form v-on:submit.prevent="search" class="w-100">
+ <div class="form-group mb-4 w-100">
+ <input
+ type="text"
+ class="form-control search-input"
+ placeholder="Search"
+ v-model="searchTerm"
+ autofocus
+ />
+ <!-- TODO: Search Button -->
+ </div>
+ </form>
+ <RecentlyModified />
+ </div>
<!-- Note -->
- <div v-if="currentView == views.note">
+ <div v-if="currentView == views.note" class="w-100">
<!-- Loading -->
<div v-if="currentNote == null">
<loading-indicator
</div>
<!-- Search -->
- <div v-if="currentView == views.search">
+ <div v-if="currentView == views.search" class="w-100">
+ <!-- Search Input -->
+ <form v-on:submit.prevent="search">
+ <div class="form-group mb-4 d-flex justify-content-center">
+ <input
+ type="text"
+ class="form-control"
+ placeholder="Search"
+ v-model="searchTerm"
+ style="max-width: 500px"
+ autofocus
+ />
+ </div>
+ </form>
+
<!-- Searching -->
<div v-if="searchResults == null">
<loading-indicator
</div>
</div>
</div>
-
- <!-- Home -->
- <RecentlyModified v-if="currentView == views.home" />
</div>
</template>
--- /dev/null
+<template>
+ <div class="d-flex justify-content-between align-items-center">
+ <!-- Logo -->
+ <div>
+ <img
+ src="../assets/logo.svg"
+ class="cursor-pointer"
+ :class="{ invisible: !showLogo }"
+ @click="navigateHome"
+ />
+ </div>
+ <div>
+ <!-- New Note -->
+ <button
+ type="button"
+ class="btn btn-sm btn-outline-primary mx-1"
+ @click="newNote"
+ >
+ New Note
+ </button>
+
+ <!-- Log Out -->
+ <button
+ type="button"
+ class="btn btn-sm btn-outline-dark mx-1"
+ @click="logout"
+ >
+ Log Out
+ </button>
+ </div>
+ </div>
+</template>
+
+<style lang="scss" scoped>
+// Use visibility hidden instead of v-show to maintain consistent height
+.invisible {
+ visibility: hidden;
+}
+</style>
+
+<script>
+export default {
+ props: {
+ showLogo: {
+ type: Boolean,
+ default: true,
+ },
+ },
+
+ methods: {
+ navigateHome: function () {
+ this.$emit("navigate-home");
+ },
+
+ newNote: function () {
+ this.$emit("new-note");
+ },
+
+ logout: function () {
+ this.$emit("logout");
+ },
+ },
+};
+</script>