@rpg-engine/long-bow 0.3.97 → 0.3.98

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 (179) hide show
  1. package/LICENSE +20 -20
  2. package/README.md +181 -181
  3. package/dist/components/Spellbook/Spell.d.ts +4 -4
  4. package/dist/components/Spellbook/Spellbook.d.ts +2 -2
  5. package/dist/components/Spellbook/cards/MobileSpellTooltip.d.ts +15 -0
  6. package/dist/components/Spellbook/cards/SpellInfo.d.ts +7 -0
  7. package/dist/components/Spellbook/cards/SpellInfoDisplay.d.ts +7 -0
  8. package/dist/components/Spellbook/cards/SpellInfoWrapper.d.ts +9 -0
  9. package/dist/components/Spellbook/cards/SpellTooltip.d.ts +6 -0
  10. package/dist/components/Spellbook/mockSpells.d.ts +2 -2
  11. package/dist/libs/CastingTypeHelper.d.ts +1 -0
  12. package/dist/long-bow.cjs.development.js +1438 -1229
  13. package/dist/long-bow.cjs.development.js.map +1 -1
  14. package/dist/long-bow.cjs.production.min.js +1 -1
  15. package/dist/long-bow.cjs.production.min.js.map +1 -1
  16. package/dist/long-bow.esm.js +1439 -1230
  17. package/dist/long-bow.esm.js.map +1 -1
  18. package/dist/stories/SpellInfoDisplay.stories.d.ts +8 -0
  19. package/package.json +100 -100
  20. package/src/.DS_Store +0 -0
  21. package/src/components/.DS_Store +0 -0
  22. package/src/components/Abstractions/ModalPortal.tsx +22 -22
  23. package/src/components/Abstractions/SlotsContainer.tsx +62 -62
  24. package/src/components/Arrow/SelectArrow.tsx +69 -69
  25. package/src/components/Arrow/img/arrow01-left-clicked.png +0 -0
  26. package/src/components/Arrow/img/arrow01-left.png +0 -0
  27. package/src/components/Arrow/img/arrow01-right-clicked.png +0 -0
  28. package/src/components/Arrow/img/arrow01-right.png +0 -0
  29. package/src/components/Arrow/img/arrow02-left-clicked.png +0 -0
  30. package/src/components/Arrow/img/arrow02-left.png +0 -0
  31. package/src/components/Arrow/img/arrow02-right-clicked.png +0 -0
  32. package/src/components/Arrow/img/arrow02-right.png +0 -0
  33. package/src/components/Button.tsx +40 -40
  34. package/src/components/Character/CharacterSelection.tsx +98 -98
  35. package/src/components/CharacterStatus/CharacterStatus.tsx +120 -120
  36. package/src/components/Chat/Chat.tsx +196 -196
  37. package/src/components/Chatdeprecated/ChatDeprecated.tsx +198 -198
  38. package/src/components/CheckButton.tsx +65 -65
  39. package/src/components/CircularController/CircularController.tsx +282 -282
  40. package/src/components/CraftBook/CraftBook.tsx +286 -286
  41. package/src/components/CraftBook/CraftingRecipe.tsx +161 -161
  42. package/src/components/CraftBook/MockItems.ts +101 -101
  43. package/src/components/DraggableContainer.tsx +180 -180
  44. package/src/components/DropdownSelectorContainer.tsx +42 -42
  45. package/src/components/Equipment/EquipmentSet.tsx +199 -199
  46. package/src/components/HistoryDialog.tsx +104 -104
  47. package/src/components/Input.tsx +15 -15
  48. package/src/components/InputRadio.tsx +41 -41
  49. package/src/components/Item/Cards/ItemInfo.tsx +298 -298
  50. package/src/components/Item/Cards/ItemInfoDisplay.tsx +135 -135
  51. package/src/components/Item/Cards/ItemInfoWrapper.tsx +62 -62
  52. package/src/components/Item/Cards/ItemTooltip.tsx +83 -83
  53. package/src/components/Item/Cards/MobileItemTooltip.tsx +149 -149
  54. package/src/components/Item/Inventory/ErrorBoundary.tsx +42 -42
  55. package/src/components/Item/Inventory/ItemContainer.tsx +231 -231
  56. package/src/components/Item/Inventory/ItemContainerTypes.ts +6 -6
  57. package/src/components/Item/Inventory/ItemQuantitySelector.tsx +138 -138
  58. package/src/components/Item/Inventory/ItemSlot.tsx +580 -580
  59. package/src/components/Item/Inventory/itemContainerHelper.ts +175 -175
  60. package/src/components/ListMenu.tsx +63 -63
  61. package/src/components/Marketplace/Marketplace.tsx +132 -132
  62. package/src/components/Marketplace/MarketplaceRows.tsx +171 -171
  63. package/src/components/Marketplace/__mocks__/index.tsx +65 -65
  64. package/src/components/Multitab/Tab.tsx +66 -66
  65. package/src/components/Multitab/TabBody.tsx +13 -13
  66. package/src/components/Multitab/TabsContainer.tsx +97 -97
  67. package/src/components/NPCDialog/.DS_Store +0 -0
  68. package/src/components/NPCDialog/NPCDialog.tsx +121 -121
  69. package/src/components/NPCDialog/NPCDialogText.tsx +113 -113
  70. package/src/components/NPCDialog/NPCMultiDialog.tsx +159 -159
  71. package/src/components/NPCDialog/QuestionDialog/QuestionDialog.tsx +237 -237
  72. package/src/components/NPCDialog/img/.DS_Store +0 -0
  73. package/src/components/ProgressBar.tsx +92 -92
  74. package/src/components/PropertySelect/PropertySelect.tsx +106 -106
  75. package/src/components/QuestInfo/QuestInfo.tsx +233 -233
  76. package/src/components/QuestList.tsx +135 -135
  77. package/src/components/RPGUIContainer.tsx +47 -47
  78. package/src/components/RPGUIForceRenderStart.tsx +45 -45
  79. package/src/components/RPGUIRoot.tsx +14 -14
  80. package/src/components/RadioButton.tsx +53 -53
  81. package/src/components/RadioInput/RadioButton.tsx +96 -96
  82. package/src/components/RadioInput/RadioInput.tsx +102 -102
  83. package/src/components/RadioInput/instruments.ts +15 -15
  84. package/src/components/RangeSlider.tsx +78 -78
  85. package/src/components/RelativeListMenu.tsx +90 -90
  86. package/src/components/ScrollList.tsx +79 -79
  87. package/src/components/Shortcuts/Shortcuts.tsx +192 -192
  88. package/src/components/Shortcuts/ShortcutsSetter.tsx +139 -139
  89. package/src/components/Shortcuts/SingleShortcut.ts +82 -82
  90. package/src/components/Shortcuts/useShortcutCooldown.ts +23 -23
  91. package/src/components/SimpleProgressBar.tsx +62 -62
  92. package/src/components/SkillProgressBar.tsx +133 -133
  93. package/src/components/SkillsContainer.tsx +206 -206
  94. package/src/components/Spellbook/Spell.tsx +236 -226
  95. package/src/components/Spellbook/Spellbook.tsx +159 -158
  96. package/src/components/Spellbook/cards/MobileSpellTooltip.tsx +137 -0
  97. package/src/components/Spellbook/cards/SpellInfo.tsx +132 -0
  98. package/src/components/Spellbook/cards/SpellInfoDisplay.tsx +31 -0
  99. package/src/components/Spellbook/cards/SpellInfoWrapper.tsx +48 -0
  100. package/src/components/Spellbook/cards/SpellTooltip.tsx +70 -0
  101. package/src/components/Spellbook/constants.ts +8 -8
  102. package/src/components/Spellbook/mockSpells.ts +85 -60
  103. package/src/components/StaticBook/StaticBook.tsx +103 -103
  104. package/src/components/TextArea.tsx +11 -11
  105. package/src/components/TimeWidget/DayNightPeriod/DayNightPeriod.tsx +35 -35
  106. package/src/components/TimeWidget/TimeWidget.tsx +65 -65
  107. package/src/components/TradingMenu/TradingItemRow.tsx +199 -199
  108. package/src/components/TradingMenu/TradingMenu.tsx +219 -219
  109. package/src/components/TradingMenu/items.mock.ts +48 -48
  110. package/src/components/Truncate.tsx +25 -25
  111. package/src/components/itemSelector/ItemSelector.tsx +136 -136
  112. package/src/components/shared/Column.tsx +16 -16
  113. package/src/components/shared/Ellipsis.tsx +68 -68
  114. package/src/components/shared/SpriteFromAtlas.tsx +104 -104
  115. package/src/components/typography/DynamicText.tsx +49 -49
  116. package/src/constants/uiColors.ts +20 -20
  117. package/src/constants/uiDevices.ts +3 -3
  118. package/src/constants/uiFonts.ts +12 -12
  119. package/src/hooks/useEventListener.ts +21 -21
  120. package/src/hooks/useOutsideAlerter.ts +25 -25
  121. package/src/index.tsx +42 -42
  122. package/src/libs/CastingTypeHelper.ts +8 -0
  123. package/src/libs/StringHelpers.ts +3 -3
  124. package/src/libs/itemCounter.ts +21 -21
  125. package/src/mocks/.DS_Store +0 -0
  126. package/src/mocks/atlas/.DS_Store +0 -0
  127. package/src/mocks/atlas/entities/entities.json +20215 -20215
  128. package/src/mocks/atlas/icons/icons.json +735 -735
  129. package/src/mocks/atlas/items/items.json +12086 -12086
  130. package/src/mocks/equipmentSet.mocks.ts +391 -391
  131. package/src/mocks/itemContainer.mocks.ts +605 -605
  132. package/src/mocks/skills.mocks.ts +128 -128
  133. package/src/stories/Arrow.stories.tsx +26 -26
  134. package/src/stories/Button.stories.tsx +36 -36
  135. package/src/stories/CharacterSelection.stories.tsx +44 -44
  136. package/src/stories/CharacterStatus.stories.tsx +29 -29
  137. package/src/stories/Chat.stories.tsx +187 -187
  138. package/src/stories/ChatDeprecated.stories.tsx +170 -170
  139. package/src/stories/CheckButton.stories.tsx +48 -48
  140. package/src/stories/CircullarController.stories.tsx +37 -37
  141. package/src/stories/CraftBook.stories.tsx +42 -42
  142. package/src/stories/DayNightPeriod.stories.tsx +27 -27
  143. package/src/stories/DraggableContainer.stories.tsx +28 -28
  144. package/src/stories/Dropdown.stories.tsx +46 -46
  145. package/src/stories/DropdownSelectorContainer.stories.tsx +41 -41
  146. package/src/stories/EquipmentSet.stories.tsx +65 -65
  147. package/src/stories/HistoryDialog.stories.tsx +61 -61
  148. package/src/stories/ItemContainer.stories.tsx +201 -201
  149. package/src/stories/ItemInfoDisplay.stories.tsx +33 -33
  150. package/src/stories/ItemQuantitySelector.stories.tsx +26 -26
  151. package/src/stories/ItemSelector.stories.tsx +77 -77
  152. package/src/stories/ItemTradingComponent.stories.tsx +35 -35
  153. package/src/stories/ListMenu.stories.tsx +56 -56
  154. package/src/stories/Marketplace.stories.tsx +42 -42
  155. package/src/stories/MarketplaceRows.stories.tsx +28 -28
  156. package/src/stories/Multitab.stories.tsx +51 -51
  157. package/src/stories/NPCDialog.stories.tsx +130 -130
  158. package/src/stories/NPCMultiDialog.stories.tsx +71 -71
  159. package/src/stories/ProgressBar.stories.tsx +23 -23
  160. package/src/stories/PropertySelect.stories.tsx +40 -40
  161. package/src/stories/QuestInfo.stories.tsx +107 -107
  162. package/src/stories/QuestList.stories.tsx +82 -82
  163. package/src/stories/RPGUIContainers.stories.tsx +42 -42
  164. package/src/stories/RadioButton.stories.tsx +49 -49
  165. package/src/stories/RadioInput.stories.tsx +34 -34
  166. package/src/stories/RangeSlider.stories.tsx +64 -64
  167. package/src/stories/ScrollList.stories.tsx +85 -85
  168. package/src/stories/Shortcuts.stories.tsx +39 -39
  169. package/src/stories/SimpleProgressBar.stories.tsx +22 -22
  170. package/src/stories/SkillProgressBar.stories.tsx +34 -34
  171. package/src/stories/SkillsContainer.stories.tsx +35 -35
  172. package/src/stories/SpellInfoDisplay.stories.tsx +27 -0
  173. package/src/stories/Spellbook.stories.tsx +104 -104
  174. package/src/stories/StaticBook.stories.tsx +32 -32
  175. package/src/stories/Text.stories.tsx +42 -42
  176. package/src/stories/TimeWidget.stories.tsx +27 -27
  177. package/src/stories/TradingMenu.stories.tsx +47 -47
  178. package/src/types/eventTypes.ts +4 -4
  179. package/src/types/index.d.ts +2 -2
