poi-plugin-quest-info-2 0.8.9 → 0.9.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (39) hide show
  1. package/.changeset/README.md +8 -0
  2. package/.changeset/config.json +11 -0
  3. package/CHANGELOG.md +20 -0
  4. package/README.md +3 -2
  5. package/build/kcQuestsData/DATA_VERSION +1 -1
  6. package/build/kcQuestsData/index.ts +1 -1
  7. package/build/kcQuestsData/quests-scn-new.json +1 -0
  8. package/build/kcQuestsData/quests-scn.json +57 -16
  9. package/build/kcanotifyGamedata/DATA_VERSION +1 -1
  10. package/build/kcanotifyGamedata/index.ts +1 -1
  11. package/build/prePostQuest.json +40 -5
  12. package/build/questCodeMap.json +6 -2
  13. package/i18n/en-US.json +8 -3
  14. package/i18n/index.ts +23 -4
  15. package/i18n/ja-JP.json +3 -3
  16. package/i18n/ko-KR.json +3 -2
  17. package/i18n/zh-CN.json +3 -3
  18. package/i18n/zh-TW.json +3 -3
  19. package/package.json +4 -2
  20. package/shims/globals.d.ts +6 -0
  21. package/src/Settings.tsx +67 -7
  22. package/src/Toolbar.tsx +53 -33
  23. package/src/__tests__/fixtures/firstLoginWithOneComplete.json +72 -0
  24. package/src/__tests__/fixtures/questList.json +338 -0
  25. package/src/__tests__/kcanotifyData.spec.ts +1 -1
  26. package/src/__tests__/kcwikiData.spec.ts +1 -1
  27. package/src/components/QuestCard/index.tsx +3 -3
  28. package/src/components/QuestCard/utils.tsx +3 -3
  29. package/src/patch.ts +3 -4
  30. package/src/poi/env.ts +4 -0
  31. package/src/poi/hooks.ts +55 -2
  32. package/src/poi/store.ts +25 -8
  33. package/src/poi/utils.ts +50 -0
  34. package/src/store/filterTags.ts +34 -13
  35. package/src/store/gameQuest.tsx +108 -5
  36. package/src/store/quest.ts +27 -83
  37. package/src/store/store.tsx +25 -19
  38. package/src/tags.tsx +83 -24
  39. package/tsconfig.json +1 -1
package/src/tags.tsx CHANGED
@@ -1,7 +1,7 @@
1
1
  import { Tag } from '@blueprintjs/core'
2
+ import { IconNames } from '@blueprintjs/icons'
2
3
  import React from 'react'
3
4
  import styled from 'styled-components'
4
- import { IN_POI } from './poi/env'
5
5
  import { useGameTab, usePluginTranslation } from './poi/hooks'
6
6
  import { GameQuest, QuestTab } from './poi/types'
7
7
  import type { UnionQuest } from './questHelper'
@@ -25,17 +25,14 @@ import {
25
25
  isYearlyQuest,
26
26
  newQuestNumber,
27
27
  } from './questHelper'
28
- import { useSyncWithGame } from './store'
29
- import { useFilterTags } from './store/filterTags'
30
- import { useGlobalGameQuest } from './store/gameQuest'
31
- import { yes } from './utils'
32
-
33
- export const ALL_CATEGORY_TAG = {
34
- name: 'All',
35
- filter: yes,
36
- } as const
37
-
38
- export const ALL_TYPE_TAG = ALL_CATEGORY_TAG
28
+ import {
29
+ ALL_CATEGORY_TAG,
30
+ ALL_TYPE_TAG,
31
+ PROGRESS_TAG,
32
+ useSyncWithGame,
33
+ } from './store'
34
+ import { useFilterProgressTag, useFilterTags } from './store/filterTags'
35
+ import { useGlobalGameQuest, useGlobalQuestStatusNum } from './store/gameQuest'
39
36
 
40
37
  const withDocQuest =
41
38
  <T,>(filterFn: (q: UnionQuest['docQuest']) => T) =>
@@ -78,9 +75,9 @@ export const TYPE_TAGS = [
78
75
  { name: 'Yearly', filter: isYearlyQuest },
79
76
  ] as const
80
77
 
81
- // TODO tag Lock / Completed
82
-
83
78
  const TagsWrapper = styled.div`
79
+ display: flex;
80
+ flex-wrap: wrap;
84
81
  margin-left: -4px;
85
82
  margin-right: -4px;
86
83
 
@@ -89,10 +86,61 @@ const TagsWrapper = styled.div`
89
86
  }
