-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Swap siteNotification to use a pinia store, and make the z-index bigg…
…er. (Fixes #151)
- Loading branch information
1 parent
a751671
commit 476ad97
Showing
3 changed files
with
60 additions
and
16 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,56 @@ | ||
import { ref } from 'vue'; | ||
import { defineStore } from 'pinia'; | ||
|
||
// eslint-disable-next-line import/prefer-default-export | ||
export const siteNotificationStore = ref({ | ||
const initialSiteNotificationObject = { | ||
// Ensure we don't need to set the same notification twice | ||
id: null, | ||
// Details | ||
display: false, | ||
title: '', | ||
message: '', | ||
actionUrl: '', | ||
}; | ||
|
||
// eslint-disable-next-line import/prefer-default-export | ||
export const useSiteNotificationStore = defineStore('siteNotification', { | ||
state: () => ({ | ||
data: initialSiteNotificationObject, | ||
}), | ||
getters: { | ||
isVisible() { | ||
return this.data.display; | ||
}, | ||
title() { | ||
return this.data.title; | ||
}, | ||
actionUrl() { | ||
return this.data.actionUrl; | ||
}, | ||
message() { | ||
return this.data.message; | ||
}, | ||
}, | ||
actions: { | ||
isSameNotification(id) { | ||
return this.data.id === id; | ||
}, | ||
lock(id) { | ||
this.$patch({ | ||
data: { id }, | ||
}); | ||
}, | ||
show(id, title, message, actionUrl) { | ||
this.$patch({ | ||
data: { | ||
id, | ||
display: true, | ||
title, | ||
message, | ||
actionUrl, | ||
}, | ||
}); | ||
}, | ||
reset() { | ||
this.$patch({ data: initialSiteNotificationObject }); | ||
}, | ||
}, | ||
}); |