@soul-refiner/design-system 0.1.21 → 0.1.22

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.22",
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
+ export 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';