@rpg-engine/long-bow 0.2.28 → 0.2.33

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 (46) hide show
  1. package/dist/components/Arrow/SelectArrow.d.ts +8 -0
  2. package/dist/components/SkillProgressBar.d.ts +2 -0
  3. package/dist/components/SkillsContainer.d.ts +2 -0
  4. package/dist/components/TradingMenu/TradingItemRow.d.ts +9 -0
  5. package/dist/components/TradingMenu/TradingMenu.d.ts +12 -0
  6. package/dist/components/TradingMenu/items.mock.d.ts +2 -0
  7. package/dist/components/shared/Ellipsis.d.ts +3 -1
  8. package/dist/index.d.ts +3 -2
  9. package/dist/long-bow.cjs.development.js +748 -686
  10. package/dist/long-bow.cjs.development.js.map +1 -1
  11. package/dist/long-bow.cjs.production.min.js +1 -1
  12. package/dist/long-bow.cjs.production.min.js.map +1 -1
  13. package/dist/long-bow.esm.js +749 -692
  14. package/dist/long-bow.esm.js.map +1 -1
  15. package/dist/stories/Arrow.stories.d.ts +5 -0
  16. package/dist/stories/ItemTradingComponent.stories.d.ts +5 -0
  17. package/dist/stories/TradingMenu.stories.d.ts +5 -0
  18. package/package.json +2 -2
  19. package/src/components/Arrow/SelectArrow.tsx +65 -0
  20. package/src/components/{PropertySelect/img/ui-arrows → Arrow/img}/arrow01-left-clicked.png +0 -0
  21. package/src/components/{PropertySelect/img/ui-arrows → Arrow/img}/arrow01-left.png +0 -0
  22. package/src/components/{PropertySelect/img/ui-arrows → Arrow/img}/arrow01-right-clicked.png +0 -0
  23. package/src/components/{PropertySelect/img/ui-arrows → Arrow/img}/arrow01-right.png +0 -0
  24. package/src/components/{PropertySelect/img/ui-arrows → Arrow/img}/arrow02-left-clicked.png +0 -0
  25. package/src/components/{PropertySelect/img/ui-arrows → Arrow/img}/arrow02-left.png +0 -0
  26. package/src/components/{PropertySelect/img/ui-arrows → Arrow/img}/arrow02-right-clicked.png +0 -0
  27. package/src/components/{PropertySelect/img/ui-arrows → Arrow/img}/arrow02-right.png +0 -0
  28. package/src/components/Item/Inventory/ItemSlot.tsx +5 -3
  29. package/src/components/NPCDialog/.DS_Store +0 -0
  30. package/src/components/NPCDialog/img/.DS_Store +0 -0
  31. package/src/components/PropertySelect/PropertySelect.tsx +12 -34
  32. package/src/components/QuestInfo/QuestInfo.tsx +8 -34
  33. package/src/components/ScrollList.tsx +2 -1
  34. package/src/components/SkillProgressBar.tsx +4 -2
  35. package/src/components/SkillsContainer.tsx +8 -37
  36. package/src/components/TradingMenu/TradingItemRow.tsx +172 -0
  37. package/src/components/TradingMenu/TradingMenu.tsx +188 -0
  38. package/src/components/TradingMenu/items.mock.ts +88 -0
  39. package/src/components/shared/Ellipsis.tsx +25 -6
  40. package/src/index.tsx +3 -2
  41. package/src/mocks/.DS_Store +0 -0
  42. package/src/stories/Arrow.stories.tsx +26 -0
  43. package/src/stories/ItemTradingComponent.stories.tsx +39 -0
  44. package/src/stories/SkillProgressBar.stories.tsx +4 -0
  45. package/src/stories/SkillsContainer.stories.tsx +4 -0
  46. package/src/stories/TradingMenu.stories.tsx +38 -0
