@rpg-engine/long-bow 0.3.51 → 0.3.52

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/dist/components/CircularController/CircularController.d.ts +7 -3
  2. package/dist/components/Item/Inventory/ItemContainer.d.ts +4 -0
  3. package/dist/components/Item/Inventory/ItemSlot.d.ts +1 -0
  4. package/dist/components/Shortcuts/Shortcuts.d.ts +21 -0
  5. package/dist/components/Shortcuts/ShortcutsSetter.d.ts +12 -0
  6. package/dist/components/Shortcuts/SingleShortcut.d.ts +1 -0
  7. package/dist/components/Spellbook/Spellbook.d.ts +5 -2
  8. package/dist/components/Spellbook/constants.d.ts +3 -3
  9. package/dist/index.d.ts +1 -1
  10. package/dist/long-bow.cjs.development.js +271 -120
  11. package/dist/long-bow.cjs.development.js.map +1 -1
  12. package/dist/long-bow.cjs.production.min.js +1 -1
  13. package/dist/long-bow.cjs.production.min.js.map +1 -1
  14. package/dist/long-bow.esm.js +273 -120
  15. package/dist/long-bow.esm.js.map +1 -1
  16. package/dist/stories/{QuickSpells.stories.d.ts → Shortcuts.stories.d.ts} +2 -2
  17. package/package.json +1 -1
  18. package/src/components/Abstractions/SlotsContainer.tsx +2 -2
  19. package/src/components/CircularController/CircularController.tsx +118 -36
  20. package/src/components/Item/Inventory/ItemContainer.tsx +39 -4
  21. package/src/components/Item/Inventory/ItemSlot.tsx +38 -3
  22. package/src/components/Shortcuts/Shortcuts.tsx +138 -0
  23. package/src/components/Shortcuts/ShortcutsSetter.tsx +127 -0
  24. package/src/components/Shortcuts/SingleShortcut.ts +61 -0
  25. package/src/components/Spellbook/Spellbook.tsx +15 -8
  26. package/src/components/Spellbook/constants.ts +5 -9
  27. package/src/components/TradingMenu/TradingMenu.tsx +2 -2
  28. package/src/components/TradingMenu/items.mock.ts +59 -0
  29. package/src/index.tsx +1 -1
  30. package/src/mocks/itemContainer.mocks.ts +22 -20
  31. package/src/stories/CircullarController.stories.tsx +9 -5
  32. package/src/stories/ItemContainer.stories.tsx +70 -1
  33. package/src/stories/Shortcuts.stories.tsx +39 -0
  34. package/src/stories/Spellbook.stories.tsx +35 -38
  35. package/dist/components/Spellbook/QuickSpells.d.ts +0 -10
  36. package/dist/components/Spellbook/SpellbookShortcuts.d.ts +0 -10
  37. package/src/components/Spellbook/QuickSpells.tsx +0 -120
  38. package/src/components/Spellbook/SpellbookShortcuts.tsx +0 -77
  39. package/src/stories/QuickSpells.stories.tsx +0 -38
