@rpg-engine/long-bow 0.6.27 → 0.6.29

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.
@@ -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 Default: import("@storybook/csf").AnnotatedStoryFn<import("@storybook/react").ReactFramework, IPartyManagerProps>;
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
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rpg-engine/long-bow",
3
- "version": "0.6.27",
3
+ "version": "0.6.29",
4
4
  "license": "MIT",
5
5
  "main": "dist/index.js",
6
6
  "typings": "dist/index.d.ts",
@@ -26,7 +26,7 @@ export const PartyManagerRow: React.FC<IPartyManagerRowProps> = ({
26
26
  onChangeLeader,
27
27
  }) => {
28
28
  const isCurrentUser = id === userId;
29
- const canRemove = isLeader || isCurrentUser; // Only leaders or the current user can remove
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
- {/* Render the "New Leader" button only if the user is the leader and not the current user */}
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
- width: 100%;
62
- display: flex;
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
- gap: 1rem;
69
- transition: background-color 0.3s ease;
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
- justify-content: space-between;
91
- min-width: 150px;
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
+ });
@@ -164,7 +164,7 @@ const StepperFooter = styled.div`
164
164
  margin-top: 1rem;
165
165
  flex: 1;
166
166
  display: flex;
167
- justify-content: flex-end;
167
+ justify-content: center;
168
168
  align-items: center;
169
169
  `;
170
170
 
@@ -1,5 +1,6 @@
1
- import React from 'react';
1
+ import React, { useMemo } from 'react';
2
2
  import styled, { CSSProperties } from 'styled-components';
3
+ import { uiColors } from '../../constants/uiColors';
3
4
  import { Stepper } from '../Stepper';
4
5
  import { DynamicText } from '../typography/DynamicText';
5
6
 
@@ -16,56 +17,61 @@ export interface ITutorialStepperProps {
16
17
  imageStyle?: CSSProperties;
17
18
  }
18
19
 
19
- export const TutorialStepper = ({
20
- lessons,
21
- onLessonFinish,
22
- imageStyle,
23
- }: ITutorialStepperProps) => {
24
- const generateLessons = () => {
25
- return lessons.map((lesson, index) => ({
26
- component: (
27
- <LessonContainer key={index} className="lesson-container">
28
- <LessonTitle className="lesson-title">{lesson.title}</LessonTitle>
29
- {lesson.image && (
30
- <LessonImage className="lesson-image" style={imageStyle}>
31
- <img src={lesson.image} alt={lesson.title} />
32
- </LessonImage>
33
- )}
34
- <LessonFooter className="lesson-footer">
35
- {lesson.body && (
36
- <LessonBody className="lesson-body">{lesson.body}</LessonBody>
37
- )}
38
- {lesson.text && <DynamicText text={lesson.text} />}
39
- </LessonFooter>
40
- </LessonContainer>
41
- ),
42
- id: index,
43
- }));
44
- };
20
+ export const TutorialStepper = React.memo(
21
+ ({ lessons, onLessonFinish, imageStyle }: ITutorialStepperProps) => {
22
+ const generateLessons = useMemo(
23
+ () =>
24
+ lessons.map((lesson, index) => ({
25
+ component: (
26
+ <LessonContainer key={index} className="lesson-container">
27
+ <LessonTitle className="lesson-title">{lesson.title}</LessonTitle>
28
+ {lesson.image && (
29
+ <LessonImage className="lesson-image" style={imageStyle}>
30
+ <img
31
+ src={lesson.image}
32
+ alt={lesson.title || 'Tutorial image'}
33
+ loading="lazy"
34
+ />
35
+ </LessonImage>
36
+ )}
37
+ <LessonFooter className="lesson-footer">
38
+ {lesson.body && (
39
+ <LessonBody className="lesson-body">{lesson.body}</LessonBody>
40
+ )}
41
+ {lesson.text && <DynamicText text={lesson.text} />}
42
+ </LessonFooter>
43
+ </LessonContainer>
44
+ ),
45
+ id: index,
46
+ })),
47
+ [lessons, imageStyle]
48
+ );
45
49
 
46
- return (
47
- <Container>
48
- <Stepper
49
- steps={generateLessons()}
50
- finalCTAButton={{
51
- label: 'Close',
52
- onClick: () => {
53
- onLessonFinish();
54
- },
55
- }}
56
- useSideArrows
57
- />
58
- </Container>
59
- );
60
- };
50
+ return (
51
+ <Container>
52
+ <Stepper
53
+ steps={generateLessons}
54
+ finalCTAButton={{
55
+ label: 'Close',
56
+ onClick: onLessonFinish,
57
+ }}
58
+ useSideArrows
59
+ />
60
+ </Container>
61
+ );
62
+ }
63
+ );
61
64
 
62
65
  const LessonBody = styled.div``;
63
66
 
64
67
  const Container = styled.div`
65
- margin: 2rem;
66
-
68
+ margin: 1rem auto;
67
69
  width: 80%;
68
- margin: 0 auto;
70
+ max-width: 600px;
71
+
72
+ @media (max-width: 600px) {
73
+ width: 95%;
74
+ }
69
75
  `;
70
76
 
71
77
  const LessonFooter = styled.div`
@@ -78,7 +84,7 @@ const LessonImage = styled.div`
78
84
  align-items: center;
79
85
  width: 100%;
80
86
  height: auto;
81
- max-width: 600px;
87
+ max-width: 500px;
82
88
  margin: auto;
83
89
 
84
90
  img {
@@ -89,6 +95,9 @@ const LessonImage = styled.div`
89
95
  }
90
96
  `;
91
97
 
92
- const LessonTitle = styled.h1``;
98
+ const LessonTitle = styled.h1`
99
+ color: ${uiColors.yellow} !important;
100
+ font-size: 0.8rem !important;
101
+ `;
93
102
 
94
103
  const LessonContainer = styled.div``;
@@ -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 { mockedPlayersRows2 } from '../components/PartySystem';
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
- export const Default = Template.bind({});
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
- Default.args = {
26
- partyRows: mockedPlayersRows2,
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
  };