@soul-refiner/design-system 0.1.21 → 0.1.23

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@soul-refiner/design-system",
3
- "version": "0.1.21",
3
+ "version": "0.1.23",
4
4
  "main": "src/index.ts",
5
5
  "license": "MIT",
6
6
  "publishConfig": {
@@ -34,7 +34,7 @@ type NativeProps = Pick<
34
34
  | 'onMouseOut'
35
35
  | 'onMouseOver'
36
36
  | 'title'
37
- > & { value?: string };
37
+ > & { value?: string; href?: string };
38
38
 
39
39
  export interface BoxProps
40
40
  extends BackgroundColor,
@@ -0,0 +1,172 @@
1
+ import React from 'react';
2
+ import styled from 'styled-components';
3
+ import { Box } from 'components';
4
+ import { ChevronLeft, ChevronRight } from 'icons';
5
+
6
+ export interface BreadcrumbProps extends React.PropsWithChildren {
7
+ previous?: boolean;
8
+ }
9
+
10
+ const Breadcrumb = ({ children, previous }: BreadcrumbProps) => {
11
+ const _children = React.Children.toArray(children);
12
+
13
+ if (previous) {
14
+ return (
15
+ <Box
16
+ $align="center"
17
+ $gap={8}
18
+ sx="& > *:last-child { color: var(--color-grey-3) !important; };"
19
+ >
20
+ <>
21
+ <ChevronLeft color="grey-3" size={24} />
22
+ {React.isValidElement(_children[0]) &&
23
+ React.cloneElement(_children[0], {
24
+ icon: undefined,
25
+ avatar: undefined,
26
+ } as any)}
27
+ </>
28
+ </Box>
29
+ );
30
+ }
31
+
32
+ return (
33
+ <Box $align="center" $gap={8}>
34
+ {_children.map((child, index) => {
35
+ if (
36
+ React.isValidElement(child) &&
37
+ (child.type as any)?.displayName === 'BreadcrumbItem'
38
+ ) {
39
+ return (
40
+ <>
41
+ {child}
42
+ {_children.length - 1 !== index && (
43
+ <ChevronRight color="grey-3" size={24} />
44
+ )}
45
+ </>
46
+ );
47
+ }
48
+ return null;
49
+ })}
50
+ </Box>
51
+ );
52
+ };
53
+
54
+ type IconColor = 'blue' | 'pink' | 'purple' | 'mint' | 'orange' | 'ocean';
55
+
56
+ export interface BreadcrumbItemProps extends React.PropsWithChildren {
57
+ avatar?: React.ReactElement;
58
+ href?: string;
59
+ icon?: React.ReactElement;
60
+ iconColor?: IconColor;
61
+ onClick?: React.MouseEventHandler;
62
+ }
63
+
64
+ const BreadcrumbItem = ({
65
+ avatar,
66
+ children,
67
+ href,
68
+ icon,
69
+ iconColor = 'blue',
70
+ onClick,
71
+ }: BreadcrumbItemProps) => {
72
+ return (
73
+ <Item
74
+ as={href ? 'a' : 'div'}
75
+ href={href}
76
+ onClick={onClick}
77
+ $type={icon ? 'icon' : avatar ? 'avatar' : 'text'}
78
+ $iconColor={`hue-${iconColor}-1`}
79
+ >
80
+ {icon && (
81
+ <IconWrapper $color={iconColor}>
82
+ {React.cloneElement(icon, { color: `hue-${iconColor}-1`, size: 24 })}
83
+ </IconWrapper>
84
+ )}
85
+ {avatar}
86
+ {children}
87
+ </Item>
88
+ );
89
+ };
90
+
91
+ Breadcrumb.Item = BreadcrumbItem;
92
+ BreadcrumbItem.displayName = 'Breadcrumb.Item';
93
+
94
+ const Item = styled.div<{
95
+ as: string;
96
+ $type: 'text' | 'avatar' | 'icon';
97
+ $iconColor?: string;
98
+ }>`
99
+ display: flex;
100
+ flex-flow: row nowrap;
101
+ align-items: center;
102
+ font-family: Inter;
103
+ color: var(--color-grey-3);
104
+
105
+ ${({ as }) =>
106
+ as === 'a'
107
+ ? `
108
+ text-decoration: none;
109
+ color: var(--color-primary-blue-2);
110
+
111
+ &:hover {
112
+ position: relative;
113
+ &:after {
114
+ content: '';
115
+ position: absolute;
116
+ width: 100%;
117
+ height: 1px;
118
+ bottom: 0px;
119
+ right: 0px;
120
+ background-color: var(--color-primary-blue-1);
121
+ }
122
+ }`
123
+ : ''}
124
+
125
+ ${({ $type, $iconColor }) =>
126
+ $type === 'icon'
127
+ ? `
128
+ gap: 32px;
129
+ font-size: 24px;
130
+ font-weight: 700;
131
+ line-height: 36px;
132
+ color: var(--color-${$iconColor});
133
+
134
+ &:hover {
135
+ &:after {
136
+ width: calc(100% - 80px);
137
+ background-color: var(--color-${$iconColor});
138
+ }
139
+ }`
140
+ : $type === 'avatar'
141
+ ? `
142
+ padding: 4px;
143
+ gap: 16px;
144
+ font-size: 18px;
145
+ font-weight: 700;
146
+ line-height: 26px;
147
+ color: var(--color-grey-1);
148
+ &:hover {
149
+ &:after {
150
+ background-color: var(--color-primary-blue-2);
151
+ }
152
+ }`
153
+ : `
154
+ padding: 4px 0px;
155
+ font-size: 16px;
156
+ font-weight: 500;
157
+ line-height: 24px;
158
+ `}
159
+ `;
160
+
161
+ const IconWrapper = styled.div<{ $color: IconColor }>`
162
+ background-color: ${({ $color }) => `var(--color-hue-${$color}-2)`};
163
+ height: 48px;
164
+ width: 48px;
165
+ display: flex;
166
+ justify-content: center;
167
+ align-items: center;
168
+ box-sizing: border-box;
169
+ border-radius: 8px;
170
+ `;
171
+
172
+ export { Breadcrumb };
@@ -0,0 +1,2 @@
1
+ export { Breadcrumb } from './breadcrumb';
2
+ export type { BreadcrumbProps, BreadcrumbItemProps } from './breadcrumb';
@@ -1,2 +1,4 @@
1
+ export { Breadcrumb } from './breadcrumb';
2
+ export type { BreadcrumbProps, BreadcrumbItemProps } from './breadcrumb';
1
3
  export { Tabs } from './tabs';
2
4
  export type { TabProps } from './tabs';
@@ -0,0 +1,88 @@
1
+ import React from 'react';
2
+ import styled from 'styled-components';
3
+ import { Box } from 'components';
4
+ import { callAll } from 'utils';
5
+ import { ChevronDown, ChevronUp } from 'icons';
6
+
7
+ export interface AccordionProps extends React.PropsWithChildren {
8
+ sx?: string;
9
+ }
10
+
11
+ const ModalContext = React.createContext<[number, (index: number) => void]>([
12
+ -1,
13
+ () => undefined,
14
+ ]);
15
+
16
+ const Accordion = ({ children, sx }: AccordionProps) => {
17
+ const [openIndex, setOpenIndex] = React.useState(-1);
18
+
19
+ const handleIndexChange = (index: number) => {
20
+ setOpenIndex((prev) => (prev === index ? -1 : index));
21
+ };
22
+
23
+ return (
24
+ <ModalContext.Provider value={[openIndex, handleIndexChange]}>
25
+ <Wrapper $sx={sx}>
26
+ {React.Children.map(children, (child, index) => {
27
+ if (React.isValidElement(child))
28
+ return React.cloneElement(child, { index } as any);
29
+ return null;
30
+ })}
31
+ </Wrapper>
32
+ </ModalContext.Provider>
33
+ );
34
+ };
35
+
36
+ const Wrapper = styled.div<{ $sx?: string }>`
37
+ ${({ $sx }) => ($sx ? $sx : '')};
38
+ `;
39
+
40
+ export interface AccordionItemProps extends React.PropsWithChildren {
41
+ index?: number;
42
+ sx?: string;
43
+ trigger: React.ReactNode;
44
+ }
45
+
46
+ const AccordionItem = ({
47
+ children,
48
+ index,
49
+ sx,
50
+ trigger,
51
+ }: AccordionItemProps) => {
52
+ const [openIndex, setOpenIndex] = React.useContext(ModalContext);
53
+
54
+ return (
55
+ <Box $dir="column">
56
+ <TriggerWrapper
57
+ onClick={callAll(
58
+ // eslint-disable-next-line
59
+ () => setOpenIndex(index!),
60
+ (trigger as React.ReactElement)?.props?.onClick
61
+ )}
62
+ >
63
+ {trigger}
64
+ {openIndex === index ? <ChevronUp /> : <ChevronDown />}
65
+ </TriggerWrapper>
66
+ <Box sx={openIndex === index ? sx : 'visibility: hidden; height: 0px;'}>
67
+ {children}
68
+ </Box>
69
+ </Box>
70
+ );
71
+ };
72
+
73
+ const TriggerWrapper = styled.button`
74
+ display: flex;
75
+ align-items: center;
76
+ justify-content: space-between;
77
+ padding: 16px;
78
+ appearance: none;
79
+ border: none;
80
+ outline: none;
81
+ background-color: transparent;
82
+ cursor: pointer;
83
+ `;
84
+
85
+ Accordion.Item = AccordionItem;
86
+ AccordionItem.displayName = 'Accordion.Item';
87
+
88
+ export { Accordion };
@@ -0,0 +1,2 @@
1
+ export { Accordion } from './accordion';
2
+ export type { AccordionProps, AccordionItemProps } from './accordion';
@@ -1,3 +1,5 @@
1
+ export { Accordion } from './accordion';
2
+ export type { AccordionProps, AccordionItemProps } from './accordion';
1
3
  export { Comment } from './comment';
2
4
  export type { CommentProps } from './comment';
3
5
  export { Message } from './message';
@@ -2,11 +2,7 @@ import React from 'react';
2
2
  import styled from 'styled-components';
3
3
  import { Button } from 'components';
4
4
  import { Close } from 'icons';
5
-
6
- const callAll =
7
- (...fns: ((...args: unknown[]) => unknown)[]) =>
8
- (...args: any) =>
9
- fns.forEach((fn) => fn && fn(...args));
5
+ import { callAll } from 'utils';
10
6
 
11
7
  const ModalContext = React.createContext<
12
8
  [boolean, React.Dispatch<React.SetStateAction<boolean>>]
@@ -0,0 +1,4 @@
1
+ export const callAll =
2
+ (...fns: ((...args: unknown[]) => unknown)[]) =>
3
+ (...args: any) =>
4
+ fns.forEach((fn) => fn && fn(...args));
@@ -11,3 +11,4 @@ export {
11
11
  isSameMonth,
12
12
  zeroPad,
13
13
  } from './date';
14
+ export { callAll } from './function';