-
-
Notifications
You must be signed in to change notification settings - Fork 45
Expand file tree
/
Copy pathtutorials.ts
More file actions
30 lines (25 loc) · 735 Bytes
/
tutorials.ts
File metadata and controls
30 lines (25 loc) · 735 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
import { defineStore } from 'pinia'
export const useTutorials = defineStore('tutorials', {
state: () => ({
openTutorials: [] as string[]
}),
getters: {
isTutorialOpen: (state) => {
return (tutorialId: string) => state.openTutorials.indexOf(tutorialId) === 0
},
currentTutorial: state => state.openTutorials[0] ?? null
},
actions: {
openTutorial (tutorialId: string) {
if (!this.openTutorials.includes(tutorialId)) {
this.openTutorials.push(tutorialId)
}
},
closeTutorial (tutorialId: string) {
const tutorialIndex = this.openTutorials.indexOf(tutorialId)
if (tutorialIndex >= 0) {
this.openTutorials.splice(tutorialIndex, 1)
}
}
}
})