@soul-refiner/design-system 0.2.35 → 0.2.36

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.
@@ -4,6 +4,7 @@ export interface CommentProps {
4
4
  createdDate: Date;
5
5
  onComment: (comment: string) => void;
6
6
  onReact: (reaction: string) => void;
7
+ onShowReplies?: () => void;
7
8
  reactions?: Record<string, number>;
8
9
  replies?: CommentProps[];
9
10
  userImageUri: string;
@@ -11,4 +12,4 @@ export interface CommentProps {
11
12
  userReactions?: string[];
12
13
  userProfileUri: string;
13
14
  }
14
- export declare const Comment: ({ content, createdDate, onComment, onReact, reactions, replies, userImageUri, userName, userReactions, userProfileUri, }: CommentProps) => React.JSX.Element;
15
+ export declare const Comment: ({ content, createdDate, onComment, onReact, onShowReplies, reactions, replies, userImageUri, userName, userReactions, userProfileUri, }: CommentProps) => React.JSX.Element;
@@ -3,14 +3,16 @@ import React from 'react';
3
3
  import styled from 'styled-components';
4
4
  import Picker from '@emoji-mart/react';
5
5
  import { Avatar, Box, P, TextInput } from '../../';
6
+ import { Button } from '../../actions/button';
6
7
  import emojis from '../../../emoji/emojis.json';
7
8
  import { ThumbsUp, Comment as CommentIcon } from '../../../icons';
8
9
  import { abbrTimeBeforeDate } from './helpers';
9
10
  import { Styles } from '../../../common';
10
- export const Comment = ({ content, createdDate, onComment, onReact, reactions, replies, userImageUri, userName, userReactions, userProfileUri, }) => {
11
+ export const Comment = ({ content, createdDate, onComment, onReact, onShowReplies, reactions, replies, userImageUri, userName, userReactions, userProfileUri, }) => {
11
12
  const id = React.useId();
12
13
  const [showPicker, setShowPicker] = React.useState(false);
13
- const [toggleShowComment, setToggleShowComment] = React.useState(false);
14
+ const [toggleShowCommentInput, setShowCommentInput] = React.useState(false);
15
+ const [toggleShowReplies, setShowReplies] = React.useState(false);
14
16
  const [comment, setComment] = React.useState('');
15
17
  const handleCommentChange = (event) => {
16
18
  setComment(event.target.value);
@@ -30,7 +32,11 @@ export const Comment = ({ content, createdDate, onComment, onReact, reactions, r
30
32
  setShowPicker((prev) => !prev);
31
33
  };
32
34
  const handlePickerBlur = () => setShowPicker(false);
33
- const handleToggleShowComment = () => setToggleShowComment((prev) => !prev);
35
+ const handleToggleCommentInput = () => setShowCommentInput((prev) => !prev);
36
+ const handleToggleReplies = () => {
37
+ onShowReplies && onShowReplies();
38
+ setShowReplies((prev) => !prev);
39
+ };
34
40
  const createdTime = abbrTimeBeforeDate(createdDate);
35
41
  const reactionElements = reactions &&
36
42
  Object.entries(reactions)
@@ -52,14 +58,18 @@ export const Comment = ({ content, createdDate, onComment, onReact, reactions, r
52
58
  React.createElement(P, { sx: "letter-spacing: -0.176px;" }, content)),
53
59
  React.createElement(Box, { "$align": "flex-start", "$dir": "row", "$display": "flex", "$gap": 16, sx: "margin: 8px 0px; position: relative;" },
54
60
  React.createElement(ThumbsUp, { color: "primary-blue-2", onClick: handlePicker, size: 24, sx: "border-radius: 50%; cursor: pointer; flex-shrink: 0;" }),
55
- React.createElement(CommentIcon, { color: "primary-blue-2", onClick: handleToggleShowComment, size: 24, sx: "border-radius: 50%; cursor: pointer; flex-shrink: 0;" }),
61
+ React.createElement(CommentIcon, { color: "primary-blue-2", onClick: handleToggleCommentInput, size: 24, sx: "border-radius: 50%; cursor: pointer; flex-shrink: 0;" }),
56
62
  React.createElement(P, { "$color": "grey-7" }, "\u2022"),
57
63
  React.createElement(P, { "$color": "grey-4", "$fontSize": 12, "$lineHeight": 24, sx: "flex-shrink: 0;" }, createdTime),
58
64
  React.createElement(Box, { "$display": "flex", "$flow": "row wrap", "$gap": 6, sx: "max-width: calc(100% - 190px); margin-left: auto;" }, reactionElements),
59
65
  showPicker && (React.createElement(PickerWrapper, null,
60
66
  React.createElement(Picker, { data: emojis, onEmojiSelect: handleReaction, onClickOutside: handlePickerBlur, maxFrequentRows: 1, navPosition: "none", previewPosition: "none", perLine: 9, theme: "auto" }))))),
61
- hasReplies && React.createElement(RepliesWrapper, null, replyElements),
62
- toggleShowComment && (React.createElement(CommentWrapper, { onSubmit: handleCommentSubmit },
67
+ hasReplies && !toggleShowReplies && (React.createElement(RepliesWrapper, null,
68
+ React.createElement(ReplyWrapper, { "$isNotLastReply": false },
69
+ React.createElement(Button, { onClick: handleToggleReplies, size: "small", sx: "color: var(--color-grey-3);", type: "text" }, "show replies"),
70
+ React.createElement(ReplyIndicator, null)))),
71
+ hasReplies && toggleShowReplies && (React.createElement(RepliesWrapper, null, replyElements)),
72
+ toggleShowCommentInput && (React.createElement(CommentWrapper, { onSubmit: handleCommentSubmit },
63
73
  React.createElement(TextInput, { bg: "var(--color-grey-10)", placeholder: "Write a reply", onChange: handleCommentChange, value: comment }))))));
64
74
  };
65
75
  const Wrapper = styled.div `
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@soul-refiner/design-system",
3
- "version": "0.2.35",
3
+ "version": "0.2.36",
4
4
  "main": "dist/index.js",
5
5
  "license": "MIT",
6
6
  "publishConfig": {