Skip to content

Commit

Permalink
Simplify Inertia logout links (#48)
Browse files Browse the repository at this point in the history
Co-authored-by: Claudio Dekker <[email protected]>
  • Loading branch information
reinink and claudiodekker authored Feb 18, 2021
1 parent 804ffba commit a3fc09a
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 41 deletions.
18 changes: 3 additions & 15 deletions stubs/inertia/resources/js/Components/DropdownLink.vue
Original file line number Diff line number Diff line change
@@ -1,17 +1,5 @@
<template>
<div>
<button type="submit" class="block w-full px-4 py-2 text-sm leading-5 text-gray-700 text-left hover:bg-gray-100 focus:outline-none focus:bg-gray-100 transition duration-150 ease-in-out" v-if="as == 'button'">
<slot />
</button>

<inertia-link :href="href" class="block px-4 py-2 text-sm leading-5 text-gray-700 hover:bg-gray-100 focus:outline-none focus:bg-gray-100 transition duration-150 ease-in-out" v-else>
<slot />
</inertia-link>
</div>
<inertia-link class="block w-full px-4 py-2 text-left text-sm leading-5 text-gray-700 hover:bg-gray-100 focus:outline-none focus:bg-gray-100 transition duration-150 ease-in-out">
<slot />
</inertia-link>
</template>

<script>
export default {
props: ['href', 'as']
}
</script>
14 changes: 4 additions & 10 deletions stubs/inertia/resources/js/Components/ResponsiveNavLink.vue
Original file line number Diff line number Diff line change
@@ -1,18 +1,12 @@
<template>
<div>
<button :class="classes" class="w-full text-left" v-if="as == 'button'">
<slot />
</button>

<inertia-link :href="href" :class="classes" v-else>
<slot />
</inertia-link>
</div>
<inertia-link :class="classes">
<slot />
</inertia-link>
</template>

<script>
export default {
props: ['active', 'href', 'as'],
props: ['active'],
computed: {
classes() {
Expand Down
22 changes: 6 additions & 16 deletions stubs/inertia/resources/js/Layouts/Authenticated.vue
Original file line number Diff line number Diff line change
Expand Up @@ -38,11 +38,9 @@
</template>

<template #content>
<form @submit.prevent="logout">
<breeze-dropdown-link as="button">
Log Out
</breeze-dropdown-link>
</form>
<breeze-dropdown-link :href="route('logout')" method="post" as="button">
Log Out
</breeze-dropdown-link>
</template>
</breeze-dropdown>
</div>
Expand Down Expand Up @@ -76,11 +74,9 @@
</div>

<div class="mt-3 space-y-1">
<form method="POST" @submit.prevent="logout">
<breeze-responsive-nav-link as="button">
Log Out
</breeze-responsive-nav-link>
</form>
<breeze-responsive-nav-link :href="route('logout')" method="post" as="button">
Log Out
</breeze-responsive-nav-link>
</div>
</div>
</div>
Expand Down Expand Up @@ -122,11 +118,5 @@
showingNavigationDropdown: false,
}
},
methods: {
logout() {
this.$inertia.post(route('logout'));
},
}
}
</script>

0 comments on commit a3fc09a

Please sign in to comment.