@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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rpg-engine/long-bow",
3
- "version": "0.3.89",
3
+ "version": "0.3.91",
4
4
  "license": "MIT",
5
5
  "main": "dist/index.js",
6
6
  "typings": "dist/index.d.ts",
@@ -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={entitiesIMG}
64
- atlasJSON={entitiesJSON}
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
  />
@@ -238,4 +238,7 @@ const ButtonWrapper = styled.div`
238
238
  justify-content: space-around;
239
239
  padding-top: 20px;
240
240
  width: 100%;
241
+ button {
242
+ padding: 0px 50px;
243
+ }
241
244
  `;
@@ -146,6 +146,10 @@ const CloseButton = styled.div`
146
146
  color: white;
147
147
  z-index: 22;
148
148
  font-size: 1.1rem;
149
+ @media (max-width: 768px) {
150
+ font-size: 1.3rem;
151
+ padding: 3px;
152
+ }
149
153
  `;
150
154
 
151
155
  const TitleContainer = styled.div`
@@ -28,9 +28,20 @@ export const Dropdown: React.FC<IDropdownProps> = ({
28
28
  useEffect(() => {
29
29
  const firstOption = options[0];
30
30
 
31
- if (firstOption && !selectedValue) {
32
- setSelectedValue(firstOption.value);
33
- setSelectedOption(firstOption.option);
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
  `;
@@ -213,4 +213,7 @@ const ButtonWrapper = styled.div`
213
213
  padding-top: 20px;
214
214
  width: 100%;
215
215
  margin-top: 1rem;
216
+ button {
217
+ padding: 0px 50px;
218
+ }
216
219
  `;
@@ -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
  };
@@ -14,7 +14,7 @@ const meta: Meta = {
14
14
 
15
15
  export default meta;
16
16
 
17
- const Template: Story<IDropdownProps> = args => (
17
+ const Template: Story<IDropdownProps> = (args) => (
18
18
  <RPGUIRoot>
19
19
  <Dropdown {...args} />
20
20
  </RPGUIRoot>