@rpg-engine/long-bow 0.5.74 → 0.5.76
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/Dropdown.d.ts +1 -0
- package/dist/components/ImageCarousel/SimpleImageCarousel.d.ts +2 -3
- package/dist/long-bow.cjs.development.js +42 -49
- 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 +42 -49
- package/dist/long-bow.esm.js.map +1 -1
- package/package.json +1 -2
- package/src/assets/images/backpack.png +0 -0
- package/src/assets/images/depot.png +0 -0
- package/src/components/Dropdown.tsx +14 -6
- package/src/components/ImageCarousel/SimpleImageCarousel.tsx +32 -48
- package/src/stories/Dropdown.stories.tsx +10 -2
- package/src/stories/SimpleImageCarousel.stories.tsx +3 -2
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rpg-engine/long-bow",
|
|
3
|
-
"version": "0.5.
|
|
3
|
+
"version": "0.5.76",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"typings": "dist/index.d.ts",
|
|
@@ -82,7 +82,6 @@
|
|
|
82
82
|
"uuid": "^8.3.2"
|
|
83
83
|
},
|
|
84
84
|
"dependencies": {
|
|
85
|
-
"@capacitor/core": "^4.6.3",
|
|
86
85
|
"@rollup/plugin-image": "^2.1.1",
|
|
87
86
|
"@rpg-engine/shared": "^0.9.19",
|
|
88
87
|
"dayjs": "^1.11.2",
|
|
Binary file
|
|
Binary file
|
|
@@ -12,12 +12,14 @@ export interface IDropdownProps {
|
|
|
12
12
|
options: IOptionsProps[];
|
|
13
13
|
width?: string;
|
|
14
14
|
onChange: (value: string) => void;
|
|
15
|
+
opensUp?: boolean; // Add a new prop to control the dropdown direction
|
|
15
16
|
}
|
|
16
17
|
|
|
17
18
|
export const Dropdown: React.FC<IDropdownProps> = ({
|
|
18
19
|
options,
|
|
19
20
|
width,
|
|
20
21
|
onChange,
|
|
22
|
+
opensUp = false, // Default value is false
|
|
21
23
|
}) => {
|
|
22
24
|
const dropdownId = uuidv4();
|
|
23
25
|
|
|
@@ -36,10 +38,6 @@ export const Dropdown: React.FC<IDropdownProps> = ({
|
|
|
36
38
|
change = options.filter(o => o.value === selectedValue).length < 1;
|
|
37
39
|
}
|
|
38
40
|
|
|
39
|
-
/**
|
|
40
|
-
* make a selection if there is no selected value already present
|
|
41
|
-
* or if there is a selected value but its not in new options
|
|
42
|
-
*/
|
|
43
41
|
if (change) {
|
|
44
42
|
setSelectedValue(firstOption.value);
|
|
45
43
|
setSelectedOption(firstOption.option);
|
|
@@ -63,7 +61,11 @@ export const Dropdown: React.FC<IDropdownProps> = ({
|
|
|
63
61
|
<label>▼</label> {selectedOption}
|
|
64
62
|
</DropdownSelect>
|
|
65
63
|
|
|
66
|
-
<DropdownOptions
|
|
64
|
+
<DropdownOptions
|
|
65
|
+
className="rpgui-dropdown-imp"
|
|
66
|
+
opened={opened}
|
|
67
|
+
opensUp={opensUp}
|
|
68
|
+
>
|
|
67
69
|
{options.map(option => {
|
|
68
70
|
return (
|
|
69
71
|
<li
|
|
@@ -100,6 +102,7 @@ const DropdownSelect = styled.p`
|
|
|
100
102
|
|
|
101
103
|
const DropdownOptions = styled.ul<{
|
|
102
104
|
opened: boolean;
|
|
105
|
+
opensUp: boolean; // Add a new prop to the styled component
|
|
103
106
|
}>`
|
|
104
107
|
position: absolute;
|
|
105
108
|
width: 100%;
|
|
@@ -107,7 +110,12 @@ const DropdownOptions = styled.ul<{
|
|
|
107
110
|
overflow-y: auto;
|
|
108
111
|
display: ${props => (props.opened ? 'block' : 'none')};
|
|
109
112
|
box-sizing: border-box;
|
|
110
|
-
|
|
113
|
+
bottom: ${props =>
|
|
114
|
+
props.opensUp ? '100%' : 'auto'}; // Adjust the position based on the prop
|
|
115
|
+
top: ${props =>
|
|
116
|
+
props.opensUp ? 'auto' : '100%'}; // Adjust the position based on the prop
|
|
117
|
+
margin: 0;
|
|
118
|
+
padding: 0;
|
|
111
119
|
@media (max-width: 768px) {
|
|
112
120
|
padding: 8px 0;
|
|
113
121
|
}
|
|
@@ -1,74 +1,58 @@
|
|
|
1
|
-
import { Capacitor } from '@capacitor/core';
|
|
2
1
|
import React, { useEffect, useRef, useState } from 'react';
|
|
3
2
|
import styled, { keyframes } from 'styled-components';
|
|
4
3
|
import SelectArrow from '../Arrow/SelectArrow';
|
|
5
4
|
|
|
6
5
|
export interface ISimpleImageCarousel {
|
|
7
|
-
|
|
8
|
-
imagesSrc: string[];
|
|
6
|
+
images: string[];
|
|
9
7
|
styles?: React.CSSProperties;
|
|
10
8
|
autoCycle?: boolean;
|
|
11
9
|
autoCycleDelay?: number;
|
|
12
10
|
stopAutoCyclingOnInteraction?: boolean;
|
|
13
11
|
}
|
|
14
12
|
|
|
15
|
-
const
|
|
16
|
-
|
|
17
|
-
return Capacitor.convertFileSrc(basePath);
|
|
18
|
-
}
|
|
19
|
-
return basePath;
|
|
20
|
-
};
|
|
21
|
-
|
|
22
|
-
export const SimpleImageCarousel = ({
|
|
23
|
-
basePath,
|
|
24
|
-
imagesSrc,
|
|
13
|
+
export const SimpleImageCarousel: React.FC<ISimpleImageCarousel> = ({
|
|
14
|
+
images,
|
|
25
15
|
styles,
|
|
26
16
|
autoCycle = false,
|
|
27
17
|
autoCycleDelay = 3000,
|
|
28
18
|
stopAutoCyclingOnInteraction = false,
|
|
29
|
-
}
|
|
19
|
+
}) => {
|
|
30
20
|
const [currentImage, setCurrentImage] = useState(0);
|
|
31
|
-
const
|
|
21
|
+
const autoCycleId = useRef<NodeJS.Timeout | null>(null);
|
|
32
22
|
|
|
33
|
-
|
|
34
|
-
|
|
23
|
+
const handleLeftClick = () => {
|
|
24
|
+
setCurrentImage(
|
|
25
|
+
prevImage => (prevImage - 1 + images?.length) % images?.length
|
|
26
|
+
);
|
|
27
|
+
if (stopAutoCyclingOnInteraction && autoCycleId.current) {
|
|
28
|
+
clearInterval(autoCycleId.current);
|
|
29
|
+
autoCycleId.current = null;
|
|
30
|
+
}
|
|
31
|
+
};
|
|
35
32
|
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
33
|
+
const handleRightClick = () => {
|
|
34
|
+
setCurrentImage(prevImage => (prevImage + 1) % images?.length);
|
|
35
|
+
if (stopAutoCyclingOnInteraction && autoCycleId.current) {
|
|
36
|
+
clearInterval(autoCycleId.current);
|
|
37
|
+
autoCycleId.current = null;
|
|
38
|
+
}
|
|
39
|
+
};
|
|
42
40
|
|
|
43
|
-
|
|
41
|
+
useEffect(() => {
|
|
42
|
+
if (autoCycle) {
|
|
43
|
+
autoCycleId.current = setInterval(() => {
|
|
44
|
+
setCurrentImage(prevImage => (prevImage + 1) % images?.length);
|
|
44
45
|
}, autoCycleDelay);
|
|
45
46
|
}
|
|
46
47
|
|
|
47
48
|
return () => {
|
|
48
|
-
if (
|
|
49
|
-
clearInterval(
|
|
49
|
+
if (autoCycleId.current) {
|
|
50
|
+
clearInterval(autoCycleId.current);
|
|
50
51
|
}
|
|
51
52
|
};
|
|
52
|
-
}, [autoCycle, autoCycleDelay]);
|
|
53
|
+
}, [autoCycle, autoCycleDelay, images?.length]);
|
|
53
54
|
|
|
54
|
-
const
|
|
55
|
-
isInteracted.current = true;
|
|
56
|
-
setCurrentImage(oldImage =>
|
|
57
|
-
oldImage === 0 ? imagesSrc.length - 1 : oldImage - 1
|
|
58
|
-
);
|
|
59
|
-
};
|
|
60
|
-
|
|
61
|
-
const handleRightClick = (isAutomatedClick: boolean = false) => {
|
|
62
|
-
if (!isAutomatedClick) {
|
|
63
|
-
isInteracted.current = true;
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
setCurrentImage(oldImage =>
|
|
67
|
-
oldImage === imagesSrc.length - 1 ? 0 : oldImage + 1
|
|
68
|
-
);
|
|
69
|
-
};
|
|
70
|
-
|
|
71
|
-
const hasMoreThanOneImage = imagesSrc.length > 1;
|
|
55
|
+
const hasMoreThanOneImage = images?.length > 1;
|
|
72
56
|
|
|
73
57
|
return (
|
|
74
58
|
<ImageContainer style={styles}>
|
|
@@ -81,8 +65,8 @@ export const SimpleImageCarousel = ({
|
|
|
81
65
|
<Carousel>
|
|
82
66
|
<FadeInCarouselImg
|
|
83
67
|
key={currentImage}
|
|
84
|
-
src={
|
|
85
|
-
alt={
|
|
68
|
+
src={images?.[currentImage]}
|
|
69
|
+
alt={`Image ${currentImage}`}
|
|
86
70
|
/>
|
|
87
71
|
</Carousel>
|
|
88
72
|
</ImageContainer>
|
|
@@ -97,8 +81,8 @@ const ImageContainer = styled.div`
|
|
|
97
81
|
height: 100%;
|
|
98
82
|
margin-right: 0.5rem;
|
|
99
83
|
max-width: 400px;
|
|
100
|
-
width: 400px;
|
|
101
84
|
position: relative;
|
|
85
|
+
width: 400px;
|
|
102
86
|
`;
|
|
103
87
|
|
|
104
88
|
const CustomLeftArrow = styled(SelectArrow)`
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { Meta, Story } from '@storybook/react';
|
|
2
2
|
import React from 'react';
|
|
3
|
+
import styled from 'styled-components';
|
|
3
4
|
import { RPGUIRoot } from '../../src';
|
|
4
5
|
import {
|
|
5
6
|
Dropdown,
|
|
@@ -14,12 +15,18 @@ const meta: Meta = {
|
|
|
14
15
|
|
|
15
16
|
export default meta;
|
|
16
17
|
|
|
17
|
-
const Template: Story<IDropdownProps> =
|
|
18
|
+
const Template: Story<IDropdownProps> = args => (
|
|
18
19
|
<RPGUIRoot>
|
|
19
|
-
<
|
|
20
|
+
<PushUp>
|
|
21
|
+
<Dropdown {...args} />
|
|
22
|
+
</PushUp>
|
|
20
23
|
</RPGUIRoot>
|
|
21
24
|
);
|
|
22
25
|
|
|
26
|
+
const PushUp = styled.div`
|
|
27
|
+
margin-top: 200px;
|
|
28
|
+
`;
|
|
29
|
+
|
|
23
30
|
export const Default = Template.bind({});
|
|
24
31
|
|
|
25
32
|
const options: IOptionsProps[] = [
|
|
@@ -43,4 +50,5 @@ const options: IOptionsProps[] = [
|
|
|
43
50
|
Default.args = {
|
|
44
51
|
options,
|
|
45
52
|
width: '100%',
|
|
53
|
+
opensUp: false,
|
|
46
54
|
};
|
|
@@ -7,6 +7,8 @@ import {
|
|
|
7
7
|
} from '../components/ImageCarousel/SimpleImageCarousel';
|
|
8
8
|
|
|
9
9
|
import styled from 'styled-components';
|
|
10
|
+
import image1 from '../assets/images/backpack.png';
|
|
11
|
+
import image2 from '../assets/images/depot.png';
|
|
10
12
|
import { RPGUIRoot } from '../components/RPGUI/RPGUIRoot';
|
|
11
13
|
|
|
12
14
|
const meta: Meta = {
|
|
@@ -37,8 +39,7 @@ const CenteredContainer = styled.div`
|
|
|
37
39
|
export const SimpleImageCarouselStory = Template.bind({});
|
|
38
40
|
|
|
39
41
|
SimpleImageCarouselStory.args = {
|
|
40
|
-
|
|
41
|
-
basePath: 'http://localhost:6006',
|
|
42
|
+
images: [image1, image2],
|
|
42
43
|
autoCycle: true,
|
|
43
44
|
stopAutoCyclingOnInteraction: true,
|
|
44
45
|
};
|