@rpg-engine/long-bow 0.6.26 → 0.6.28
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/PartySystem/PartyManager/PartyManager.d.ts +0 -1
- package/dist/components/PartySystem/mockedConstantes/mockedValues.d.ts +2 -0
- package/dist/long-bow.cjs.development.js +60 -7
- 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 +59 -8
- package/dist/long-bow.esm.js.map +1 -1
- package/dist/stories/PartyManager.stories.d.ts +2 -1
- package/package.json +1 -1
- package/src/components/PartySystem/PartyManager/PartyManager.tsx +2 -3
- package/src/components/PartySystem/PartyManager/PartyManagerRows.tsx +8 -14
- package/src/components/PartySystem/mockedConstantes/mockedValues.tsx +38 -0
- package/src/stories/PartyManager.stories.tsx +24 -4
|
@@ -2,4 +2,5 @@ import { Meta } from '@storybook/react';
|
|
|
2
2
|
import { IPartyManagerProps } from '../components/PartySystem/PartyManager/PartyManager';
|
|
3
3
|
declare const meta: Meta;
|
|
4
4
|
export default meta;
|
|
5
|
-
export declare const
|
|
5
|
+
export declare const YouAreLeader: import("@storybook/csf").AnnotatedStoryFn<import("@storybook/react").ReactFramework, IPartyManagerProps>;
|
|
6
|
+
export declare const YouAreNotLeader: import("@storybook/csf").AnnotatedStoryFn<import("@storybook/react").ReactFramework, IPartyManagerProps>;
|
package/package.json
CHANGED
|
@@ -6,7 +6,7 @@ import { PartyManagerRow } from './PartyManagerRows';
|
|
|
6
6
|
|
|
7
7
|
export interface IPartyManagerProps {
|
|
8
8
|
partyRows: ICharacterPartyShared | null;
|
|
9
|
-
|
|
9
|
+
|
|
10
10
|
userId: string;
|
|
11
11
|
onRemovePlayer: (id: string) => void;
|
|
12
12
|
onChangeLeader: (id: string) => void;
|
|
@@ -14,7 +14,6 @@ export interface IPartyManagerProps {
|
|
|
14
14
|
|
|
15
15
|
export const PartyManager: React.FC<IPartyManagerProps> = ({
|
|
16
16
|
partyRows,
|
|
17
|
-
isLeader,
|
|
18
17
|
userId,
|
|
19
18
|
onRemovePlayer,
|
|
20
19
|
onChangeLeader,
|
|
@@ -49,7 +48,7 @@ export const PartyManager: React.FC<IPartyManagerProps> = ({
|
|
|
49
48
|
charName={partyRow.name}
|
|
50
49
|
charClass={partyRow.class}
|
|
51
50
|
id={partyRow._id}
|
|
52
|
-
isLeader={
|
|
51
|
+
isLeader={partyRow._id === partyRows.leader._id}
|
|
53
52
|
leaderId={partyRows.leader._id}
|
|
54
53
|
onRemovePlayer={() => onRemovePlayer(partyRow._id)}
|
|
55
54
|
onChangeLeader={() => onChangeLeader(partyRow._id)}
|
|
@@ -26,7 +26,7 @@ export const PartyManagerRow: React.FC<IPartyManagerRowProps> = ({
|
|
|
26
26
|
onChangeLeader,
|
|
27
27
|
}) => {
|
|
28
28
|
const isCurrentUser = id === userId;
|
|
29
|
-
const canRemove =
|
|
29
|
+
const canRemove = leaderId === userId || isCurrentUser;
|
|
30
30
|
|
|
31
31
|
return (
|
|
32
32
|
<PartyWrapper>
|
|
@@ -46,8 +46,7 @@ export const PartyManagerRow: React.FC<IPartyManagerRowProps> = ({
|
|
|
46
46
|
{isCurrentUser ? 'Leave' : 'Remove'}
|
|
47
47
|
</HighlightedText>
|
|
48
48
|
)}
|
|
49
|
-
{
|
|
50
|
-
{isLeader && leaderId !== id && (
|
|
49
|
+
{leaderId === userId && leaderId !== id && (
|
|
51
50
|
<HighlightedText onPointerDown={() => onChangeLeader(id)}>
|
|
52
51
|
New Leader
|
|
53
52
|
</HighlightedText>
|
|
@@ -58,17 +57,14 @@ export const PartyManagerRow: React.FC<IPartyManagerRowProps> = ({
|
|
|
58
57
|
};
|
|
59
58
|
|
|
60
59
|
const PartyWrapper = styled.div`
|
|
61
|
-
|
|
62
|
-
|
|
60
|
+
display: grid;
|
|
61
|
+
grid-template-columns: 2fr 1fr 1fr;
|
|
63
62
|
align-items: center;
|
|
64
|
-
justify-content: space-between;
|
|
65
63
|
padding: 0.5rem;
|
|
66
64
|
min-height: 50px;
|
|
67
65
|
box-sizing: border-box;
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
overflow-x: auto;
|
|
66
|
+
width: 100%;
|
|
67
|
+
border-bottom: 1px solid ${uiColors.darkGray};
|
|
72
68
|
|
|
73
69
|
&:hover {
|
|
74
70
|
background-color: ${uiColors.darkGray};
|
|
@@ -77,7 +73,6 @@ const PartyWrapper = styled.div`
|
|
|
77
73
|
`;
|
|
78
74
|
|
|
79
75
|
const TextContainer = styled.div`
|
|
80
|
-
flex: 1;
|
|
81
76
|
color: ${uiColors.white};
|
|
82
77
|
overflow: hidden;
|
|
83
78
|
white-space: nowrap;
|
|
@@ -87,7 +82,6 @@ const TextContainer = styled.div`
|
|
|
87
82
|
const ButtonContainer = styled.div`
|
|
88
83
|
display: flex;
|
|
89
84
|
align-items: center;
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
gap: 1rem; // Increased gap for better spacing between buttons
|
|
85
|
+
gap: 1rem;
|
|
86
|
+
justify-content: flex-start;
|
|
93
87
|
`;
|
|
@@ -172,3 +172,41 @@ export const mockedPartyManager: any[] = [
|
|
|
172
172
|
isLeader: false,
|
|
173
173
|
},
|
|
174
174
|
];
|
|
175
|
+
|
|
176
|
+
// Function to generate mock data for when you are the leader
|
|
177
|
+
export const getMockedPlayersRowsLeader = (
|
|
178
|
+
userId: string
|
|
179
|
+
): ICharacterPartyShared => ({
|
|
180
|
+
id: uuidv4(),
|
|
181
|
+
leader: {
|
|
182
|
+
_id: userId, // You are the leader
|
|
183
|
+
class: CharacterClass.Warrior,
|
|
184
|
+
name: 'YourName',
|
|
185
|
+
},
|
|
186
|
+
members: [
|
|
187
|
+
{ _id: uuidv4(), class: CharacterClass.Druid, name: 'Member1' },
|
|
188
|
+
{ _id: uuidv4(), class: CharacterClass.Sorcerer, name: 'Member2' },
|
|
189
|
+
{ _id: uuidv4(), class: CharacterClass.Rogue, name: 'Member3' },
|
|
190
|
+
],
|
|
191
|
+
maxSize: 5,
|
|
192
|
+
size: 4,
|
|
193
|
+
});
|
|
194
|
+
|
|
195
|
+
// Function to generate mock data for when you are not the leader
|
|
196
|
+
export const getMockedPlayersRowsNotLeader = (
|
|
197
|
+
userId: string
|
|
198
|
+
): ICharacterPartyShared => ({
|
|
199
|
+
id: uuidv4(),
|
|
200
|
+
leader: {
|
|
201
|
+
_id: uuidv4(), // Someone else is the leader
|
|
202
|
+
class: CharacterClass.Druid,
|
|
203
|
+
name: 'LeaderName',
|
|
204
|
+
},
|
|
205
|
+
members: [
|
|
206
|
+
{ _id: userId, class: CharacterClass.Warrior, name: 'YourName' }, // You are a member
|
|
207
|
+
{ _id: uuidv4(), class: CharacterClass.Sorcerer, name: 'Member2' },
|
|
208
|
+
{ _id: uuidv4(), class: CharacterClass.Rogue, name: 'Member3' },
|
|
209
|
+
],
|
|
210
|
+
maxSize: 5,
|
|
211
|
+
size: 4,
|
|
212
|
+
});
|
|
@@ -1,6 +1,12 @@
|
|
|
1
|
+
import { v4 as uuidv4 } from 'uuid';
|
|
2
|
+
|
|
3
|
+
// Storybook setup
|
|
1
4
|
import { Meta, Story } from '@storybook/react';
|
|
2
5
|
import React from 'react';
|
|
3
|
-
import {
|
|
6
|
+
import {
|
|
7
|
+
getMockedPlayersRowsLeader,
|
|
8
|
+
getMockedPlayersRowsNotLeader,
|
|
9
|
+
} from '../components/PartySystem';
|
|
4
10
|
import {
|
|
5
11
|
IPartyManagerProps,
|
|
6
12
|
PartyManager,
|
|
@@ -19,9 +25,23 @@ const Template: Story<IPartyManagerProps> = args => (
|
|
|
19
25
|
<PartyManager {...args} />
|
|
20
26
|
</RPGUIRoot>
|
|
21
27
|
);
|
|
28
|
+
// Assume this is your user ID
|
|
29
|
+
const yourUserId = uuidv4();
|
|
22
30
|
|
|
23
|
-
|
|
31
|
+
// Story where you are the leader
|
|
32
|
+
export const YouAreLeader = Template.bind({});
|
|
33
|
+
YouAreLeader.args = {
|
|
34
|
+
partyRows: getMockedPlayersRowsLeader(yourUserId),
|
|
35
|
+
userId: yourUserId,
|
|
36
|
+
onRemovePlayer: (id: string) => console.log(`Remove player with ID: ${id}`),
|
|
37
|
+
onChangeLeader: (id: string) => console.log(`Change leader to ID: ${id}`),
|
|
38
|
+
};
|
|
24
39
|
|
|
25
|
-
|
|
26
|
-
|
|
40
|
+
// Story where you are not the leader
|
|
41
|
+
export const YouAreNotLeader = Template.bind({});
|
|
42
|
+
YouAreNotLeader.args = {
|
|
43
|
+
partyRows: getMockedPlayersRowsNotLeader(yourUserId),
|
|
44
|
+
userId: yourUserId,
|
|
45
|
+
onRemovePlayer: (id: string) => console.log(`Remove player with ID: ${id}`),
|
|
46
|
+
onChangeLeader: (id: string) => console.log(`Change leader to ID: ${id}`),
|
|
27
47
|
};
|