@soul-refiner/design-system 0.2.45 → 0.2.49
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.
|
@@ -7,6 +7,7 @@ export interface CommentProps {
|
|
|
7
7
|
onComment: (comment: string, id?: string) => void;
|
|
8
8
|
onReact: (reaction: string) => void;
|
|
9
9
|
onShowReplies?: () => void;
|
|
10
|
+
reactionModal?: React.ReactElement;
|
|
10
11
|
reactions?: Record<string, number>;
|
|
11
12
|
replies?: React.ReactElement[];
|
|
12
13
|
userImageUri: string;
|
|
@@ -14,4 +15,4 @@ export interface CommentProps {
|
|
|
14
15
|
userReactions?: string[];
|
|
15
16
|
userProfileUri: string;
|
|
16
17
|
}
|
|
17
|
-
export declare const Comment: ({ content, createdDate, hasMoreReplies, id, onComment, onReact, onShowReplies, reactions, replies, userImageUri, userName, userReactions, userProfileUri, }: CommentProps) => React.JSX.Element;
|
|
18
|
+
export declare const Comment: ({ content, createdDate, hasMoreReplies, id, onComment, onReact, onShowReplies, reactionModal, reactions, replies, userImageUri, userName, userReactions, userProfileUri, }: CommentProps) => React.JSX.Element;
|
|
@@ -9,7 +9,8 @@ import emojis from '../../../emoji/emojis.json';
|
|
|
9
9
|
import { Styles } from '../../../common';
|
|
10
10
|
import { ThumbsUp, Comment as CommentIcon } from '../../../icons';
|
|
11
11
|
import { abbrTimeBeforeDate } from './helpers';
|
|
12
|
-
|
|
12
|
+
const MAX_REACTIONS_SHOWN = 5;
|
|
13
|
+
export const Comment = ({ content, createdDate, hasMoreReplies, id, onComment, onReact, onShowReplies, reactionModal, reactions, replies, userImageUri, userName, userReactions, userProfileUri, }) => {
|
|
13
14
|
const [showPicker, setShowPicker] = React.useState(false);
|
|
14
15
|
const [pickerTriggerLoc, setPickerTriggerLoc] = React.useState({
|
|
15
16
|
x: 0,
|
|
@@ -48,8 +49,9 @@ export const Comment = ({ content, createdDate, hasMoreReplies, id, onComment, o
|
|
|
48
49
|
const createdTime = abbrTimeBeforeDate(createdDate);
|
|
49
50
|
const reactionElements = reactions &&
|
|
50
51
|
Object.entries(reactions)
|
|
52
|
+
.slice(0, MAX_REACTIONS_SHOWN)
|
|
51
53
|
.sort((a, b) => (a[1] < b[1] ? 1 : -1))
|
|
52
|
-
.map((reaction) => (React.createElement(Reaction, { key: id + reaction[0], "$align": "center", "$dir": "row", "$gap": 5, "$userSelected": userReactions?.includes(reaction[0]) },
|
|
54
|
+
.map((reaction) => (React.createElement(Reaction, { key: id + reaction[0], onClick: () => onReact(reaction[0]), "$align": "center", "$dir": "row", "$gap": 5, "$userSelected": userReactions?.includes(reaction[0]) },
|
|
53
55
|
reaction[0],
|
|
54
56
|
React.createElement(P, { "$bold": true, "$fontSize": 10, "$lineHeight": 14 }, reaction[1]))));
|
|
55
57
|
const hasReplies = !!_replies?.length && _replies.length > 0;
|
|
@@ -75,7 +77,9 @@ export const Comment = ({ content, createdDate, hasMoreReplies, id, onComment, o
|
|
|
75
77
|
React.createElement(CommentIcon, { color: "primary-blue-2", onClick: handleToggleCommentInput, size: 24, sx: "border-radius: 50%; cursor: pointer; flex-shrink: 0;" }),
|
|
76
78
|
React.createElement(P, { "$color": "grey-7" }, "\u2022"),
|
|
77
79
|
React.createElement(P, { "$color": "grey-4", "$fontSize": 12, "$lineHeight": 24, sx: "flex-shrink: 0;" }, createdTime),
|
|
78
|
-
React.createElement(Box, { "$display": "flex", "$flow": "row wrap", "$gap": 6, sx: "max-width: calc(100% - 190px); margin-left: auto;" },
|
|
80
|
+
React.createElement(Box, { "$display": "flex", "$flow": "row wrap", "$gap": 6, sx: "max-width: calc(100% - 190px); margin-left: auto;" },
|
|
81
|
+
reactionElements,
|
|
82
|
+
reactionModal),
|
|
79
83
|
showPicker && (React.createElement(Portal, null,
|
|
80
84
|
React.createElement(PickerWrapper, { "$pickerOrientation": pickerOrientation, "$top": pickerTriggerLoc.y, "$left": pickerTriggerLoc.x },
|
|
81
85
|
React.createElement(Picker, { data: emojis, onEmojiSelect: handleReaction, onClickOutside: handlePickerBlur, maxFrequentRows: 1, navPosition: "none", previewPosition: "none", perLine: 9, theme: "auto" })))))),
|
|
@@ -127,7 +131,7 @@ const CommentBox = styled.div `
|
|
|
127
131
|
`;
|
|
128
132
|
const PickerWrapper = styled.div `
|
|
129
133
|
position: absolute;
|
|
130
|
-
z-index:
|
|
134
|
+
z-index: 1000;
|
|
131
135
|
|
|
132
136
|
${({ $pickerOrientation }) => $pickerOrientation === 'up' ? 'transform: translateY(-345px);' : ''}
|
|
133
137
|
top: ${({ $top }) => $top}px;
|
|
@@ -138,6 +142,7 @@ const Reaction = styled.div `
|
|
|
138
142
|
display: flex;
|
|
139
143
|
padding: 2px 6px;
|
|
140
144
|
border-radius: 12px;
|
|
145
|
+
cursor: pointer;
|
|
141
146
|
${({ $userSelected }) => $userSelected
|
|
142
147
|
? `
|
|
143
148
|
background-color: var(--color-primary-blue-4);
|