@rpg-engine/long-bow 0.8.130 → 0.8.133
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/Store/PaymentMethodModal.d.ts +8 -0
- package/dist/components/Store/Store.d.ts +3 -0
- package/dist/index.d.ts +1 -0
- package/dist/long-bow.cjs.development.js +78 -10
- 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 +79 -12
- package/dist/long-bow.esm.js.map +1 -1
- package/package.json +1 -1
- package/src/components/Store/PaymentMethodModal.tsx +140 -0
- package/src/components/Store/Store.tsx +22 -7
- package/src/components/Store/StoreItemDetails.tsx +1 -0
- package/src/components/Store/StoreItemRow.tsx +4 -1
- package/src/index.tsx +1 -0
- package/src/stories/Features/store/Store.stories.tsx +2 -0
package/package.json
CHANGED
|
@@ -0,0 +1,140 @@
|
|
|
1
|
+
import React, { useCallback } from 'react';
|
|
2
|
+
import { FaCreditCard } from 'react-icons/fa';
|
|
3
|
+
import { GiCrystalBall } from 'react-icons/gi';
|
|
4
|
+
import styled from 'styled-components';
|
|
5
|
+
import ModalPortal from '../Abstractions/ModalPortal';
|
|
6
|
+
import { Button, ButtonTypes } from '../Button';
|
|
7
|
+
|
|
8
|
+
export interface IPaymentMethodModalProps {
|
|
9
|
+
dcBalance: number;
|
|
10
|
+
onPayWithDC: () => void;
|
|
11
|
+
onPayWithCard: () => void;
|
|
12
|
+
onClose: () => void;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
export const PaymentMethodModal: React.FC<IPaymentMethodModalProps> = ({
|
|
16
|
+
dcBalance,
|
|
17
|
+
onPayWithDC,
|
|
18
|
+
onPayWithCard,
|
|
19
|
+
onClose,
|
|
20
|
+
}) => {
|
|
21
|
+
const stopPropagation = useCallback((e: React.MouseEvent | React.TouchEvent | React.PointerEvent) => {
|
|
22
|
+
e.stopPropagation();
|
|
23
|
+
}, []);
|
|
24
|
+
|
|
25
|
+
return (
|
|
26
|
+
<ModalPortal>
|
|
27
|
+
<Overlay onPointerDown={onClose} />
|
|
28
|
+
<ModalContainer>
|
|
29
|
+
<ModalContent
|
|
30
|
+
onClick={stopPropagation as React.MouseEventHandler}
|
|
31
|
+
onTouchStart={stopPropagation as React.TouchEventHandler}
|
|
32
|
+
onPointerDown={stopPropagation as React.PointerEventHandler}
|
|
33
|
+
>
|
|
34
|
+
<Title>How would you like to pay?</Title>
|
|
35
|
+
|
|
36
|
+
<OptionButton onClick={onPayWithDC} className="rpgui-button">
|
|
37
|
+
<GiCrystalBall />
|
|
38
|
+
<OptionLabel>
|
|
39
|
+
<span>Pay with DC</span>
|
|
40
|
+
<OptionBalance>{dcBalance.toLocaleString()} DC available</OptionBalance>
|
|
41
|
+
</OptionLabel>
|
|
42
|
+
</OptionButton>
|
|
43
|
+
|
|
44
|
+
<OptionButton onClick={onPayWithCard} className="rpgui-button">
|
|
45
|
+
<FaCreditCard />
|
|
46
|
+
<OptionLabel>
|
|
47
|
+
<span>Pay with Credit Card</span>
|
|
48
|
+
</OptionLabel>
|
|
49
|
+
</OptionButton>
|
|
50
|
+
|
|
51
|
+
<CancelWrapper>
|
|
52
|
+
<Button buttonType={ButtonTypes.RPGUIButton} onPointerDown={onClose}>
|
|
53
|
+
Cancel
|
|
54
|
+
</Button>
|
|
55
|
+
</CancelWrapper>
|
|
56
|
+
</ModalContent>
|
|
57
|
+
</ModalContainer>
|
|
58
|
+
</ModalPortal>
|
|
59
|
+
);
|
|
60
|
+
};
|
|
61
|
+
|
|
62
|
+
const Overlay = styled.div`
|
|
63
|
+
position: fixed;
|
|
64
|
+
inset: 0;
|
|
65
|
+
background: rgba(0, 0, 0, 0.65);
|
|
66
|
+
z-index: 1000;
|
|
67
|
+
`;
|
|
68
|
+
|
|
69
|
+
const ModalContainer = styled.div`
|
|
70
|
+
position: fixed;
|
|
71
|
+
inset: 0;
|
|
72
|
+
display: flex;
|
|
73
|
+
align-items: center;
|
|
74
|
+
justify-content: center;
|
|
75
|
+
z-index: 1001;
|
|
76
|
+
pointer-events: none;
|
|
77
|
+
`;
|
|
78
|
+
|
|
79
|
+
const ModalContent = styled.div`
|
|
80
|
+
background: #1a1a2e;
|
|
81
|
+
border: 2px solid #f59e0b;
|
|
82
|
+
border-radius: 8px;
|
|
83
|
+
padding: 24px;
|
|
84
|
+
min-width: 320px;
|
|
85
|
+
max-width: 90%;
|
|
86
|
+
display: flex;
|
|
87
|
+
flex-direction: column;
|
|
88
|
+
gap: 12px;
|
|
89
|
+
pointer-events: auto;
|
|
90
|
+
animation: scaleIn 0.2s ease-out;
|
|
91
|
+
|
|
92
|
+
@keyframes scaleIn {
|
|
93
|
+
from { transform: scale(0.85); opacity: 0; }
|
|
94
|
+
to { transform: scale(1); opacity: 1; }
|
|
95
|
+
}
|
|
96
|
+
`;
|
|
97
|
+
|
|
98
|
+
const Title = styled.h3`
|
|
99
|
+
margin: 0 0 8px;
|
|
100
|
+
font-family: 'Press Start 2P', cursive;
|
|
101
|
+
font-size: 0.75rem;
|
|
102
|
+
color: #fef08a;
|
|
103
|
+
text-align: center;
|
|
104
|
+
`;
|
|
105
|
+
|
|
106
|
+
const OptionButton = styled.button`
|
|
107
|
+
display: flex;
|
|
108
|
+
align-items: center;
|
|
109
|
+
gap: 12px;
|
|
110
|
+
width: 100%;
|
|
111
|
+
padding: 10px 14px;
|
|
112
|
+
cursor: pointer;
|
|
113
|
+
font-family: 'Press Start 2P', cursive;
|
|
114
|
+
font-size: 0.65rem;
|
|
115
|
+
|
|
116
|
+
svg {
|
|
117
|
+
font-size: 1.25rem;
|
|
118
|
+
flex-shrink: 0;
|
|
119
|
+
}
|
|
120
|
+
`;
|
|
121
|
+
|
|
122
|
+
const OptionLabel = styled.div`
|
|
123
|
+
display: flex;
|
|
124
|
+
flex-direction: column;
|
|
125
|
+
align-items: flex-start;
|
|
126
|
+
gap: 4px;
|
|
127
|
+
`;
|
|
128
|
+
|
|
129
|
+
const OptionBalance = styled.span`
|
|
130
|
+
font-size: 0.55rem;
|
|
131
|
+
color: #fef08a;
|
|
132
|
+
opacity: 0.8;
|
|
133
|
+
`;
|
|
134
|
+
|
|
135
|
+
const CancelWrapper = styled.div`
|
|
136
|
+
display: flex;
|
|
137
|
+
justify-content: center;
|
|
138
|
+
margin-top: 4px;
|
|
139
|
+
filter: grayscale(0.6);
|
|
140
|
+
`;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { IItemPack, IPurchase, IProductBlueprint, ItemRarities, ItemSubType, ItemType, UserAccountTypes, PaymentCurrency, PurchaseType } from '@rpg-engine/shared';
|
|
2
2
|
import React, { ReactNode, useMemo, useState } from 'react';
|
|
3
|
-
import { FaHistory, FaShoppingCart } from 'react-icons/fa';
|
|
3
|
+
import { FaHistory, FaShoppingCart, FaWallet } from 'react-icons/fa';
|
|
4
4
|
import styled from 'styled-components';
|
|
5
5
|
import { uiColors } from '../../constants/uiColors';
|
|
6
6
|
import { DraggableContainer } from '../DraggableContainer';
|
|
@@ -24,7 +24,10 @@ export interface IStoreProps {
|
|
|
24
24
|
atlasJSON: any;
|
|
25
25
|
atlasIMG: string;
|
|
26
26
|
onPurchase: (purchase: Partial<IPurchase>) => Promise<boolean>;
|
|
27
|
-
onShowHistory?: () => void;
|
|
27
|
+
onShowHistory?: () => void;
|
|
28
|
+
onShowWallet?: () => void;
|
|
29
|
+
walletLabel?: string;
|
|
30
|
+
packsTabLabel?: string;
|
|
28
31
|
userAccountType: UserAccountTypes;
|
|
29
32
|
loading?: boolean;
|
|
30
33
|
error?: string;
|
|
@@ -43,7 +46,9 @@ export const Store: React.FC<IStoreProps> = ({
|
|
|
43
46
|
atlasJSON,
|
|
44
47
|
atlasIMG,
|
|
45
48
|
onPurchase,
|
|
46
|
-
onShowHistory,
|
|
49
|
+
onShowHistory,
|
|
50
|
+
onShowWallet,
|
|
51
|
+
walletLabel,
|
|
47
52
|
userAccountType,
|
|
48
53
|
loading = false,
|
|
49
54
|
error,
|
|
@@ -54,6 +59,7 @@ export const Store: React.FC<IStoreProps> = ({
|
|
|
54
59
|
textInputItemKeys = [],
|
|
55
60
|
customPacksContent,
|
|
56
61
|
customWalletContent,
|
|
62
|
+
packsTabLabel = 'Packs',
|
|
57
63
|
}) => {
|
|
58
64
|
const [selectedPack, setSelectedPack] = useState<IItemPack | null>(null);
|
|
59
65
|
const [activeTab, setActiveTab] = useState<TabId>(() => {
|
|
@@ -167,7 +173,7 @@ export const Store: React.FC<IStoreProps> = ({
|
|
|
167
173
|
},
|
|
168
174
|
packs: {
|
|
169
175
|
id: 'packs',
|
|
170
|
-
title:
|
|
176
|
+
title: packsTabLabel,
|
|
171
177
|
content: customPacksContent ?? (
|
|
172
178
|
<StorePacksSection
|
|
173
179
|
packs={packs.filter(pack => pack.priceUSD < 9.99)}
|
|
@@ -242,7 +248,7 @@ export const Store: React.FC<IStoreProps> = ({
|
|
|
242
248
|
) : (
|
|
243
249
|
<Container>
|
|
244
250
|
<TopBar>
|
|
245
|
-
<
|
|
251
|
+
<LeftButtons>
|
|
246
252
|
{onShowHistory && (
|
|
247
253
|
<CTAButton
|
|
248
254
|
icon={<FaHistory />}
|
|
@@ -250,7 +256,14 @@ export const Store: React.FC<IStoreProps> = ({
|
|
|
250
256
|
onClick={onShowHistory}
|
|
251
257
|
/>
|
|
252
258
|
)}
|
|
253
|
-
|
|
259
|
+
{onShowWallet && (
|
|
260
|
+
<CTAButton
|
|
261
|
+
icon={<FaWallet />}
|
|
262
|
+
label={walletLabel ?? 'DC Wallet'}
|
|
263
|
+
onClick={onShowWallet}
|
|
264
|
+
/>
|
|
265
|
+
)}
|
|
266
|
+
</LeftButtons>
|
|
254
267
|
<CartButton>
|
|
255
268
|
<CTAButton
|
|
256
269
|
icon={<FaShoppingCart />}
|
|
@@ -316,7 +329,9 @@ const TopBar = styled.div`
|
|
|
316
329
|
margin-top: 0.5rem;
|
|
317
330
|
`;
|
|
318
331
|
|
|
319
|
-
const
|
|
332
|
+
const LeftButtons = styled.div`
|
|
333
|
+
display: flex;
|
|
334
|
+
gap: 0.5rem;
|
|
320
335
|
min-width: fit-content;
|
|
321
336
|
margin-right: auto;
|
|
322
337
|
`;
|
|
@@ -44,6 +44,7 @@ export const StoreItemDetails: React.FC<IStoreItemDetailsProps> = ({
|
|
|
44
44
|
<ItemName>{item.name}</ItemName>
|
|
45
45
|
<ItemPrice>
|
|
46
46
|
${'priceUSD' in item ? item.priceUSD : item.price}
|
|
47
|
+
{(item as any).dcPrice ? ` · ${((item as any).dcPrice as number).toLocaleString()} DC` : ''}
|
|
47
48
|
</ItemPrice>
|
|
48
49
|
<Description>{item.description}</Description>
|
|
49
50
|
</ItemInfo>
|
|
@@ -71,7 +71,10 @@ export const StoreItemRow: React.FC<IStoreItemRowProps> = ({
|
|
|
71
71
|
|
|
72
72
|
<ItemDetails>
|
|
73
73
|
<ItemName>{item.name}</ItemName>
|
|
74
|
-
<ItemPrice
|
|
74
|
+
<ItemPrice>
|
|
75
|
+
${item.price}
|
|
76
|
+
{(item as any).dcPrice ? ` · ${((item as any).dcPrice as number).toLocaleString()} DC` : ''}
|
|
77
|
+
</ItemPrice>
|
|
75
78
|
<ItemDescription>{item.description}</ItemDescription>
|
|
76
79
|
</ItemDetails>
|
|
77
80
|
|
package/src/index.tsx
CHANGED
|
@@ -61,6 +61,7 @@ export * from './components/Store/CartView';
|
|
|
61
61
|
export * from './components/Store/hooks/useStoreCart';
|
|
62
62
|
export * from './components/Store/MetadataCollector';
|
|
63
63
|
export * from './components/Store/Store';
|
|
64
|
+
export * from './components/Store/PaymentMethodModal';
|
|
64
65
|
export * from './components/Table/Table';
|
|
65
66
|
export * from './components/TextArea';
|
|
66
67
|
export * from './components/TimeWidget/TimeWidget';
|
|
@@ -230,6 +230,8 @@ export const Default: Story = {
|
|
|
230
230
|
return Promise.resolve(true);
|
|
231
231
|
}}
|
|
232
232
|
onShowHistory={() => console.log('Show History clicked in story')}
|
|
233
|
+
onShowWallet={() => console.log('DC Wallet clicked in story')}
|
|
234
|
+
walletLabel="DC Wallet: 1,200"
|
|
233
235
|
onClose={() => console.log('Store closed')}
|
|
234
236
|
atlasJSON={itemsAtlasJSON}
|
|
235
237
|
atlasIMG={itemsAtlasIMG}
|