-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #2 from krazkidd:pinia
Encapsulate app state in a Pinia store
- Loading branch information
Showing
11 changed files
with
329 additions
and
190 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,34 +1,17 @@ | ||
<script setup lang="ts"> | ||
const props = defineProps<{ | ||
isLocked: boolean | ||
}>(); | ||
import { useAppSettingsStore } from '~~/stores/AppSettings' | ||
const emit = defineEmits<{ | ||
(e: "lock"): void; | ||
(e: "unlock"): void; | ||
}>(); | ||
const isLocked = ref(props.isLocked); | ||
function handleClick(): void { | ||
isLocked.value = !isLocked.value; | ||
if (isLocked.value) { | ||
emit('lock'); | ||
} else { | ||
emit('unlock'); | ||
} | ||
} | ||
const appSettingsStore = useAppSettingsStore(); | ||
</script> | ||
|
||
<template> | ||
<Button | ||
@click="handleClick" | ||
:icon="`pi pi-${ isLocked ? 'lock' : 'lock-open' }`" | ||
:severity="`${ isLocked ? 'secondary' : 'warning' }`" | ||
@click="appSettingsStore.setIsLocked(!appSettingsStore.getIsLocked)" | ||
:icon="`pi pi-${ appSettingsStore.getIsLocked ? 'lock' : 'lock-open' }`" | ||
:severity="`${ appSettingsStore.getIsLocked ? 'secondary' : 'warning' }`" | ||
text | ||
rounded | ||
:aria-label="`${ isLocked ? 'Unlock lineup' : 'Lock lineup' }`" | ||
:title="`${ isLocked ? 'Unlock lineup' : 'Lock lineup' }`" | ||
:aria-label="`${ appSettingsStore.getIsLocked ? 'Unlock lineup' : 'Lock lineup' }`" | ||
:title="`${ appSettingsStore.getIsLocked ? 'Unlock lineup' : 'Lock lineup' }`" | ||
/> | ||
</template> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.