@@ -1,10 +0,0 @@
1
- import { IRawSpell } from '@rpg-engine/shared';
2
- import React from 'react';
3
- export declare type QuickSpellsProps = {
4
- quickSpells: IRawSpell[];
5
- onSpellCast: (spellKey: string) => void;
6
- mana: number;
7
- isBlockedCastingByKeyboard?: boolean;
8
- };
9
- export declare const QuickSpells: React.FC<QuickSpellsProps>;
10
- export declare const SpellShortcut: import("styled-components").StyledComponent<"button", any, {}, never>;
@@ -1,10 +0,0 @@
1
- import { IRawSpell } from '@rpg-engine/shared';
2
- import React from 'react';
3
- declare type Props = {
4
- setSettingShortcutIndex: (index: number) => void;
5
- settingShortcutIndex: number;
6
- shortcuts: IRawSpell[];
7
- removeShortcut: (index: number) => void;
8
- };
9
- export declare const SpellbookShortcuts: React.FC<Props>;
10
- export {};
@@ -1,120 +0,0 @@
1
- import { IRawSpell } from '@rpg-engine/shared';
2
- import React, { useEffect } from 'react';
3
- import styled from 'styled-components';
4
- import { uiColors } from '../../constants/uiColors';
5
-
6
- export type QuickSpellsProps = {
7
- quickSpells: IRawSpell[];
8
- onSpellCast: (spellKey: string) => void;
9
- mana: number;
10
- isBlockedCastingByKeyboard?: boolean;
11
- };
12
-
13
- export const QuickSpells: React.FC<QuickSpellsProps> = ({
14
- quickSpells,
15
- onSpellCast,
16
- mana,
17
- isBlockedCastingByKeyboard = false,
18
- }) => {
19
- useEffect(() => {
20
- const handleKeyDown = (e: KeyboardEvent) => {
21
- if (isBlockedCastingByKeyboard) return;
22
-
23
- const shortcutIndex = Number(e.key) - 1;
24
- if (shortcutIndex >= 0 && shortcutIndex <= 3) {
25
- const shortcut = quickSpells[shortcutIndex];
26
- if (shortcut?.key && mana >= shortcut?.manaCost) {
27
- onSpellCast(shortcut.key);
28
- }
29
- }
30
- };
31
-
32
- window.addEventListener('keydown', handleKeyDown);
33
-
34
- return () => {
35
- window.removeEventListener('keydown', handleKeyDown);
36
- };
37
- }, [quickSpells, isBlockedCastingByKeyboard]);
38
-
39
- return (
40
- <List>
41
- {Array.from({ length: 4 }).map((_, i) => (
42
- <SpellShortcut
43
- key={i}
44
- onClick={onSpellCast.bind(null, quickSpells[i]?.key)}
45
- disabled={mana < quickSpells[i]?.manaCost}
46
- >
47
- <span className="mana">
48
- {quickSpells[i]?.key && quickSpells[i]?.manaCost}
49
- </span>
50
- <span className="magicWords">
51
- {quickSpells[i]?.magicWords.split(' ').map(word => word[0])}
52
- </span>
53
- <span className="keyboard">{i + 1}</span>
54
- </SpellShortcut>
55
- ))}
56
- </List>
57
- );
58
- };
59
-
60
- export const SpellShortcut = styled.button`
61
- width: 3rem;
62
- height: 3rem;
63
- background-color: ${uiColors.lightGray};
64
- border: 2px solid ${uiColors.darkGray};
65
- border-radius: 50%;
66
- text-transform: uppercase;
67
- font-size: 0.7rem;
68
- font-weight: bold;
69
- display: flex;
70
- align-items: center;
71
- justify-content: center;
72
- position: relative;
73
-
74
- span {
75
- pointer-events: none;
76
- }
77
-
78
- .mana {
79
- position: absolute;
80
- top: -5px;
81
- right: 0;
82
- font-size: 0.65rem;
83
- color: ${uiColors.blue};
84
- }
85
-
86
- .magicWords {
87
- margin-top: 4px;
88
- }
89
-
90
- .keyboard {
91
- position: absolute;
92
- bottom: -5px;
93
- left: 0;
94
- font-size: 0.65rem;
95
- color: ${uiColors.yellow};
96
- }
97
-
98
- &:hover,
99
- &:focus {
100
- background-color: ${uiColors.darkGray};
101
- }
102
-
103
- &:active {
104
- background-color: ${uiColors.gray};
105
- }
106
-
107
- &:disabled {
108
- opacity: 0.5;
109
- }
110
- `;
111
-
112
- const List = styled.p`
113
- width: 100%;
114
- display: flex;
115
- align-items: center;
116
- justify-content: center;
117
- gap: 0.5rem;
118
- box-sizing: border-box;
119
- margin: 0 !important;
120
- `;
@@ -1,77 +0,0 @@
1
- import { IRawSpell } from '@rpg-engine/shared';
2
- import React from 'react';
3
- import styled from 'styled-components';
4
- import { uiColors } from '../../constants/uiColors';
5
-
6
- type Props = {
7
- setSettingShortcutIndex: (index: number) => void;
8
- settingShortcutIndex: number;
9
- shortcuts: IRawSpell[];
10
- removeShortcut: (index: number) => void;
11
- };
12
-
13
- export const SpellbookShortcuts: React.FC<Props> = ({
14
- setSettingShortcutIndex,
15
- settingShortcutIndex,
16
- shortcuts,
17
- removeShortcut,
18
- }) => (
19
- <List id="shortcuts_list">
20
- Spells shortcuts:
21
- {Array.from({ length: 4 }).map((_, i) => (
22
- <SpellShortcut
23
- key={i}
24
- onClick={() => {
25
- removeShortcut(i);
26
- if (!shortcuts[i]?.key) setSettingShortcutIndex(i);
27
- }}
28
- disabled={settingShortcutIndex !== -1 && settingShortcutIndex !== i}
29
- isBeingSet={settingShortcutIndex === i}
30
- >
31
- <span>{shortcuts[i]?.magicWords.split(' ').map(word => word[0])}</span>
32
- </SpellShortcut>
33
- ))}
34
- </List>
35
- );
36
- const SpellShortcut = styled.button<{ isBeingSet?: boolean }>`
37
- width: 2.6rem;
38
- height: 2.6rem;
39
- background-color: ${uiColors.lightGray};
40
- border: 2px solid
41
- ${({ isBeingSet }) => (isBeingSet ? uiColors.yellow : uiColors.darkGray)};
42
- border-radius: 50%;
43
- text-transform: uppercase;
44
- font-size: 0.7rem;
45
- font-weight: bold;
46
- display: flex;
47
- align-items: center;
48
- justify-content: center;
49
-
50
- span {
51
- margin-top: 4px;
52
- }
53
-
54
- &:hover,
55
- &:focus {
56
- background-color: ${uiColors.darkGray};
57
- }
58
-
59
- &:active {
60
- background-color: ${uiColors.gray};
61
- }
62
-
63
- &:disabled {
64
- opacity: 0.5;
65
- }
66
- `;
67
-
68
- const List = styled.p`
69
- width: 100%;
70
- display: flex;
71
- align-items: center;
72
- justify-content: flex-end;
73
- gap: 0.5rem;
74
- padding: 0.5rem;
75
- box-sizing: border-box;
76
- margin: 0 !important;
77
- `;
@@ -1,38 +0,0 @@
1
- import { Meta, Story } from '@storybook/react';
2
- import React from 'react';
3
- import { RPGUIRoot } from '../components/RPGUIRoot';
4
- import { SPELL_SHORTCUTS_STORAGE_KEY } from '../components/Spellbook/constants';
5
- import {
6
- QuickSpells,
7
- QuickSpellsProps,
8
- } from '../components/Spellbook/QuickSpells';
9
-
10
- const meta: Meta = {
11
- title: 'QuickSpells',
12
- component: QuickSpells,
13
- };
14
-
15
- export default meta;
16
-
17
- const Template: Story<QuickSpellsProps> = args => {
18
- return (
19
- <RPGUIRoot>
20
- <div
21
- style={{
22
- width: '100%',
23
- }}
24
- >
25
- <QuickSpells {...args} />
26
- </div>
27
- </RPGUIRoot>
28
- );
29
- };
30
-
31
- export const Default = Template.bind({});
32
- Default.args = {
33
- onSpellCast: spellKey => console.log(spellKey),
34
- quickSpells: JSON.parse(
35
- localStorage.getItem(SPELL_SHORTCUTS_STORAGE_KEY) as string
36
- ),
37
- mana: 100,
38
- };