@rpg-engine/long-bow 0.1.91 → 0.1.92

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.
Files changed (88) hide show
  1. package/LICENSE +20 -20
  2. package/README.md +181 -181
  3. package/dist/components/Item/Inventory/itemContainerHelper.d.ts +2 -2
  4. package/dist/long-bow.cjs.development.js +49 -2
  5. package/dist/long-bow.cjs.development.js.map +1 -1
  6. package/dist/long-bow.cjs.production.min.js +1 -1
  7. package/dist/long-bow.cjs.production.min.js.map +1 -1
  8. package/dist/long-bow.esm.js +49 -2
  9. package/dist/long-bow.esm.js.map +1 -1
  10. package/package.json +98 -98
  11. package/src/components/Abstractions/SlotsContainer.tsx +42 -42
  12. package/src/components/Button.tsx +30 -30
  13. package/src/components/Chat/Chat.tsx +193 -193
  14. package/src/components/CheckButton.tsx +65 -65
  15. package/src/components/DraggableContainer.tsx +150 -150
  16. package/src/components/Dropdown.tsx +57 -57
  17. package/src/components/Equipment/EquipmentSet.tsx +134 -134
  18. package/src/components/Input.tsx +11 -11
  19. package/src/components/Item/Cards/ItemTooltip.tsx +32 -32
  20. package/src/components/Item/Inventory/ItemContainer.tsx +65 -65
  21. package/src/components/Item/Inventory/ItemContainerTypes.ts +4 -4
  22. package/src/components/Item/Inventory/ItemSlot.tsx +199 -199
  23. package/src/components/Item/Inventory/itemContainerHelper.ts +94 -81
  24. package/src/components/ListMenu.tsx +65 -65
  25. package/src/components/Multitab/Tab.tsx +57 -57
  26. package/src/components/Multitab/TabBody.tsx +13 -13
  27. package/src/components/Multitab/TabsContainer.tsx +97 -97
  28. package/src/components/NPCDialog/NPCDialog.tsx +145 -145
  29. package/src/components/NPCDialog/NPCDialogText.tsx +53 -53
  30. package/src/components/NPCDialog/QuestionDialog/QuestionDialog.tsx +239 -239
  31. package/src/components/ProgressBar.tsx +91 -91
  32. package/src/components/PropertySelect/PropertySelect.tsx +101 -101
  33. package/src/components/PropertySelect/img/ui-arrows/arrow01-left-clicked.png +0 -0
  34. package/src/components/PropertySelect/img/ui-arrows/arrow01-left.png +0 -0
  35. package/src/components/PropertySelect/img/ui-arrows/arrow01-right-clicked.png +0 -0
  36. package/src/components/PropertySelect/img/ui-arrows/arrow01-right.png +0 -0
  37. package/src/components/PropertySelect/img/ui-arrows/arrow02-left-clicked.png +0 -0
  38. package/src/components/PropertySelect/img/ui-arrows/arrow02-left.png +0 -0
  39. package/src/components/PropertySelect/img/ui-arrows/arrow02-right-clicked.png +0 -0
  40. package/src/components/PropertySelect/img/ui-arrows/arrow02-right.png +0 -0
  41. package/src/components/QuestInfo/QuestInfo.tsx +143 -143
  42. package/src/components/RPGUIContainer.tsx +47 -47
  43. package/src/components/RPGUIRoot.tsx +14 -14
  44. package/src/components/RadioButton.tsx +53 -53
  45. package/src/components/RangeSlider.tsx +68 -68
  46. package/src/components/RelativeListMenu.tsx +83 -83
  47. package/src/components/ScrollList.tsx +77 -77
  48. package/src/components/SimpleProgressBar.tsx +62 -62
  49. package/src/components/SkillProgressBar.tsx +123 -123
  50. package/src/components/SkillsContainer.tsx +196 -196
  51. package/src/components/TextArea.tsx +11 -11
  52. package/src/components/Truncate.tsx +25 -25
  53. package/src/components/shared/Column.tsx +16 -16
  54. package/src/components/shared/SpriteFromAtlas.tsx +99 -99
  55. package/src/components/typography/DynamicText.tsx +49 -49
  56. package/src/constants/uiColors.ts +10 -10
  57. package/src/hooks/useEventListener.ts +21 -21
  58. package/src/hooks/useOutsideAlerter.ts +25 -25
  59. package/src/index.tsx +25 -25
  60. package/src/libs/StringHelpers.ts +3 -3
  61. package/src/mocks/atlas/icons/icons.json +735 -735
  62. package/src/mocks/atlas/items/items.json +5215 -5215
  63. package/src/mocks/equipmentSet.mocks.ts +347 -347
  64. package/src/mocks/itemContainer.mocks.ts +249 -249
  65. package/src/mocks/skills.mocks.ts +122 -122
  66. package/src/stories/Button.stories.tsx +36 -36
  67. package/src/stories/Chat.stories.tsx +170 -170
  68. package/src/stories/CheckButton.stories.tsx +48 -48
  69. package/src/stories/DraggableContainer.stories.tsx +28 -28
  70. package/src/stories/Dropdown.stories.tsx +46 -46
  71. package/src/stories/EquipmentSet.stories.tsx +50 -50
  72. package/src/stories/ItemContainer.stories.tsx +50 -50
  73. package/src/stories/ListMenu.stories.tsx +56 -56
  74. package/src/stories/Multitab.stories.tsx +51 -51
  75. package/src/stories/NPCDialog.stories.tsx +130 -130
  76. package/src/stories/ProgressBar.stories.tsx +23 -23
  77. package/src/stories/PropertySelect.stories.tsx +41 -41
  78. package/src/stories/QuestInfo.stories.tsx +76 -76
  79. package/src/stories/RPGUIContainers.stories.tsx +42 -42
  80. package/src/stories/RadioButton.stories.tsx +49 -49
  81. package/src/stories/RangeSlider.stories.tsx +60 -60
  82. package/src/stories/ScrollList.stories.tsx +85 -85
  83. package/src/stories/SimpleProgressBar.stories.tsx +22 -22
  84. package/src/stories/SkillProgressBar.stories.tsx +30 -30
  85. package/src/stories/SkillsContainer.stories.tsx +31 -31
  86. package/src/stories/Text.stories.tsx +42 -42
  87. package/src/types/eventTypes.ts +4 -4
  88. package/src/types/index.d.ts +2 -2