@@ -0,0 +1,188 @@
1
+ import { ITradeResponseItem, TradeTransactionType } from '@rpg-engine/shared';
2
+ import React, { useEffect, useState } from 'react';
3
+ import styled from 'styled-components';
4
+ import { Button, ButtonTypes } from '../Button';
5
+ import { DraggableContainer } from '../DraggableContainer';
6
+ import { RPGUIContainerTypes } from '../RPGUIContainer';
7
+ import { TradingItemRow } from './TradingItemRow';
8
+ export interface ITrandingMenu {
9
+ traderItems: ITradeResponseItem[];
10
+ onClose: () => void;
11
+ type: TradeTransactionType;
12
+ atlasJSON: any;
13
+ atlasIMG: any;
14
+ characterAvailableGold: number;
15
+ onChangeTraderItems: (traderItems: ITradeResponseItem[]) => void;
16
+ }
17
+
18
+ export const TradingMenu: React.FC<ITrandingMenu> = ({
19
+ traderItems,
20
+ onClose,
21
+ type,
22
+ atlasJSON,
23
+ atlasIMG,
24
+ characterAvailableGold,
25
+ onChangeTraderItems,
26
+ }) => {
27
+ const [sum, setSum] = useState(0);
28
+ let newSumArray = 0;
29
+ const updateChartTotals = (item: ITradeResponseItem) => {
30
+ const itemIndex = traderItems.findIndex(
31
+ itemArray => itemArray.itemId === item.itemId
32
+ );
33
+ traderItems[itemIndex] = item;
34
+
35
+ traderItems.forEach(item => {
36
+ if (item.qty) newSumArray += item.qty * item.price;
37
+ setSum(newSumArray);
38
+ });
39
+ };
40
+
41
+ useEffect(() => {
42
+ if (onChangeTraderItems) {
43
+ onChangeTraderItems(traderItems);
44
+ }
45
+ }, [traderItems]);
46
+ const Capitalize = (word: string) => {
47
+ return word[0].toUpperCase() + word.substring(1);
48
+ };
49
+
50
+ return (
51
+ <TradingMenuDraggableContainer
52
+ type={RPGUIContainerTypes.Framed}
53
+ onCloseButton={() => {
54
+ if (onClose) onClose();
55
+ }}
56
+ width="500px"
57
+ cancelDrag=".equipment-container-body .arrow-selector"
58
+ >
59
+ <>
60
+ <div style={{ width: '100%' }}>
61
+ <Title>{Capitalize(type)} Menu</Title>
62
+ <hr className="golden" />
63
+ </div>
64
+ <TradingComponentScrollWrapper>
65
+ {traderItems.map(tradeItem => (
66
+ <ItemWrapper>
67
+ <TradingItemRow
68
+ atlasIMG={atlasIMG}
69
+ atlasJSON={atlasJSON}
70
+ updateChartTotals={updateChartTotals}
71
+ traderItem={tradeItem}
72
+ />
73
+ </ItemWrapper>
74
+ ))}
75
+ </TradingComponentScrollWrapper>
76
+ <GoldWrapper>
77
+ <p>Available Gold:</p>
78
+ <p>${characterAvailableGold}</p>
79
+ </GoldWrapper>
80
+ <TotalWrapper>
81
+ <p>Total:</p>
82
+ <p>${sum}</p>
83
+ </TotalWrapper>
84
+ {sum > characterAvailableGold ? (
85
+ <AlertWrapper>
86
+ <p> Sorry, not enough money.</p>
87
+ </AlertWrapper>
88
+ ) : (
89
+ <GoldWrapper>
90
+ <p>Final Gold:</p>
91
+ <p>${characterAvailableGold - sum}</p>
92
+ </GoldWrapper>
93
+ )}
94
+
95
+ <ButtonWrapper>
96
+ <Button
97
+ buttonType={ButtonTypes.RPGUIButton}
98
+ disabled={sum > characterAvailableGold}
99
+ >
100
+ Confirm
101
+ </Button>
102
+ <Button buttonType={ButtonTypes.RPGUIButton}>Cancel</Button>
103
+ </ButtonWrapper>
104
+ </>
105
+ </TradingMenuDraggableContainer>
106
+ );
107
+ };
108
+
109
+ const TradingMenuDraggableContainer = styled(DraggableContainer)`
110
+ .container-close {
111
+ top: 10px;
112
+ right: 10px;
113
+ }
114
+
115
+ .quest-title {
116
+ text-align: left;
117
+ margin-left: 44px;
118
+ margin-top: 20px;
119
+ color: yellow;
120
+ }
121
+
122
+ .quest-desc {
123
+ margin-top: 12px;
124
+ margin-left: 44px;
125
+ }
126
+
127
+ .rpgui-progress {
128
+ min-width: 80%;
129
+ margin: 0 auto;
130
+ }
131
+ `;
132
+
133
+ const Title = styled.h1`
134
+ z-index: 22;
135
+ font-size: 0.6rem;
136
+ color: yellow !important;
137
+ `;
138
+
139
+ const TradingComponentScrollWrapper = styled.div`
140
+ overflow-y: scroll;
141
+ height: 500px;
142
+ width: 100%;
143
+ margin-top: 1rem;
144
+ `;
145
+
146
+ const ItemWrapper = styled.div`
147
+ margin: auto;
148
+ display: flex;
149
+ justify-content: space-between;
150
+ `;
151
+
152
+ const TotalWrapper = styled.div`
153
+ display: flex;
154
+ margin: auto;
155
+ justify-content: space-between;
156
+ height: 20px;
157
+ margin-left: 0.8rem;
158
+ `;
159
+
160
+ const GoldWrapper = styled.div`
161
+ margin-top: 1rem;
162
+ display: flex;
163
+ justify-content: space-between;
164
+ height: 20px;
165
+ p {
166
+ color: yellow !important;
167
+ }
168
+ width: 100%;
169
+ margin-left: 0.8rem;
170
+ `;
171
+
172
+ const AlertWrapper = styled.div`
173
+ display: flex;
174
+ width: 100%;
175
+ justify-content: center;
176
+ height: 20px;
177
+ p {
178
+ color: red !important;
179
+ }
180
+ `;
181
+
182
+ const ButtonWrapper = styled.div`
183
+ display: flex;
184
+ justify-content: space-around;
185
+ padding-top: 20px;
186
+ width: 100%;
187
+ margin-top: 1rem;
188
+ `;
@@ -0,0 +1,88 @@
1
+ import { ITransactionItem } from '@rpg-engine/shared';
2
+ export const itemMock: ITransactionItem[] = [
3
+ {
4
+ texturePath: 'swords/broad-sword.png',
5
+ itemId: 'itemId03',
6
+ name: 'Silver Short Sword Premium',
7
+ price: 100,
8
+ key: 'Short sword',
9
+ },
10
+ {
11
+ texturePath: 'swords/broad-sword.png',
12
+ itemId: 'itemId01',
13
+ name: 'Short sword',
14
+ price: 100,
15
+ key: 'Short sword',
16
+ },
17
+ {
18
+ texturePath: 'swords/broad-sword.png',
19
+ itemId: 'itemId02',
20
+ name: 'Short sword',
21
+ price: 100,
22
+ key: 'Short sword',
23
+ },
24
+ {
25
+ texturePath: 'swords/broad-sword.png',
26
+ itemId: 'itemId03',
27
+ name: 'Short sword',
28
+ price: 100,
29
+ key: 'Short sword',
30
+ },
31
+ {
32
+ texturePath: 'swords/broad-sword.png',
33
+ itemId: 'itemId01',
34
+ name: 'Short sword',
35
+ price: 100,
36
+ key: 'Short sword',
37
+ },
38
+ {
39
+ texturePath: 'swords/broad-sword.png',
40
+ itemId: 'itemId02',
41
+ name: 'Short sword',
42
+ price: 100,
43
+ key: 'Short sword',
44
+ },
45
+ {
46
+ texturePath: 'swords/broad-sword.png',
47
+ itemId: 'itemId03',
48
+ name: 'Short sword',
49
+ price: 100,
50
+ key: 'Short sword',
51
+ },
52
+ {
53
+ texturePath: 'swords/broad-sword.png',
54
+ itemId: 'itemId01',
55
+ name: 'Short sword',
56
+ price: 100,
57
+ key: 'Short sword',
58
+ },
59
+ {
60
+ texturePath: 'swords/broad-sword.png',
61
+ itemId: 'itemId02',
62
+ name: 'Short sword',
63
+ price: 100,
64
+ key: 'Short sword',
65
+ },
66
+ {
67
+ texturePath: 'swords/broad-sword.png',
68
+ itemId: 'itemId03',
69
+ name: 'Short sword',
70
+ price: 100,
71
+ key: 'Short sword',
72
+ },
73
+ {
74
+ texturePath: 'swords/broad-sword.png',
75
+ itemId: 'itemId01',
76
+ name: 'Short sword',
77
+ price: 100,
78
+ key: 'Short sword',
79
+ },
80
+ {
81
+ texturePath: 'swords/broad-sword.png',
82
+ itemId: 'itemId02',
83
+ name: 'Short sword',
84
+ price: 100,
85
+ key: 'Short sword',
86
+ },
87
+
88
+ ];
@@ -4,25 +4,43 @@ import styled from 'styled-components';
4
4
  interface IProps {
5
5
  children: React.ReactNode;
6
6
  maxLines: 1 | 2 | 3;
7
+ maxWidth: number;
8
+ fontSize?: string;
7
9
  }
