@soul-refiner/design-system 0.2.135 → 1.0.0
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/hooks/click-outside.d.ts +2 -0
- package/dist/components/hooks/click-outside.js +10 -0
- package/dist/components/hooks/event-listenter.d.ts +1 -0
- package/dist/components/hooks/event-listenter.js +15 -0
- package/dist/components/hooks/hover.d.ts +2 -0
- package/dist/components/hooks/hover.js +9 -0
- package/dist/components/hooks/index.d.ts +4 -0
- package/dist/components/hooks/index.js +4 -0
- package/dist/components/hooks/window-size.d.ts +4 -0
- package/dist/components/hooks/window-size.js +13 -0
- package/dist/components/navigation/breadcrumb/breadcrumb.js +2 -3
- package/dist/components/navigation/inner/inner.d.ts +2 -1
- package/dist/components/navigation/inner/inner.js +8 -32
- package/dist/components/navigation/tabs/tabs.js +3 -3
- package/dist/components/surfaces/calendar_date/calendar_date.d.ts +1 -2
- package/dist/components/surfaces/calendar_date/calendar_date.js +9 -14
- package/dist/components/surfaces/post/helpers.d.ts +1 -0
- package/dist/components/surfaces/post/helpers.js +26 -0
- package/package.json +23 -23
|
@@ -0,0 +1,10 @@
|
|
|
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
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const useEventListener: (eventType: string, callback: (...args: any[]) => unknown, element?: Window & typeof globalThis) => void;
|
|
@@ -0,0 +1,15 @@
|
|
|
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
|
+
};
|
|
@@ -0,0 +1,9 @@
|
|
|
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
|
+
};
|
|
@@ -0,0 +1,13 @@
|
|
|
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
|
+
};
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
'use client';
|
|
2
2
|
import React from 'react';
|
|
3
3
|
import styled from 'styled-components';
|
|
4
|
-
import Link from 'next/link';
|
|
5
4
|
import { Box } from '../../';
|
|
6
5
|
import { ChevronLeft, ChevronRight } from '../../../icons';
|
|
7
6
|
const Breadcrumb = ({ children, previous }) => {
|
|
@@ -29,14 +28,14 @@ const Breadcrumb = ({ children, previous }) => {
|
|
|
29
28
|
})));
|
|
30
29
|
};
|
|
31
30
|
const BreadcrumbItem = ({ avatar, children, href, icon, iconColor = 'blue', onClick, }) => {
|
|
32
|
-
return (React.createElement(Item, {
|
|
31
|
+
return (React.createElement(Item, { as: href ? 'a' : 'div', href: href, onClick: onClick, "$type": icon ? 'icon' : avatar ? 'avatar' : 'text', "$iconColor": `hue-${iconColor}-1` },
|
|
33
32
|
icon && (React.createElement(IconWrapper, { "$color": iconColor }, React.cloneElement(icon, { color: `hue-${iconColor}-1`, size: 24 }))),
|
|
34
33
|
avatar,
|
|
35
34
|
children));
|
|
36
35
|
};
|
|
37
36
|
Breadcrumb.Item = BreadcrumbItem;
|
|
38
37
|
BreadcrumbItem.displayName = 'Breadcrumb.Item';
|
|
39
|
-
const Item = styled
|
|
38
|
+
const Item = styled.div `
|
|
40
39
|
display: flex;
|
|
41
40
|
flex-flow: row nowrap;
|
|
42
41
|
align-items: center;
|
|
@@ -9,7 +9,7 @@ declare const InnerNav: {
|
|
|
9
9
|
displayName: string;
|
|
10
10
|
};
|
|
11
11
|
Dropdown: {
|
|
12
|
-
({ children, icon, label, open, sx, onClick, }: InnerNavDropdownProps): React.JSX.Element;
|
|
12
|
+
({ children, href, icon, label, open, sx, onClick, }: InnerNavDropdownProps): React.JSX.Element;
|
|
13
13
|
displayName: string;
|
|
14
14
|
};
|
|
15
15
|
BackButton: {
|
|
@@ -63,6 +63,7 @@ export interface InnerNavItemProps {
|
|
|
63
63
|
* Dropdown
|
|
64
64
|
*/
|
|
65
65
|
export interface InnerNavDropdownProps extends React.PropsWithChildren {
|
|
66
|
+
href?: string;
|
|
66
67
|
icon?: React.ReactElement;
|
|
67
68
|
label: React.ReactNode;
|
|
68
69
|
open: boolean;
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import styled from 'styled-components';
|
|
3
|
-
import Link from 'next/link';
|
|
4
3
|
import { Button } from '../../../components/actions/button';
|
|
5
4
|
import { Drawer } from '../../../components/surfaces/drawer';
|
|
6
5
|
import { ChevronDown, ChevronLeft, ChevronUp, Plus } from '../../../icons';
|
|
@@ -54,11 +53,12 @@ const NavWrapper = styled.nav `
|
|
|
54
53
|
border-right: 1px solid var(--color-grey-9);
|
|
55
54
|
`;
|
|
56
55
|
const InnerNavItem = ({ active, href, icon, label, sx }) => {
|
|
57
|
-
|
|
56
|
+
const isAnchor = !!href;
|
|
57
|
+
return (React.createElement(Item, { "$active": active, "$sx": sx, as: isAnchor ? 'a' : 'button', href: href },
|
|
58
58
|
icon,
|
|
59
59
|
label));
|
|
60
60
|
};
|
|
61
|
-
const Item = styled
|
|
61
|
+
const Item = styled.button `
|
|
62
62
|
padding: 14px 16px;
|
|
63
63
|
display: flex;
|
|
64
64
|
gap: 16px;
|
|
@@ -85,9 +85,10 @@ const Item = styled(Link) `
|
|
|
85
85
|
`;
|
|
86
86
|
InnerNav.Item = InnerNavItem;
|
|
87
87
|
InnerNavItem.displayName = 'InnerNav.Item';
|
|
88
|
-
const InnerNavDropdown = ({ children, icon, label, open, sx, onClick, }) => {
|
|
88
|
+
const InnerNavDropdown = ({ children, href, icon, label, open, sx, onClick, }) => {
|
|
89
|
+
const isAnchor = !!href;
|
|
89
90
|
return (React.createElement(React.Fragment, null,
|
|
90
|
-
React.createElement(
|
|
91
|
+
React.createElement(Item, { "$active": false, "$sx": sx, as: isAnchor ? 'a' : 'button', href: !!onClick ? undefined : href, onClick: onClick },
|
|
91
92
|
icon,
|
|
92
93
|
React.createElement(DropdownTriggerWrapper, null,
|
|
93
94
|
label,
|
|
@@ -107,40 +108,15 @@ const DropdownTriggerWrapper = styled.div `
|
|
|
107
108
|
align-items: center;
|
|
108
109
|
flex: 1;
|
|
109
110
|
`;
|
|
110
|
-
const DropdownItem = styled.a `
|
|
111
|
-
padding: 14px 16px;
|
|
112
|
-
display: flex;
|
|
113
|
-
gap: 16px;
|
|
114
|
-
align-items: center;
|
|
115
|
-
border-radius: 8px;
|
|
116
|
-
font-family: var(--font-inter);
|
|
117
|
-
font-weight: 500;
|
|
118
|
-
font-size: 16px;
|
|
119
|
-
line-height: 24px;
|
|
120
|
-
color: var(--color-blue-2);
|
|
121
|
-
cursor: pointer;
|
|
122
|
-
svg {
|
|
123
|
-
fill: var(--color-blue-2);
|
|
124
|
-
}
|
|
125
|
-
${({ $active }) => $active
|
|
126
|
-
? `
|
|
127
|
-
background-color: var(--color-primary-blue-3);`
|
|
128
|
-
: `
|
|
129
|
-
&:hover {
|
|
130
|
-
background-color: var(--color-primary-blue-4);
|
|
131
|
-
}`}
|
|
132
|
-
|
|
133
|
-
${({ $sx }) => ($sx ? $sx : '')}
|
|
134
|
-
`;
|
|
135
111
|
InnerNav.Dropdown = InnerNavDropdown;
|
|
136
112
|
InnerNavDropdown.displayName = 'InnerNav.Dropdown';
|
|
137
113
|
const InnerNavBackButton = ({ href, label, sx }) => {
|
|
138
|
-
return (React.createElement(BackButton, { href: href, "$sx": sx
|
|
114
|
+
return (React.createElement(BackButton, { href: href, "$sx": sx },
|
|
139
115
|
React.createElement("div", null,
|
|
140
116
|
React.createElement(ChevronLeft, { size: 24 })),
|
|
141
117
|
label));
|
|
142
118
|
};
|
|
143
|
-
const BackButton = styled
|
|
119
|
+
const BackButton = styled.a `
|
|
144
120
|
display: flex;
|
|
145
121
|
align-items: center;
|
|
146
122
|
gap: 8px;
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
'use client';
|
|
2
2
|
import React from 'react';
|
|
3
3
|
import styled from 'styled-components';
|
|
4
|
-
import Link from 'next/link';
|
|
5
4
|
import { P } from '../../';
|
|
6
5
|
const colorLookup = {
|
|
7
6
|
blue: {
|
|
@@ -65,16 +64,17 @@ const Wrapper = styled.div `
|
|
|
65
64
|
${({ $sx }) => ($sx ? $sx : '')}
|
|
66
65
|
`;
|
|
67
66
|
const Item = ({ active, color, disabled, href, icon, label, onClick, size = 'large', }) => {
|
|
67
|
+
const isAnchor = !!href;
|
|
68
68
|
const inputColor = disabled ? 'grey' : color ? color : 'blue';
|
|
69
69
|
const iconColor = colorLookup[inputColor].icon;
|
|
70
70
|
const bgColor = colorLookup[inputColor].bg;
|
|
71
71
|
const fontSize = size === 'large' ? 16 : size === 'medium' ? 14 : 12;
|
|
72
72
|
const lineHeight = size === 'large' ? 24 : size === 'medium' ? 20 : 16;
|
|
73
|
-
return (React.createElement(Element, {
|
|
73
|
+
return (React.createElement(Element, { as: isAnchor ? 'a' : 'div', href: href, onClick: !disabled && onClick ? onClick : undefined, "$active": active, "$color": iconColor, "$disabled": disabled, "$hasIcon": !!icon, "$size": size },
|
|
74
74
|
icon && React.createElement(IconWrapper, { "$bg": bgColor }, icon),
|
|
75
75
|
React.createElement(P, { "$fontSize": fontSize, "$lineHeight": lineHeight, "$semiBold": true }, label)));
|
|
76
76
|
};
|
|
77
|
-
const Element = styled
|
|
77
|
+
const Element = styled.div `
|
|
78
78
|
position: relative;
|
|
79
79
|
display: flex;
|
|
80
80
|
align-items: center;
|
|
@@ -6,6 +6,5 @@ export interface CalendarDateProps {
|
|
|
6
6
|
startTime?: string;
|
|
7
7
|
endTime?: string;
|
|
8
8
|
sx?: string;
|
|
9
|
-
size?: 'small' | 'large';
|
|
10
9
|
}
|
|
11
|
-
export declare const CalendarDate: ({ monthAbbreviation, date, dayOfWeek, startTime, endTime, sx,
|
|
10
|
+
export declare const CalendarDate: ({ monthAbbreviation, date, dayOfWeek, startTime, endTime, sx, }: CalendarDateProps) => React.JSX.Element;
|
|
@@ -2,15 +2,13 @@
|
|
|
2
2
|
import React from 'react';
|
|
3
3
|
import styled from 'styled-components';
|
|
4
4
|
import { H, P } from '../../atoms/typography';
|
|
5
|
-
export const CalendarDate = ({ monthAbbreviation, date, dayOfWeek, startTime, endTime, sx,
|
|
5
|
+
export const CalendarDate = ({ monthAbbreviation, date, dayOfWeek, startTime, endTime, sx, }) => {
|
|
6
6
|
return (React.createElement(Container, { "$sx": sx },
|
|
7
|
-
React.createElement(CalendarContainer,
|
|
8
|
-
React.createElement(MonthContainer,
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
size === 'large' && (React.createElement(H.One, { "$textAlign": "center", "$semiBold": true }, date)),
|
|
13
|
-
size === 'small' && (React.createElement(H.Six, { "$color": "grey-2", "$textAlign": "center" }, date)))),
|
|
7
|
+
React.createElement(CalendarContainer, null,
|
|
8
|
+
React.createElement(MonthContainer, null,
|
|
9
|
+
React.createElement(H.Seven, { "$color": "white", "$textAlign": "center", sx: "font-weight: 600;" }, monthAbbreviation)),
|
|
10
|
+
React.createElement(DateContainer, null,
|
|
11
|
+
React.createElement(H.One, { "$textAlign": "center", sx: "font-weight: 600;" }, date))),
|
|
14
12
|
dayOfWeek && startTime && endTime && (React.createElement(TimeContainer, null,
|
|
15
13
|
React.createElement(P, { as: "span", "$color": "red-5" }, `${dayOfWeek}, ${startTime} -> ${endTime}`)))));
|
|
16
14
|
};
|
|
@@ -24,21 +22,18 @@ const Container = styled.div `
|
|
|
24
22
|
const CalendarContainer = styled.div `
|
|
25
23
|
display: flex;
|
|
26
24
|
flex-direction: column;
|
|
27
|
-
|
|
28
|
-
${({ $size }) => ($size === 'large' ? 'width: 120px;' : 'width: 64px;')}
|
|
25
|
+
width: 120px;
|
|
29
26
|
`;
|
|
30
27
|
const MonthContainer = styled.div `
|
|
28
|
+
padding: 8px 16px;
|
|
31
29
|
background-color: var(--color-red-5);
|
|
32
30
|
border-radius: 16px 16px 0 0;
|
|
33
|
-
|
|
34
|
-
${({ $size }) => $size === 'large' ? 'padding: 8px 16px;' : 'padding: 2px 8px;'}
|
|
35
31
|
`;
|
|
36
32
|
const DateContainer = styled.div `
|
|
33
|
+
padding: 8px 16px;
|
|
37
34
|
background-color: white;
|
|
38
35
|
border-radius: 0 0 16px 16px;
|
|
39
36
|
box-shadow: var(--elevation-3);
|
|
40
|
-
|
|
41
|
-
${({ $size }) => $size === 'large' ? 'padding: 8px 16px;' : 'padding: 2px 16px;'}
|
|
42
37
|
`;
|
|
43
38
|
const TimeContainer = styled.div `
|
|
44
39
|
margin-top: 16px;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const abbrTimeBeforeDate: (date: Date) => string;
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
export const abbrTimeBeforeDate = (date) => {
|
|
2
|
+
const now = new Date();
|
|
3
|
+
const diff = now.getTime() - date.getTime();
|
|
4
|
+
if (diff < 60000) {
|
|
5
|
+
// under 1 min
|
|
6
|
+
return 'Just now';
|
|
7
|
+
}
|
|
8
|
+
else if (diff < 3600000) {
|
|
9
|
+
// under one hour
|
|
10
|
+
const minutes = Math.floor(diff / 60000);
|
|
11
|
+
return `${minutes} ${minutes === 1 ? 'min' : 'mins'}`;
|
|
12
|
+
}
|
|
13
|
+
else if (diff < 86400000) {
|
|
14
|
+
// under one day
|
|
15
|
+
const hours = Math.floor(diff / 3600000);
|
|
16
|
+
return `${hours} ${hours === 1 ? 'hour' : 'hours'}`;
|
|
17
|
+
}
|
|
18
|
+
else if (diff < 604800000) {
|
|
19
|
+
// under one week
|
|
20
|
+
const days = Math.floor(diff / 86400000);
|
|
21
|
+
return `${days} ${days === 1 ? 'day' : 'days'}`;
|
|
22
|
+
}
|
|
23
|
+
else {
|
|
24
|
+
return date.toDateString().slice(4);
|
|
25
|
+
}
|
|
26
|
+
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@soul-refiner/design-system",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "1.0.0",
|
|
4
4
|
"main": "dist/index.js",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"publishConfig": {
|
|
@@ -53,29 +53,29 @@
|
|
|
53
53
|
"prepare": "husky install"
|
|
54
54
|
},
|
|
55
55
|
"dependencies": {
|
|
56
|
-
"@emoji-mart/react": "
|
|
57
|
-
"@udecode/plate": "
|
|
58
|
-
"emoji-mart": "
|
|
59
|
-
"next": "
|
|
60
|
-
"react": "
|
|
61
|
-
"react-dnd": "
|
|
62
|
-
"react-dnd-html5-backend": "
|
|
63
|
-
"react-dom": "
|
|
64
|
-
"react-is": "
|
|
65
|
-
"react-player": "
|
|
66
|
-
"react-tooltip": "
|
|
67
|
-
"scheduler": "
|
|
68
|
-
"slate": "
|
|
69
|
-
"slate-history": "
|
|
70
|
-
"slate-hyperscript": "
|
|
71
|
-
"slate-react": "
|
|
72
|
-
"styled-components": "
|
|
56
|
+
"@emoji-mart/react": "~1.1.1",
|
|
57
|
+
"@udecode/plate": "~22.0.2",
|
|
58
|
+
"emoji-mart": "~5.5.2",
|
|
59
|
+
"next": "~13.5",
|
|
60
|
+
"react": "18.2.0",
|
|
61
|
+
"react-dnd": "~16.0.1",
|
|
62
|
+
"react-dnd-html5-backend": "~16.0.1",
|
|
63
|
+
"react-dom": "~18.2.0",
|
|
64
|
+
"react-is": "~18.2.0",
|
|
65
|
+
"react-player": "~2.13.0",
|
|
66
|
+
"react-tooltip": "~5.18.0",
|
|
67
|
+
"scheduler": "~0.23.0",
|
|
68
|
+
"slate": "~0.94.1",
|
|
69
|
+
"slate-history": "~0.93.0",
|
|
70
|
+
"slate-hyperscript": "~0.77.0",
|
|
71
|
+
"slate-react": "~0.97.1",
|
|
72
|
+
"styled-components": "~6.1.1"
|
|
73
73
|
},
|
|
74
74
|
"peerDependencies": {
|
|
75
|
-
"next": "
|
|
76
|
-
"react": "
|
|
77
|
-
"react-dom": "
|
|
78
|
-
"react-player": "
|
|
79
|
-
"styled-components": "
|
|
75
|
+
"next": "~13.5",
|
|
76
|
+
"react": "~18.2.0",
|
|
77
|
+
"react-dom": "~18.2.0",
|
|
78
|
+
"react-player": "~2.13.0",
|
|
79
|
+
"styled-components": "~6.1.1"
|
|
80
80
|
}
|
|
81
81
|
}
|