@@ -1,239 +1,239 @@
1
- import React, { useEffect, useState } from 'react';
2
- import styled from 'styled-components';
3
- import { useEventListener } from '../../../hooks/useEventListener';
4
- import { DynamicText } from '../../typography/DynamicText';
5
-
6
- export interface IQuestionDialogAnswer {
7
- id: number;
8
- text: string;
9
- nextQuestionId?: number;
10
- }
11
-
12
- export interface IQuestionDialog {
13
- id: number;
14
- text: string;
15
- answerIds?: number[];
16
- }
17
-
18
- export interface IProps {
19
- questions: IQuestionDialog[];
20
- answers: IQuestionDialogAnswer[];
21
- onClose: () => void;
22
- }
23
-
24
- export const QuestionDialog: React.FC<IProps> = ({
25
- questions,
26
- answers,
27
- onClose,
28
- }) => {
29
- const [currentQuestion, setCurrentQuestion] = useState(questions[0]);
30
-
31
- const [canShowAnswers, setCanShowAnswers] = useState<boolean>(false);
32
-
33
- const onGetFirstAnswer = () => {
34
- if (!currentQuestion.answerIds || currentQuestion.answerIds.length === 0) {
35
- return null;
36
- }
37
-
38
- const firstAnswerId = currentQuestion.answerIds![0];
39
-
40
- return answers.find(answer => answer.id === firstAnswerId);
41
- };
42
-
43
- const [
44
- currentAnswer,
45
- setCurrentAnswer,
46
- ] = useState<IQuestionDialogAnswer | null>(onGetFirstAnswer()!);
47
-
48
- useEffect(() => {
49
- setCurrentAnswer(onGetFirstAnswer()!);
50
- }, [currentQuestion]);
51
-
52
- const onGetAnswers = (answerIds: number[]) => {
53
- return answerIds.map((answerId: number) =>
54
- answers.find(answer => answer.id === answerId)
55
- );
56
- };
57
-
58
- const onKeyPress = (e: KeyboardEvent) => {
59
- switch (e.key) {
60
- case 'ArrowDown':
61
- // select next answer, if any.
62
- // if no next answer, select first answer
63
- // const nextAnswer = onGetAnswers(currentQuestion.answerIds!).find(
64
- // (answer) => answer?.id === currentAnswer!.id + 1
65
- // );
66
-
67
- const nextAnswerIndex = onGetAnswers(
68
- currentQuestion.answerIds!
69
- ).findIndex(answer => answer?.id === currentAnswer!.id + 1);
70
-
71
- const nextAnswerID = currentQuestion.answerIds![nextAnswerIndex];
72
-
73
- // console.log(nextAnswerIndex);
74
-
75
- const nextAnswer = onGetAnswers(currentQuestion.answerIds!).find(
76
- answer => answer?.id === nextAnswerID
77
- );
78
-
79
- setCurrentAnswer(nextAnswer || onGetFirstAnswer()!);
80
-
81
- break;
82
- case 'ArrowUp':
83
- // select previous answer, if any.
84
- // if no previous answer, select last answer
85
-
86
- const previousAnswerIndex = onGetAnswers(
87
- currentQuestion.answerIds!
88
- ).findIndex(answer => answer?.id === currentAnswer!.id - 1);
89
-
90
- const previousAnswerID =
91
- currentQuestion.answerIds &&
92
- currentQuestion.answerIds[previousAnswerIndex];
93
-
94
- const previousAnswer = onGetAnswers(currentQuestion.answerIds!).find(
95
- answer => answer?.id === previousAnswerID
96
- );
97
-
98
- if (previousAnswer) {
99
- setCurrentAnswer(previousAnswer);
100
- } else {
101
- setCurrentAnswer(onGetAnswers(currentQuestion.answerIds!).pop()!);
102
- }
103
-
104
- break;
105
- case 'Enter':
106
- setCanShowAnswers(false);
107
-
108
- if (!currentAnswer?.nextQuestionId) {
109
- onClose();
110
- return;
111
- } else {
112
- setCurrentQuestion(
113
- questions.find(
114
- question => question.id === currentAnswer!.nextQuestionId
115
- )!
116
- );
117
- }
118
-
119
- break;
120
- }
121
- };
122
- useEventListener('keydown', onKeyPress);
123
-
124
- const onAnswerClick = (answer: IQuestionDialogAnswer) => {
125
- setCanShowAnswers(false);
126
- if (answer.nextQuestionId) {
127
- // if there is a next question, go to it
128
- setCurrentQuestion(
129
- questions.find(question => question.id === answer.nextQuestionId)!
130
- );
131
- } else {
132
- // else, finish dialog!
133
- onClose();
134
- }
135
- };
136
-
137
- const onRenderCurrentAnswers = () => {
138
- const answerIds = currentQuestion.answerIds;
139
- if (!answerIds) {
140
- return null;
141
- }
142
-
143
- const answers = onGetAnswers(answerIds);
144
-
145
- if (!answers) {
146
- return null;
147
- }
148
-
149
- return answers.map(answer => {
150
- const isSelected = currentAnswer?.id === answer?.id;
151
- const selectedColor = isSelected ? 'yellow' : 'white';
152
-
153
- if (answer) {
154
- return (
155
- <AnswerRow key={`answer_${answer.id}`}>
156
- <AnswerSelectedIcon color={selectedColor}>
157
- {isSelected ? 'X' : null}
158
- </AnswerSelectedIcon>
159
-
160
- <Answer
161
- key={answer.id}
162
- onClick={() => onAnswerClick(answer)}
163
- color={selectedColor}
164
- >
165
- {answer.text}
166
- </Answer>
167
- </AnswerRow>
168
- );
169
- }
170
-
171
- return null;
172
- });
173
- };
174
-
175
- return (
176
- <Container>
177
- <QuestionContainer>
178
- <DynamicText
179
- text={currentQuestion.text}
180
- onStart={() => setCanShowAnswers(false)}
181
- onFinish={() => setCanShowAnswers(true)}
182
- />
183
- </QuestionContainer>
184
-
185
- {canShowAnswers && (
186
- <AnswersContainer>{onRenderCurrentAnswers()}</AnswersContainer>
187
- )}
188
- </Container>
189
- );
190
- };
191
-
192
- const Container = styled.div`
193
- display: flex;
194
- word-break: break-all;
195
- box-sizing: border-box;
196
- justify-content: flex-start;
197
- align-items: flex-start;
198
- flex-wrap: wrap;
199
- `;
200
-
201
- const QuestionContainer = styled.div`
202
- flex: 100%;
203
- width: 100%;
204
- `;
205
-
206
- const AnswersContainer = styled.div`
207
- flex: 100%;
208
- `;
209
-
210
- interface IAnswerProps {
211
- color: string;
212
- }
213
-
214
- const Answer = styled.p<IAnswerProps>`
215
- flex: auto;
216
- color: ${props => props.color} !important;
217
- font-size: 0.65rem !important;
218
- background: inherit;
219
- border: none;
220
- `;
221
-
222
- const AnswerSelectedIcon = styled.span<IAnswerProps>`
223
- flex: 5% 0 0;
224
- color: ${props => props.color} !important;
225
- `;
226
-
227
- const AnswerRow = styled.div`
228
- display: flex;
229
- flex-wrap: wrap;
230
- justify-content: center;
231
- align-items: center;
232
- margin-bottom: 0.5rem;
233
- height: 22px;
234
- p {
235
- line-height: unset;
236
- margin-top: 0;
237
- margin-bottom: 0rem;
238
- }
239
- `;
1
+ import React, { useEffect, useState } from 'react';
2
+ import styled from 'styled-components';
3
+ import { useEventListener } from '../../../hooks/useEventListener';
4
+ import { DynamicText } from '../../typography/DynamicText';
5
+
6
+ export interface IQuestionDialogAnswer {
7
+ id: number;
8
+ text: string;
9
+ nextQuestionId?: number;
10
+ }
11
+
12
+ export interface IQuestionDialog {
13
+ id: number;
14
+ text: string;
15
+ answerIds?: number[];
16
+ }
17
+
18
+ export interface IProps {
19
+ questions: IQuestionDialog[];
20
+ answers: IQuestionDialogAnswer[];
21
+ onClose: () => void;
22
+ }
23
+
24
+ export const QuestionDialog: React.FC<IProps> = ({
25
+ questions,
26
+ answers,
27
+ onClose,
28
+ }) => {
29
+ const [currentQuestion, setCurrentQuestion] = useState(questions[0]);
30
+
31
+ const [canShowAnswers, setCanShowAnswers] = useState<boolean>(false);
32
+
33
+ const onGetFirstAnswer = () => {
34
+ if (!currentQuestion.answerIds || currentQuestion.answerIds.length === 0) {
35
+ return null;
36
+ }
37
+
38
+ const firstAnswerId = currentQuestion.answerIds![0];
39
+
40
+ return answers.find(answer => answer.id === firstAnswerId);
41
+ };
42
+
43
+ const [
44
+ currentAnswer,
45
+ setCurrentAnswer,
46
+ ] = useState<IQuestionDialogAnswer | null>(onGetFirstAnswer()!);
47
+
48
+ useEffect(() => {
49
+ setCurrentAnswer(onGetFirstAnswer()!);
50
+ }, [currentQuestion]);
51
+
52
+ const onGetAnswers = (answerIds: number[]) => {
53
+ return answerIds.map((answerId: number) =>
54
+ answers.find(answer => answer.id === answerId)
55
+ );
56
+ };
57
+
58
+ const onKeyPress = (e: KeyboardEvent) => {
59
+ switch (e.key) {
60
+ case 'ArrowDown':
61
+ // select next answer, if any.
62
+ // if no next answer, select first answer
63
+ // const nextAnswer = onGetAnswers(currentQuestion.answerIds!).find(
64
+ // (answer) => answer?.id === currentAnswer!.id + 1
65
+ // );
66
+
67
+ const nextAnswerIndex = onGetAnswers(
68
+ currentQuestion.answerIds!
69
+ ).findIndex(answer => answer?.id === currentAnswer!.id + 1);
70
+
71
+ const nextAnswerID = currentQuestion.answerIds![nextAnswerIndex];
72
+
73
+ // console.log(nextAnswerIndex);
74
+
75
+ const nextAnswer = onGetAnswers(currentQuestion.answerIds!).find(
76
+ answer => answer?.id === nextAnswerID
77
+ );
78
+
79
+ setCurrentAnswer(nextAnswer || onGetFirstAnswer()!);
80
+
81
+ break;
82
+ case 'ArrowUp':
83
+ // select previous answer, if any.
84
+ // if no previous answer, select last answer
85
+
86
+ const previousAnswerIndex = onGetAnswers(
87
+ currentQuestion.answerIds!
88
+ ).findIndex(answer => answer?.id === currentAnswer!.id - 1);
89
+
90
+ const previousAnswerID =
91
+ currentQuestion.answerIds &&
92
+ currentQuestion.answerIds[previousAnswerIndex];
93
+
94
+ const previousAnswer = onGetAnswers(currentQuestion.answerIds!).find(
95
+ answer => answer?.id === previousAnswerID
96
+ );
97
+
98
+ if (previousAnswer) {
99
+ setCurrentAnswer(previousAnswer);
100
+ } else {
101
+ setCurrentAnswer(onGetAnswers(currentQuestion.answerIds!).pop()!);
102
+ }
103
+
104
+ break;
105
+ case 'Enter':
106
+ setCanShowAnswers(false);
107
+
108
+ if (!currentAnswer?.nextQuestionId) {
109
+ onClose();
110
+ return;
111
+ } else {
112
+ setCurrentQuestion(
113
+ questions.find(
114
+ question => question.id === currentAnswer!.nextQuestionId
115
+ )!
116
+ );
117
+ }
118
+
119
+ break;
120
+ }
121
+ };
122
+ useEventListener('keydown', onKeyPress);
123
+
124
+ const onAnswerClick = (answer: IQuestionDialogAnswer) => {
125
+ setCanShowAnswers(false);
126
+ if (answer.nextQuestionId) {
127
+ // if there is a next question, go to it
128
+ setCurrentQuestion(
129
+ questions.find(question => question.id === answer.nextQuestionId)!
130
+ );
131
+ } else {
132
+ // else, finish dialog!
133
+ onClose();
134
+ }
135
+ };
136
+
137
+ const onRenderCurrentAnswers = () => {
138
+ const answerIds = currentQuestion.answerIds;
139
+ if (!answerIds) {
140
+ return null;
141
+ }
142
+
143
+ const answers = onGetAnswers(answerIds);
144
+
145
+ if (!answers) {
146
+ return null;
147
+ }
148
+
149
+ return answers.map(answer => {
150
+ const isSelected = currentAnswer?.id === answer?.id;
151
+ const selectedColor = isSelected ? 'yellow' : 'white';
152
+
153
+ if (answer) {
154
+ return (
155
+ <AnswerRow key={`answer_${answer.id}`}>
156
+ <AnswerSelectedIcon color={selectedColor}>
157
+ {isSelected ? 'X' : null}
158
+ </AnswerSelectedIcon>
159
+
160
+ <Answer
161
+ key={answer.id}
162
+ onClick={() => onAnswerClick(answer)}
163
+ color={selectedColor}
164
+ >
165
+ {answer.text}
166
+ </Answer>
167
+ </AnswerRow>
168
+ );
169
+ }
170
+
171
+ return null;
172
+ });
173
+ };
174
+
175
+ return (
176
+ <Container>
177
+ <QuestionContainer>
178
+ <DynamicText
179
+ text={currentQuestion.text}
180
+ onStart={() => setCanShowAnswers(false)}
181
+ onFinish={() => setCanShowAnswers(true)}
182
+ />
183
+ </QuestionContainer>
184
+
185
+ {canShowAnswers && (
186
+ <AnswersContainer>{onRenderCurrentAnswers()}</AnswersContainer>
187
+ )}
188
+ </Container>
189
+ );
190
+ };
191
+
192
+ const Container = styled.div`
193
+ display: flex;
194
+ word-break: break-all;
195
+ box-sizing: border-box;
196
+ justify-content: flex-start;
197
+ align-items: flex-start;
198
+ flex-wrap: wrap;
199
+ `;
200
+
201
+ const QuestionContainer = styled.div`
202
+ flex: 100%;
203
+ width: 100%;
204
+ `;
205
+
206
+ const AnswersContainer = styled.div`
207
+ flex: 100%;
208
+ `;
209
+
210
+ interface IAnswerProps {
211
+ color: string;
212
+ }
213
+
214
+ const Answer = styled.p<IAnswerProps>`
215
+ flex: auto;
216
+ color: ${props => props.color} !important;
217
+ font-size: 0.65rem !important;
218
+ background: inherit;
219
+ border: none;
220
+ `;
221
+
222
+ const AnswerSelectedIcon = styled.span<IAnswerProps>`
223
+ flex: 5% 0 0;
224
+ color: ${props => props.color} !important;
225
+ `;
226
+
227
+ const AnswerRow = styled.div`
228
+ display: flex;
229
+ flex-wrap: wrap;
230
+ justify-content: center;
231
+ align-items: center;
232
+ margin-bottom: 0.5rem;
233
+ height: 22px;
234
+ p {
235
+ line-height: unset;
236
+ margin-top: 0;
237
+ margin-bottom: 0rem;
238
+ }
239
+ `;
@@ -1,91 +1,91 @@
1
- import React from 'react';
2
- import styled from 'styled-components';
3
-
4
- export interface IBarProps {
5
- max: number;
6
- value: number;
7
- color: 'red' | 'blue' | 'green';
8
- style?: Record<string, any>;
9
- displayText?: boolean;
10
- percentageWidth?: number;
11
- minWidth?: number;
12
- }
13
-
14
- export const ProgressBar: React.FC<IBarProps> = ({
15
- max,
16
- value,
17
- color,
18
- displayText = true,
19
- percentageWidth = 40,
20
- minWidth = 100,
21
- style,
22
- }) => {
23
- const calculatePercentageValue = function(max: number, value: number) {
24
- if (value > max) {
25
- value = max;
26
- }
27
- return (value * 100) / max;
28
- };
29
-
30
- return (
31
- <Container
32
- className="rpgui-progress"
33
- data-value={calculatePercentageValue(max, value) / 100}
34
- data-rpguitype="progress"
35
- percentageWidth={percentageWidth}
36
- minWidth={minWidth}
37
- style={style}
38
- >
39
- {displayText && (
40
- <TextOverlay>
41
- <ProgressBarText>
42
- {value}/{max}
43
- </ProgressBarText>
44
- </TextOverlay>
45
- )}
46
- <div className=" rpgui-progress-track">
47
- <div
48
- className={`rpgui-progress-fill ${color} `}
49
- style={{
50
- left: '0px',
51
- width: calculatePercentageValue(max, value) + '%',
52
- }}
53
- ></div>
54
- </div>
55
- <div className=" rpgui-progress-left-edge"></div>
56
- <div className=" rpgui-progress-right-edge"></div>
57
- </Container>
58
- );
59
- };
60
-
61
- const ProgressBarText = styled.span`
62
- font-size: 1rem;
63
- color: white;
64
- text-align: center;
65
- z-index: 1;
66
- position: absolute;
67
- left: 50%;
68
- transform: translateX(-50%);
69
- top: 12px;
70
- `;
71
-
72
- const TextOverlay = styled.div`
73
- width: 100%;
74
- position: relative;
75
- `;
76
-
77
- interface IContainerProps {
78
- percentageWidth?: number;
79
- minWidth?: number;
80
- style?: Record<string, any>;
81
- }
82
-
83
- const Container = styled.div<IContainerProps>`
84
- display: flex;
85
- flex-direction: column;
86
- min-width: ${props => props.minWidth}px;
87
- width: ${props => props.percentageWidth}%;
88
- justify-content: start;
89
- align-items: flex-start;
90
- ${props => props.style}
91
- `;
1
+ import React from 'react';
2
+ import styled from 'styled-components';
3
+
4
+ export interface IBarProps {
5
+ max: number;
6
+ value: number;
7
+ color: 'red' | 'blue' | 'green';
8
+ style?: Record<string, any>;
9
+ displayText?: boolean;
10
+ percentageWidth?: number;
11
+ minWidth?: number;
12
+ }
13
+
14
+ export const ProgressBar: React.FC<IBarProps> = ({
15
+ max,
16
+ value,
17
+ color,
18
+ displayText = true,
19
+ percentageWidth = 40,
20
+ minWidth = 100,
21
+ style,
22
+ }) => {
23
+ const calculatePercentageValue = function(max: number, value: number) {
24
+ if (value > max) {
25
+ value = max;
26
+ }
27
+ return (value * 100) / max;
28
+ };
29
+
30
+ return (
31
+ <Container
32
+ className="rpgui-progress"
33
+ data-value={calculatePercentageValue(max, value) / 100}
34
+ data-rpguitype="progress"
35
+ percentageWidth={percentageWidth}
36
+ minWidth={minWidth}
37
+ style={style}
38
+ >
39
+ {displayText && (
40
+ <TextOverlay>
41
+ <ProgressBarText>
42
+ {value}/{max}
43
+ </ProgressBarText>
44
+ </TextOverlay>
45
+ )}
46
+ <div className=" rpgui-progress-track">
47
+ <div
48
+ className={`rpgui-progress-fill ${color} `}
49
+ style={{
50
+ left: '0px',
51
+ width: calculatePercentageValue(max, value) + '%',
52
+ }}
53
+ ></div>
54
+ </div>
55
+ <div className=" rpgui-progress-left-edge"></div>
56
+ <div className=" rpgui-progress-right-edge"></div>
57
+ </Container>
58
+ );
59
+ };
60
+
61
+ const ProgressBarText = styled.span`
62
+ font-size: 1rem;
63
+ color: white;
64
+ text-align: center;
65
+ z-index: 1;
66
+ position: absolute;
67
+ left: 50%;
68
+ transform: translateX(-50%);
69
+ top: 12px;
70
+ `;
71
+
72
+ const TextOverlay = styled.div`
73
+ width: 100%;
74
+ position: relative;
75
+ `;
76
+
77
+ interface IContainerProps {
78
+ percentageWidth?: number;
79
+ minWidth?: number;
80
+ style?: Record<string, any>;
81
+ }
82
+
83
+ const Container = styled.div<IContainerProps>`
84
+ display: flex;
85
+ flex-direction: column;
86
+ min-width: ${props => props.minWidth}px;
87
+ width: ${props => props.percentageWidth}%;
88
+ justify-content: start;
89
+ align-items: flex-start;
90
+ ${props => props.style}
91
+ `;