8
10
 
9
- export const Ellipsis = ({ children, maxLines }: IProps) => {
11
+ export const Ellipsis = ({
12
+ children,
13
+ maxLines,
14
+ maxWidth,
15
+ fontSize,
16
+ }: IProps) => {
10
17
  return (
11
- <Container>
12
- <div className={`ellipsis-${maxLines}-lines`}>{children}</div>
18
+ <Container maxWidth={maxWidth} fontSize={fontSize}>
19
+ <p className={`ellipsis-${maxLines}-lines`}>{children}</p>
13
20
  </Container>
14
21
  );
15
22
  };
16
23
 
17
- const Container = styled.div`
24
+ interface IContainerProps {
25
+ maxWidth: number;
26
+ fontSize?: string;
27
+ }
28
+
29
+ const Container = styled.div<IContainerProps>`
30
+ p {
31
+ font-size: ${props => props.fontSize || '1rem'};
32
+ }
33
+
18
34
  .ellipsis-1-lines {
19
35
  white-space: nowrap;
20
36
  text-overflow: ellipsis;
21
37
  overflow: hidden;
38
+ max-width: ${props => props.maxWidth}px;
22
39
  }
23
40
  .ellipsis-2-lines {
24
41
  display: -webkit-box;
25
- max-width: 100%;
42
+ max-width: ${props => props.maxWidth}px;
43
+
26
44
  height: 25px;
27
45
  margin: 0 auto;
28
46
  line-height: 1;
@@ -33,7 +51,8 @@ const Container = styled.div`
33
51
  }
34
52
  .ellipsis-3-lines {
35
53
  display: -webkit-box;
36
- max-width: 100%;
54
+ max-width: ${props => props.maxWidth}px;
55
+
37
56
  height: 43px;
38
57
  margin: 0 auto;
39
58
  line-height: 1;
package/src/index.tsx CHANGED
@@ -5,11 +5,13 @@ export * from './components/CheckButton';
5
5
  export * from './components/DraggableContainer';
6
6
  export * from './components/Dropdown';
7
7
  export * from './components/Equipment/EquipmentSet';
8
+ export * from './components/HistoryDialog';
8
9
  export * from './components/Input';
9
10
  export * from './components/Item/Inventory/ItemContainer';
10
11
  export * from './components/Item/Inventory/ItemSlot';
11
12
  export * from './components/ListMenu';
12
13
  export * from './components/NPCDialog/NPCDialog';
14
+ export * from './components/NPCDialog/NPCMultiDialog';
13
15
  export * from './components/NPCDialog/QuestionDialog/QuestionDialog';
14
16
  export * from './components/ProgressBar';
15
17
  export * from './components/PropertySelect/PropertySelect';
@@ -23,8 +25,7 @@ export * from './components/shared/SpriteFromAtlas';
23
25
  export * from './components/SkillProgressBar';
24
26
  export * from './components/SkillsContainer';
25
27
  export * from './components/TextArea';
28
+ export * from './components/TradingMenu/TradingMenu';
26
29
  export * from './components/Truncate';
27
30
  export * from './components/typography/DynamicText';
28
- export * from './components/NPCDialog/NPCMultiDialog';
29
- export * from './components/HistoryDialog';
30
31
  export { useEventListener } from './hooks/useEventListener';
Binary file
@@ -0,0 +1,26 @@
1
+ import { Meta, Story } from '@storybook/react';
2
+ import React from 'react';
3
+ import { RPGUIRoot } from '..';
4
+ import SelectArrow, { ArrowBarProps } from '../components/Arrow/SelectArrow';
5
+
6
+ const meta: Meta = {
7
+ title: 'Arrow',
8
+ component: SelectArrow,
9
+ };
10
+
11
+ export default meta;
12
+
13
+ const Template: Story<ArrowBarProps> = args => (
14
+ <RPGUIRoot>
15
+ <SelectArrow {...args} />
16
+ </RPGUIRoot>
17
+ );
18
+
19
+ export const Default = Template.bind({});
20
+
21
+ Default.args = {
22
+ direction: 'left',
23
+ onClick: () => {
24
+ console.log('clicked');
25
+ },
26
+ };
@@ -0,0 +1,39 @@
1
+ import { ITransactionItem } from '@rpg-engine/shared';
2
+ import { Meta, Story } from '@storybook/react';
3
+ import React from 'react';
4
+ import { RPGUIRoot } from '../components/RPGUIRoot';
5
+ import { itemMock } from '../components/TradingMenu/items.mock';
6
+ import {
7
+ ITradeComponentProps,
8
+ TradingItemRow,
9
+ } from '../components/TradingMenu/TradingItemRow';
10
+ import atlasJSON from '../mocks/atlas/items/items.json';
11
+ import atlasIMG from '../mocks/atlas/items/items.png';
12
+
13
+ const updateChartTotals = (itemInfo: ITransactionItem) => {
14
+ console.log(itemInfo);
15
+ // will be needed read all itens from chart list ignoring the current item (itemInfo) and recalculate the totals
16
+ // with the amount updated set the total to a state to be shown to the player.
17
+ // OBS: This list with Id, quantity and amount will be the one to send to API,
18
+ // because the API need to know wichi Items and the quantity of it to make a purchese and set the itens to the player.
19
+ };
20
+
21
+ const meta: Meta = {
22
+ title: 'Trading Item',
23
+ component: TradingItemRow,
24
+ };
25
+ export default meta;
26
+
27
+ const Template: Story<ITradeComponentProps> = args => (
28
+ <RPGUIRoot>
29
+ <TradingItemRow {...args} traderItem={itemMock[0]} />
30
+ </RPGUIRoot>
31
+ );
32
+
33
+ export const Default = Template.bind({});
34
+
35
+ Default.args = {
36
+ atlasIMG: atlasIMG,
37
+ atlasJSON: atlasJSON,
38
+ updateChartTotals,
39
+ };
@@ -1,6 +1,8 @@
1
1
  import { Meta, Story } from '@storybook/react';
2
2
  import React from 'react';
3
3
  import { RPGUIRoot } from '../../src/components/RPGUIRoot';
4
+ import atlasJSON from '../mocks/atlas/items/items.json';
5
+ import atlasIMG from '../mocks/atlas/items/items.png';
4
6
  import {
5
7
  ISkillProgressBarProps,
6
8
  SkillProgressBar,
@@ -27,4 +29,6 @@ Default.args = {
27
29
  skillPoints: 10,
28
30
  skillPointsToNextLevel: 100,
29
31
  texturePath: 'swords/broad-sword.png',
32
+ atlasIMG: atlasIMG,
33
+ atlasJSON: atlasJSON,
30
34
  };
@@ -6,6 +6,8 @@ import {
6
6
  SkillsContainer,
7
7
  } from '../../src/components/SkillsContainer';
8
8
  import { skillMock } from '../../src/mocks/skills.mocks';
9
+ import atlasJSON from '../mocks/atlas/items/items.json';
10
+ import atlasIMG from '../mocks/atlas/items/items.png';
9
11
 
10
12
  const meta: Meta = {
11
13
  title: 'Skills Container',
@@ -20,6 +22,8 @@ const Template: Story<ISkillContainerProps> = args => (
20
22
  {...args}
21
23
  skill={skillMock}
22
24
  onCloseButton={() => console.log('close skill container')}
25
+ atlasIMG={atlasIMG}
26
+ atlasJSON={atlasJSON}
23
27
  />
24
28
  </RPGUIRoot>
25
29
  );
@@ -0,0 +1,38 @@
1
+ import { Meta, Story } from '@storybook/react';
2
+ import React from 'react';
3
+ import { RPGUIRoot } from '../components/RPGUIRoot';
4
+ import { itemMock } from '../components/TradingMenu/items.mock';
5
+ import {
6
+ ITrandingMenu,
7
+ TradingMenu,
8
+ } from '../components/TradingMenu/TradingMenu';
9
+ import atlasJSON from '../mocks/atlas/items/items.json';
10
+ import atlasIMG from '../mocks/atlas/items/items.png';
11
+
12
+ const meta: Meta = {
13
+ title: 'Trading Menu',
14
+ component: TradingMenu,
15
+ };
16
+
17
+ export default meta;
18
+
19
+ const Template: Story<ITrandingMenu> = args => (
20
+ <RPGUIRoot>
21
+ <TradingMenu {...args} />
22
+ </RPGUIRoot>
23
+ );
24
+
25
+ export const Default = Template.bind({});
26
+
27
+ const onClose = () => {
28
+ console.log('close');
29
+ };
30
+
31
+ Default.args = {
32
+ traderItems: itemMock,
33
+ onClose: onClose,
34
+ type: 'buy',
35
+ atlasJSON: atlasJSON,
36
+ atlasIMG: atlasIMG,
37
+ characterAvailableGold: 1000,
38
+ };