@rpg-engine/long-bow 0.8.131 → 0.8.134
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 +1 -0
- package/dist/index.d.ts +1 -0
- package/dist/long-bow.cjs.development.js +122 -8
- 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 +122 -9
- package/dist/long-bow.esm.js.map +1 -1
- package/package.json +1 -1
- package/src/components/Store/PaymentMethodModal.tsx +219 -0
- package/src/components/Store/Store.tsx +3 -1
- 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,219 @@
|
|
|
1
|
+
import React, { useCallback, useState } from 'react';
|
|
2
|
+
import { FaTimes } from 'react-icons/fa';
|
|
3
|
+
import styled from 'styled-components';
|
|
4
|
+
import ModalPortal from '../Abstractions/ModalPortal';
|
|
5
|
+
import { Button, ButtonTypes } from '../Button';
|
|
6
|
+
|
|
7
|
+
export interface IPaymentMethodModalProps {
|
|
8
|
+
dcBalance: number;
|
|
9
|
+
onPayWithDC: () => void;
|
|
10
|
+
onPayWithCard: () => void;
|
|
11
|
+
onClose: () => void;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
type PaymentMethod = 'dc' | 'card';
|
|
15
|
+
|
|
16
|
+
export const PaymentMethodModal: React.FC<IPaymentMethodModalProps> = ({
|
|
17
|
+
dcBalance,
|
|
18
|
+
onPayWithDC,
|
|
19
|
+
onPayWithCard,
|
|
20
|
+
onClose,
|
|
21
|
+
}) => {
|
|
22
|
+
const [selected, setSelected] = useState<PaymentMethod>('card');
|
|
23
|
+
|
|
24
|
+
const stopPropagation = useCallback(
|
|
25
|
+
(e: React.MouseEvent | React.TouchEvent | React.PointerEvent) => {
|
|
26
|
+
e.stopPropagation();
|
|
27
|
+
},
|
|
28
|
+
[]
|
|
29
|
+
);
|
|
30
|
+
|
|
31
|
+
const handleConfirm = useCallback(() => {
|
|
32
|
+
if (selected === 'dc') {
|
|
33
|
+
onPayWithDC();
|
|
34
|
+
} else {
|
|
35
|
+
onPayWithCard();
|
|
36
|
+
}
|
|
37
|
+
}, [selected, onPayWithDC, onPayWithCard]);
|
|
38
|
+
|
|
39
|
+
return (
|
|
40
|
+
<ModalPortal>
|
|
41
|
+
<Overlay onPointerDown={onClose} />
|
|
42
|
+
<ModalContainer>
|
|
43
|
+
<ModalContent
|
|
44
|
+
onClick={stopPropagation as React.MouseEventHandler}
|
|
45
|
+
onTouchStart={stopPropagation as React.TouchEventHandler}
|
|
46
|
+
onPointerDown={stopPropagation as React.PointerEventHandler}
|
|
47
|
+
>
|
|
48
|
+
<Header>
|
|
49
|
+
<Title>How would you like to pay?</Title>
|
|
50
|
+
<CloseButton onPointerDown={onClose} aria-label="Close">
|
|
51
|
+
<FaTimes />
|
|
52
|
+
</CloseButton>
|
|
53
|
+
</Header>
|
|
54
|
+
|
|
55
|
+
<Options>
|
|
56
|
+
<RadioOption
|
|
57
|
+
$selected={selected === 'card'}
|
|
58
|
+
onPointerDown={() => setSelected('card')}
|
|
59
|
+
>
|
|
60
|
+
<RadioCircle $selected={selected === 'card'} />
|
|
61
|
+
<OptionText>
|
|
62
|
+
<OptionLabel>Credit Card</OptionLabel>
|
|
63
|
+
<OptionSub>Stripe secure checkout</OptionSub>
|
|
64
|
+
</OptionText>
|
|
65
|
+
</RadioOption>
|
|
66
|
+
|
|
67
|
+
<RadioOption
|
|
68
|
+
$selected={selected === 'dc'}
|
|
69
|
+
onPointerDown={() => setSelected('dc')}
|
|
70
|
+
>
|
|
71
|
+
<RadioCircle $selected={selected === 'dc'} />
|
|
72
|
+
<OptionText>
|
|
73
|
+
<OptionLabel>Definya Coin</OptionLabel>
|
|
74
|
+
<OptionSub>{dcBalance.toLocaleString()} DC available</OptionSub>
|
|
75
|
+
</OptionText>
|
|
76
|
+
</RadioOption>
|
|
77
|
+
</Options>
|
|
78
|
+
|
|
79
|
+
<ConfirmRow>
|
|
80
|
+
<Button buttonType={ButtonTypes.RPGUIButton} onPointerDown={handleConfirm}>
|
|
81
|
+
Confirm
|
|
82
|
+
</Button>
|
|
83
|
+
</ConfirmRow>
|
|
84
|
+
</ModalContent>
|
|
85
|
+
</ModalContainer>
|
|
86
|
+
</ModalPortal>
|
|
87
|
+
);
|
|
88
|
+
};
|
|
89
|
+
|
|
90
|
+
const Overlay = styled.div`
|
|
91
|
+
position: fixed;
|
|
92
|
+
inset: 0;
|
|
93
|
+
background: rgba(0, 0, 0, 0.65);
|
|
94
|
+
z-index: 1000;
|
|
95
|
+
`;
|
|
96
|
+
|
|
97
|
+
const ModalContainer = styled.div`
|
|
98
|
+
position: fixed;
|
|
99
|
+
inset: 0;
|
|
100
|
+
display: flex;
|
|
101
|
+
align-items: center;
|
|
102
|
+
justify-content: center;
|
|
103
|
+
z-index: 1001;
|
|
104
|
+
pointer-events: none;
|
|
105
|
+
`;
|
|
106
|
+
|
|
107
|
+
const ModalContent = styled.div`
|
|
108
|
+
background: #1a1a2e;
|
|
109
|
+
border: 2px solid #f59e0b;
|
|
110
|
+
border-radius: 8px;
|
|
111
|
+
padding: 20px 24px 24px;
|
|
112
|
+
min-width: 300px;
|
|
113
|
+
max-width: 90%;
|
|
114
|
+
display: flex;
|
|
115
|
+
flex-direction: column;
|
|
116
|
+
gap: 16px;
|
|
117
|
+
pointer-events: auto;
|
|
118
|
+
animation: scaleIn 0.15s ease-out;
|
|
119
|
+
|
|
120
|
+
@keyframes scaleIn {
|
|
121
|
+
from { transform: scale(0.85); opacity: 0; }
|
|
122
|
+
to { transform: scale(1); opacity: 1; }
|
|
123
|
+
}
|
|
124
|
+
`;
|
|
125
|
+
|
|
126
|
+
const Header = styled.div`
|
|
127
|
+
display: flex;
|
|
128
|
+
align-items: center;
|
|
129
|
+
justify-content: space-between;
|
|
130
|
+
`;
|
|
131
|
+
|
|
132
|
+
const Title = styled.h3`
|
|
133
|
+
margin: 0;
|
|
134
|
+
font-family: 'Press Start 2P', cursive;
|
|
135
|
+
font-size: 0.7rem;
|
|
136
|
+
color: #fef08a;
|
|
137
|
+
`;
|
|
138
|
+
|
|
139
|
+
const CloseButton = styled.button`
|
|
140
|
+
background: none;
|
|
141
|
+
border: none;
|
|
142
|
+
color: rgba(255, 255, 255, 0.6);
|
|
143
|
+
cursor: pointer;
|
|
144
|
+
font-size: 1rem;
|
|
145
|
+
padding: 4px;
|
|
146
|
+
display: flex;
|
|
147
|
+
align-items: center;
|
|
148
|
+
|
|
149
|
+
&:hover {
|
|
150
|
+
color: #ffffff;
|
|
151
|
+
}
|
|
152
|
+
`;
|
|
153
|
+
|
|
154
|
+
const Options = styled.div`
|
|
155
|
+
display: flex;
|
|
156
|
+
flex-direction: column;
|
|
157
|
+
gap: 8px;
|
|
158
|
+
`;
|
|
159
|
+
|
|
160
|
+
const RadioOption = styled.div<{ $selected: boolean }>`
|
|
161
|
+
display: flex;
|
|
162
|
+
align-items: center;
|
|
163
|
+
gap: 12px;
|
|
164
|
+
padding: 10px 12px;
|
|
165
|
+
border: 1px solid ${({ $selected }) => ($selected ? '#f59e0b' : 'rgba(255,255,255,0.15)')};
|
|
166
|
+
border-radius: 6px;
|
|
167
|
+
background: ${({ $selected }) => ($selected ? 'rgba(245,158,11,0.1)' : 'transparent')};
|
|
168
|
+
cursor: pointer;
|
|
169
|
+
transition: border-color 0.15s, background 0.15s;
|
|
170
|
+
|
|
171
|
+
&:hover {
|
|
172
|
+
border-color: #f59e0b;
|
|
173
|
+
}
|
|
174
|
+
`;
|
|
175
|
+
|
|
176
|
+
const RadioCircle = styled.div<{ $selected: boolean }>`
|
|
177
|
+
width: 16px;
|
|
178
|
+
height: 16px;
|
|
179
|
+
border-radius: 50%;
|
|
180
|
+
border: 2px solid ${({ $selected }) => ($selected ? '#f59e0b' : 'rgba(255,255,255,0.4)')};
|
|
181
|
+
display: flex;
|
|
182
|
+
align-items: center;
|
|
183
|
+
justify-content: center;
|
|
184
|
+
flex-shrink: 0;
|
|
185
|
+
|
|
186
|
+
&::after {
|
|
187
|
+
content: '';
|
|
188
|
+
width: 8px;
|
|
189
|
+
height: 8px;
|
|
190
|
+
border-radius: 50%;
|
|
191
|
+
background: #f59e0b;
|
|
192
|
+
opacity: ${({ $selected }) => ($selected ? 1 : 0)};
|
|
193
|
+
transition: opacity 0.15s;
|
|
194
|
+
}
|
|
195
|
+
`;
|
|
196
|
+
|
|
197
|
+
const OptionText = styled.div`
|
|
198
|
+
display: flex;
|
|
199
|
+
flex-direction: column;
|
|
200
|
+
gap: 3px;
|
|
201
|
+
`;
|
|
202
|
+
|
|
203
|
+
const OptionLabel = styled.span`
|
|
204
|
+
font-family: 'Press Start 2P', cursive;
|
|
205
|
+
font-size: 0.65rem;
|
|
206
|
+
color: #ffffff;
|
|
207
|
+
`;
|
|
208
|
+
|
|
209
|
+
const OptionSub = styled.span`
|
|
210
|
+
font-family: 'Press Start 2P', cursive;
|
|
211
|
+
font-size: 0.5rem;
|
|
212
|
+
color: rgba(255, 255, 255, 0.55);
|
|
213
|
+
`;
|
|
214
|
+
|
|
215
|
+
const ConfirmRow = styled.div`
|
|
216
|
+
display: flex;
|
|
217
|
+
justify-content: center;
|
|
218
|
+
margin-top: 4px;
|
|
219
|
+
`;
|
|
@@ -27,6 +27,7 @@ export interface IStoreProps {
|
|
|
27
27
|
onShowHistory?: () => void;
|
|
28
28
|
onShowWallet?: () => void;
|
|
29
29
|
walletLabel?: string;
|
|
30
|
+
packsTabLabel?: string;
|
|
30
31
|
userAccountType: UserAccountTypes;
|
|
31
32
|
loading?: boolean;
|
|
32
33
|
error?: string;
|
|
@@ -58,6 +59,7 @@ export const Store: React.FC<IStoreProps> = ({
|
|
|
58
59
|
textInputItemKeys = [],
|
|
59
60
|
customPacksContent,
|
|
60
61
|
customWalletContent,
|
|
62
|
+
packsTabLabel = 'Packs',
|
|
61
63
|
}) => {
|
|
62
64
|
const [selectedPack, setSelectedPack] = useState<IItemPack | null>(null);
|
|
63
65
|
const [activeTab, setActiveTab] = useState<TabId>(() => {
|
|
@@ -171,7 +173,7 @@ export const Store: React.FC<IStoreProps> = ({
|
|
|
171
173
|
},
|
|
172
174
|
packs: {
|
|
173
175
|
id: 'packs',
|
|
174
|
-
title:
|
|
176
|
+
title: packsTabLabel,
|
|
175
177
|
content: customPacksContent ?? (
|
|
176
178
|
<StorePacksSection
|
|
177
179
|
packs={packs.filter(pack => pack.priceUSD < 9.99)}
|
|
@@ -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}
|