@soul-refiner/design-system 0.2.31 → 0.2.33

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.
@@ -1,5 +1,6 @@
1
1
  import React from 'react';
2
2
  export interface PostProps extends React.PropsWithChildren {
3
+ actions?: React.ReactNode;
3
4
  author: string;
4
5
  authorActive?: boolean;
5
6
  authorHref: string;
@@ -7,5 +8,6 @@ export interface PostProps extends React.PropsWithChildren {
7
8
  content: string;
8
9
  createdDate: string;
9
10
  images?: string[];
11
+ onComment: (comment: string) => void;
10
12
  }
11
- export declare const Post: ({ author, authorActive, authorHref, authorImage, children, content, createdDate, images, }: PostProps) => React.JSX.Element;
13
+ export declare const Post: ({ actions, author, authorActive, authorHref, authorImage, children, content, createdDate, images, onComment, }: PostProps) => React.JSX.Element;
@@ -3,13 +3,20 @@ 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 = ({ actions, author, authorActive, authorHref, authorImage, children, content, createdDate, images, onComment, }) => {
7
7
  const id = React.useId();
8
8
  const [comment, setComment] = React.useState('');
9
+ const _actions = React.Children.toArray(actions);
9
10
  const _comments = React.Children.toArray(children);
10
11
  const handleCommentChange = (event) => {
11
12
  setComment(event.target.value);
12
13
  };
14
+ const handleCommentSubmit = (event) => {
15
+ event.stopPropagation();
16
+ event.preventDefault();
17
+ onComment(comment);
18
+ setComment('');
19
+ };
13
20
  const subtitle = abbrTimeBeforeDate(new Date(createdDate));
14
21
  return (React.createElement(Wrapper, null,
15
22
  React.createElement(Header, null,
@@ -21,8 +28,9 @@ export const Post = ({ author, authorActive, authorHref, authorImage, children,
21
28
  images.length > 4 && (React.createElement(H, { as: "p", className: "more-than", "$color": "grey-10", "$fontSize": 28, "$lineHeight": 36, "$semiBold": true },
22
29
  "+",
23
30
  images.length - 4)))),
24
- !!_comments.length && React.createElement(CommentWrapper, null, children),
25
- React.createElement(CommentInputWrapper, null,
31
+ !!_comments.length && React.createElement(CommentWrapper, null, _comments),
32
+ !!_actions.length && React.createElement(ActionsWrapper, null, _actions),
33
+ React.createElement(CommentInputWrapper, { onSubmit: handleCommentSubmit },
26
34
  React.createElement(Avatar, { href: authorHref, image: authorImage, size: 40 }),
27
35
  React.createElement(TextInput, { bg: "var(--color-grey-10)", placeholder: "Write a comment", onChange: handleCommentChange, value: comment }))));
28
36
  };
@@ -90,13 +98,20 @@ const ImageWrapper = styled.div `
90
98
  flex: 1;
91
99
  min-width: min(227px, 80vw);
92
100
  `;
101
+ const ActionsWrapper = styled.div `
102
+ display: flex;
103
+ justify-content: space-around;
104
+ align-items: center;
105
+ padding: 24px;
106
+ border-bottom: 1px solid var(--color-grey-9);
107
+ `;
93
108
  const CommentWrapper = styled.div `
94
109
  padding: 24px;
95
110
  display: flex;
96
111
  flex-flow: column nowrap;
97
112
  gap: 24px;
98
113
  `;
99
- const CommentInputWrapper = styled.div `
114
+ const CommentInputWrapper = styled.form `
100
115
  padding: 24px;
101
116
  display: flex;
102
117
  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.33",
4
4
  "main": "dist/index.js",
5
5
  "license": "MIT",
6
6
  "publishConfig": {
@@ -24,14 +24,14 @@
24
24
  }
25
25
  },
26
26
  "devDependencies": {
27
- "@storybook/addon-essentials": "^7.0.10",
28
- "@storybook/addon-interactions": "^7.0.10",
29
- "@storybook/addon-links": "^7.0.10",
30
- "@storybook/addons": "^7.0.10",
31
- "@storybook/blocks": "^7.0.10",
32
- "@storybook/react": "^7.0.10",
33
- "@storybook/react-vite": "^7.0.10",
34
- "@storybook/testing-library": "^0.0.14-next.2",
27
+ "@storybook/addon-essentials": "^7.2.1",
28
+ "@storybook/addon-interactions": "^7.2.1",
29
+ "@storybook/addon-links": "^7.2.1",
30
+ "@storybook/addons": "^7.2.1",
31
+ "@storybook/blocks": "^7.2.1",
32
+ "@storybook/react": "^7.2.1",
33
+ "@storybook/react-vite": "^7.2.1",
34
+ "@storybook/testing-library": "^0.2.0",
35
35
  "@types/styled-components": "^5.1.26",
36
36
  "@typescript-eslint/eslint-plugin": "^5.59.5",
37
37
  "@typescript-eslint/parser": "^5.59.5",
@@ -42,7 +42,7 @@
42
42
  "prettier": "^2.8.8",
43
43
  "pretty-quick": "^3.1.3",
44
44
  "prop-types": "^15.8.1",
45
- "storybook": "^7.0.10",
45
+ "storybook": "^7.2.1",
46
46
  "tsconfig-paths-webpack-plugin": "^4.0.1",
47
47
  "typescript": "^5.0.4",
48
48
  "vite": "^4.3.5",