@rpg-engine/long-bow 0.7.16 → 0.7.17
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.
- package/dist/components/Arrow/SelectArrow.d.ts +1 -0
- package/dist/long-bow.cjs.development.js +48 -21
- package/dist/long-bow.cjs.development.js.map +1 -1
- package/dist/long-bow.cjs.production.min.js +1 -1
- package/dist/long-bow.cjs.production.min.js.map +1 -1
- package/dist/long-bow.esm.js +48 -21
- package/dist/long-bow.esm.js.map +1 -1
- package/package.json +1 -1
- package/src/components/Arrow/SelectArrow.tsx +7 -0
- package/src/components/TradingMenu/TradingItemRow.tsx +41 -20
package/package.json
CHANGED
|
@@ -9,11 +9,13 @@ export interface ArrowBarProps extends React.HTMLAttributes<HTMLDivElement> {
|
|
|
9
9
|
direction: 'right' | 'left';
|
|
10
10
|
onPointerDown: () => void;
|
|
11
11
|
size?: number;
|
|
12
|
+
scale?: number;
|
|
12
13
|
}
|
|
13
14
|
|
|
14
15
|
export const SelectArrow: React.FC<ArrowBarProps> = ({
|
|
15
16
|
direction = 'left',
|
|
16
17
|
size,
|
|
18
|
+
scale = 1,
|
|
17
19
|
onPointerDown,
|
|
18
20
|
...props
|
|
19
21
|
}) => {
|
|
@@ -22,12 +24,14 @@ export const SelectArrow: React.FC<ArrowBarProps> = ({
|
|
|
22
24
|
{direction === 'left' ? (
|
|
23
25
|
<LeftArrow
|
|
24
26
|
size={size}
|
|
27
|
+
scale={scale}
|
|
25
28
|
onPointerDown={() => onPointerDown()}
|
|
26
29
|
{...props}
|
|
27
30
|
></LeftArrow>
|
|
28
31
|
) : (
|
|
29
32
|
<RightArrow
|
|
30
33
|
size={size}
|
|
34
|
+
scale={scale}
|
|
31
35
|
onPointerDown={() => onPointerDown()}
|
|
32
36
|
{...props}
|
|
33
37
|
></RightArrow>
|
|
@@ -38,6 +42,7 @@ export const SelectArrow: React.FC<ArrowBarProps> = ({
|
|
|
38
42
|
|
|
39
43
|
interface IArrowProps {
|
|
40
44
|
size?: number;
|
|
45
|
+
scale?: number;
|
|
41
46
|
}
|
|
42
47
|
|
|
43
48
|
const LeftArrow = styled.span<IArrowProps>`
|
|
@@ -47,6 +52,7 @@ const LeftArrow = styled.span<IArrowProps>`
|
|
|
47
52
|
position: absolute;
|
|
48
53
|
width: ${props => props.size || 40}px;
|
|
49
54
|
height: ${props => props.size || 42}px;
|
|
55
|
+
transform: scale(${props => props.scale || 1});
|
|
50
56
|
:active {
|
|
51
57
|
background-image: url(${LeftArrowClickIcon});
|
|
52
58
|
}
|
|
@@ -60,6 +66,7 @@ const RightArrow = styled.span<IArrowProps>`
|
|
|
60
66
|
width: ${props => props.size || 40}px;
|
|
61
67
|
height: ${props => props.size || 42}px;
|
|
62
68
|
background-size: 100% 100%;
|
|
69
|
+
transform: scale(${props => props.scale || 1});
|
|
63
70
|
:active {
|
|
64
71
|
background-image: url(${RightArrowClickIcon});
|
|
65
72
|
}
|
|
@@ -5,7 +5,7 @@ import {
|
|
|
5
5
|
UserAccountTypes,
|
|
6
6
|
} from '@rpg-engine/shared';
|
|
7
7
|
import capitalize from 'lodash/capitalize';
|
|
8
|
-
import React from 'react';
|
|
8
|
+
import React, { useEffect, useState } from 'react';
|
|
9
9
|
import styled from 'styled-components';
|
|
10
10
|
import { uiColors } from '../../constants/uiColors';
|
|
11
11
|
import { uiFonts } from '../../constants/uiFonts';
|
|
@@ -39,6 +39,30 @@ export const TradingItemRow: React.FC<ITradeComponentProps> = ({
|
|
|
39
39
|
scale,
|
|
40
40
|
isBuy,
|
|
41
41
|
}) => {
|
|
42
|
+
const [inputQty, setInputQty] = useState(selectedQty.toString());
|
|
43
|
+
|
|
44
|
+
useEffect(() => {
|
|
45
|
+
setInputQty(selectedQty.toString());
|
|
46
|
+
}, [selectedQty]);
|
|
47
|
+
|
|
48
|
+
const handleQuantityChange = (e: React.ChangeEvent<HTMLInputElement>) => {
|
|
49
|
+
const newQty = parseInt(e.target.value, 10);
|
|
50
|
+
if (!isNaN(newQty)) {
|
|
51
|
+
setInputQty(e.target.value);
|
|
52
|
+
onQuantityChange(
|
|
53
|
+
traderItem,
|
|
54
|
+
Math.max(0, Math.min(newQty, traderItem.stackQty ?? 999))
|
|
55
|
+
);
|
|
56
|
+
}
|
|
57
|
+
};
|
|
58
|
+
|
|
59
|
+
const handleBlur = () => {
|
|
60
|
+
const newQty = parseInt(inputQty, 10);
|
|
61
|
+
if (isNaN(newQty)) {
|
|
62
|
+
setInputQty(selectedQty.toString());
|
|
63
|
+
}
|
|
64
|
+
};
|
|
65
|
+
|
|
42
66
|
const onLeftClick = (qty = 1) => {
|
|
43
67
|
onQuantityChange(traderItem, Math.max(0, selectedQty - qty));
|
|
44
68
|
};
|
|
@@ -136,6 +160,7 @@ export const TradingItemRow: React.FC<ITradeComponentProps> = ({
|
|
|
136
160
|
className="arrow-selector"
|
|
137
161
|
direction="left"
|
|
138
162
|
onPointerDown={onLeftClick.bind(null, outerQty)}
|
|
163
|
+
scale={0.8}
|
|
139
164
|
/>
|
|
140
165
|
<StyledArrow
|
|
141
166
|
size={32}
|
|
@@ -143,11 +168,12 @@ export const TradingItemRow: React.FC<ITradeComponentProps> = ({
|
|
|
143
168
|
direction="left"
|
|
144
169
|
onPointerDown={onLeftClick}
|
|
145
170
|
/>
|
|
146
|
-
<
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
171
|
+
<QuantityInput
|
|
172
|
+
type="text"
|
|
173
|
+
value={inputQty}
|
|
174
|
+
onChange={handleQuantityChange}
|
|
175
|
+
onBlur={handleBlur}
|
|
176
|
+
/>
|
|
151
177
|
<StyledArrow
|
|
152
178
|
size={32}
|
|
153
179
|
className="arrow-selector"
|
|
@@ -159,6 +185,7 @@ export const TradingItemRow: React.FC<ITradeComponentProps> = ({
|
|
|
159
185
|
className="arrow-selector"
|
|
160
186
|
direction="right"
|
|
161
187
|
onPointerDown={onRightClick.bind(null, outerQty)}
|
|
188
|
+
scale={0.8}
|
|
162
189
|
/>
|
|
163
190
|
</QuantityContainer>
|
|
164
191
|
</ItemWrapper>
|
|
@@ -221,19 +248,6 @@ const NameValue = styled.div`
|
|
|
221
248
|
}
|
|
222
249
|
`;
|
|
223
250
|
|
|
224
|
-
const Item = styled.span`
|
|
225
|
-
color: white;
|
|
226
|
-
text-align: center;
|
|
227
|
-
z-index: 1;
|
|
228
|
-
|
|
229
|
-
width: 100%;
|
|
230
|
-
`;
|
|
231
|
-
|
|
232
|
-
const TextOverlay = styled.div`
|
|
233
|
-
width: 100%;
|
|
234
|
-
position: relative;
|
|
235
|
-
`;
|
|
236
|
-
|
|
237
251
|
interface IContainerProps {
|
|
238
252
|
percentageWidth?: number;
|
|
239
253
|
minWidth?: number;
|
|
@@ -252,6 +266,13 @@ const QuantityContainer = styled.div<IContainerProps>`
|
|
|
252
266
|
flex: 40%;
|
|
253
267
|
`;
|
|
254
268
|
|
|
255
|
-
const
|
|
269
|
+
const QuantityInput = styled.input`
|
|
270
|
+
width: 40px;
|
|
271
|
+
text-align: center;
|
|
272
|
+
background-color: ${uiColors.darkGray};
|
|
273
|
+
color: white;
|
|
274
|
+
border: 1px solid ${uiColors.lightGray};
|
|
275
|
+
padding: 2px;
|
|
256
276
|
font-size: ${uiFonts.size.small};
|
|
277
|
+
border: none;
|
|
257
278
|
`;
|