@rpg-engine/long-bow 0.6.19 → 0.6.21

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rpg-engine/long-bow",
3
- "version": "0.6.19",
3
+ "version": "0.6.21",
4
4
  "license": "MIT",
5
5
  "main": "dist/index.js",
6
6
  "typings": "dist/index.d.ts",
@@ -2,14 +2,12 @@ import { ICharacterPartyShared, isMobileOrTablet } from '@rpg-engine/shared';
2
2
  import React from 'react';
3
3
  import styled from 'styled-components';
4
4
  import { uiColors } from '../../../constants/uiColors';
5
- import { DraggableContainer } from '../../DraggableContainer';
6
- import { RPGUIContainerTypes } from '../../RPGUI/RPGUIContainer';
7
5
  import { PartyManagerRow } from './PartyManagerRows';
8
6
 
9
7
  export interface IPartyManagerProps {
10
8
  partyRows: ICharacterPartyShared | null;
11
9
  isLeader: boolean;
12
- onClose?: () => void;
10
+ userId: string;
13
11
  onRemovePlayer: (id: string) => void;
14
12
  onChangeLeader: (id: string) => void;
15
13
  }
@@ -17,20 +15,14 @@ export interface IPartyManagerProps {
17
15
  export const PartyManager: React.FC<IPartyManagerProps> = ({
18
16
  partyRows,
19
17
  isLeader,
20
- onClose,
18
+ userId,
21
19
  onRemovePlayer,
22
20
  onChangeLeader,
23
21
  }) => {
24
22
  const invitationActionText = isMobileOrTablet() ? 'Tap' : 'Right click';
25
23
 
26
24
  return (
27
- <DraggableContainer
28
- type={RPGUIContainerTypes.Framed}
29
- onCloseButton={onClose}
30
- width="800px"
31
- height="400px"
32
- cancelDrag=".partyRows"
33
- >
25
+ <>
34
26
  <Wrapper>
35
27
  <div style={{ width: '100%' }}>
36
28
  <Title>Party Dashboard</Title>
@@ -41,6 +33,7 @@ export const PartyManager: React.FC<IPartyManagerProps> = ({
41
33
  {partyRows && partyRows.members ? (
42
34
  <>
43
35
  <PartyManagerRow
36
+ userId={userId}
44
37
  key={partyRows.leader._id}
45
38
  id={partyRows.leader._id}
46
39
  leaderId={partyRows.leader._id}
@@ -52,6 +45,7 @@ export const PartyManager: React.FC<IPartyManagerProps> = ({
52
45
  />
53
46
  {partyRows.members.map(partyRow => (
54
47
  <PartyManagerRow
48
+ userId={userId}
55
49
  key={partyRow._id}
56
50
  charName={partyRow.name}
57
51
  charClass={partyRow.class}
@@ -64,20 +58,26 @@ export const PartyManager: React.FC<IPartyManagerProps> = ({
64
58
  ))}
65
59
  </>
66
60
  ) : (
67
- <>
68
- <NotInParty>
69
- <p>You're not in a party.</p>
70
- <p>
71
- Tip: <YellowText>{invitationActionText}</YellowText> on a player
72
- to invite them.
73
- </p>
74
- </NotInParty>
75
- </>
61
+ <NotInParty>
62
+ <p>You're not in a party.</p>
63
+ <p>
64
+ Tip: <YellowText>{invitationActionText}</YellowText> on a player
65
+ to invite them.
66
+ </p>
67
+ </NotInParty>
76
68
  )}
77
69
  </RowsWrapper>
78
- </DraggableContainer>
70
+ </>
79
71
  );
80
72
  };
73
+
74
+ const RowsWrapper = styled.div`
75
+ width: 100%;
76
+ max-height: 300px;
77
+ overflow-y: auto;
78
+ overflow-x: hidden;
79
+ `;
80
+
81
81
  const YellowText = styled.span`
82
82
  color: ${uiColors.yellow} !important;
83
83
  `;
@@ -88,10 +88,6 @@ const Wrapper = styled.div`
88
88
  width: 100%;
89
89
  `;
90
90
 
91
- const RowsWrapper = styled.div`
92
- width: 100%;
93
- `;
94
-
95
91
  const Title = styled.h1`
96
92
  font-size: 0.6rem;
97
93
  color: ${uiColors.yellow} !important;
@@ -1,7 +1,8 @@
1
1
  import React from 'react';
2
2
  import styled from 'styled-components';
3
3
  import { uiColors } from '../../../constants/uiColors';
4
- import { Button, ButtonTypes } from '../../Button';
4
+ import { HighlightedText } from '../../Text/HighlightedText';
5
+ import { Ellipsis } from '../../shared/Ellipsis';
5
6
 
6
7
  export interface IPartyManagerRowProps {
7
8
  id: string;
@@ -9,6 +10,7 @@ export interface IPartyManagerRowProps {
9
10
  charClass: string;
10
11
  isLeader: boolean;
11
12
  leaderId: string;
13
+ userId: string;
12
14
  onRemovePlayer: (id: string) => void;
13
15
  onChangeLeader: (id: string) => void;
14
16
  }
@@ -19,28 +21,38 @@ export const PartyManagerRow: React.FC<IPartyManagerRowProps> = ({
19
21
  isLeader,
20
22
  id,
21
23
  leaderId,
24
+ userId,
22
25
  onRemovePlayer,
23
26
  onChangeLeader,
24
27
  }) => {
28
+ const isCurrentUser = id === userId;
29
+ const canRemove = isLeader || isCurrentUser; // Only leaders or the current user can remove
30
+
25
31
  return (
26
32
  <PartyWrapper>
27
- <TextContainer>{charName}</TextContainer>
28
- <TextContainer>{charClass}</TextContainer>
29
- <div className="cancel-button">
30
- <Button
31
- buttonType={ButtonTypes.RPGUIButton}
32
- onPointerDown={() => onRemovePlayer(id)}
33
- >
34
- Remove
35
- </Button>
36
- </div>
37
- <Button
38
- buttonType={ButtonTypes.RPGUIButton}
39
- disabled={!isLeader || leaderId === id}
40
- onPointerDown={() => onChangeLeader(id)}
41
- >
42
- New Leader
43
- </Button>
33
+ <TextContainer>
34
+ <Ellipsis maxLines={1} maxWidth="200px" fontSize="0.8rem">
35
+ {charName}
36
+ </Ellipsis>
37
+ </TextContainer>
38
+ <TextContainer>
39
+ <Ellipsis maxLines={1} maxWidth="200px" fontSize="0.8rem">
40
+ {charClass}
41
+ </Ellipsis>
42
+ </TextContainer>
43
+ <ButtonContainer>
44
+ {canRemove && (
45
+ <HighlightedText onPointerDown={() => onRemovePlayer(id)}>
46
+ {isCurrentUser ? 'Leave' : 'Remove'}
47
+ </HighlightedText>
48
+ )}
49
+ {/* Render the "New Leader" button only if the user is the leader and not the current user */}
50
+ {isLeader && leaderId !== id && (
51
+ <HighlightedText onPointerDown={() => onChangeLeader(id)}>
52
+ New Leader
53
+ </HighlightedText>
54
+ )}
55
+ </ButtonContainer>
44
56
  </PartyWrapper>
45
57
  );
46
58
  };
@@ -49,12 +61,33 @@ const PartyWrapper = styled.div`
49
61
  width: 100%;
50
62
  display: flex;
51
63
  align-items: center;
52
- justify-content: space-around;
53
- .cancel-button {
54
- filter: grayscale(0.7);
64
+ justify-content: space-between;
65
+ padding: 0.5rem;
66
+ min-height: 50px;
67
+ box-sizing: border-box;
68
+ gap: 1rem;
69
+ transition: background-color 0.3s ease; // Smooth transition for background color
70
+
71
+ overflow-x: auto;
72
+
73
+ &:hover {
74
+ background-color: ${uiColors.darkGray}; // Darker overlay color on hover
75
+ cursor: pointer; // Change cursor to pointer for better UX feedback
55
76
  }
56
77
  `;
57
78
 
58
79
  const TextContainer = styled.div`
80
+ flex: 1;
59
81
  color: ${uiColors.white};
82
+ overflow: hidden;
83
+ white-space: nowrap;
84
+ text-overflow: ellipsis;
85
+ `;
86
+
87
+ const ButtonContainer = styled.div`
88
+ display: flex;
89
+ align-items: center;
90
+ justify-content: flex-end;
91
+ min-width: 150px;
92
+ gap: 0.5rem;
60
93
  `;
@@ -90,6 +90,13 @@ export const mockedPlayersRows2: ICharacterPartyShared = {
90
90
  { _id: uuidv4(), class: CharacterClass.Druid, name: 'blblb' },
91
91
  { _id: uuidv4(), class: CharacterClass.Druid, name: 'blblb' },
92
92
  { _id: uuidv4(), class: CharacterClass.Druid, name: 'blblb' },
93
+ { _id: uuidv4(), class: CharacterClass.Druid, name: 'blblb' },
94
+ { _id: uuidv4(), class: CharacterClass.Druid, name: 'blblb' },
95
+ { _id: uuidv4(), class: CharacterClass.Druid, name: 'blblb' },
96
+ { _id: uuidv4(), class: CharacterClass.Druid, name: 'blblb' },
97
+ { _id: uuidv4(), class: CharacterClass.Druid, name: 'blblb' },
98
+ { _id: uuidv4(), class: CharacterClass.Druid, name: 'blblb' },
99
+ { _id: uuidv4(), class: CharacterClass.Druid, name: 'blblb' },
93
100
  ],
94
101
  maxSize: 5,
95
102
  size: 4,
@@ -0,0 +1,25 @@
1
+ import React from 'react';
2
+ import styled from 'styled-components';
3
+ import { uiColors } from '../../constants/uiColors';
4
+
5
+ interface IProps extends React.HTMLAttributes<HTMLParagraphElement> {
6
+ children: string;
7
+ }
8
+
9
+ export const HighlightedText = ({ children, ...rest }: IProps) => {
10
+ return <Text {...rest}>{children}</Text>;
11
+ };
12
+
13
+ const Text = styled.p`
14
+ color: ${uiColors.yellow} !important;
15
+
16
+ font-weight: bold;
17
+ font-size: 1.2rem;
18
+
19
+ // show the cursor as a pointer when hovering over the text
20
+
21
+ &:hover {
22
+ text-decoration: underline;
23
+ cursor: pointer;
24
+ }
25
+ `;