@soul-refiner/design-system 0.2.43 → 0.2.45
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/dist/components/atoms/box/box.d.ts +2 -2
- package/dist/components/atoms/typography/typography.d.ts +2 -4
- package/dist/components/editor/navbar/navbar.d.ts +2 -2
- package/dist/components/editor/simple_editor/navbar.d.ts +2 -2
- package/dist/components/surfaces/comment/comment.js +16 -3
- package/dist/components/surfaces/index.d.ts +2 -0
- package/dist/components/surfaces/index.js +1 -0
- package/dist/components/surfaces/portal/index.d.ts +2 -0
- package/dist/components/surfaces/portal/index.js +1 -0
- package/dist/components/surfaces/portal/portal.d.ts +5 -0
- package/dist/components/surfaces/portal/portal.js +26 -0
- package/dist/components/surfaces/post/post.d.ts +1 -2
- package/dist/components/surfaces/post/post.js +3 -22
- package/package.json +4 -2
|
@@ -9,7 +9,7 @@ export interface BoxProps extends BackgroundColor, BorderRadius, Elevation, Flex
|
|
|
9
9
|
sx?: string;
|
|
10
10
|
}
|
|
11
11
|
export declare const Box: ({ $display, sx, ...args }: BoxProps) => React.JSX.Element;
|
|
12
|
-
export declare const Component: import("styled-components").IStyledComponent<"web", "
|
|
12
|
+
export declare const Component: import("styled-components").IStyledComponent<"web", import("styled-components/dist/types").Substitute<React.DetailedHTMLProps<React.HTMLAttributes<HTMLDivElement>, HTMLDivElement>, BoxProps & {
|
|
13
13
|
$sx?: string | undefined;
|
|
14
|
-
}
|
|
14
|
+
}>>;
|
|
15
15
|
export {};
|
|
@@ -1,9 +1,7 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
1
2
|
import { Color, Styleable, TextClamp, TypographyStyle, TypographyWeight } from '../../../types';
|
|
2
3
|
export type TypographyProps = Pick<React.HTMLAttributes<HTMLParagraphElement>, 'children' | 'className' | 'dangerouslySetInnerHTML' | 'id' | 'onBlur' | 'onBlurCapture' | 'onClick' | 'onChange' | 'onCopy' | 'onCut' | 'onKeyDown' | 'onKeyDownCapture' | 'onKeyUp' | 'onKeyUpCapture' | 'onMouseDown' | 'onMouseDownCapture' | 'onMouseEnter' | 'onMouseLeave' | 'onMouseOut' | 'onMouseOver'> & {
|
|
3
4
|
value?: string;
|
|
4
5
|
href?: string;
|
|
5
6
|
} & Color & Styleable & TextClamp & TypographyStyle & TypographyWeight;
|
|
6
|
-
export declare const Typography: import("styled-components").IStyledComponent<"web", "
|
|
7
|
-
value?: string | undefined;
|
|
8
|
-
href?: string | undefined;
|
|
9
|
-
} & Color & Styleable & TextClamp & TypographyStyle & TypographyWeight, never>;
|
|
7
|
+
export declare const Typography: import("styled-components").IStyledComponent<"web", import("styled-components/dist/types").Substitute<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLParagraphElement>, HTMLParagraphElement>, TypographyProps>>;
|
|
@@ -3,6 +3,6 @@ export interface EditorBarProps {
|
|
|
3
3
|
handleUploadImage: (files: FileList) => Promise<string>;
|
|
4
4
|
}
|
|
5
5
|
export declare const EditorBar: ({ handleUploadImage }: EditorBarProps) => React.JSX.Element;
|
|
6
|
-
export declare const MenuButton: import("styled-components").IStyledComponent<"web", "
|
|
6
|
+
export declare const MenuButton: import("styled-components").IStyledComponent<"web", import("styled-components/dist/types").Substitute<React.DetailedHTMLProps<React.ButtonHTMLAttributes<HTMLButtonElement>, HTMLButtonElement>, {
|
|
7
7
|
$active?: boolean | undefined;
|
|
8
|
-
}
|
|
8
|
+
}>>;
|
|
@@ -3,6 +3,6 @@ export interface EditorBarProps {
|
|
|
3
3
|
handleUploadImage: (files: FileList) => Promise<string>;
|
|
4
4
|
}
|
|
5
5
|
export declare const EditorBar: ({ handleUploadImage }: EditorBarProps) => React.JSX.Element;
|
|
6
|
-
export declare const MenuButton: import("styled-components").IStyledComponent<"web", "
|
|
6
|
+
export declare const MenuButton: import("styled-components").IStyledComponent<"web", import("styled-components/dist/types").Substitute<React.DetailedHTMLProps<React.ButtonHTMLAttributes<HTMLButtonElement>, HTMLButtonElement>, {
|
|
7
7
|
$active?: boolean | undefined;
|
|
8
|
-
}
|
|
8
|
+
}>>;
|
|
@@ -4,12 +4,18 @@ import styled from 'styled-components';
|
|
|
4
4
|
import Picker from '@emoji-mart/react';
|
|
5
5
|
import { Avatar, Box, P, TextInput } from '../../';
|
|
6
6
|
import { Button } from '../../actions/button';
|
|
7
|
+
import { Portal } from '../portal';
|
|
7
8
|
import emojis from '../../../emoji/emojis.json';
|
|
9
|
+
import { Styles } from '../../../common';
|
|
8
10
|
import { ThumbsUp, Comment as CommentIcon } from '../../../icons';
|
|
9
11
|
import { abbrTimeBeforeDate } from './helpers';
|
|
10
|
-
import { Styles } from '../../../common';
|
|
11
12
|
export const Comment = ({ content, createdDate, hasMoreReplies, id, onComment, onReact, onShowReplies, reactions, replies, userImageUri, userName, userReactions, userProfileUri, }) => {
|
|
12
13
|
const [showPicker, setShowPicker] = React.useState(false);
|
|
14
|
+
const [pickerTriggerLoc, setPickerTriggerLoc] = React.useState({
|
|
15
|
+
x: 0,
|
|
16
|
+
y: 0,
|
|
17
|
+
});
|
|
18
|
+
const [pickerOrientation, setPickerOrientation] = React.useState('up');
|
|
13
19
|
const [toggleShowCommentInput, setShowCommentInput] = React.useState(false);
|
|
14
20
|
const [toggleShowReplies, setShowReplies] = React.useState(false);
|
|
15
21
|
const [comment, setComment] = React.useState('');
|
|
@@ -30,6 +36,8 @@ export const Comment = ({ content, createdDate, hasMoreReplies, id, onComment, o
|
|
|
30
36
|
const handlePicker = (event) => {
|
|
31
37
|
event.stopPropagation();
|
|
32
38
|
setShowPicker((prev) => !prev);
|
|
39
|
+
setPickerTriggerLoc({ y: event.clientY, x: event.clientX });
|
|
40
|
+
setPickerOrientation(event.clientY > 400 ? 'up' : 'down');
|
|
33
41
|
};
|
|
34
42
|
const handlePickerBlur = () => setShowPicker(false);
|
|
35
43
|
const handleToggleCommentInput = () => setShowCommentInput((prev) => !prev);
|
|
@@ -68,8 +76,9 @@ export const Comment = ({ content, createdDate, hasMoreReplies, id, onComment, o
|
|
|
68
76
|
React.createElement(P, { "$color": "grey-7" }, "\u2022"),
|
|
69
77
|
React.createElement(P, { "$color": "grey-4", "$fontSize": 12, "$lineHeight": 24, sx: "flex-shrink: 0;" }, createdTime),
|
|
70
78
|
React.createElement(Box, { "$display": "flex", "$flow": "row wrap", "$gap": 6, sx: "max-width: calc(100% - 190px); margin-left: auto;" }, reactionElements),
|
|
71
|
-
showPicker && (React.createElement(
|
|
72
|
-
React.createElement(
|
|
79
|
+
showPicker && (React.createElement(Portal, null,
|
|
80
|
+
React.createElement(PickerWrapper, { "$pickerOrientation": pickerOrientation, "$top": pickerTriggerLoc.y, "$left": pickerTriggerLoc.x },
|
|
81
|
+
React.createElement(Picker, { data: emojis, onEmojiSelect: handleReaction, onClickOutside: handlePickerBlur, maxFrequentRows: 1, navPosition: "none", previewPosition: "none", perLine: 9, theme: "auto" })))))),
|
|
73
82
|
hasReplies && toggleShowReplies && (React.createElement(RepliesWrapper, null, replyElements)),
|
|
74
83
|
!toggleShowReplies && !hasMoreReplies && hasReplies && (React.createElement(RepliesWrapper, null,
|
|
75
84
|
React.createElement(ReplyWrapper, { "$hasLine": false },
|
|
@@ -119,6 +128,10 @@ const CommentBox = styled.div `
|
|
|
119
128
|
const PickerWrapper = styled.div `
|
|
120
129
|
position: absolute;
|
|
121
130
|
z-index: 5;
|
|
131
|
+
|
|
132
|
+
${({ $pickerOrientation }) => $pickerOrientation === 'up' ? 'transform: translateY(-345px);' : ''}
|
|
133
|
+
top: ${({ $top }) => $top}px;
|
|
134
|
+
left: ${({ $left }) => $left}px;
|
|
122
135
|
`;
|
|
123
136
|
const Reaction = styled.div `
|
|
124
137
|
${Styles.flex}
|
|
@@ -8,5 +8,7 @@ export { Message } from './message';
|
|
|
8
8
|
export type { MessageProps } from './message';
|
|
9
9
|
export { Modal } from './modal';
|
|
10
10
|
export type { ModalContentProps, ModalProps } from './modal';
|
|
11
|
+
export { Portal } from './portal';
|
|
12
|
+
export type { PortalProps } from './portal';
|
|
11
13
|
export { Post } from './post';
|
|
12
14
|
export type { PostProps } from './post';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { Portal } from './portal';
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
import React from 'react';
|
|
3
|
+
import ReactDOM from 'react-dom';
|
|
4
|
+
export const Portal = ({ children, wrapperId = 'root-portal-wrapper', }) => {
|
|
5
|
+
const [wrapper, setWrapper] = React.useState(null);
|
|
6
|
+
React.useEffect(() => {
|
|
7
|
+
let element = document.getElementById(wrapperId);
|
|
8
|
+
let portalCreated = false;
|
|
9
|
+
if (!element) {
|
|
10
|
+
portalCreated = true;
|
|
11
|
+
element = document.createElement('div');
|
|
12
|
+
element.setAttribute('id', wrapperId);
|
|
13
|
+
document.body.appendChild(element);
|
|
14
|
+
}
|
|
15
|
+
setWrapper(element);
|
|
16
|
+
return () => {
|
|
17
|
+
if (portalCreated && element?.parentNode) {
|
|
18
|
+
element.parentNode.removeChild(element);
|
|
19
|
+
}
|
|
20
|
+
};
|
|
21
|
+
}, [wrapperId]);
|
|
22
|
+
if (!wrapper) {
|
|
23
|
+
return null;
|
|
24
|
+
}
|
|
25
|
+
return ReactDOM.createPortal(children, wrapper);
|
|
26
|
+
};
|
|
@@ -10,6 +10,5 @@ export interface PostProps extends React.PropsWithChildren {
|
|
|
10
10
|
hasComments?: boolean;
|
|
11
11
|
id?: string;
|
|
12
12
|
images?: string[];
|
|
13
|
-
onComment: (comment: string) => void;
|
|
14
13
|
}
|
|
15
|
-
export declare const Post: ({ actions, author, authorActive, authorHref, authorImage, children, content, createdDate, hasComments, images,
|
|
14
|
+
export declare const Post: ({ actions, author, authorActive, authorHref, authorImage, children, content, createdDate, hasComments, images, }: PostProps) => React.JSX.Element;
|
|
@@ -1,22 +1,12 @@
|
|
|
1
1
|
'use client';
|
|
2
2
|
import React from 'react';
|
|
3
3
|
import styled from 'styled-components';
|
|
4
|
-
import { Avatar, H, P
|
|
4
|
+
import { Avatar, H, P } from '../../';
|
|
5
5
|
import { abbrTimeBeforeDate } from './helpers';
|
|
6
|
-
export const Post = ({ actions, author, authorActive, authorHref, authorImage, children, content, createdDate, hasComments, images,
|
|
6
|
+
export const Post = ({ actions, author, authorActive, authorHref, authorImage, children, content, createdDate, hasComments, images, }) => {
|
|
7
7
|
const id = React.useId();
|
|
8
|
-
const [comment, setComment] = React.useState('');
|
|
9
8
|
const _actions = React.Children.toArray(actions);
|
|
10
9
|
const _comments = React.Children.toArray(children);
|
|
11
|
-
const handleCommentChange = (event) => {
|
|
12
|
-
setComment(event.target.value);
|
|
13
|
-
};
|
|
14
|
-
const handleCommentSubmit = (event) => {
|
|
15
|
-
event.stopPropagation();
|
|
16
|
-
event.preventDefault();
|
|
17
|
-
onComment(comment);
|
|
18
|
-
setComment('');
|
|
19
|
-
};
|
|
20
10
|
const subtitle = abbrTimeBeforeDate(new Date(createdDate));
|
|
21
11
|
return (React.createElement(Wrapper, { id: id },
|
|
22
12
|
React.createElement(Header, null,
|
|
@@ -29,10 +19,7 @@ export const Post = ({ actions, author, authorActive, authorHref, authorImage, c
|
|
|
29
19
|
"+",
|
|
30
20
|
images.length - 4)))),
|
|
31
21
|
!!_actions.length && React.createElement(ActionsWrapper, null, _actions),
|
|
32
|
-
hasComments && !!_comments.length && (React.createElement(CommentWrapper, null, _comments))
|
|
33
|
-
hasComments && (React.createElement(CommentInputWrapper, { onSubmit: handleCommentSubmit },
|
|
34
|
-
React.createElement(Avatar, { href: authorHref, image: authorImage, size: 40 }),
|
|
35
|
-
React.createElement(TextInput, { bg: "var(--color-grey-10)", placeholder: "Write a comment", onChange: handleCommentChange, value: comment })))));
|
|
22
|
+
hasComments && !!_comments.length && (React.createElement(CommentWrapper, null, _comments))));
|
|
36
23
|
};
|
|
37
24
|
const Wrapper = styled.div `
|
|
38
25
|
max-width: 700px;
|
|
@@ -111,9 +98,3 @@ const CommentWrapper = styled.div `
|
|
|
111
98
|
flex-flow: column nowrap;
|
|
112
99
|
gap: 24px;
|
|
113
100
|
`;
|
|
114
|
-
const CommentInputWrapper = styled.form `
|
|
115
|
-
padding: 24px;
|
|
116
|
-
display: flex;
|
|
117
|
-
gap: 12px;
|
|
118
|
-
align-items: center;
|
|
119
|
-
`;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@soul-refiner/design-system",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.45",
|
|
4
4
|
"main": "dist/index.js",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"publishConfig": {
|
|
@@ -32,6 +32,7 @@
|
|
|
32
32
|
"@storybook/react": "^7.2.1",
|
|
33
33
|
"@storybook/react-vite": "^7.2.1",
|
|
34
34
|
"@storybook/testing-library": "^0.2.0",
|
|
35
|
+
"@types/react-dom": "18.2.0",
|
|
35
36
|
"@types/styled-components": "^5.1.26",
|
|
36
37
|
"@typescript-eslint/eslint-plugin": "^5.59.5",
|
|
37
38
|
"@typescript-eslint/parser": "^5.59.5",
|
|
@@ -72,5 +73,6 @@
|
|
|
72
73
|
"slate-hyperscript": "^0.77.0",
|
|
73
74
|
"slate-react": "^0.97.1",
|
|
74
75
|
"styled-components": "^6.0.0-rc.3"
|
|
75
|
-
}
|
|
76
|
+
},
|
|
77
|
+
"packageManager": "yarn@3.6.1"
|
|
76
78
|
}
|