@@ -1,158 +1,159 @@
1
- import { IRawSpell, IShortcut } from '@rpg-engine/shared';
2
- import React, { Fragment, useEffect, useMemo, useState } from 'react';
3
- import styled from 'styled-components';
4
- import { uiFonts } from '../../constants/uiFonts';
5
- import { DraggableContainer } from '../DraggableContainer';
6
- import { Input } from '../Input';
7
- import { RPGUIContainerTypes } from '../RPGUIContainer';
8
- import { ShortcutsSetter } from '../Shortcuts/ShortcutsSetter';
9
- import { Spell } from './Spell';
10
-
11
- export interface ISpellbookProps {
12
- onClose?: () => void;
13
- onInputFocus?: () => void;
14
- onInputBlur?: () => void;
15
- spells: IRawSpell[];
16
- magicLevel: number;
17
- mana: number;
18
- onSpellClick: (spellKey: string) => void;
19
- setSpellShortcut: (key: string, index: number) => void;
20
- shortcuts: IShortcut[];
21
- removeShortcut: (index: number) => void;
22
- atlasIMG: any;
23
- atlasJSON: any;
24
- scale?: number;
25
- spellCooldowns?: Record<string, number>;
26
- }
27
-
28
- export const Spellbook: React.FC<ISpellbookProps> = ({
29
- onClose,
30
- onInputFocus,
31
- onInputBlur,
32
- spells,
33
- magicLevel,
34
- mana,
35
- onSpellClick,
36
- setSpellShortcut,
37
- shortcuts,
38
- removeShortcut,
39
- atlasIMG,
40
- atlasJSON,
41
- scale,
42
- spellCooldowns,
43
- }) => {
44
- const [search, setSearch] = useState('');
45
- const [settingShortcutIndex, setSettingShortcutIndex] = useState(-1);
46
-
47
- useEffect(() => {
48
- const handleEscapeClose = (e: KeyboardEvent) => {
49
- if (e.key === 'Escape') {
50
- onClose?.();
51
- }
52
- };
53
-
54
- document.addEventListener('keydown', handleEscapeClose);
55
-
56
- return () => {
57
- document.removeEventListener('keydown', handleEscapeClose);
58
- };
59
- }, [onClose]);
60
-
61
- const spellsToDisplay = useMemo(() => {
62
- return spells
63
- .sort((a, b) => {
64
- if (a.minMagicLevelRequired > b.minMagicLevelRequired) return 1;
65
- if (a.minMagicLevelRequired < b.minMagicLevelRequired) return -1;
66
- return 0;
67
- })
68
- .filter(
69
- spell =>
70
- spell.name.toLocaleLowerCase().includes(search.toLocaleLowerCase()) ||
71
- spell.magicWords
72
- .toLocaleLowerCase()
73
- .includes(search.toLocaleLowerCase())
74
- );
75
- }, [search, spells]);
76
-
77
- const setShortcut = (spellKey: string) => {
78
- setSpellShortcut?.(spellKey, settingShortcutIndex);
79
- setSettingShortcutIndex(-1);
80
- };
81
-
82
- return (
83
- <DraggableContainer
84
- type={RPGUIContainerTypes.Framed}
85
- onCloseButton={onClose}
86
- width="inherit"
87
- height="inherit"
88
- cancelDrag="#spellbook-search, #shortcuts_list, .spell"
89
- scale={scale}
90
- >
91
- <Container>
92
- <Title>Learned Spells</Title>
93
-
94
- <ShortcutsSetter
95
- setSettingShortcutIndex={setSettingShortcutIndex}
96
- settingShortcutIndex={settingShortcutIndex}
97
- shortcuts={shortcuts}
98
- removeShortcut={removeShortcut}
99
- atlasIMG={atlasIMG}
100
- atlasJSON={atlasJSON}
101
- />
102
-
103
- <Input
104
- placeholder="Search for spell"
105
- value={search}
106
- onChange={e => setSearch(e.target.value)}
107
- onFocus={onInputFocus}
108
- onBlur={onInputBlur}
109
- id="spellbook-search"
110
- />
111
-
112
- <SpellList>
113
- {spellsToDisplay.map(spell => (
114
- <Fragment key={spell.key}>
115
- <Spell
116
- charMana={mana}
117
- charMagicLevel={magicLevel}
118
- onPointerUp={
119
- settingShortcutIndex !== -1 ? setShortcut : onSpellClick
120
- }
121
- spellKey={spell.key}
122
- isSettingShortcut={settingShortcutIndex !== -1}
123
- activeCooldown={
124
- spellCooldowns?.[spell.magicWords.replaceAll(' ', '_')]
125
- }
126
- {...spell}
127
- />
128
- </Fragment>
129
- ))}
130
- </SpellList>
131
- </Container>
132
- </DraggableContainer>
133
- );
134
- };
135
-
136
- const Title = styled.h1`
137
- font-size: ${uiFonts.size.large} !important;
138
- margin-bottom: 0 !important;
139
- `;
140
-
141
- const Container = styled.div`
142
- width: 100%;
143
- height: 100%;
144
- color: white;
145
- display: flex;
146
- flex-direction: column;
147
- `;
148
-
149
- const SpellList = styled.div`
150
- width: 100%;
151
- min-height: 0;
152
- flex: 1;
153
- overflow-y: auto;
154
- display: flex;
155
- flex-direction: column;
156
- gap: 1.5rem;
157
- margin-top: 1rem;
158
- `;
1
+ import { IShortcut, ISpell } from '@rpg-engine/shared';
2
+ import React, { Fragment, useEffect, useMemo, useState } from 'react';
3
+ import styled from 'styled-components';
4
+ import { uiFonts } from '../../constants/uiFonts';
5
+ import { DraggableContainer } from '../DraggableContainer';
6
+ import { Input } from '../Input';
7
+ import { RPGUIContainerTypes } from '../RPGUIContainer';
8
+ import { ShortcutsSetter } from '../Shortcuts/ShortcutsSetter';
9
+ import { Spell } from './Spell';
10
+
11
+ export interface ISpellbookProps {
12
+ onClose?: () => void;
13
+ onInputFocus?: () => void;
14
+ onInputBlur?: () => void;
15
+ spells: ISpell[];
16
+ magicLevel: number;
17
+ mana: number;
18
+ onSpellClick: (spellKey: string) => void;
19
+ setSpellShortcut: (key: string, index: number) => void;
20
+ shortcuts: IShortcut[];
21
+ removeShortcut: (index: number) => void;
22
+ atlasIMG: any;
23
+ atlasJSON: any;
24
+ scale?: number;
25
+ spellCooldowns?: Record<string, number>;
26
+ }
27
+
28
+ export const Spellbook: React.FC<ISpellbookProps> = ({
29
+ onClose,
30
+ onInputFocus,
31
+ onInputBlur,
32
+ spells,
33
+ magicLevel,
34
+ mana,
35
+ onSpellClick,
36
+ setSpellShortcut,
37
+ shortcuts,
38
+ removeShortcut,
39
+ atlasIMG,
40
+ atlasJSON,
41
+ scale,
42
+ spellCooldowns,
43
+ }) => {
44
+ const [search, setSearch] = useState('');
45
+ const [settingShortcutIndex, setSettingShortcutIndex] = useState(-1);
46
+
47
+ useEffect(() => {
48
+ const handleEscapeClose = (e: KeyboardEvent) => {
49
+ if (e.key === 'Escape') {
50
+ onClose?.();
51
+ }
52
+ };
53
+
54
+ document.addEventListener('keydown', handleEscapeClose);
55
+
56
+ return () => {
57
+ document.removeEventListener('keydown', handleEscapeClose);
58
+ };
59
+ }, [onClose]);
60
+
61
+ const spellsToDisplay = useMemo(() => {
62
+ return spells
63
+ .sort((a, b) => {
64
+ if (a.minMagicLevelRequired > b.minMagicLevelRequired) return 1;
65
+ if (a.minMagicLevelRequired < b.minMagicLevelRequired) return -1;
66
+ return 0;
67
+ })
68
+ .filter(
69
+ spell =>
70
+ spell.name.toLocaleLowerCase().includes(search.toLocaleLowerCase()) ||
71
+ spell.magicWords
72
+ .toLocaleLowerCase()
73
+ .includes(search.toLocaleLowerCase())
74
+ );
75
+ }, [search, spells]);
76
+
77
+ const setShortcut = (spellKey: string) => {
78
+ setSpellShortcut?.(spellKey, settingShortcutIndex);
79
+ setSettingShortcutIndex(-1);
80
+ };
81
+
82
+ return (
83
+ <DraggableContainer
84
+ type={RPGUIContainerTypes.Framed}
85
+ onCloseButton={onClose}
86
+ width="inherit"
87
+ height="inherit"
88
+ cancelDrag="#spellbook-search, #shortcuts_list, .spell"
89
+ scale={scale}
90
+ >
91
+ <Container>
92
+ <Title>Learned Spells</Title>
93
+
94
+ <ShortcutsSetter
95
+ setSettingShortcutIndex={setSettingShortcutIndex}
96
+ settingShortcutIndex={settingShortcutIndex}
97
+ shortcuts={shortcuts}
98
+ removeShortcut={removeShortcut}
99
+ atlasIMG={atlasIMG}
100
+ atlasJSON={atlasJSON}
101
+ />
102
+
103
+ <Input
104
+ placeholder="Search for spell"
105
+ value={search}
106
+ onChange={e => setSearch(e.target.value)}
107
+ onFocus={onInputFocus}
108
+ onBlur={onInputBlur}
109
+ id="spellbook-search"
110
+ />
111
+
112
+ <SpellList>
113
+ {spellsToDisplay.map(spell => (
114
+ <Fragment key={spell.key}>
115
+ <Spell
116
+ charMana={mana}
117
+ charMagicLevel={magicLevel}
118
+ onPointerUp={
119
+ settingShortcutIndex !== -1 ? setShortcut : onSpellClick
120
+ }
121
+ spellKey={spell.key}
122
+ isSettingShortcut={settingShortcutIndex !== -1}
123
+ spell={spell}
124
+ activeCooldown={
125
+ spellCooldowns?.[spell.magicWords.replaceAll(' ', '_')]
126
+ }
127
+ {...spell}
128
+ />
129
+ </Fragment>
130
+ ))}
131
+ </SpellList>
132
+ </Container>
133
+ </DraggableContainer>
134
+ );
135
+ };
136
+
137
+ const Title = styled.h1`
138
+ font-size: ${uiFonts.size.large} !important;
139
+ margin-bottom: 0 !important;
140
+ `;
141
+
142
+ const Container = styled.div`
143
+ width: 100%;
144
+ height: 100%;
145
+ color: white;
146
+ display: flex;
147
+ flex-direction: column;
148
+ `;
149
+
150
+ const SpellList = styled.div`
151
+ width: 100%;
152
+ min-height: 0;
153
+ flex: 1;
154
+ overflow-y: auto;
155
+ display: flex;
156
+ flex-direction: column;
157
+ gap: 1.5rem;
158
+ margin-top: 1rem;
159
+ `;
@@ -0,0 +1,137 @@
1
+ import { ISpell } from '@rpg-engine/shared';
2
+ import React, { useRef } from 'react';
3
+ import styled from 'styled-components';
4
+ import ModalPortal from '../../Abstractions/ModalPortal';
5
+ import { SpellInfoDisplay } from './SpellInfoDisplay';
6
+
7
+ interface IListMenuOption {
8
+ id: string;
9
+ text: string;
10
+ }
11
+
12
+ export interface MobileSpellTooltipProps {
13
+ spell: ISpell;
14
+ closeTooltip: () => void;
15
+ scale?: number;
16
+ options?: IListMenuOption[];
17
+ onSelected?: (selectedOptionId: string) => void;
18
+ }
19
+
20
+ export const MobileSpellTooltip: React.FC<MobileSpellTooltipProps> = ({
21
+ spell,
22
+ closeTooltip,
23
+ scale = 1,
24
+ options,
25
+ onSelected,
26
+ }) => {
27
+ const ref = useRef<HTMLDivElement>(null);
28
+
29
+ const handleFadeOut = () => {
30
+ ref.current?.classList.add('fadeOut');
31
+ };
32
+
33
+ return (
34
+ <ModalPortal>
35
+ <Container
36
+ ref={ref}
37
+ onTouchEnd={() => {
38
+ handleFadeOut();
39
+ setTimeout(() => {
40
+ closeTooltip();
41
+ }, 100);
42
+ }}
43
+ scale={scale}
44
+ >
45
+ <SpellInfoDisplay spell={spell} isMobile />
46
+ <OptionsContainer>
47
+ {options?.map(option => (
48
+ <Option
49
+ key={option.id}
50
+ onTouchEnd={() => {
51
+ handleFadeOut();
52
+ setTimeout(() => {
53
+ onSelected?.(option.id);
54
+ closeTooltip();
55
+ }, 100);
56
+ }}
57
+ >
58
+ {option.text}
59
+ </Option>
60
+ ))}
61
+ </OptionsContainer>
62
+ </Container>
63
+ </ModalPortal>
64
+ );
65
+ };
66
+
67
+ const Container = styled.div<{ scale: number }>`
68
+ position: absolute;
69
+ z-index: 100;
70
+ left: 0;
71
+ top: 0;
72
+ width: 100vw;
73
+ height: 100vh;
74
+ background-color: rgba(0 0 0 / 0.5);
75
+ display: flex;
76
+ justify-content: center;
77
+ align-items: center;
78
+ gap: 0.5rem;
79
+ transition: opacity 0.08s;
80
+ animation: fadeIn 0.1s forwards;
81
+
82
+ @keyframes fadeIn {
83
+ 0% {
84
+ opacity: 0;
85
+ }
86
+ 100% {
87
+ opacity: 0.92;
88
+ }
89
+ }
90
+
91
+ @keyframes fadeOut {
92
+ 0% {
93
+ opacity: 0.92;
94
+ }
95
+ 100% {
96
+ opacity: 0;
97
+ }
98
+ }
99
+
100
+ &.fadeOut {
101
+ animation: fadeOut 0.1s forwards;
102
+ }
103
+
104
+ @media (max-width: 580px) {
105
+ flex-direction: column;
106
+ }
107
+ `;
108
+
109
+ const OptionsContainer = styled.div`
110
+ display: flex;
111
+ flex-direction: column;
112
+ gap: 0.5rem;
113
+ flex-wrap: wrap;
114
+
115
+ @media (max-width: 580px) {
116
+ flex-direction: row;
117
+ justify-content: center;
118
+ }
119
+ `;
120
+
121
+ const Option = styled.button`
122
+ padding: 1rem;
123
+ background-color: #333;
124
+ color: white;
125
+ border: none;
126
+ border-radius: 3px;
127
+ width: 8rem;
128
+ transition: background-color 0.1s;
129
+
130
+ &:hover {
131
+ background-color: #555;
132
+ }
133
+
134
+ @media (max-width: 580px) {
135
+ padding: 1rem 0.5rem;
136
+ }
137
+ `;
@@ -0,0 +1,132 @@
1
+ import { ISpell } from '@rpg-engine/shared';
2
+ import React from 'react';
3
+ import styled from 'styled-components';
4
+ import { uiColors } from '../../../constants/uiColors';
5
+ import { uiFonts } from '../../../constants/uiFonts';
6
+ import { formatSpellCastingType } from '../../../libs/CastingTypeHelper';
7
+
8
+ interface ISpellInfoProps {
9
+ spell: ISpell;
10
+ }
11
+
12
+ export const SpellInfo: React.FC<ISpellInfoProps> = ({ spell }) => {
13
+ const {
14
+ magicWords,
15
+ name,
16
+ manaCost,
17
+ requiredItem,
18
+ description,
19
+ castingType,
20
+ cooldown,
21
+ maxDistanceGrid,
22
+ } = spell;
23
+ return (
24
+ <Container>
25
+ <Header>
26
+ <div>
27
+ <Title>{name}</Title>
28
+ <Type>{magicWords}</Type>
29
+ </div>
30
+ </Header>
31
+ <Statistic>
32
+ <div className="label">Casting Type:</div>
33
+ <div className="value">{formatSpellCastingType(castingType)}</div>
34
+ </Statistic>
35
+ <Statistic>
36
+ <div className="label">Magic words:</div>
37
+ <div className="value">{magicWords}</div>
38
+ </Statistic>
39
+ <Statistic>
40
+ <div className="label">Mana cost:</div>
41
+ <div className="value">{manaCost}</div>
42
+ </Statistic>
43
+ <Statistic>
44
+ <div className="label">Cooldown:</div>
45
+ <div className="value">{cooldown}</div>
46
+ </Statistic>
47
+ <Statistic>
48
+ <div className="label">Max Distance Grid:</div>
49
+ <div className="value">{maxDistanceGrid}</div>
50
+ </Statistic>
51
+ <Statistic>
52
+ {requiredItem && (
53
+ <>
54
+ <div className="label">Required Item:</div>
55
+ <div className="value">{requiredItem}</div>
56
+ </>
57
+ )}
58
+ </Statistic>
59
+ <Description>{description}</Description>
60
+ </Container>
61
+ );
62
+ };
63
+
64
+ const Container = styled.div`
65
+ color: white;
66
+ background-color: #222;
67
+ border-radius: 5px;
68
+ padding: 0.5rem;
69
+ font-size: ${uiFonts.size.small};
70
+ border: 3px solid ${uiColors.lightGray};
71
+ height: max-content;
72
+ width: 30rem;
73
+
74
+ @media (max-width: 580px) {
75
+ width: 80vw;
76
+ }
77
+ `;
78
+
79
+ const Title = styled.div`
80
+ font-size: ${uiFonts.size.medium};
81
+ font-weight: bold;
82
+ margin-bottom: 0.5rem;
83
+ display: flex;
84
+ align-items: center;
85
+ margin: 0;
86
+ `;
87
+
88
+ const Type = styled.div`
89
+ font-size: ${uiFonts.size.small};
90
+ margin-top: 0.2rem;
91
+ color: ${uiColors.lightGray};
92
+ `;
93
+
94
+ const Description = styled.div`
95
+ margin-top: 1.5rem;
96
+ font-size: ${uiFonts.size.small};
97
+ color: ${uiColors.lightGray};
98
+ font-style: italic;
99
+ `;
100
+
101
+ const Header = styled.div`
102
+ display: flex;
103
+ align-items: center;
104
+ justify-content: space-between;
105
+ margin-bottom: 0.5rem;
106
+ `;
107
+
108
+ const Statistic = styled.div`
109
+ margin-bottom: 0.4rem;
110
+ width: max-content;
111
+
112
+ .label {
113
+ display: inline-block;
114
+ margin-right: 0.5rem;
115
+ color: inherit;
116
+ }
117
+
118
+ .value {
119
+ display: inline-block;
120
+ color: inherit;
121
+ }
122
+
123
+ &.better,
124
+ .better {
125
+ color: ${uiColors.lightGreen};
126
+ }
127
+
128
+ &.worse,
129
+ .worse {
130
+ color: ${uiColors.cardinal};
131
+ }
132
+ `;
@@ -0,0 +1,31 @@
1
+ import { ISpell } from '@rpg-engine/shared';
2
+ import React from 'react';
3
+ import styled from 'styled-components';
4
+ import { SpellInfo } from './SpellInfo';
5
+
6
+ export interface ISpellInfoDisplayProps {
7
+ spell: ISpell;
8
+ isMobile?: boolean;
9
+ }
10
+
11
+ export const SpellInfoDisplay: React.FC<ISpellInfoDisplayProps> = ({
12
+ spell,
13
+ isMobile,
14
+ }) => {
15
+ return (
16
+ <Flex $isMobile={isMobile}>
17
+ <SpellInfo spell={spell} />
18
+ </Flex>
19
+ );
20
+ };
21
+
22
+ const Flex = styled.div<{ $isMobile?: boolean }>`
23
+ display: flex;
24
+ gap: 0.5rem;
25
+ flex-direction: ${({ $isMobile }) => ($isMobile ? 'row-reverse' : 'row')};
26
+
27
+ @media (max-width: 580px) {
28
+ flex-direction: column-reverse;
29
+ align-items: center;
30
+ }
31
+ `;
@@ -0,0 +1,48 @@
1
+ import { ISpell } from '@rpg-engine/shared';
2
+ import React, { useState } from 'react';
3
+ import { MobileSpellTooltip } from './MobileSpellTooltip';
4
+ import { MagicTooltip } from './SpellTooltip';
5
+
6
+ interface ISpellInfoWrapperProps {
7
+ spell: ISpell;
8
+ children: React.ReactNode;
9
+ scale?: number;
10
+ }
11
+
12
+ export const SpellInfoWrapper: React.FC<ISpellInfoWrapperProps> = ({
13
+ children,
14
+ spell,
15
+ scale,
16
+ }) => {
17
+ const [isTooltipVisible, setIsTooltipVisible] = useState(false);
18
+ const [isTooltipMobileVisible, setIsTooltipMobileVisible] = useState(false);
19
+
20
+ return (
21
+ <div
22
+ onMouseEnter={() => {
23
+ if (!isTooltipMobileVisible) setIsTooltipVisible(true);
24
+ }}
25
+ onMouseLeave={setIsTooltipVisible.bind(null, false)}
26
+ onTouchEnd={() => {
27
+ setIsTooltipMobileVisible(true);
28
+ setIsTooltipVisible(false);
29
+ }}
30
+ >
31
+ {children}
32
+
33
+ {isTooltipVisible && !isTooltipMobileVisible && (
34
+ <MagicTooltip spell={spell} />
35
+ )}
36
+ {isTooltipMobileVisible && (
37
+ <MobileSpellTooltip
38
+ closeTooltip={() => {
39
+ setIsTooltipMobileVisible(false);
40
+ console.log('close');
41
+ }}
42
+ spell={spell}
43
+ scale={scale}
44
+ />
45
+ )}
46
+ </div>
47
+ );
48
+ };