@rpg-engine/long-bow 0.4.97 → 0.4.99

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.
@@ -0,0 +1,6 @@
1
+ import { Meta } from '@storybook/react';
2
+ import { IImageCarouselProps } from '../components/ImageCarousel/ImageCarousel';
3
+ declare const meta: Meta;
4
+ export default meta;
5
+ export declare const OverlayImageWithText: import("@storybook/csf").AnnotatedStoryFn<import("@storybook/react").ReactFramework, IImageCarouselProps>;
6
+ export declare const ImageGallery: import("@storybook/csf").AnnotatedStoryFn<import("@storybook/react").ReactFramework, IImageCarouselProps>;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rpg-engine/long-bow",
3
- "version": "0.4.97",
3
+ "version": "0.4.99",
4
4
  "license": "MIT",
5
5
  "main": "dist/index.js",
6
6
  "typings": "dist/index.d.ts",
@@ -83,7 +83,7 @@
83
83
  },
84
84
  "dependencies": {
85
85
  "@rollup/plugin-image": "^2.1.1",
86
- "@rpg-engine/shared": "^0.8.52",
86
+ "@rpg-engine/shared": "^0.8.61",
87
87
  "dayjs": "^1.11.2",
88
88
  "font-awesome": "^4.7.0",
89
89
  "fs-extra": "^10.1.0",
@@ -0,0 +1,142 @@
1
+ import React, { useState } from 'react';
2
+ import styled from 'styled-components';
3
+ import SelectArrow from '../Arrow/SelectArrow';
4
+ import { DraggableContainer } from '../DraggableContainer';
5
+ import { RPGUIContainerTypes } from '../RPGUIContainer';
6
+ import { DynamicText } from '../typography/DynamicText';
7
+
8
+ export interface ITextImageProps {
9
+ image: string;
10
+ textPosition?: 'flex-start' | 'flex-end';
11
+ text: string;
12
+ }
13
+
14
+ export interface IImageCarouselProps {
15
+ textImage: ITextImageProps[];
16
+ isTextFixed: boolean;
17
+ }
18
+
19
+ export const ImageCarousel: React.FC<IImageCarouselProps> = ({
20
+ textImage,
21
+ isTextFixed,
22
+ }) => {
23
+ const [textImageSelected, setTextImageSelected] = useState(textImage[0]);
24
+
25
+ const goToPreviousImage = () => {
26
+ const currentIndex = textImage.indexOf(textImageSelected);
27
+ if (currentIndex > 0) {
28
+ setTextImageSelected(textImage[currentIndex - 1]);
29
+ }
30
+ };
31
+
32
+ const goToNextImage = () => {
33
+ const currentIndex = textImage.indexOf(textImageSelected);
34
+ if (currentIndex < textImage.length - 1) {
35
+ setTextImageSelected(textImage[currentIndex + 1]);
36
+ }
37
+ };
38
+
39
+ return (
40
+ <CarouselWrapper type={RPGUIContainerTypes.Framed}>
41
+ {isTextFixed ? (
42
+ <>
43
+ <BackgroundImage
44
+ imagePath={textImageSelected.image}
45
+ isTextFixed={isTextFixed}
46
+ >
47
+ <ArrowContainer>
48
+ {textImageSelected !== textImage[0] && (
49
+ <SelectArrow
50
+ direction="left"
51
+ onPointerDown={() => goToPreviousImage()}
52
+ ></SelectArrow>
53
+ )}
54
+
55
+ {textImageSelected !== textImage[textImage.length - 1] && (
56
+ <SelectArrow
57
+ direction="right"
58
+ onPointerDown={() => goToNextImage()}
59
+ ></SelectArrow>
60
+ )}
61
+ </ArrowContainer>
62
+ </BackgroundImage>
63
+ <Description
64
+ textPosition={textImageSelected.textPosition ?? 'flex-start'}
65
+ isTextFixed={isTextFixed}
66
+ >
67
+ <DynamicText text={textImageSelected.text} />
68
+ </Description>
69
+ </>
70
+ ) : (
71
+ <BackgroundImage
72
+ imagePath={textImageSelected.image}
73
+ isTextFixed={isTextFixed}
74
+ >
75
+ <ArrowContainer>
76
+ {textImageSelected !== textImage[0] && (
77
+ <SelectArrow
78
+ direction="left"
79
+ onPointerDown={() => goToPreviousImage()}
80
+ ></SelectArrow>
81
+ )}
82
+ <Description
83
+ textPosition={textImageSelected.textPosition ?? 'flex-start'}
84
+ isTextFixed={isTextFixed}
85
+ >
86
+ <DynamicText text={textImageSelected.text} />
87
+ </Description>
88
+ {textImageSelected !== textImage[textImage.length - 1] && (
89
+ <SelectArrow
90
+ direction="right"
91
+ onPointerDown={() => goToNextImage()}
92
+ ></SelectArrow>
93
+ )}
94
+ </ArrowContainer>
95
+ </BackgroundImage>
96
+ )}
97
+ </CarouselWrapper>
98
+ );
99
+ };
100
+
101
+ interface IBackgroundImage {
102
+ imagePath: string;
103
+ isTextFixed: boolean;
104
+ }
105
+
106
+ interface ITextDescription {
107
+ textPosition: 'flex-start' | 'flex-end';
108
+ isTextFixed: boolean;
109
+ }
110
+
111
+ const CarouselWrapper = styled(DraggableContainer)`
112
+ width: 100%;
113
+ height: 100%;
114
+ `;
115
+
116
+ const ArrowContainer = styled.span`
117
+ display: flex;
118
+ height: 100%;
119
+ align-items: center;
120
+ `;
121
+
122
+ const BackgroundImage = styled.div<IBackgroundImage>`
123
+ background-image: url(${props => props.imagePath});
124
+ background-repeat: no-repeat;
125
+ background-attachment: fixed;
126
+ background-size: cover;
127
+ width: 100%;
128
+ height: ${props => (props.isTextFixed ? '80%' : '100%')};
129
+ `;
130
+ const Description = styled.div<ITextDescription>`
131
+ width: 100%;
132
+ height: ${props => (props.isTextFixed ? 'auto' : '100%')};
133
+ display: flex;
134
+ align-items: ${props => props.textPosition};
135
+ p {
136
+ background-color: ${props =>
137
+ props.isTextFixed ? 'none' : 'rgba(0, 0, 0, 0.6)'};
138
+ border-radius: 5px;
139
+ text-align: justify;
140
+ height: auto;
141
+ }
142
+ `;
package/src/index.tsx CHANGED
@@ -10,6 +10,7 @@ export * from './components/Dropdown';
10
10
  export * from './components/DropdownSelectorContainer';
11
11
  export * from './components/Equipment/EquipmentSet';
12
12
  export * from './components/HistoryDialog';
13
+ export * from './components/ImageCarousel/ImageCarousel';
13
14
  export * from './components/Input';
14
15
  export { ErrorBoundary } from './components/Item/Inventory/ErrorBoundary';
15
16
  export * from './components/Item/Inventory/ItemContainer';
@@ -0,0 +1,76 @@
1
+ import { Meta, Story } from '@storybook/react';
2
+ import React from 'react';
3
+ import {
4
+ IImageCarouselProps,
5
+ ITextImageProps,
6
+ ImageCarousel,
7
+ } from '../components/ImageCarousel/ImageCarousel';
8
+ import image from '../components/ImageCarousel/images/001.png';
9
+ import { RPGUIRoot } from '../components/RPGUIRoot';
10
+
11
+ const meta: Meta = {
12
+ title: 'Tutorial System/Image Carousel',
13
+ component: ImageCarousel,
14
+ };
15
+
16
+ export default meta;
17
+
18
+ const Template: Story<IImageCarouselProps> = args => {
19
+ return (
20
+ <RPGUIRoot>
21
+ <ImageCarousel {...args} />
22
+ </RPGUIRoot>
23
+ );
24
+ };
25
+
26
+ export const OverlayImageWithText = Template.bind({});
27
+ export const ImageGallery = Template.bind({});
28
+
29
+ const OverlayImageWithTextProps: ITextImageProps[] = [
30
+ {
31
+ image: image,
32
+ textPosition: 'flex-start',
33
+ text:
34
+ '123Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industrys standard dummy text ever since the 1500s.',
35
+ },
36
+ {
37
+ image: image,
38
+ textPosition: 'flex-end',
39
+ text:
40
+ '456Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industrys standard dummy text ever since the 1500s',
41
+ },
42
+ {
43
+ image: image,
44
+ textPosition: 'flex-start',
45
+ text:
46
+ 'text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum.',
47
+ },
48
+ ];
49
+
50
+ const ImageGalleryProps: ITextImageProps[] = [
51
+ {
52
+ image: image,
53
+ text:
54
+ '123Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industrys standard dummy text ever since the 1500s.',
55
+ },
56
+ {
57
+ image: image,
58
+ text:
59
+ '456Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industrys standard dummy text ever since the 1500s',
60
+ },
61
+ {
62
+ image: image,
63
+ text:
64
+ 'text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum.',
65
+ },
66
+ ];
67
+
68
+ ImageGallery.args = {
69
+ textImage: ImageGalleryProps,
70
+ isTextFixed: true,
71
+ };
72
+
73
+ OverlayImageWithText.args = {
74
+ textImage: OverlayImageWithTextProps,
75
+ isTextFixed: false,
76
+ };