-
Notifications
You must be signed in to change notification settings - Fork 2
Exercise8 #10
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: exercise7
Are you sure you want to change the base?
Exercise8 #10
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,37 @@ | ||
| <template> | ||
| <a | ||
| :href="href" | ||
| class="inline-flex m-1.5 px-2.5 py-2 rounded-lg shadow-md text-white text-center | ||
| cursor-pointer justify-center items-center" | ||
| :class="(!disabled ? `bg-${color}-500 hover:bg-${color}-600` : `bg-gray-500`) + (bold ? ' font-semibold' : '')"> | ||
| <slot></slot> | ||
| </a> | ||
| </template> | ||
|
|
||
| <script> | ||
| export default { | ||
| name: 'BasicButton', | ||
| props: { | ||
| color: { | ||
| type: String, | ||
| default: 'blue' | ||
| }, | ||
| bold: { | ||
| type: Boolean, | ||
| default: false | ||
| }, | ||
| href: { | ||
| type: String, | ||
| default: undefined | ||
| }, | ||
| disabled: { | ||
| type: Boolean, | ||
| default: false | ||
| } | ||
| } | ||
| } | ||
| </script> | ||
|
|
||
| <style scoped> | ||
|
|
||
| </style> | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,15 @@ | ||
| <template> | ||
| <footer class="flex justify-center py-4"> | ||
| <span>(c) 2021 Dojo</span> | ||
| </footer> | ||
| </template> | ||
|
|
||
| <script> | ||
| export default { | ||
| name: "BasicFooter" | ||
| } | ||
| </script> | ||
|
|
||
| <style scoped> | ||
|
|
||
| </style> |
This file was deleted.
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
| @@ -0,0 +1,58 @@ | ||||||
| <template> | ||||||
| <div class="h-12"> | ||||||
| <nav | ||||||
| class="flex fixed w-full items-center justify-between lg:justify-around px-3 bg-blue-50 shadow-lg z-10" | ||||||
| > | ||||||
| <section> | ||||||
| <BasicButton class="lg:hidden" :bold="true" :color="'gray'" @click.native="sidebarOpen = true">≡ Menu | ||||||
| </BasicButton> | ||||||
| DojoNews | ||||||
| </section> | ||||||
| <section class="hidden lg:block lg:flex lg:justify-between lg:bg-transparent"> | ||||||
| <NavMenu :is-authenticated="isAuthenticated" @logout="logout()"></NavMenu> | ||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
| </section> | ||||||
| </nav> | ||||||
| <div | ||||||
| class="absolute z-20 w-full h-full bg-gray-50 opacity-50" | ||||||
| :class="sidebarOpen ? '' : 'hidden'" | ||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
| @click="sidebarOpen = false" | ||||||
| > | ||||||
| </div> | ||||||
| <aside | ||||||
| class="fixed z-30 w-1/2 sm:w-1/3 px-3 h-full bg-white shadow-xl transition-all duration-500 flex flex-col" | ||||||
| :class="sidebarOpen ? 'left-0' : '-left-1/2 md:-left-1/3'" | ||||||
| > | ||||||
| <button class="self-end" @click="sidebarOpen = false">[x]</button> | ||||||
| <NavMenu :vertical="true" :is-authenticated="isAuthenticated" @logout="logout(); sidebarOpen = false" | ||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Please use a dedicated method when you have to split commands with |
||||||
| @navigated="sidebarOpen = false"></NavMenu> | ||||||
| </aside> | ||||||
| </div> | ||||||
| </template> | ||||||
|
|
||||||
| <script> | ||||||
| import {mapGetters, mapMutations} from 'vuex' | ||||||
|
|
||||||
| export default { | ||||||
| computed: { | ||||||
| ...mapGetters({ | ||||||
| isAuthenticated: 'auth/isAuthenticated', | ||||||
| userId: 'auth/userId' | ||||||
| }) | ||||||
| }, | ||||||
| data() { | ||||||
| return { | ||||||
| sidebarOpen: false | ||||||
| } | ||||||
| }, | ||||||
| methods: { | ||||||
| async logout() { | ||||||
| this.unsetToken() | ||||||
| await this.$apolloHelpers.onLogout() | ||||||
| await this.$nuxt.refresh() | ||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Components should be reactive. Refetching data manually shouldn't be necessary.
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It shouldn't, but somehow the tests fail otherwise 🤷♂️ |
||||||
| }, | ||||||
| ...mapMutations({ | ||||||
| unsetToken: 'auth/unsetToken' | ||||||
| }) | ||||||
| } | ||||||
| } | ||||||
| </script> | ||||||
| Original file line number | Diff line number | Diff line change | ||||||
|---|---|---|---|---|---|---|---|---|
| @@ -0,0 +1,29 @@ | ||||||||
| <template> | ||||||||
| <div class="flex" :class="vertical ? 'justify-start flex-col' : 'justify-between flex-row'"> | ||||||||
| <NuxtLinkButton @click="$emit('navigated')" to="/" color="gray" href="/">Posts</NuxtLinkButton> | ||||||||
| <NuxtLinkButton @click="$emit('navigated')" to="/about" color="gray" href="/about">About us</NuxtLinkButton> | ||||||||
| <NuxtLinkButton @click="$emit('navigated')" v-if="!isAuthenticated" :to="{name: 'login', params: {returnPath: '/'}}" | ||||||||
| color="green" href="/login" id="login-button"> | ||||||||
| Login | ||||||||
| </NuxtLinkButton> | ||||||||
| <BasicButton v-else :color="'red'" @click.native="$emit('logout')" id="logout-button">Logout</BasicButton> | ||||||||
| </div> | ||||||||
| </template> | ||||||||
| <script> | ||||||||
| export default { | ||||||||
| name: "NavMenu", | ||||||||
| props: { | ||||||||
| isAuthenticated: { | ||||||||
| type: Boolean, | ||||||||
| }, | ||||||||
| vertical: { | ||||||||
| type: Boolean, | ||||||||
| default: false | ||||||||
| } | ||||||||
| } | ||||||||
| } | ||||||||
| </script> | ||||||||
|
|
||||||||
| <style scoped> | ||||||||
|
|
||||||||
| </style> | ||||||||
|
Comment on lines
+27
to
+29
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,30 @@ | ||
| <template> | ||
| <nuxt-link @click.native="$emit('click')" :to="this.to" tag="div" class="flex"> | ||
| <BasicButton :color="this.color" class="flex-grow" :href="this.href"> | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is |
||
| <slot></slot> | ||
| </BasicButton> | ||
| </nuxt-link> | ||
| </template> | ||
|
|
||
| <script> | ||
| import Vue from 'vue' | ||
|
|
||
| export default Vue.component("NuxtLinkButton", { | ||
| props: { | ||
| to: { | ||
| required: true | ||
| }, | ||
| color: { | ||
| type: String, | ||
| default: 'blue' | ||
| }, | ||
| href: { | ||
| type: String, | ||
| } | ||
| } | ||
| }) | ||
| </script> | ||
|
|
||
| <style scoped> | ||
|
|
||
| </style> | ||
This file was deleted.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
PurgeCSS will not be able to pick up the class names here. Don't use string interpolation like that in tailwind, instead, enumerate the classes.