@soul-refiner/design-system 0.2.31 → 0.2.32

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,5 +7,6 @@ export interface PostProps extends React.PropsWithChildren {
7
7
  content: string;
8
8
  createdDate: string;
9
9
  images?: string[];
10
+ onComment: (comment: string) => void;
10
11
  }
11
- export declare const Post: ({ author, authorActive, authorHref, authorImage, children, content, createdDate, images, }: PostProps) => React.JSX.Element;
12
+ export declare const Post: ({ author, authorActive, authorHref, authorImage, children, content, createdDate, images, onComment, }: PostProps) => React.JSX.Element;
@@ -3,13 +3,19 @@ import React from 'react';
3
3
  import styled from 'styled-components';
4
4
  import { Avatar, H, P, TextInput } from '../../';
5
5
  import { abbrTimeBeforeDate } from './helpers';
6
- export const Post = ({ author, authorActive, authorHref, authorImage, children, content, createdDate, images, }) => {
6
+ export const Post = ({ author, authorActive, authorHref, authorImage, children, content, createdDate, images, onComment, }) => {
7
7
  const id = React.useId();
8
8
  const [comment, setComment] = React.useState('');
9
9
  const _comments = React.Children.toArray(children);
10
10
  const handleCommentChange = (event) => {
11
11
  setComment(event.target.value);
12
12
  };
13
+ const handleCommentSubmit = (event) => {
14
+ event.stopPropagation();
15
+ event.preventDefault();
16
+ onComment(comment);
17
+ setComment('');
18
+ };
13
19
  const subtitle = abbrTimeBeforeDate(new Date(createdDate));
14
20
  return (React.createElement(Wrapper, null,
15
21
  React.createElement(Header, null,
@@ -22,7 +28,7 @@ export const Post = ({ author, authorActive, authorHref, authorImage, children,
22
28
  "+",
23
29
  images.length - 4)))),
24
30
  !!_comments.length && React.createElement(CommentWrapper, null, children),
25
- React.createElement(CommentInputWrapper, null,
31
+ React.createElement(CommentInputWrapper, { onSubmit: handleCommentSubmit },
26
32
  React.createElement(Avatar, { href: authorHref, image: authorImage, size: 40 }),
27
33
  React.createElement(TextInput, { bg: "var(--color-grey-10)", placeholder: "Write a comment", onChange: handleCommentChange, value: comment }))));
28
34
  };
@@ -96,7 +102,7 @@ const CommentWrapper = styled.div `
96
102
  flex-flow: column nowrap;
97
103
  gap: 24px;
98
104
  `;
99
- const CommentInputWrapper = styled.div `
105
+ const CommentInputWrapper = styled.form `
100
106
  padding: 24px;
101
107
  display: flex;
102
108
  gap: 12px;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@soul-refiner/design-system",
3
- "version": "0.2.31",
3
+ "version": "0.2.32",
4
4
  "main": "dist/index.js",
5
5
  "license": "MIT",
6
6
  "publishConfig": {