@soul-refiner/design-system 0.2.105 → 0.2.106
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/iconography/avatar/avatar.d.ts +1 -2
- package/dist/components/iconography/avatar/avatar.js +11 -27
- package/dist/components/index.d.ts +0 -1
- package/dist/components/index.js +0 -1
- package/dist/components/surfaces/comment/comment.d.ts +2 -1
- package/dist/components/surfaces/comment/comment.js +2 -2
- package/dist/components/surfaces/post/post.d.ts +2 -1
- package/dist/components/surfaces/post/post.js +2 -2
- package/package.json +1 -1
- package/dist/components/hooks/click-outside.d.ts +0 -2
- package/dist/components/hooks/click-outside.js +0 -10
- package/dist/components/hooks/event-listenter.d.ts +0 -1
- package/dist/components/hooks/event-listenter.js +0 -15
- package/dist/components/hooks/hover.d.ts +0 -2
- package/dist/components/hooks/hover.js +0 -9
- package/dist/components/hooks/index.d.ts +0 -4
- package/dist/components/hooks/index.js +0 -4
- package/dist/components/hooks/window-size.d.ts +0 -4
- package/dist/components/hooks/window-size.js +0 -13
|
@@ -16,14 +16,13 @@ export interface AvatarProps extends NativeProps {
|
|
|
16
16
|
title?: React.ReactNode;
|
|
17
17
|
tooltipContent?: React.ReactElement;
|
|
18
18
|
tooltipSx?: string;
|
|
19
|
-
tooltipWrapperId?: string;
|
|
20
19
|
}
|
|
21
20
|
/**
|
|
22
21
|
*
|
|
23
22
|
* Avatar
|
|
24
23
|
*/
|
|
25
24
|
declare const Avatar: {
|
|
26
|
-
({ as, href, image, size, status, subtitle, sx, textPosition, title, tooltipContent, tooltipSx,
|
|
25
|
+
({ as, href, image, size, status, subtitle, sx, textPosition, title, tooltipContent, tooltipSx, ...rest }: AvatarProps): React.JSX.Element;
|
|
27
26
|
displayName: string;
|
|
28
27
|
Group: {
|
|
29
28
|
({ children, numDisplayed, total }: AvatarGroupProps): React.JSX.Element;
|
|
@@ -1,9 +1,8 @@
|
|
|
1
1
|
'use client';
|
|
2
2
|
import React from 'react';
|
|
3
3
|
import styled from 'styled-components';
|
|
4
|
-
import { Box, H, P
|
|
4
|
+
import { Box, H, P } from '../../';
|
|
5
5
|
import { Approved, Busy, Declined, Default, Focus, Locked, Offline, Online, Subscribed, } from './icons';
|
|
6
|
-
import { useHover } from '../../../';
|
|
7
6
|
/**
|
|
8
7
|
* Lookup tables for sizes
|
|
9
8
|
*/
|
|
@@ -58,14 +57,16 @@ const iconOffsetY = {
|
|
|
58
57
|
*
|
|
59
58
|
* Avatar
|
|
60
59
|
*/
|
|
61
|
-
const Avatar = ({ as = 'button', href, image, size = 64, status, subtitle, sx, textPosition = 'left', title, tooltipContent, tooltipSx,
|
|
60
|
+
const Avatar = ({ as = 'button', href, image, size = 64, status, subtitle, sx, textPosition = 'left', title, tooltipContent, tooltipSx, ...rest }) => {
|
|
62
61
|
const [displayDefault, setDisplayDefault] = React.useState(false);
|
|
63
|
-
const componentWrapperRef = React.useRef(null);
|
|
64
|
-
const tooltipRef = React.useRef(null);
|
|
65
|
-
const hovered = useHover(componentWrapperRef);
|
|
66
|
-
const tooltipHovered = useHover(tooltipRef);
|
|
67
62
|
const Icon = iconReference?.[status ?? 'none'];
|
|
68
|
-
return (React.createElement(
|
|
63
|
+
return (React.createElement(Box, { "$align": "center", "$gap": 18, sx: `
|
|
64
|
+
position: relative;
|
|
65
|
+
&:hover > div:nth-of-type(2) {
|
|
66
|
+
display: flex;
|
|
67
|
+
}
|
|
68
|
+
${sx}
|
|
69
|
+
`, ...rest },
|
|
69
70
|
React.createElement(Container, { as: as, "$size": size, href: href },
|
|
70
71
|
!displayDefault && (React.createElement("img", { src: image ?? '', onError: () => setDisplayDefault(true) })),
|
|
71
72
|
displayDefault && React.createElement(Default, null),
|
|
@@ -74,26 +75,9 @@ const Avatar = ({ as = 'button', href, image, size = 64, status, subtitle, sx, t
|
|
|
74
75
|
(title || subtitle) && (React.createElement(TextContainer, { "$textPosition": textPosition },
|
|
75
76
|
title && (React.createElement(H, { as: "h3", "$bold": true, "$color": "grey-2", "$textClampLines": 1, sx: "font-size: 26px;" }, title)),
|
|
76
77
|
subtitle && (React.createElement(P, { "$color": "grey-4", "$textClampLines": 1 }, subtitle)))),
|
|
77
|
-
tooltipContent && (React.createElement(
|
|
78
|
-
React.createElement(TooltipContainer, { id: "tooltip-container", ref: tooltipRef, "$sx": `${hovered || tooltipHovered ? 'display: flex' : 'display: none'}; ${tooltipSx}` }, tooltipContent)))));
|
|
78
|
+
tooltipContent && (React.createElement(TooltipContainer, { "$sx": tooltipSx }, tooltipContent))));
|
|
79
79
|
};
|
|
80
80
|
Avatar.displayName = 'Avatar';
|
|
81
|
-
const ComponentWrapper = styled.div `
|
|
82
|
-
display: flex;
|
|
83
|
-
align-items: center;
|
|
84
|
-
gap: 18px;
|
|
85
|
-
flex: none;
|
|
86
|
-
flex-flow: row;
|
|
87
|
-
flex-direction: row;
|
|
88
|
-
justify-content: normal;
|
|
89
|
-
background-color: var(--page-bg);
|
|
90
|
-
box-shadow: none;
|
|
91
|
-
margin: 0px;
|
|
92
|
-
padding: 0px;
|
|
93
|
-
position: relative;
|
|
94
|
-
|
|
95
|
-
${({ $sx }) => ($sx ? $sx : '')};
|
|
96
|
-
`;
|
|
97
81
|
const Container = styled.div `
|
|
98
82
|
flex-shrink: 0;
|
|
99
83
|
display: flex;
|
|
@@ -131,13 +115,13 @@ const TextContainer = styled.div `
|
|
|
131
115
|
order: ${({ $textPosition }) => ($textPosition === 'left' ? -1 : 1)};
|
|
132
116
|
`;
|
|
133
117
|
const TooltipContainer = styled.div `
|
|
118
|
+
display: none;
|
|
134
119
|
position: absolute;
|
|
135
120
|
top: 100%;
|
|
136
121
|
z-index: 250;
|
|
137
122
|
background-color: var(--color-white);
|
|
138
123
|
border-radius: 24px;
|
|
139
124
|
box-shadow: var(--elevation-2);
|
|
140
|
-
// pointer-events: none;
|
|
141
125
|
${({ $sx }) => ($sx ? $sx : '')}
|
|
142
126
|
`;
|
|
143
127
|
const Group = ({ children, numDisplayed, total }) => {
|
package/dist/components/index.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
export interface CommentProps {
|
|
3
3
|
avatarTooltipContent?: React.ReactElement;
|
|
4
|
+
avatarTooltipSx?: string;
|
|
4
5
|
content: string;
|
|
5
6
|
createdDate: Date;
|
|
6
7
|
hasMoreReplies?: boolean;
|
|
@@ -16,4 +17,4 @@ export interface CommentProps {
|
|
|
16
17
|
userReactions?: string[];
|
|
17
18
|
userProfileUri: string;
|
|
18
19
|
}
|
|
19
|
-
export declare const Comment: ({ avatarTooltipContent, content, createdDate, hasMoreReplies, id, onComment, onReact, onShowReplies, reactionModal, reactions, replies, userImageUri, userName, userReactions, userProfileUri, }: CommentProps) => React.JSX.Element;
|
|
20
|
+
export declare const Comment: ({ avatarTooltipContent, avatarTooltipSx, content, createdDate, hasMoreReplies, id, onComment, onReact, onShowReplies, reactionModal, reactions, replies, userImageUri, userName, userReactions, userProfileUri, }: CommentProps) => React.JSX.Element;
|
|
@@ -10,7 +10,7 @@ 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 = ({ avatarTooltipContent, content, createdDate, hasMoreReplies, id, onComment, onReact, onShowReplies, reactionModal, reactions, replies, userImageUri, userName, userReactions, userProfileUri, }) => {
|
|
13
|
+
export const Comment = ({ avatarTooltipContent, avatarTooltipSx, content, createdDate, hasMoreReplies, id, onComment, onReact, onShowReplies, reactionModal, reactions, replies, userImageUri, userName, userReactions, userProfileUri, }) => {
|
|
14
14
|
const [showPicker, setShowPicker] = React.useState(false);
|
|
15
15
|
const [pickerTriggerLoc, setPickerTriggerLoc] = React.useState({
|
|
16
16
|
x: 0,
|
|
@@ -66,7 +66,7 @@ export const Comment = ({ avatarTooltipContent, content, createdDate, hasMoreRep
|
|
|
66
66
|
React.createElement(ReplyIndicator, null)));
|
|
67
67
|
});
|
|
68
68
|
return (React.createElement(Wrapper, { id: id },
|
|
69
|
-
React.createElement(Avatar, { href: userProfileUri, image: userImageUri, size: 32, tooltipContent: avatarTooltipContent }),
|
|
69
|
+
React.createElement(Avatar, { href: userProfileUri, image: userImageUri, size: 32, tooltipContent: avatarTooltipContent, tooltipSx: avatarTooltipSx }),
|
|
70
70
|
React.createElement(Box, { "$flex": 1, "$dir": "column" },
|
|
71
71
|
React.createElement(ContentWrapper, { "$hasReplies": hasReplies || !!hasMoreReplies },
|
|
72
72
|
React.createElement(CommentBox, null,
|
|
@@ -6,6 +6,7 @@ export interface PostProps extends React.PropsWithChildren {
|
|
|
6
6
|
authorHref: string;
|
|
7
7
|
authorImage: string;
|
|
8
8
|
avatarTooltipContent?: React.ReactElement;
|
|
9
|
+
avatarTooltipSx?: string;
|
|
9
10
|
content: string;
|
|
10
11
|
createdDate: string;
|
|
11
12
|
dropdown?: React.ReactElement;
|
|
@@ -15,4 +16,4 @@ export interface PostProps extends React.PropsWithChildren {
|
|
|
15
16
|
isPaywalled?: boolean;
|
|
16
17
|
onJoin?: () => void;
|
|
17
18
|
}
|
|
18
|
-
export declare const Post: ({ actions, author, authorActive, authorHref, authorImage, avatarTooltipContent, children, content, createdDate, dropdown, hasComments, id, images, isPaywalled, onJoin, }: PostProps) => React.JSX.Element;
|
|
19
|
+
export declare const Post: ({ actions, author, authorActive, authorHref, authorImage, avatarTooltipContent, avatarTooltipSx, children, content, createdDate, dropdown, hasComments, id, images, isPaywalled, onJoin, }: PostProps) => React.JSX.Element;
|
|
@@ -6,14 +6,14 @@ import { TimeAgo } from '../../atoms/time_ago/time_ago';
|
|
|
6
6
|
import { Button } from '../../actions/button';
|
|
7
7
|
import { Avatar } from '../../iconography/avatar';
|
|
8
8
|
import { Lock } from '../../../icons';
|
|
9
|
-
export const Post = ({ actions, author, authorActive, authorHref, authorImage, avatarTooltipContent, children, content, createdDate, dropdown, hasComments, id, images, isPaywalled = false, onJoin, }) => {
|
|
9
|
+
export const Post = ({ actions, author, authorActive, authorHref, authorImage, avatarTooltipContent, avatarTooltipSx, children, content, createdDate, dropdown, hasComments, id, images, isPaywalled = false, onJoin, }) => {
|
|
10
10
|
const componentId = React.useId();
|
|
11
11
|
const _actions = React.Children.toArray(actions);
|
|
12
12
|
const _comments = React.Children.toArray(children);
|
|
13
13
|
return (React.createElement(Wrapper, { id: id },
|
|
14
14
|
React.createElement(Header, null,
|
|
15
15
|
React.createElement(Avatar, { href: authorHref, image: authorImage, size: 64, status: authorActive ? 'online' : undefined, subtitle: React.createElement(P, { as: "span", sx: "vertical-align: top;", "$fontSize": 14, "$lineHeight": 20 },
|
|
16
|
-
React.createElement(TimeAgo, { date: new Date(createdDate) })), title: React.createElement(H, { as: "span", "$bold": true, "$fontSize": 18, "$lineHeight": 26 }, author), textPosition: "right", tooltipContent: avatarTooltipContent }),
|
|
16
|
+
React.createElement(TimeAgo, { date: new Date(createdDate) })), title: React.createElement(H, { as: "span", "$bold": true, "$fontSize": 18, "$lineHeight": 26 }, author), textPosition: "right", tooltipContent: avatarTooltipContent, tooltipSx: avatarTooltipSx }),
|
|
17
17
|
dropdown),
|
|
18
18
|
!!content?.length && (React.createElement("div", { style: { padding: 24 } },
|
|
19
19
|
React.createElement(P, { "$textClampLines": isPaywalled ? 2 : undefined }, content))),
|
package/package.json
CHANGED
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
'use client';
|
|
2
|
-
import { useEventListener } from './event-listenter';
|
|
3
|
-
export const useClickOutside = (ref, cb) => {
|
|
4
|
-
useEventListener('click', (e) => {
|
|
5
|
-
if (ref?.current == null ||
|
|
6
|
-
ref?.current?.contains(e.target))
|
|
7
|
-
return;
|
|
8
|
-
cb(e);
|
|
9
|
-
}, document);
|
|
10
|
-
};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export declare const useEventListener: (eventType: string, callback: (...args: any[]) => unknown, element?: Window & typeof globalThis) => void;
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
'use client';
|
|
2
|
-
import React from 'react';
|
|
3
|
-
export const useEventListener = (eventType, callback, element = window) => {
|
|
4
|
-
const callbackRef = React.useRef(callback);
|
|
5
|
-
React.useEffect(() => {
|
|
6
|
-
callbackRef.current = callback;
|
|
7
|
-
}, [callback]);
|
|
8
|
-
React.useEffect(() => {
|
|
9
|
-
if (element == null)
|
|
10
|
-
return;
|
|
11
|
-
const handler = (e) => callbackRef.current(e);
|
|
12
|
-
element.addEventListener(eventType, handler);
|
|
13
|
-
return () => element.removeEventListener(eventType, handler);
|
|
14
|
-
}, [eventType, element]);
|
|
15
|
-
};
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
'use client';
|
|
2
|
-
import React from 'react';
|
|
3
|
-
import { useEventListener } from './event-listenter';
|
|
4
|
-
export const useHover = (ref) => {
|
|
5
|
-
const [hovered, setHovered] = React.useState(false);
|
|
6
|
-
useEventListener('mouseover', () => setHovered(true), ref?.current);
|
|
7
|
-
useEventListener('mouseout', () => setHovered(false), ref?.current);
|
|
8
|
-
return hovered;
|
|
9
|
-
};
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
'use client';
|
|
2
|
-
import React from 'react';
|
|
3
|
-
import { useEventListener } from './event-listenter';
|
|
4
|
-
export const useWindowSize = () => {
|
|
5
|
-
const [windowSize, setWindowSize] = React.useState({
|
|
6
|
-
width: window.innerWidth,
|
|
7
|
-
height: window.innerHeight,
|
|
8
|
-
});
|
|
9
|
-
useEventListener('resize', () => {
|
|
10
|
-
setWindowSize({ width: window.innerWidth, height: window.innerHeight });
|
|
11
|
-
});
|
|
12
|
-
return windowSize;
|
|
13
|
-
};
|