@rpg-engine/long-bow 0.6.1 → 0.6.2
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/Item/Inventory/ItemGem.d.ts +5 -6
- package/dist/components/Stepper.d.ts +14 -0
- package/dist/index.d.ts +1 -0
- package/dist/long-bow.cjs.development.js +113 -30
- 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 +113 -31
- package/dist/long-bow.esm.js.map +1 -1
- package/dist/stories/Stepper.stories.d.ts +5 -0
- package/package.json +1 -1
- package/src/components/Item/Inventory/ItemGem.tsx +51 -35
- package/src/components/Item/Inventory/ItemSlotRenderer.tsx +1 -3
- package/src/components/Stepper.tsx +115 -0
- package/src/components/TradingMenu/TradingMenu.tsx +2 -2
- package/src/index.tsx +1 -0
- package/src/mocks/itemContainer.mocks.ts +6 -6
- package/src/stories/Stepper.stories.tsx +48 -0
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { Meta } from '@storybook/react';
|
|
2
|
+
import { ArrowBarProps } from '../components/Arrow/SelectArrow';
|
|
3
|
+
declare const meta: Meta;
|
|
4
|
+
export default meta;
|
|
5
|
+
export declare const Default: import("@storybook/csf").AnnotatedStoryFn<import("@storybook/react").ReactFramework, ArrowBarProps>;
|
package/package.json
CHANGED
|
@@ -1,44 +1,48 @@
|
|
|
1
|
+
import { IItem } from '@rpg-engine/shared';
|
|
1
2
|
import React from 'react';
|
|
2
3
|
import styled from 'styled-components';
|
|
3
|
-
import { uiFonts } from '../../../constants/uiFonts';
|
|
4
|
-
import { Ellipsis } from '../../shared/Ellipsis';
|
|
5
4
|
|
|
6
5
|
interface IProps {
|
|
7
|
-
|
|
8
|
-
gemQty: number;
|
|
9
|
-
qtyClassName: string;
|
|
6
|
+
item: IItem;
|
|
10
7
|
}
|
|
11
8
|
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
9
|
+
const gemColors: { [key: string]: string } = {
|
|
10
|
+
'emerald-gem': '#50C878', // Emerald green
|
|
11
|
+
'topaz-radiance': '#FFC87C', // Topaz yellow
|
|
12
|
+
'sapphire-gem': '#0F52BA', // Sapphire blue
|
|
13
|
+
'ruby-gem': '#E0115F', // Ruby red
|
|
14
|
+
'misty-quartz-gem': '#D9D9F3', // Misty Quartz purple
|
|
15
|
+
'coral-reef-gem': '#FF7F50', // Coral reef orange
|
|
16
|
+
'jasper-gem': '#D73B3E', // Jasper red
|
|
17
|
+
'earthstone-gem': '#8B4513', // Earthstone brown
|
|
18
|
+
'obsidian-gem': '#0B0C0E', // Obsidian black
|
|
19
|
+
'amethyst-gem': '#9966CC', // Amethyst purple
|
|
20
|
+
};
|
|
21
|
+
|
|
22
|
+
const defaultColor = '#FFFFFF'; // Default color (white)
|
|
23
|
+
|
|
24
|
+
export const onRenderGems = (item: IItem) => {
|
|
25
|
+
const gemQty = item.attachedGems?.length || 0;
|
|
17
26
|
|
|
18
27
|
if (gemQty > 0) {
|
|
19
|
-
return
|
|
20
|
-
<ItemSlotQty
|
|
21
|
-
itemId={itemId}
|
|
22
|
-
gemQty={gemQty}
|
|
23
|
-
qtyClassName={qtyClassName}
|
|
24
|
-
/>
|
|
25
|
-
);
|
|
28
|
+
return <ItemSlotQty item={item} />;
|
|
26
29
|
}
|
|
27
30
|
return undefined;
|
|
28
31
|
};
|
|
29
32
|
|
|
30
|
-
export const ItemSlotQty = ({
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
}: IProps): JSX.Element => {
|
|
35
|
-
const gemArray = Array.from({ length: gemQty }, () => '🔶');
|
|
33
|
+
export const ItemSlotQty = ({ item }: IProps): JSX.Element => {
|
|
34
|
+
console.log(item.attachedGems);
|
|
35
|
+
|
|
36
|
+
const itemId = item._id;
|
|
36
37
|
|
|
37
38
|
return (
|
|
38
39
|
<ItemQtyContainer key={`qty-${itemId}`} className="item-slot-qty">
|
|
39
|
-
|
|
40
|
-
<
|
|
41
|
-
|
|
40
|
+
{item.attachedGems?.map((gem, index) => (
|
|
41
|
+
<Gem
|
|
42
|
+
key={`${itemId}-gem-${index}`}
|
|
43
|
+
color={gemColors[gem.key] || defaultColor}
|
|
44
|
+
/>
|
|
45
|
+
))}
|
|
42
46
|
</ItemQtyContainer>
|
|
43
47
|
);
|
|
44
48
|
};
|
|
@@ -47,18 +51,30 @@ const ItemQtyContainer = styled.div`
|
|
|
47
51
|
position: relative;
|
|
48
52
|
width: 85%;
|
|
49
53
|
height: 16px;
|
|
50
|
-
top:
|
|
51
|
-
left:
|
|
54
|
+
top: 26px;
|
|
55
|
+
left: -2px;
|
|
52
56
|
pointer-events: none;
|
|
53
|
-
|
|
57
|
+
transform: scale(0.8);
|
|
54
58
|
display: flex;
|
|
59
|
+
align-items: center;
|
|
60
|
+
justify-content: center;
|
|
61
|
+
opacity: 0.8;
|
|
55
62
|
`;
|
|
56
63
|
|
|
57
|
-
const
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
|
|
64
|
+
const Gem = styled.div<{ color: string }>`
|
|
65
|
+
width: 8px;
|
|
66
|
+
height: 8px;
|
|
67
|
+
background-color: ${({ color }) => color};
|
|
68
|
+
border: 1px solid black;
|
|
69
|
+
transform: rotate(45deg);
|
|
70
|
+
margin: 0 2px;
|
|
71
|
+
box-shadow: 0 0 5px ${({ color }) => color}; /* Glow effect */
|
|
72
|
+
transition: transform 0.2s, box-shadow 0.2s; /* Smooth transition for hover effect */
|
|
73
|
+
|
|
74
|
+
&:hover {
|
|
75
|
+
transform: rotate(45deg) scale(1.2);
|
|
76
|
+
box-shadow: 0 0 10px ${({ color }) => color}; /* Enhanced glow on hover */
|
|
63
77
|
}
|
|
64
78
|
`;
|
|
79
|
+
|
|
80
|
+
export default ItemSlotQty;
|
|
@@ -36,9 +36,7 @@ export const ItemSlotRenderer: React.FC<IProps> = ({
|
|
|
36
36
|
};
|
|
37
37
|
|
|
38
38
|
const renderGems = (item: IItem) => {
|
|
39
|
-
return (
|
|
40
|
-
item.attachedGems && onRenderGems(item._id, item.attachedGems.length)
|
|
41
|
-
);
|
|
39
|
+
return item.attachedGems && onRenderGems(item);
|
|
42
40
|
};
|
|
43
41
|
|
|
44
42
|
const renderItem = (item: IItem | null) => {
|
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
import React, { useState } from 'react';
|
|
2
|
+
import styled from 'styled-components';
|
|
3
|
+
import { uiColors } from '../constants/uiColors';
|
|
4
|
+
import SelectArrow from './Arrow/SelectArrow';
|
|
5
|
+
import { Button, ButtonTypes } from './Button';
|
|
6
|
+
|
|
7
|
+
interface IStep {
|
|
8
|
+
component: React.ReactNode;
|
|
9
|
+
id: number;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
interface IStepperProps {
|
|
13
|
+
steps: IStep[];
|
|
14
|
+
finalCTAButton?: {
|
|
15
|
+
label: string;
|
|
16
|
+
onClick: (() => void) | (() => Promise<void>) | ((e: any) => Promise<void>);
|
|
17
|
+
};
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
export const Stepper: React.FC<IStepperProps> = ({ steps, finalCTAButton }) => {
|
|
21
|
+
const [currentStep, setCurrentStep] = useState(0);
|
|
22
|
+
|
|
23
|
+
const currentComponent = steps[currentStep]?.component;
|
|
24
|
+
|
|
25
|
+
const totalSteps = steps.length;
|
|
26
|
+
|
|
27
|
+
const onStepChange = (step: number) => {
|
|
28
|
+
setCurrentStep(step);
|
|
29
|
+
};
|
|
30
|
+
|
|
31
|
+
return (
|
|
32
|
+
<StepperContainer className="stepper-container">
|
|
33
|
+
<StepperTop>
|
|
34
|
+
{Array.from({ length: totalSteps }, (_, i) => (
|
|
35
|
+
<ProgressIndicator
|
|
36
|
+
key={i}
|
|
37
|
+
isActive={i <= currentStep}
|
|
38
|
+
onClick={() => onStepChange(i)}
|
|
39
|
+
/>
|
|
40
|
+
))}
|
|
41
|
+
</StepperTop>
|
|
42
|
+
|
|
43
|
+
<StepperBody>{currentComponent}</StepperBody>
|
|
44
|
+
|
|
45
|
+
<StepperFooter>
|
|
46
|
+
{currentStep > 0 && (
|
|
47
|
+
<SelectArrow
|
|
48
|
+
direction="left"
|
|
49
|
+
onPointerDown={() => onStepChange(Math.max(0, currentStep - 1))}
|
|
50
|
+
/>
|
|
51
|
+
)}
|
|
52
|
+
|
|
53
|
+
{currentStep < totalSteps - 1 && (
|
|
54
|
+
<SelectArrow
|
|
55
|
+
direction="right"
|
|
56
|
+
onPointerDown={() =>
|
|
57
|
+
onStepChange(Math.min(totalSteps - 1, currentStep + 1))
|
|
58
|
+
}
|
|
59
|
+
/>
|
|
60
|
+
)}
|
|
61
|
+
|
|
62
|
+
{currentStep === totalSteps - 1 && finalCTAButton && (
|
|
63
|
+
<Button
|
|
64
|
+
buttonType={ButtonTypes.RPGUIButton}
|
|
65
|
+
onPointerDown={() => finalCTAButton.onClick}
|
|
66
|
+
>
|
|
67
|
+
{finalCTAButton.label}
|
|
68
|
+
</Button>
|
|
69
|
+
)}
|
|
70
|
+
</StepperFooter>
|
|
71
|
+
</StepperContainer>
|
|
72
|
+
);
|
|
73
|
+
};
|
|
74
|
+
|
|
75
|
+
const StepperContainer = styled.div`
|
|
76
|
+
display: flex;
|
|
77
|
+
flex-direction: column;
|
|
78
|
+
height: 100%; // Ensure the container takes up full height
|
|
79
|
+
`;
|
|
80
|
+
|
|
81
|
+
const StepperTop = styled.div`
|
|
82
|
+
flex: 1; // Small top
|
|
83
|
+
|
|
84
|
+
display: flex;
|
|
85
|
+
flex-wrap: wrap;
|
|
86
|
+
justify-content: center;
|
|
87
|
+
align-items: center;
|
|
88
|
+
|
|
89
|
+
margin-bottom: 1rem;
|
|
90
|
+
`;
|
|
91
|
+
|
|
92
|
+
const StepperBody = styled.div`
|
|
93
|
+
flex: 8; // Big content space
|
|
94
|
+
`;
|
|
95
|
+
|
|
96
|
+
const StepperFooter = styled.div`
|
|
97
|
+
margin-top: 1rem;
|
|
98
|
+
flex: 1; // Small footer
|
|
99
|
+
|
|
100
|
+
display: flex;
|
|
101
|
+
justify-content: flex-end;
|
|
102
|
+
`;
|
|
103
|
+
|
|
104
|
+
const ProgressIndicator = styled.div<{ isActive: boolean }>`
|
|
105
|
+
width: 20px;
|
|
106
|
+
height: 20px;
|
|
107
|
+
border-radius: 50%;
|
|
108
|
+
background-color: ${({ isActive }) =>
|
|
109
|
+
isActive ? uiColors.orange : uiColors.lightGray};
|
|
110
|
+
margin: 0 5px;
|
|
111
|
+
transition: background-color 0.3s;
|
|
112
|
+
opacity: ${({ isActive }) => (isActive ? 1 : 0.25)};
|
|
113
|
+
border: 1px solid ${uiColors.raisinBlack};
|
|
114
|
+
cursor: pointer;
|
|
115
|
+
`;
|
|
@@ -117,7 +117,7 @@ export const TradingMenu: React.FC<ITradingMenu> = ({
|
|
|
117
117
|
</TradingComponentScrollWrapper>
|
|
118
118
|
<GoldWrapper>
|
|
119
119
|
<p>Available Gold:</p>
|
|
120
|
-
<p>${characterAvailableGold}</p>
|
|
120
|
+
<p>${characterAvailableGold.toFixed(2)}</p>
|
|
121
121
|
</GoldWrapper>
|
|
122
122
|
<TotalWrapper>
|
|
123
123
|
<p>Total:</p>
|
|
@@ -130,7 +130,7 @@ export const TradingMenu: React.FC<ITradingMenu> = ({
|
|
|
130
130
|
) : (
|
|
131
131
|
<GoldWrapper>
|
|
132
132
|
<p>Final Gold:</p>
|
|
133
|
-
<p>${getFinalGold()}</p>
|
|
133
|
+
<p>${getFinalGold().toFixed(2)}</p>
|
|
134
134
|
</GoldWrapper>
|
|
135
135
|
)}
|
|
136
136
|
|
package/src/index.tsx
CHANGED
|
@@ -40,6 +40,7 @@ export * from './components/Shortcuts/Shortcuts';
|
|
|
40
40
|
export * from './components/SkillProgressBar';
|
|
41
41
|
export * from './components/SkillsContainer';
|
|
42
42
|
export * from './components/Spellbook/Spellbook';
|
|
43
|
+
export * from './components/Stepper';
|
|
43
44
|
export * from './components/TextArea';
|
|
44
45
|
export * from './components/TimeWidget/TimeWidget';
|
|
45
46
|
export * from './components/TradingMenu/TradingMenu';
|
|
@@ -57,8 +57,8 @@ export const items: IItem[] = [
|
|
|
57
57
|
attachedGems: [
|
|
58
58
|
{
|
|
59
59
|
gemEntityEffectsAdd: ['poison'],
|
|
60
|
-
key: '
|
|
61
|
-
name: '
|
|
60
|
+
key: 'ruby-gem',
|
|
61
|
+
name: 'Ruby Gem',
|
|
62
62
|
gemStatBuff: {
|
|
63
63
|
attack: 5,
|
|
64
64
|
defense: 4,
|
|
@@ -66,8 +66,8 @@ export const items: IItem[] = [
|
|
|
66
66
|
},
|
|
67
67
|
{
|
|
68
68
|
gemEntityEffectsAdd: ['poison'],
|
|
69
|
-
key: '
|
|
70
|
-
name: '
|
|
69
|
+
key: 'misty-quartz-gem',
|
|
70
|
+
name: 'Misty Quartz Gem',
|
|
71
71
|
gemStatBuff: {
|
|
72
72
|
attack: 5,
|
|
73
73
|
defense: 4,
|
|
@@ -75,8 +75,8 @@ export const items: IItem[] = [
|
|
|
75
75
|
},
|
|
76
76
|
{
|
|
77
77
|
gemEntityEffectsAdd: ['poison'],
|
|
78
|
-
key: '
|
|
79
|
-
name: '
|
|
78
|
+
key: 'coral-reef-gem',
|
|
79
|
+
name: 'Coral Reef Gem',
|
|
80
80
|
gemStatBuff: {
|
|
81
81
|
attack: 5,
|
|
82
82
|
defense: 4,
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import { Meta, Story } from '@storybook/react';
|
|
2
|
+
import React from 'react';
|
|
3
|
+
import { RPGUIRoot } from '..';
|
|
4
|
+
import { ArrowBarProps } from '../components/Arrow/SelectArrow';
|
|
5
|
+
import { Stepper } from '../components/Stepper';
|
|
6
|
+
|
|
7
|
+
const meta: Meta = {
|
|
8
|
+
title: 'Stepper',
|
|
9
|
+
component: Stepper,
|
|
10
|
+
};
|
|
11
|
+
|
|
12
|
+
export default meta;
|
|
13
|
+
|
|
14
|
+
const Template: Story<ArrowBarProps> = args => (
|
|
15
|
+
<RPGUIRoot>
|
|
16
|
+
<Stepper
|
|
17
|
+
steps={[
|
|
18
|
+
{
|
|
19
|
+
component: <div>Step 1</div>,
|
|
20
|
+
id: 0,
|
|
21
|
+
},
|
|
22
|
+
{
|
|
23
|
+
component: <div>Step 2</div>,
|
|
24
|
+
id: 1,
|
|
25
|
+
},
|
|
26
|
+
{
|
|
27
|
+
component: <div>Step 3</div>,
|
|
28
|
+
id: 2,
|
|
29
|
+
},
|
|
30
|
+
]}
|
|
31
|
+
finalCTAButton={{
|
|
32
|
+
label: 'Submit',
|
|
33
|
+
onClick: () => {
|
|
34
|
+
console.log('Submitting your data');
|
|
35
|
+
},
|
|
36
|
+
}}
|
|
37
|
+
></Stepper>
|
|
38
|
+
</RPGUIRoot>
|
|
39
|
+
);
|
|
40
|
+
|
|
41
|
+
export const Default = Template.bind({});
|
|
42
|
+
|
|
43
|
+
Default.args = {
|
|
44
|
+
direction: 'left',
|
|
45
|
+
onPointerDown: () => {
|
|
46
|
+
console.log('clicked');
|
|
47
|
+
},
|
|
48
|
+
};
|