Skip to content

Commit

Permalink
Merge pull request #235 from Perdolique/231-account-entry-point
Browse files Browse the repository at this point in the history
Account entry point and PerdMenu refactoring
  • Loading branch information
Perdolique authored Nov 21, 2024
2 parents 1549f4e + a1c2abe commit 6595e9a
Show file tree
Hide file tree
Showing 8 changed files with 93 additions and 41 deletions.
55 changes: 47 additions & 8 deletions app/components/PageHeader.vue
Original file line number Diff line number Diff line change
Expand Up @@ -10,19 +10,35 @@
/>
</button>

<PerdButton
<PerdMenu
v-if="isAuthenticated"
:class="$style.button"
@click="removeAuthSession"
small
:class="$style.profileMenu"
>
Log out
</PerdButton>
<template #trigger="{ toggleMenu, isMenuVisible }">
<button
:class="[$style.profileTrigger, { active: isMenuVisible }]"
@click="toggleMenu"
>
<Icon
name="tabler:user"
size="1.5em"
/>
</button>
</template>

<OptionButton
icon="tabler:logout"
@click="removeAuthSession"
>
Log out
</OptionButton>
</PerdMenu>
</nav>
</template>

<script lang="ts" setup>
import PerdButton from '~/components/PerdButton.vue';
import PerdMenu from '~/components/PerdMenu.vue';
import OptionButton from '~/components/PerdMenu/OptionButton.vue';
const { isAuthenticated, resetAuthentication } = useUserStore()
const { toggleSidebarMobile } = useAppState()
Expand Down Expand Up @@ -77,7 +93,30 @@
}
}
.button {
.profileMenu {
margin-left: auto;
}
.profileTrigger {
width: 40px;
height: 40px;
cursor: pointer;
padding: var(--spacing-8);
border-radius: var(--border-radius-12);
color: var(--text);
background-color: transparent;
outline: none;
transition: background-color var(--transition-time-quick);
&:focus-visible,
&:hover {
background-color: var(--background-200);
}
&:global(.active),
&:active {
background-color: var(--background-300);
}
}
</style>
23 changes: 5 additions & 18 deletions app/components/PerdMenu.vue
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,11 @@
ref="rootRef"
:class="$style.component"
>
<PerdButton
secondary
small
:icon="icon"
@click.passive="toggleMenu"
>
{{ text }}
</PerdButton>
<slot
name="trigger"
:toggle-menu="toggleMenu"
:is-menu-visible="isMenuVisible"
/>

<div
:class="[$style.menu, {
Expand All @@ -24,14 +21,6 @@

<script lang="ts" setup>
import { onClickOutside } from '@vueuse/core';
import PerdButton from './PerdButton.vue';
interface Props {
readonly icon: string;
readonly text: string;
}
defineProps<Props>()
const isMenuVisible = ref(false)
const rootRef = useTemplateRef('rootRef')
Expand All @@ -42,8 +31,6 @@
onClickOutside(rootRef, () => {
isMenuVisible.value = false
}, {
ignore: ['dialog']
});
</script>

Expand Down
1 change: 1 addition & 0 deletions app/components/PerdToast.vue
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@

<style module>
.component {
pointer-events: auto; /* Parent element has pointer-events: none */
position: relative;
max-width: 400px;
display: grid;
Expand Down
1 change: 1 addition & 0 deletions app/components/PerdToaster.vue
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@
<style module>
.component {
position: fixed;
pointer-events: none;
top: 0;
right: 0;
padding: var(--spacing-24);
Expand Down
4 changes: 2 additions & 2 deletions app/components/checklists/ChecklistItem.vue
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@
/>

<div :class="$style.name">
<temlplate v-if="checkMode">
<template v-if="checkMode">
{{ item.equipment.name }}
</temlplate>
</template>

<PerdLink
v-else
Expand Down
16 changes: 12 additions & 4 deletions app/pages/checklists/[checklistId].vue
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,18 @@
Reset
</PerdButton>

<PerdMenu
icon="tabler:settings"
text="Options"
>
<PerdMenu>
<template #trigger="{ toggleMenu }">
<PerdButton
small
secondary
icon="tabler:settings"
@click="toggleMenu"
>
Options
</PerdButton>
</template>

<OptionButton
icon="tabler:trash"
@click="showDeleteConfirmation"
Expand Down
18 changes: 13 additions & 5 deletions app/pages/equipment/item/[itemId]/index.vue
Original file line number Diff line number Diff line change
@@ -1,11 +1,18 @@
<template>
<PageContent :page-title="itemName">
<template #actions>
<PerdMenu
v-if="user.isAdmin"
icon="tabler:adjustments"
text="Manage"
>
<PerdMenu v-if="user.isAdmin">
<template #trigger="{ toggleMenu }">
<PerdButton
small
secondary
icon="tabler:adjustments"
@click="toggleMenu"
>
Manage
</PerdButton>
</template>

<OptionButton
icon="tabler:pencil"
@click="onEdit"
Expand Down Expand Up @@ -127,6 +134,7 @@
import OptionButton from '~/components/PerdMenu/OptionButton.vue';
import PerdTag from '~/components/PerdTag.vue';
import ConfirmationDialog from '~/components/dialogs/ConfirmationDialog.vue';
import PerdButton from '~/components/PerdButton.vue';
definePageMeta({
layout: 'page'
Expand Down
16 changes: 12 additions & 4 deletions app/pages/manager/equipment/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,18 @@
Add item
</PerdButton>

<PerdMenu
icon="tabler:link"
text="Manage"
>
<PerdMenu>
<template #trigger="{ toggleMenu }">
<PerdButton
small
secondary
icon="tabler:link"
@click="toggleMenu"
>
Manage
</PerdButton>
</template>

<OptionButton
icon="tabler:tag"
@click="handleTypesClick"
Expand Down

0 comments on commit 6595e9a

Please sign in to comment.