90
87
  `
91
88
 
92
- export const CategoryTags = () => {
89
+ export const ProgressTags = () => {
93
90
  const { t } = usePluginTranslation()
91
+ const { progressTag, toggleTag } = useFilterProgressTag()
92
+ const {
93
+ lockedQuestNum,
94
+ unlockedQuestNum,
95
+ completedQuestNum,
96
+ alreadyCompletedQuestNum,
97
+ } = useGlobalQuestStatusNum()
98
+ const completedQuestSuffix =
99
+ completedQuestNum > 0
100
+ ? `${alreadyCompletedQuestNum} + ${completedQuestNum}`
101
+ : alreadyCompletedQuestNum
102
+ return (
103
+ <>
104
+ <Tag
105
+ onClick={() => {
106
+ toggleTag(PROGRESS_TAG.Locked)
107
+ }}
108
+ intent={progressTag === PROGRESS_TAG.Locked ? 'success' : 'none'}
109
+ interactive={true}
110
+ >
111
+ {t('Locked', { number: lockedQuestNum })}
112
+ </Tag>
113
+ <Tag
114
+ icon={IconNames.EXCHANGE}
115
+ onClick={() => {
116
+ toggleTag(PROGRESS_TAG.Unlocked)
117
+ }}
118
+ intent={progressTag === PROGRESS_TAG.Unlocked ? 'success' : 'none'}
119
+ interactive={true}
120
+ >
121
+ {t('Unlocked', { number: unlockedQuestNum })}
122
+ </Tag>
123
+ <Tag
124
+ onClick={() => {
125
+ toggleTag(PROGRESS_TAG.AlreadyCompleted)
126
+ }}
127
+ intent={
128
+ progressTag === PROGRESS_TAG.AlreadyCompleted ? 'success' : 'none'
129
+ }
130
+ interactive={true}
131
+ >
132
+ {t('Already Completed', {
133
+ number: completedQuestSuffix,
134
+ })}
135
+ </Tag>
136
+ </>
137
+ )
138
+ }
94
139
 
140
+ export const CategoryTags = () => {
141
+ const { t } = usePluginTranslation()
95
142
  const { categoryTags, setCategoryTags } = useFilterTags()
143
+
96
144
  return (
97
145
  <TagsWrapper>
98
146
  {CATEGORY_TAGS.map(({ name }) => (
@@ -111,6 +159,8 @@ export const CategoryTags = () => {
111
159
  {t(name)}
112
160
  </Tag>
113
161
  ))}
162
+
163
+ <ProgressTags />
114
164
  </TagsWrapper>
115
165
  )
116
166
  }
@@ -120,6 +170,8 @@ export const TypeTags = () => {
120
170
  const gameTab = useGameTab()
121
171
  const { syncWithGame } = useSyncWithGame()
122
172
  const gameQuests = useGlobalGameQuest()
173
+ const { progressTag } = useFilterProgressTag()
174
+
123
175
  const inProgressQuest = gameQuests.filter((gameQuest) =>
124
176
  isInProgressQuest(gameQuest)
125
177
  )
@@ -136,15 +188,22 @@ export const TypeTags = () => {
136
188
  >
137
189
  {t('All')}
138
190
  </Tag>
139
- {IN_POI && (
140
- <Tag
141
- intent={typeTags['In Progress'] ? 'primary' : 'none'}
142
- interactive={true}
143
- onClick={() => setTypeTags('In Progress')}
144
- >
145
- {t('In Progress', { number: inProgressQuest.length })}
146
- </Tag>
147
- )}
191
+
192
+ <Tag
193
+ intent={
194
+ typeTags['In Progress']
195
+ ? progressTag === PROGRESS_TAG.AlreadyCompleted ||
196
+ progressTag === PROGRESS_TAG.Locked
197
+ ? 'warning'
198
+ : 'primary'
199
+ : 'none'
200
+ }
201
+ interactive={true}
202
+ onClick={() => setTypeTags('In Progress')}
203
+ >
204
+ {t('In Progress', { number: inProgressQuest.length })}
205
+ </Tag>
206
+
148
207
  {hasNewQuest && (
149
208
  <Tag
150
209
  intent={typeTags['New'] ? 'primary' : 'none'}
package/tsconfig.json CHANGED
@@ -13,7 +13,7 @@
13
13
  ] /* Specify library files to be included in the compilation. */,
14
14
  // "allowJs": true, /* Allow javascript files to be compiled. */
15
15
  // "checkJs": true, /* Report errors in .js files. */
16
- "jsx": "preserve", /* Specify JSX code generation: 'preserve', 'react-native', or 'react'. */
16
+ "jsx": "react", /* Specify JSX code generation: 'preserve', 'react-native', or 'react'. */
17
17
  // "declaration": true, /* Generates corresponding '.d.ts' file. */
18
18
  // "declarationMap": true, /* Generates a sourcemap for each corresponding '.d.ts' file. */
19
19
  // "sourceMap": true, /* Generates corresponding '.map' file. */