@rpg-engine/long-bow 0.1.794 → 0.2.2
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/LICENSE +20 -20
- package/README.md +181 -181
- package/dist/components/Button.d.ts +1 -0
- package/dist/components/Equipment/EquipmentSet.d.ts +5 -3
- package/dist/components/Item/Cards/ItemTooltip.d.ts +6 -0
- package/dist/components/Item/Inventory/ItemContainer.d.ts +4 -6
- package/dist/components/Item/Inventory/ItemContainerTypes.d.ts +6 -0
- package/dist/components/Item/Inventory/ItemSlot.d.ts +5 -9
- package/dist/components/Item/Inventory/itemContainerHelper.d.ts +2 -7
- package/dist/components/PropertySelect/PropertySelect.d.ts +12 -0
- package/dist/components/QuestInfo/QuestInfo.d.ts +14 -0
- package/dist/components/RelativeListMenu.d.ts +13 -0
- package/dist/index.d.ts +1 -1
- package/dist/long-bow.cjs.development.js +748 -1194
- 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 +748 -1196
- package/dist/long-bow.esm.js.map +1 -1
- package/dist/mocks/equipmentSet.mocks.d.ts +2 -2
- package/dist/stories/Button.stories.d.ts +5 -0
- package/dist/stories/Chat.stories.d.ts +5 -0
- package/dist/stories/CheckButton.stories.d.ts +5 -0
- package/dist/stories/DraggableContainer.stories.d.ts +5 -0
- package/dist/stories/Dropdown.stories.d.ts +5 -0
- package/dist/stories/EquipmentSet.stories.d.ts +5 -0
- package/dist/stories/ItemContainer.stories.d.ts +5 -0
- package/dist/stories/ListMenu.stories.d.ts +5 -0
- package/dist/stories/Multitab.stories.d.ts +6 -0
- package/dist/stories/NPCDialog.stories.d.ts +7 -0
- package/dist/stories/ProgressBar.stories.d.ts +8 -0
- package/dist/stories/PropertySelect.stories.d.ts +5 -0
- package/dist/stories/QuestInfo.stories.d.ts +5 -0
- package/dist/stories/RPGUIContainers.stories.d.ts +5 -0
- package/dist/stories/RadioButton.stories.d.ts +5 -0
- package/dist/stories/RangeSlider.stories.d.ts +5 -0
- package/dist/stories/ScrollList.stories.d.ts +5 -0
- package/dist/stories/SimpleProgressBar.stories.d.ts +5 -0
- package/dist/stories/SkillProgressBar.stories.d.ts +5 -0
- package/dist/stories/SkillsContainer.stories.d.ts +5 -0
- package/dist/stories/Text.stories.d.ts +7 -0
- package/package.json +98 -96
- package/src/components/Abstractions/SlotsContainer.tsx +42 -42
- package/src/components/Button.tsx +30 -29
- package/src/components/Chat/Chat.tsx +193 -193
- package/src/components/CheckButton.tsx +65 -65
- package/src/components/DraggableContainer.tsx +150 -150
- package/src/components/Dropdown.tsx +57 -57
- package/src/components/Equipment/EquipmentSet.tsx +138 -180
- package/src/components/Input.tsx +11 -11
- package/src/components/Item/Cards/ItemTooltip.tsx +32 -0
- package/src/components/Item/Inventory/ItemContainer.tsx +68 -113
- package/src/components/Item/Inventory/ItemContainerTypes.ts +6 -0
- package/src/components/Item/Inventory/ItemSlot.tsx +212 -158
- package/src/components/Item/Inventory/itemContainerHelper.ts +146 -81
- package/src/components/ListMenu.tsx +65 -65
- package/src/components/Multitab/Tab.tsx +57 -57
- package/src/components/Multitab/TabBody.tsx +13 -13
- package/src/components/Multitab/TabsContainer.tsx +97 -97
- package/src/components/NPCDialog/NPCDialog.tsx +145 -145
- package/src/components/NPCDialog/NPCDialogText.tsx +53 -53
- package/src/components/NPCDialog/QuestionDialog/QuestionDialog.tsx +237 -242
- package/src/components/ProgressBar.tsx +91 -91
- package/src/components/PropertySelect/PropertySelect.tsx +101 -0
- package/src/components/PropertySelect/img/ui-arrows/arrow01-left-clicked.png +0 -0
- package/src/components/PropertySelect/img/ui-arrows/arrow01-left.png +0 -0
- package/src/components/PropertySelect/img/ui-arrows/arrow01-right-clicked.png +0 -0
- package/src/components/PropertySelect/img/ui-arrows/arrow01-right.png +0 -0
- package/src/components/PropertySelect/img/ui-arrows/arrow02-left-clicked.png +0 -0
- package/src/components/PropertySelect/img/ui-arrows/arrow02-left.png +0 -0
- package/src/components/PropertySelect/img/ui-arrows/arrow02-right-clicked.png +0 -0
- package/src/components/PropertySelect/img/ui-arrows/arrow02-right.png +0 -0
- package/src/components/QuestInfo/QuestInfo.tsx +143 -0
- package/src/components/QuestInfo/img/default.png +0 -0
- package/src/components/RPGUIContainer.tsx +47 -47
- package/src/components/RPGUIRoot.tsx +14 -14
- package/src/components/RadioButton.tsx +53 -53
- package/src/components/RangeSlider.tsx +68 -68
- package/src/components/RelativeListMenu.tsx +83 -0
- package/src/components/ScrollList.tsx +77 -77
- package/src/components/SimpleProgressBar.tsx +62 -62
- package/src/components/SkillProgressBar.tsx +123 -124
- package/src/components/SkillsContainer.tsx +196 -235
- package/src/components/TextArea.tsx +11 -11
- package/src/components/Truncate.tsx +25 -25
- package/src/components/shared/Column.tsx +16 -16
- package/src/components/shared/SpriteFromAtlas.tsx +99 -99
- package/src/components/typography/DynamicText.tsx +49 -49
- package/src/constants/uiColors.ts +10 -10
- package/src/hooks/useEventListener.ts +21 -21
- package/src/hooks/useOutsideAlerter.ts +25 -25
- package/src/index.tsx +25 -25
- package/src/libs/StringHelpers.ts +3 -3
- package/src/mocks/atlas/icons/icons.json +735 -303
- package/src/mocks/atlas/icons/icons.png +0 -0
- package/src/mocks/atlas/items/items.json +5215 -5195
- package/src/mocks/atlas/items/items.png +0 -0
- package/src/mocks/equipmentSet.mocks.ts +347 -347
- package/src/mocks/itemContainer.mocks.ts +281 -249
- package/src/mocks/skills.mocks.ts +122 -122
- package/src/stories/Button.stories.tsx +36 -0
- package/src/stories/Chat.stories.tsx +170 -0
- package/src/stories/CheckButton.stories.tsx +48 -0
- package/src/stories/DraggableContainer.stories.tsx +28 -0
- package/src/stories/Dropdown.stories.tsx +46 -0
- package/src/stories/EquipmentSet.stories.tsx +51 -0
- package/src/stories/ItemContainer.stories.tsx +51 -0
- package/src/stories/ListMenu.stories.tsx +56 -0
- package/src/stories/Multitab.stories.tsx +51 -0
- package/src/stories/NPCDialog.stories.tsx +130 -0
- package/src/stories/ProgressBar.stories.tsx +23 -0
- package/src/stories/PropertySelect.stories.tsx +41 -0
- package/src/stories/QuestInfo.stories.tsx +76 -0
- package/src/stories/RPGUIContainers.stories.tsx +42 -0
- package/src/stories/RadioButton.stories.tsx +49 -0
- package/src/stories/RangeSlider.stories.tsx +60 -0
- package/src/stories/ScrollList.stories.tsx +85 -0
- package/src/stories/SimpleProgressBar.stories.tsx +22 -0
- package/src/stories/SkillProgressBar.stories.tsx +30 -0
- package/src/stories/SkillsContainer.stories.tsx +31 -0
- package/src/stories/Text.stories.tsx +42 -0
- package/src/types/eventTypes.ts +4 -4
- package/src/types/index.d.ts +2 -2
- package/dist/components/Item/Cards/ItemCard.d.ts +0 -9
- package/dist/components/shared/SpriteIcon.d.ts +0 -9
- package/dist/components/store/UI.store.d.ts +0 -38
- package/src/components/Item/Cards/ItemCard.tsx +0 -36
- package/src/components/shared/SpriteIcon.tsx +0 -67
- package/src/components/store/UI.store.ts +0 -232
|
@@ -1,65 +1,65 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import styled from 'styled-components';
|
|
3
|
-
|
|
4
|
-
interface IListMenuOption {
|
|
5
|
-
id: string;
|
|
6
|
-
text: string;
|
|
7
|
-
}
|
|
8
|
-
|
|
9
|
-
export interface IListMenuProps {
|
|
10
|
-
x: number;
|
|
11
|
-
y: number;
|
|
12
|
-
options: IListMenuOption[];
|
|
13
|
-
onSelected: (selectedOptionId: string) => void;
|
|
14
|
-
fontSize?: number;
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
export const ListMenu: React.FC<IListMenuProps> = ({
|
|
18
|
-
options,
|
|
19
|
-
onSelected,
|
|
20
|
-
x,
|
|
21
|
-
y,
|
|
22
|
-
fontSize = 0.8,
|
|
23
|
-
}) => {
|
|
24
|
-
return (
|
|
25
|
-
<Container x={x} y={y} fontSize={fontSize}>
|
|
26
|
-
<ul className="rpgui-list-imp" style={{ overflow: 'hidden' }}>
|
|
27
|
-
{options.map((params, index) => (
|
|
28
|
-
<ListElement
|
|
29
|
-
key={params?.id || index}
|
|
30
|
-
onClick={() => {
|
|
31
|
-
onSelected(params?.id);
|
|
32
|
-
}}
|
|
33
|
-
>
|
|
34
|
-
{params?.text || 'No text'}
|
|
35
|
-
</ListElement>
|
|
36
|
-
))}
|
|
37
|
-
</ul>
|
|
38
|
-
</Container>
|
|
39
|
-
);
|
|
40
|
-
};
|
|
41
|
-
|
|
42
|
-
interface IContainerProps {
|
|
43
|
-
x?: number;
|
|
44
|
-
y?: number;
|
|
45
|
-
fontSize?: number;
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
const Container = styled.div<IContainerProps>`
|
|
49
|
-
display: flex;
|
|
50
|
-
flex-direction: column;
|
|
51
|
-
width: 100%;
|
|
52
|
-
justify-content: start;
|
|
53
|
-
align-items: flex-start;
|
|
54
|
-
position: absolute;
|
|
55
|
-
top: ${props => props.y || 0}px;
|
|
56
|
-
left: ${props => props.x || 0}px;
|
|
57
|
-
|
|
58
|
-
li {
|
|
59
|
-
font-size: ${props => props.fontSize}em;
|
|
60
|
-
}
|
|
61
|
-
`;
|
|
62
|
-
|
|
63
|
-
const ListElement = styled.li`
|
|
64
|
-
margin-right: 0.5rem;
|
|
65
|
-
`;
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import styled from 'styled-components';
|
|
3
|
+
|
|
4
|
+
interface IListMenuOption {
|
|
5
|
+
id: string;
|
|
6
|
+
text: string;
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
export interface IListMenuProps {
|
|
10
|
+
x: number;
|
|
11
|
+
y: number;
|
|
12
|
+
options: IListMenuOption[];
|
|
13
|
+
onSelected: (selectedOptionId: string) => void;
|
|
14
|
+
fontSize?: number;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
export const ListMenu: React.FC<IListMenuProps> = ({
|
|
18
|
+
options,
|
|
19
|
+
onSelected,
|
|
20
|
+
x,
|
|
21
|
+
y,
|
|
22
|
+
fontSize = 0.8,
|
|
23
|
+
}) => {
|
|
24
|
+
return (
|
|
25
|
+
<Container x={x} y={y} fontSize={fontSize}>
|
|
26
|
+
<ul className="rpgui-list-imp" style={{ overflow: 'hidden' }}>
|
|
27
|
+
{options.map((params, index) => (
|
|
28
|
+
<ListElement
|
|
29
|
+
key={params?.id || index}
|
|
30
|
+
onClick={() => {
|
|
31
|
+
onSelected(params?.id);
|
|
32
|
+
}}
|
|
33
|
+
>
|
|
34
|
+
{params?.text || 'No text'}
|
|
35
|
+
</ListElement>
|
|
36
|
+
))}
|
|
37
|
+
</ul>
|
|
38
|
+
</Container>
|
|
39
|
+
);
|
|
40
|
+
};
|
|
41
|
+
|
|
42
|
+
interface IContainerProps {
|
|
43
|
+
x?: number;
|
|
44
|
+
y?: number;
|
|
45
|
+
fontSize?: number;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
const Container = styled.div<IContainerProps>`
|
|
49
|
+
display: flex;
|
|
50
|
+
flex-direction: column;
|
|
51
|
+
width: 100%;
|
|
52
|
+
justify-content: start;
|
|
53
|
+
align-items: flex-start;
|
|
54
|
+
position: absolute;
|
|
55
|
+
top: ${props => props.y || 0}px;
|
|
56
|
+
left: ${props => props.x || 0}px;
|
|
57
|
+
|
|
58
|
+
li {
|
|
59
|
+
font-size: ${props => props.fontSize}em;
|
|
60
|
+
}
|
|
61
|
+
`;
|
|
62
|
+
|
|
63
|
+
const ListElement = styled.li`
|
|
64
|
+
margin-right: 0.5rem;
|
|
65
|
+
`;
|
|
@@ -1,57 +1,57 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import styled from 'styled-components';
|
|
3
|
-
import { MultitabType } from './TabsContainer';
|
|
4
|
-
|
|
5
|
-
export interface ISingleTab {
|
|
6
|
-
active: boolean;
|
|
7
|
-
label: string;
|
|
8
|
-
onClick: () => void;
|
|
9
|
-
type: MultitabType;
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
export const Tab: React.FC<ISingleTab> = ({ active, label, onClick, type }) => {
|
|
13
|
-
return (
|
|
14
|
-
<CustomTab activeTab={active} onClick={onClick} className={type}>
|
|
15
|
-
<p>{label}</p>
|
|
16
|
-
</CustomTab>
|
|
17
|
-
);
|
|
18
|
-
};
|
|
19
|
-
|
|
20
|
-
interface ICustomTab {
|
|
21
|
-
activeTab: boolean;
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
const CustomTab = styled.div<ICustomTab>`
|
|
25
|
-
width: 120px;
|
|
26
|
-
color: white;
|
|
27
|
-
font-size: 0.8rem;
|
|
28
|
-
|
|
29
|
-
&.gray {
|
|
30
|
-
border-left: 0.25rem solid rgba(0, 0, 0, 0.25);
|
|
31
|
-
border-right: 0.25rem solid rgba(0, 0, 0, 0.25);
|
|
32
|
-
border-top: 0.25rem solid rgba(0, 0, 0, 0.25);
|
|
33
|
-
background: ${props => (props.activeTab ? '#4E4A4E' : '#2b292b')};
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
&.brown {
|
|
37
|
-
border-left: 0.25rem solid #996d55;
|
|
38
|
-
border-right: 0.25rem solid #996d55;
|
|
39
|
-
border-top: 0.25rem solid #996d55;
|
|
40
|
-
background: ${props => (props.activeTab ? '#BF886A' : '#B67051')};
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
margin-right: 10px;
|
|
44
|
-
p {
|
|
45
|
-
text-align: center;
|
|
46
|
-
font-size: 0.6rem;
|
|
47
|
-
|
|
48
|
-
opacity: ${props => (props.activeTab ? '1' : '0.5')};
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
border-radius: 5px 5px 0 0;
|
|
52
|
-
|
|
53
|
-
z-index: ${props => (props.activeTab ? 1 : -1)};
|
|
54
|
-
|
|
55
|
-
position: relative;
|
|
56
|
-
top: 0.3rem;
|
|
57
|
-
`;
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import styled from 'styled-components';
|
|
3
|
+
import { MultitabType } from './TabsContainer';
|
|
4
|
+
|
|
5
|
+
export interface ISingleTab {
|
|
6
|
+
active: boolean;
|
|
7
|
+
label: string;
|
|
8
|
+
onClick: () => void;
|
|
9
|
+
type: MultitabType;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
export const Tab: React.FC<ISingleTab> = ({ active, label, onClick, type }) => {
|
|
13
|
+
return (
|
|
14
|
+
<CustomTab activeTab={active} onClick={onClick} className={type}>
|
|
15
|
+
<p>{label}</p>
|
|
16
|
+
</CustomTab>
|
|
17
|
+
);
|
|
18
|
+
};
|
|
19
|
+
|
|
20
|
+
interface ICustomTab {
|
|
21
|
+
activeTab: boolean;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
const CustomTab = styled.div<ICustomTab>`
|
|
25
|
+
width: 120px;
|
|
26
|
+
color: white;
|
|
27
|
+
font-size: 0.8rem;
|
|
28
|
+
|
|
29
|
+
&.gray {
|
|
30
|
+
border-left: 0.25rem solid rgba(0, 0, 0, 0.25);
|
|
31
|
+
border-right: 0.25rem solid rgba(0, 0, 0, 0.25);
|
|
32
|
+
border-top: 0.25rem solid rgba(0, 0, 0, 0.25);
|
|
33
|
+
background: ${props => (props.activeTab ? '#4E4A4E' : '#2b292b')};
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
&.brown {
|
|
37
|
+
border-left: 0.25rem solid #996d55;
|
|
38
|
+
border-right: 0.25rem solid #996d55;
|
|
39
|
+
border-top: 0.25rem solid #996d55;
|
|
40
|
+
background: ${props => (props.activeTab ? '#BF886A' : '#B67051')};
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
margin-right: 10px;
|
|
44
|
+
p {
|
|
45
|
+
text-align: center;
|
|
46
|
+
font-size: 0.6rem;
|
|
47
|
+
|
|
48
|
+
opacity: ${props => (props.activeTab ? '1' : '0.5')};
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
border-radius: 5px 5px 0 0;
|
|
52
|
+
|
|
53
|
+
z-index: ${props => (props.activeTab ? 1 : -1)};
|
|
54
|
+
|
|
55
|
+
position: relative;
|
|
56
|
+
top: 0.3rem;
|
|
57
|
+
`;
|
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import styled from 'styled-components';
|
|
3
|
-
|
|
4
|
-
interface IProps {
|
|
5
|
-
id: string;
|
|
6
|
-
children: React.ReactNode;
|
|
7
|
-
}
|
|
8
|
-
|
|
9
|
-
export const TabBody: React.FC<IProps> = ({ id, children }) => {
|
|
10
|
-
return <Container data-tab-id={id}>{children}</Container>;
|
|
11
|
-
};
|
|
12
|
-
|
|
13
|
-
const Container = styled.div``;
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import styled from 'styled-components';
|
|
3
|
+
|
|
4
|
+
interface IProps {
|
|
5
|
+
id: string;
|
|
6
|
+
children: React.ReactNode;
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
export const TabBody: React.FC<IProps> = ({ id, children }) => {
|
|
10
|
+
return <Container data-tab-id={id}>{children}</Container>;
|
|
11
|
+
};
|
|
12
|
+
|
|
13
|
+
const Container = styled.div``;
|
|
@@ -1,97 +1,97 @@
|
|
|
1
|
-
import React, { useState } from 'react';
|
|
2
|
-
import styled from 'styled-components';
|
|
3
|
-
import { DraggableContainer } from '../DraggableContainer';
|
|
4
|
-
import { RPGUIContainerTypes } from '../RPGUIContainer';
|
|
5
|
-
import { Tab } from './Tab';
|
|
6
|
-
|
|
7
|
-
interface ITab {
|
|
8
|
-
label: string;
|
|
9
|
-
id: string;
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
export enum MultitabType {
|
|
13
|
-
Brown = 'brown',
|
|
14
|
-
Gray = 'gray',
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
export interface ITabsContainer {
|
|
18
|
-
children: React.ReactNode;
|
|
19
|
-
onCloseButton?: () => void;
|
|
20
|
-
tabs: ITab[];
|
|
21
|
-
type: MultitabType;
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
export const TabsContainer: React.FC<ITabsContainer> = ({
|
|
25
|
-
children,
|
|
26
|
-
onCloseButton,
|
|
27
|
-
tabs,
|
|
28
|
-
type = MultitabType.Brown,
|
|
29
|
-
}) => {
|
|
30
|
-
const [selectedTab, setSelectedTab] = useState(tabs[0].id); //by default the first one
|
|
31
|
-
|
|
32
|
-
const onRenderTabs = () =>
|
|
33
|
-
tabs.map((tab, index) => (
|
|
34
|
-
<Tab
|
|
35
|
-
type={type}
|
|
36
|
-
active={selectedTab === tab.id}
|
|
37
|
-
label={tab.label}
|
|
38
|
-
key={`${tab.label}_${index}`}
|
|
39
|
-
onClick={() => setSelectedTab(tab.id)}
|
|
40
|
-
/>
|
|
41
|
-
));
|
|
42
|
-
|
|
43
|
-
const onGetContainerType = () => {
|
|
44
|
-
switch (type) {
|
|
45
|
-
case 'brown':
|
|
46
|
-
return RPGUIContainerTypes.FramedGold;
|
|
47
|
-
case 'gray':
|
|
48
|
-
return RPGUIContainerTypes.Framed;
|
|
49
|
-
default:
|
|
50
|
-
return RPGUIContainerTypes.Framed;
|
|
51
|
-
}
|
|
52
|
-
};
|
|
53
|
-
|
|
54
|
-
return (
|
|
55
|
-
<DraggableContainer
|
|
56
|
-
onCloseButton={onCloseButton}
|
|
57
|
-
type={onGetContainerType()}
|
|
58
|
-
>
|
|
59
|
-
{onRenderTabs()}
|
|
60
|
-
<BodyContainer selectedTab={selectedTab} className={type}>
|
|
61
|
-
{children}
|
|
62
|
-
</BodyContainer>
|
|
63
|
-
</DraggableContainer>
|
|
64
|
-
);
|
|
65
|
-
};
|
|
66
|
-
|
|
67
|
-
interface IBodyContainer {
|
|
68
|
-
selectedTab: string;
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
const BodyContainer = styled.div<IBodyContainer>`
|
|
72
|
-
display: flex;
|
|
73
|
-
width: 100%;
|
|
74
|
-
height: 100%;
|
|
75
|
-
justify-content: space-between;
|
|
76
|
-
|
|
77
|
-
/* hide everything that is not data-tab-id selectedTab */
|
|
78
|
-
& > *:not([data-tab-id=${props => props.selectedTab}]) {
|
|
79
|
-
display: none;
|
|
80
|
-
}
|
|
81
|
-
|
|
82
|
-
&.brown {
|
|
83
|
-
border: 0.25rem solid #996D55;
|
|
84
|
-
background-color: #BF886A;
|
|
85
|
-
}
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
&.gray {
|
|
89
|
-
border: 0.25rem solid rgba(0, 0, 0, 0.25);
|
|
90
|
-
background-color: #4E4A4E;
|
|
91
|
-
}
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
border-radius: 5px;
|
|
95
|
-
padding: 0.5rem;
|
|
96
|
-
|
|
97
|
-
`;
|
|
1
|
+
import React, { useState } from 'react';
|
|
2
|
+
import styled from 'styled-components';
|
|
3
|
+
import { DraggableContainer } from '../DraggableContainer';
|
|
4
|
+
import { RPGUIContainerTypes } from '../RPGUIContainer';
|
|
5
|
+
import { Tab } from './Tab';
|
|
6
|
+
|
|
7
|
+
interface ITab {
|
|
8
|
+
label: string;
|
|
9
|
+
id: string;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
export enum MultitabType {
|
|
13
|
+
Brown = 'brown',
|
|
14
|
+
Gray = 'gray',
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
export interface ITabsContainer {
|
|
18
|
+
children: React.ReactNode;
|
|
19
|
+
onCloseButton?: () => void;
|
|
20
|
+
tabs: ITab[];
|
|
21
|
+
type: MultitabType;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
export const TabsContainer: React.FC<ITabsContainer> = ({
|
|
25
|
+
children,
|
|
26
|
+
onCloseButton,
|
|
27
|
+
tabs,
|
|
28
|
+
type = MultitabType.Brown,
|
|
29
|
+
}) => {
|
|
30
|
+
const [selectedTab, setSelectedTab] = useState(tabs[0].id); //by default the first one
|
|
31
|
+
|
|
32
|
+
const onRenderTabs = () =>
|
|
33
|
+
tabs.map((tab, index) => (
|
|
34
|
+
<Tab
|
|
35
|
+
type={type}
|
|
36
|
+
active={selectedTab === tab.id}
|
|
37
|
+
label={tab.label}
|
|
38
|
+
key={`${tab.label}_${index}`}
|
|
39
|
+
onClick={() => setSelectedTab(tab.id)}
|
|
40
|
+
/>
|
|
41
|
+
));
|
|
42
|
+
|
|
43
|
+
const onGetContainerType = () => {
|
|
44
|
+
switch (type) {
|
|
45
|
+
case 'brown':
|
|
46
|
+
return RPGUIContainerTypes.FramedGold;
|
|
47
|
+
case 'gray':
|
|
48
|
+
return RPGUIContainerTypes.Framed;
|
|
49
|
+
default:
|
|
50
|
+
return RPGUIContainerTypes.Framed;
|
|
51
|
+
}
|
|
52
|
+
};
|
|
53
|
+
|
|
54
|
+
return (
|
|
55
|
+
<DraggableContainer
|
|
56
|
+
onCloseButton={onCloseButton}
|
|
57
|
+
type={onGetContainerType()}
|
|
58
|
+
>
|
|
59
|
+
{onRenderTabs()}
|
|
60
|
+
<BodyContainer selectedTab={selectedTab} className={type}>
|
|
61
|
+
{children}
|
|
62
|
+
</BodyContainer>
|
|
63
|
+
</DraggableContainer>
|
|
64
|
+
);
|
|
65
|
+
};
|
|
66
|
+
|
|
67
|
+
interface IBodyContainer {
|
|
68
|
+
selectedTab: string;
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
const BodyContainer = styled.div<IBodyContainer>`
|
|
72
|
+
display: flex;
|
|
73
|
+
width: 100%;
|
|
74
|
+
height: 100%;
|
|
75
|
+
justify-content: space-between;
|
|
76
|
+
|
|
77
|
+
/* hide everything that is not data-tab-id selectedTab */
|
|
78
|
+
& > *:not([data-tab-id=${props => props.selectedTab}]) {
|
|
79
|
+
display: none;
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
&.brown {
|
|
83
|
+
border: 0.25rem solid #996D55;
|
|
84
|
+
background-color: #BF886A;
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
|
|
88
|
+
&.gray {
|
|
89
|
+
border: 0.25rem solid rgba(0, 0, 0, 0.25);
|
|
90
|
+
background-color: #4E4A4E;
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
|
|
94
|
+
border-radius: 5px;
|
|
95
|
+
padding: 0.5rem;
|
|
96
|
+
|
|
97
|
+
`;
|