@soul-refiner/design-system 0.2.105 → 0.2.107
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/actions/button/button.d.ts +1 -1
- package/dist/components/actions/button/button.js +22 -0
- package/dist/components/custom/index.d.ts +2 -0
- package/dist/components/custom/index.js +1 -0
- package/dist/components/custom/users_selection/index.d.ts +2 -0
- package/dist/components/custom/users_selection/index.js +1 -0
- package/dist/components/custom/users_selection/users_selection.d.ts +22 -0
- package/dist/components/custom/users_selection/users_selection.js +118 -0
- 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 +1 -1
- package/dist/components/index.js +1 -1
- package/dist/components/input/checkbox/checkbox.d.ts +2 -1
- package/dist/components/input/checkbox/checkbox.js +3 -2
- package/dist/components/input/search/search.js +1 -0
- 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
|
@@ -2,7 +2,7 @@ import React from 'react';
|
|
|
2
2
|
type NativeProps = Pick<React.HTMLAttributes<HTMLButtonElement>, 'dangerouslySetInnerHTML' | 'onClick' | 'onMouseDown' | 'onMouseDownCapture' | 'onMouseEnter' | 'onMouseLeave' | 'onMouseOut' | 'onMouseOver'> & {
|
|
3
3
|
value?: string;
|
|
4
4
|
};
|
|
5
|
-
type ButtonTypes = 'primary' | 'secondary' | 'outlined' | 'danger' | 'text' | 'raised' | 'special';
|
|
5
|
+
type ButtonTypes = 'primary' | 'secondary' | 'outlined' | 'danger' | 'text' | 'raised' | 'special' | 'dropdown';
|
|
6
6
|
type ButtonSize = 'small' | 'large';
|
|
7
7
|
type ButtonShape = 'none' | 'small' | 'medium-small' | 'large';
|
|
8
8
|
export interface ButtonProps extends NativeProps, React.PropsWithChildren {
|
|
@@ -51,6 +51,7 @@ const Components = () => ({
|
|
|
51
51
|
raised: Raised,
|
|
52
52
|
special: Special,
|
|
53
53
|
text: Text,
|
|
54
|
+
dropdown: Dropdown,
|
|
54
55
|
});
|
|
55
56
|
const base = css `
|
|
56
57
|
font-family: var(--font-inter);
|
|
@@ -246,3 +247,24 @@ const Special = styled(Box) `
|
|
|
246
247
|
|
|
247
248
|
${({ $sx }) => ($sx ? $sx : '')}
|
|
248
249
|
`;
|
|
250
|
+
const Dropdown = styled(Box) `
|
|
251
|
+
width: 100%;
|
|
252
|
+
background-color: var(--color-blue-10);
|
|
253
|
+
color: var(--color-grey-3);
|
|
254
|
+
border: 1px solid var(--color-primary-blue-2);
|
|
255
|
+
justify-content: flex-start;
|
|
256
|
+
padding: 16px;
|
|
257
|
+
border-radius: 8px;
|
|
258
|
+
border: 0;
|
|
259
|
+
|
|
260
|
+
&:hover {
|
|
261
|
+
border: 0;
|
|
262
|
+
background-color: var(--color-blue-10);
|
|
263
|
+
}
|
|
264
|
+
|
|
265
|
+
${base}
|
|
266
|
+
${Styles.flex}
|
|
267
|
+
${Styles.padding}
|
|
268
|
+
|
|
269
|
+
${({ $sx }) => ($sx ? $sx : '')}
|
|
270
|
+
`;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { UsersSelection } from './users_selection';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { UsersSelection } from './users_selection';
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
type NativeProps = Pick<React.HTMLAttributes<HTMLDivElement>, 'children' | 'onBlur' | 'onBlurCapture' | 'onClick' | 'onChange' | 'onMouseDown' | 'onMouseDownCapture' | 'onMouseEnter' | 'onMouseLeave' | 'onMouseOut' | 'onMouseOver'>;
|
|
3
|
+
type User = {
|
|
4
|
+
id: string;
|
|
5
|
+
fullName: string;
|
|
6
|
+
imageSrc: string;
|
|
7
|
+
};
|
|
8
|
+
export interface UsersSelectionProps extends NativeProps, React.PropsWithChildren {
|
|
9
|
+
closeOnBlur?: boolean;
|
|
10
|
+
disabled?: boolean;
|
|
11
|
+
offset?: [number, number];
|
|
12
|
+
sx?: string;
|
|
13
|
+
containerSx?: string;
|
|
14
|
+
searchSx?: string;
|
|
15
|
+
users: User[];
|
|
16
|
+
label: string;
|
|
17
|
+
title: string;
|
|
18
|
+
userIsChecked: Record<string, boolean>;
|
|
19
|
+
setUserIsChecked: React.Dispatch<React.SetStateAction<Record<string, boolean>>>;
|
|
20
|
+
}
|
|
21
|
+
export declare const UsersSelection: ({ closeOnBlur, disabled, offset, sx, containerSx, searchSx, users, label, title, userIsChecked, setUserIsChecked, ...rest }: UsersSelectionProps) => React.JSX.Element;
|
|
22
|
+
export {};
|
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
import { Group } from '../../../icons';
|
|
3
|
+
import React from 'react';
|
|
4
|
+
import styled from 'styled-components';
|
|
5
|
+
import { Button, P, Search, Checkbox, Box } from '../../';
|
|
6
|
+
export const UsersSelection = ({ closeOnBlur = true, disabled = false, offset = [0, 0], sx, containerSx, searchSx, users, label, title, userIsChecked, setUserIsChecked, ...rest }) => {
|
|
7
|
+
const wrapperRef = React.useRef(null);
|
|
8
|
+
const [open, setOpen] = React.useState(true);
|
|
9
|
+
const [searchValue, setSearchValue] = React.useState('');
|
|
10
|
+
React.useEffect(() => {
|
|
11
|
+
if (disabled) {
|
|
12
|
+
setOpen(false);
|
|
13
|
+
}
|
|
14
|
+
}, [disabled]);
|
|
15
|
+
const handleOpen = () => {
|
|
16
|
+
if (disabled) {
|
|
17
|
+
return;
|
|
18
|
+
}
|
|
19
|
+
setOpen((prev) => !prev);
|
|
20
|
+
};
|
|
21
|
+
const handleBlur = (event) => {
|
|
22
|
+
if (closeOnBlur &&
|
|
23
|
+
wrapperRef?.current &&
|
|
24
|
+
!wrapperRef?.current?.contains(event.relatedTarget)) {
|
|
25
|
+
setOpen(false);
|
|
26
|
+
}
|
|
27
|
+
};
|
|
28
|
+
return (React.createElement(Wrapper, { "$sx": sx, tabIndex: 0, ref: wrapperRef, onBlurCapture: handleBlur, ...rest },
|
|
29
|
+
React.createElement(Button, { type: "dropdown", isDropdownOpen: open, onClick: handleOpen },
|
|
30
|
+
React.createElement(Group, { size: 16, sx: "margin-right: 16px;" }),
|
|
31
|
+
label),
|
|
32
|
+
open && (React.createElement(Container, { "$offset": offset, "$sx": containerSx },
|
|
33
|
+
React.createElement(P, null, title),
|
|
34
|
+
React.createElement(Search, { onChange: (event) => setSearchValue(event.target.value), onClearText: () => setSearchValue(''), value: searchValue, size: "large", placeholder: "Search...", sx: `margin-top: 8px; margin-bottom: 8px; border-radius: 76px; ${searchSx}` }),
|
|
35
|
+
users
|
|
36
|
+
.filter((user) => searchValue
|
|
37
|
+
? user.fullName
|
|
38
|
+
.toLowerCase()
|
|
39
|
+
.includes(searchValue.toLowerCase())
|
|
40
|
+
: true)
|
|
41
|
+
.map((user) => (React.createElement(React.Fragment, { key: user.id },
|
|
42
|
+
React.createElement(OptionWrapper, { "$disabled": disabled, onClick: () => setUserIsChecked({
|
|
43
|
+
...userIsChecked,
|
|
44
|
+
[user.id]: !userIsChecked[user.id],
|
|
45
|
+
}) },
|
|
46
|
+
React.createElement(Box, { "$display": "flex", "$align": "center" },
|
|
47
|
+
React.createElement(Image, { src: user.imageSrc }),
|
|
48
|
+
React.createElement(P, { "$color": 'grey-4', "$fontSize": 14, "$lineHeight": 20, "$mediumBold": true, "$textClampLines": 1 }, user.fullName),
|
|
49
|
+
React.createElement(Checkbox, { selected: userIsChecked[user.id], sx: "margin-left: auto;" }))),
|
|
50
|
+
React.createElement(Spacer, null))))))));
|
|
51
|
+
};
|
|
52
|
+
const Wrapper = styled.div `
|
|
53
|
+
position: relative;
|
|
54
|
+
display: block;
|
|
55
|
+
outline: none;
|
|
56
|
+
${({ $sx }) => ($sx ? $sx : '')}
|
|
57
|
+
`;
|
|
58
|
+
const Container = styled.div `
|
|
59
|
+
min-width: 280px;
|
|
60
|
+
max-height: 600px;
|
|
61
|
+
display: flex;
|
|
62
|
+
flex-direction: column;
|
|
63
|
+
background-color: var(--color-white);
|
|
64
|
+
position: absolute;
|
|
65
|
+
width: 100%;
|
|
66
|
+
outline: none;
|
|
67
|
+
cursor: pointer;
|
|
68
|
+
box-shadow: var(--elevation-2);
|
|
69
|
+
border-radius: 8px;
|
|
70
|
+
overflow: auto;
|
|
71
|
+
padding: 24px;
|
|
72
|
+
|
|
73
|
+
${({ $sx }) => ($sx ? $sx : '')}
|
|
74
|
+
|
|
75
|
+
${({ $offset }) => $offset ? `transform: translate(${$offset[0]}px, ${$offset[1]}px);` : ''}
|
|
76
|
+
`;
|
|
77
|
+
const OptionWrapper = styled.div `
|
|
78
|
+
position: relative;
|
|
79
|
+
padding: 12px 16px;
|
|
80
|
+
user-select: none;
|
|
81
|
+
gap: 8px;
|
|
82
|
+
|
|
83
|
+
& > * {
|
|
84
|
+
pointer-events: none;
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
${({ $disabled }) => {
|
|
88
|
+
if ($disabled) {
|
|
89
|
+
return `cursor: initial;
|
|
90
|
+
color: var(--color-grey-7);
|
|
91
|
+
background-color: var(--color-grey-10);`;
|
|
92
|
+
}
|
|
93
|
+
return `
|
|
94
|
+
&:hover {
|
|
95
|
+
background-color: var(--color-blue-10);
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
&:active {
|
|
99
|
+
background-color: var(--color-grey-8);
|
|
100
|
+
}
|
|
101
|
+
`;
|
|
102
|
+
}}
|
|
103
|
+
`;
|
|
104
|
+
const Image = styled.img `
|
|
105
|
+
border-radius: 50%;
|
|
106
|
+
width: 40px;
|
|
107
|
+
height: 40px;
|
|
108
|
+
margin-right: 16px;
|
|
109
|
+
`;
|
|
110
|
+
const Spacer = styled.div `
|
|
111
|
+
width: 100%;
|
|
112
|
+
height: 1px;
|
|
113
|
+
background-color: var(--color-grey-8);
|
|
114
|
+
|
|
115
|
+
&:hover {
|
|
116
|
+
appearance: none;
|
|
117
|
+
}
|
|
118
|
+
`;
|
|
@@ -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 }) => {
|
|
@@ -3,9 +3,9 @@ export * from './atoms';
|
|
|
3
3
|
export * from './card';
|
|
4
4
|
export * from './editor';
|
|
5
5
|
export * from './feedback';
|
|
6
|
-
export * from './hooks';
|
|
7
6
|
export * from './iconography';
|
|
8
7
|
export * from './input';
|
|
9
8
|
export * from './navigation';
|
|
10
9
|
export * from './surfaces';
|
|
11
10
|
export * from './table';
|
|
11
|
+
export * from './custom';
|
package/dist/components/index.js
CHANGED
|
@@ -3,9 +3,9 @@ export * from './atoms';
|
|
|
3
3
|
export * from './card';
|
|
4
4
|
export * from './editor';
|
|
5
5
|
export * from './feedback';
|
|
6
|
-
export * from './hooks';
|
|
7
6
|
export * from './iconography';
|
|
8
7
|
export * from './input';
|
|
9
8
|
export * from './navigation';
|
|
10
9
|
export * from './surfaces';
|
|
11
10
|
export * from './table';
|
|
11
|
+
export * from './custom';
|
|
@@ -3,6 +3,7 @@ type NativeProps = Pick<React.HTMLAttributes<HTMLDivElement>, 'onClick' | 'onCha
|
|
|
3
3
|
export interface CheckboxProps extends NativeProps {
|
|
4
4
|
disabled?: boolean;
|
|
5
5
|
selected: boolean;
|
|
6
|
+
sx?: string;
|
|
6
7
|
}
|
|
7
|
-
export declare const Checkbox: ({ disabled, selected, ...rest }: CheckboxProps) => React.JSX.Element;
|
|
8
|
+
export declare const Checkbox: ({ disabled, selected, sx, ...rest }: CheckboxProps) => React.JSX.Element;
|
|
8
9
|
export {};
|
|
@@ -3,8 +3,8 @@ import React from 'react';
|
|
|
3
3
|
import styled from 'styled-components';
|
|
4
4
|
import { Styles } from '../../../common';
|
|
5
5
|
import { Checkmark } from '../../../icons';
|
|
6
|
-
export const Checkbox = ({ disabled, selected, ...rest }) => {
|
|
7
|
-
return (React.createElement(Box, { "$align": "center", "$disabled": !!disabled, "$display": "flex", "$justify": "center", "$selected": selected, ...rest }, selected && React.createElement(Checkmark, { color: "white" })));
|
|
6
|
+
export const Checkbox = ({ disabled, selected, sx, ...rest }) => {
|
|
7
|
+
return (React.createElement(Box, { "$align": "center", "$disabled": !!disabled, "$display": "flex", "$justify": "center", "$selected": selected, "$sx": sx, ...rest }, selected && React.createElement(Checkmark, { color: "white" })));
|
|
8
8
|
};
|
|
9
9
|
const Box = styled.div `
|
|
10
10
|
display: flex;
|
|
@@ -19,4 +19,5 @@ const Box = styled.div `
|
|
|
19
19
|
border: 1px solid var(--color-primary-blue-2);`
|
|
20
20
|
: 'border: 1px solid var(--color-grey-8);'}
|
|
21
21
|
${Styles.flex}
|
|
22
|
+
${({ $sx }) => ($sx ? $sx : '')}
|
|
22
23
|
`;
|
|
@@ -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
|
-
};
|