@rpg-engine/long-bow 0.3.89 → 0.3.91
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/Character/CharacterSelection.d.ts +2 -0
- package/dist/long-bow.cjs.development.js +56 -20262
- 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 +56 -20262
- package/dist/long-bow.esm.js.map +1 -1
- package/package.json +1 -1
- package/src/components/Character/CharacterSelection.tsx +9 -7
- package/src/components/CraftBook/CraftBook.tsx +3 -0
- package/src/components/DraggableContainer.tsx +4 -0
- package/src/components/Dropdown.tsx +21 -7
- package/src/components/TradingMenu/TradingMenu.tsx +3 -0
- package/src/stories/CharacterSelection.stories.tsx +6 -7
- package/src/stories/Dropdown.stories.tsx +1 -1
package/package.json
CHANGED
|
@@ -3,8 +3,6 @@ import styled from 'styled-components';
|
|
|
3
3
|
|
|
4
4
|
import { SpriteFromAtlas } from '../shared/SpriteFromAtlas';
|
|
5
5
|
|
|
6
|
-
import entitiesJSON from '../../mocks/atlas/entities/entities.json';
|
|
7
|
-
import entitiesIMG from '../../mocks/atlas/entities/entities.png';
|
|
8
6
|
import { ErrorBoundary } from '../Item/Inventory/ErrorBoundary';
|
|
9
7
|
import PropertySelect, {
|
|
10
8
|
IPropertiesProps,
|
|
@@ -17,14 +15,18 @@ export interface ICharacterProps {
|
|
|
17
15
|
|
|
18
16
|
export interface ICharacterSelectionProps {
|
|
19
17
|
availableCharacters: ICharacterProps[];
|
|
18
|
+
atlasJSON: any;
|
|
19
|
+
atlasIMG: any;
|
|
20
20
|
onChange: (textureKey: string) => void;
|
|
21
21
|
}
|
|
22
22
|
|
|
23
23
|
export const CharacterSelection: React.FC<ICharacterSelectionProps> = ({
|
|
24
24
|
availableCharacters,
|
|
25
|
+
atlasJSON,
|
|
26
|
+
atlasIMG,
|
|
25
27
|
onChange,
|
|
26
28
|
}) => {
|
|
27
|
-
const propertySelectValues = availableCharacters.map(item => {
|
|
29
|
+
const propertySelectValues = availableCharacters.map((item) => {
|
|
28
30
|
return {
|
|
29
31
|
id: item.textureKey,
|
|
30
32
|
name: item.name,
|
|
@@ -56,12 +58,12 @@ export const CharacterSelection: React.FC<ICharacterSelectionProps> = ({
|
|
|
56
58
|
|
|
57
59
|
return (
|
|
58
60
|
<Container>
|
|
59
|
-
{selectedSpriteKey && (
|
|
61
|
+
{selectedSpriteKey && atlasIMG && atlasJSON && (
|
|
60
62
|
<ErrorBoundary>
|
|
61
63
|
<SpriteFromAtlas
|
|
62
64
|
spriteKey={selectedSpriteKey}
|
|
63
|
-
atlasIMG={
|
|
64
|
-
atlasJSON={
|
|
65
|
+
atlasIMG={atlasIMG}
|
|
66
|
+
atlasJSON={atlasJSON}
|
|
65
67
|
imgScale={4}
|
|
66
68
|
height={80}
|
|
67
69
|
width={64}
|
|
@@ -78,7 +80,7 @@ export const CharacterSelection: React.FC<ICharacterSelectionProps> = ({
|
|
|
78
80
|
)}
|
|
79
81
|
<PropertySelect
|
|
80
82
|
availableProperties={propertySelectValues}
|
|
81
|
-
onChange={value => {
|
|
83
|
+
onChange={(value) => {
|
|
82
84
|
setSelectedValue(value);
|
|
83
85
|
}}
|
|
84
86
|
/>
|
|
@@ -28,9 +28,20 @@ export const Dropdown: React.FC<IDropdownProps> = ({
|
|
|
28
28
|
useEffect(() => {
|
|
29
29
|
const firstOption = options[0];
|
|
30
30
|
|
|
31
|
-
if (firstOption
|
|
32
|
-
|
|
33
|
-
|
|
31
|
+
if (firstOption) {
|
|
32
|
+
let change = !selectedValue;
|
|
33
|
+
if (!change) {
|
|
34
|
+
change = options.filter((o) => o.value === selectedValue).length < 1;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
/**
|
|
38
|
+
* make a selection if there is no selected value already present
|
|
39
|
+
* or if there is a selected value but its not in new options
|
|
40
|
+
*/
|
|
41
|
+
if (change) {
|
|
42
|
+
setSelectedValue(firstOption.value);
|
|
43
|
+
setSelectedOption(firstOption.option);
|
|
44
|
+
}
|
|
34
45
|
}
|
|
35
46
|
}, [options]);
|
|
36
47
|
|
|
@@ -45,13 +56,13 @@ export const Dropdown: React.FC<IDropdownProps> = ({
|
|
|
45
56
|
<DropdownSelect
|
|
46
57
|
id={`dropdown-${dropdownId}`}
|
|
47
58
|
className="rpgui-dropdown-imp rpgui-dropdown-imp-header"
|
|
48
|
-
onPointerDown={() => setOpened(prev => !prev)}
|
|
59
|
+
onPointerDown={() => setOpened((prev) => !prev)}
|
|
49
60
|
>
|
|
50
61
|
<label>▼</label> {selectedOption}
|
|
51
62
|
</DropdownSelect>
|
|
52
63
|
|
|
53
64
|
<DropdownOptions className="rpgui-dropdown-imp" opened={opened}>
|
|
54
|
-
{options.map(option => {
|
|
65
|
+
{options.map((option) => {
|
|
55
66
|
return (
|
|
56
67
|
<li
|
|
57
68
|
key={option.id}
|
|
@@ -72,7 +83,7 @@ export const Dropdown: React.FC<IDropdownProps> = ({
|
|
|
72
83
|
|
|
73
84
|
const Container = styled.div<{ width: string | undefined }>`
|
|
74
85
|
position: relative;
|
|
75
|
-
width: ${props => props.width || '100%'};
|
|
86
|
+
width: ${(props) => props.width || '100%'};
|
|
76
87
|
`;
|
|
77
88
|
|
|
78
89
|
const DropdownSelect = styled.p`
|
|
@@ -85,6 +96,9 @@ const DropdownOptions = styled.ul<{
|
|
|
85
96
|
}>`
|
|
86
97
|
position: absolute;
|
|
87
98
|
width: 100%;
|
|
88
|
-
display: ${props => (props.opened ? 'block' : 'none')};
|
|
99
|
+
display: ${(props) => (props.opened ? 'block' : 'none')};
|
|
89
100
|
box-sizing: border-box;
|
|
101
|
+
@media (max-width: 768px) {
|
|
102
|
+
padding: 8px 0;
|
|
103
|
+
}
|
|
90
104
|
`;
|
|
@@ -4,6 +4,8 @@ import { RPGUIRoot } from '..';
|
|
|
4
4
|
import CharacterSelection, {
|
|
5
5
|
ICharacterProps,
|
|
6
6
|
} from '../components/Character/CharacterSelection';
|
|
7
|
+
import atlasJSON from '../mocks/atlas/entities/entities.json';
|
|
8
|
+
import atlasIMG from '../mocks/atlas/entities/entities.png';
|
|
7
9
|
|
|
8
10
|
const meta: Meta = {
|
|
9
11
|
title: 'Character Selection',
|
|
@@ -12,14 +14,9 @@ const meta: Meta = {
|
|
|
12
14
|
|
|
13
15
|
export default meta;
|
|
14
16
|
|
|
15
|
-
const Template: Story<any> = args => (
|
|
17
|
+
const Template: Story<any> = (args) => (
|
|
16
18
|
<RPGUIRoot>
|
|
17
|
-
<CharacterSelection
|
|
18
|
-
{...args}
|
|
19
|
-
onChange={value => {
|
|
20
|
-
console.log(value);
|
|
21
|
-
}}
|
|
22
|
-
/>
|
|
19
|
+
<CharacterSelection {...args} />
|
|
23
20
|
</RPGUIRoot>
|
|
24
21
|
);
|
|
25
22
|
|
|
@@ -42,4 +39,6 @@ const availableCharacters: ICharacterProps[] = [
|
|
|
42
39
|
|
|
43
40
|
Default.args = {
|
|
44
41
|
availableCharacters: availableCharacters,
|
|
42
|
+
atlasJSON: atlasJSON,
|
|
43
|
+
atlasIMG: atlasIMG,
|
|
45
44
|
};
|