@soul-refiner/design-system 1.0.0 → 1.0.1

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.
@@ -1,6 +1,7 @@
1
1
  'use client';
2
2
  import React from 'react';
3
3
  import styled from 'styled-components';
4
+ import Link from 'next/link';
4
5
  import { Box } from '../../';
5
6
  import { ChevronLeft, ChevronRight } from '../../../icons';
6
7
  const Breadcrumb = ({ children, previous }) => {
@@ -28,14 +29,14 @@ const Breadcrumb = ({ children, previous }) => {
28
29
  })));
29
30
  };
30
31
  const BreadcrumbItem = ({ avatar, children, href, icon, iconColor = 'blue', onClick, }) => {
31
- return (React.createElement(Item, { as: href ? 'a' : 'div', href: href, onClick: onClick, "$type": icon ? 'icon' : avatar ? 'avatar' : 'text', "$iconColor": `hue-${iconColor}-1` },
32
+ return (React.createElement(Item, { href: href || '#', onClick: onClick, "$type": icon ? 'icon' : avatar ? 'avatar' : 'text', "$iconColor": `hue-${iconColor}-1`, scroll: false },
32
33
  icon && (React.createElement(IconWrapper, { "$color": iconColor }, React.cloneElement(icon, { color: `hue-${iconColor}-1`, size: 24 }))),
33
34
  avatar,
34
35
  children));
35
36
  };
36
37
  Breadcrumb.Item = BreadcrumbItem;
37
38
  BreadcrumbItem.displayName = 'Breadcrumb.Item';
38
- const Item = styled.div `
39
+ const Item = styled(Link) `
39
40
  display: flex;
40
41
  flex-flow: row nowrap;
41
42
  align-items: center;
@@ -9,7 +9,7 @@ declare const InnerNav: {
9
9
  displayName: string;
10
10
  };
11
11
  Dropdown: {
12
- ({ children, href, icon, label, open, sx, onClick, }: InnerNavDropdownProps): React.JSX.Element;
12
+ ({ children, icon, label, open, sx, onClick, }: InnerNavDropdownProps): React.JSX.Element;
13
13
  displayName: string;
14
14
  };
15
15
  BackButton: {
@@ -63,7 +63,6 @@ export interface InnerNavItemProps {
63
63
  * Dropdown
64
64
  */
65
65
  export interface InnerNavDropdownProps extends React.PropsWithChildren {
66
- href?: string;
67
66
  icon?: React.ReactElement;
68
67
  label: React.ReactNode;
69
68
  open: boolean;
@@ -1,5 +1,6 @@
1
1
  import React from 'react';
2
2
  import styled from 'styled-components';
3
+ import Link from 'next/link';
3
4
  import { Button } from '../../../components/actions/button';
4
5
  import { Drawer } from '../../../components/surfaces/drawer';
5
6
  import { ChevronDown, ChevronLeft, ChevronUp, Plus } from '../../../icons';
@@ -53,12 +54,11 @@ const NavWrapper = styled.nav `
53
54
  border-right: 1px solid var(--color-grey-9);
54
55
  `;
55
56
  const InnerNavItem = ({ active, href, icon, label, sx }) => {
56
- const isAnchor = !!href;
57
- return (React.createElement(Item, { "$active": active, "$sx": sx, as: isAnchor ? 'a' : 'button', href: href },
57
+ return (React.createElement(Item, { "$active": active, "$sx": sx, href: href || '#', scroll: false },
58
58
  icon,
59
59
  label));
60
60
  };
61
- const Item = styled.button `
61
+ const Item = styled(Link) `
62
62
  padding: 14px 16px;
63
63
  display: flex;
64
64
  gap: 16px;
@@ -85,10 +85,9 @@ const Item = styled.button `
85
85
  `;
86
86
  InnerNav.Item = InnerNavItem;
87
87
  InnerNavItem.displayName = 'InnerNav.Item';
88
- const InnerNavDropdown = ({ children, href, icon, label, open, sx, onClick, }) => {
89
- const isAnchor = !!href;
88
+ const InnerNavDropdown = ({ children, icon, label, open, sx, onClick, }) => {
90
89
  return (React.createElement(React.Fragment, null,
91
- React.createElement(Item, { "$active": false, "$sx": sx, as: isAnchor ? 'a' : 'button', href: !!onClick ? undefined : href, onClick: onClick },
90
+ React.createElement(DropdownItem, { "$active": false, "$sx": sx, onClick: onClick },
92
91
  icon,
93
92
  React.createElement(DropdownTriggerWrapper, null,
94
93
  label,
@@ -108,15 +107,40 @@ const DropdownTriggerWrapper = styled.div `
108
107
  align-items: center;
109
108
  flex: 1;
110
109
  `;
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
+ `;
111
135
  InnerNav.Dropdown = InnerNavDropdown;
112
136
  InnerNavDropdown.displayName = 'InnerNav.Dropdown';
113
137
  const InnerNavBackButton = ({ href, label, sx }) => {
114
- return (React.createElement(BackButton, { href: href, "$sx": sx },
138
+ return (React.createElement(BackButton, { href: href, "$sx": sx, scroll: false },
115
139
  React.createElement("div", null,
116
140
  React.createElement(ChevronLeft, { size: 24 })),
117
141
  label));
118
142
  };
119
- const BackButton = styled.a `
143
+ const BackButton = styled(Link) `
120
144
  display: flex;
121
145
  align-items: center;
122
146
  gap: 8px;
@@ -1,6 +1,7 @@
1
1
  'use client';
2
2
  import React from 'react';
3
3
  import styled from 'styled-components';
4
+ import Link from 'next/link';
4
5
  import { P } from '../../';
5
6
  const colorLookup = {
6
7
  blue: {
@@ -64,17 +65,16 @@ const Wrapper = styled.div `
64
65
  ${({ $sx }) => ($sx ? $sx : '')}
65
66
  `;
66
67
  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, { as: isAnchor ? 'a' : 'div', href: href, onClick: !disabled && onClick ? onClick : undefined, "$active": active, "$color": iconColor, "$disabled": disabled, "$hasIcon": !!icon, "$size": size },
73
+ return (React.createElement(Element, { onClick: !disabled && onClick ? onClick : undefined, href: href || '#', scroll: false, "$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.div `
77
+ const Element = styled(Link) `
78
78
  position: relative;
79
79
  display: flex;
80
80
  align-items: center;
@@ -6,5 +6,6 @@ export interface CalendarDateProps {
6
6
  startTime?: string;
7
7
  endTime?: string;
8
8
  sx?: string;
9
+ size?: 'small' | 'large';
9
10
  }
10
- export declare const CalendarDate: ({ monthAbbreviation, date, dayOfWeek, startTime, endTime, sx, }: CalendarDateProps) => React.JSX.Element;
11
+ export declare const CalendarDate: ({ monthAbbreviation, date, dayOfWeek, startTime, endTime, sx, size, }: CalendarDateProps) => React.JSX.Element;
@@ -2,13 +2,15 @@
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, size = 'large', }) => {
6
6
  return (React.createElement(Container, { "$sx": sx },
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))),
7
+ React.createElement(CalendarContainer, { "$size": size },
8
+ React.createElement(MonthContainer, { "$size": size },
9
+ size === 'large' && (React.createElement(H.Seven, { "$color": "white", "$textAlign": "center", "$semiBold": true }, monthAbbreviation)),
10
+ size === 'small' && (React.createElement(P, { "$color": "white", "$textAlign": "center", "$fontSize": 14 }, monthAbbreviation))),
11
+ React.createElement(DateContainer, { "$size": size },
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)))),
12
14
  dayOfWeek && startTime && endTime && (React.createElement(TimeContainer, null,
13
15
  React.createElement(P, { as: "span", "$color": "red-5" }, `${dayOfWeek}, ${startTime} -> ${endTime}`)))));
14
16
  };
@@ -22,18 +24,21 @@ const Container = styled.div `
22
24
  const CalendarContainer = styled.div `
23
25
  display: flex;
24
26
  flex-direction: column;
25
- width: 120px;
27
+
28
+ ${({ $size }) => ($size === 'large' ? 'width: 120px;' : 'width: 64px;')}
26
29
  `;
27
30
  const MonthContainer = styled.div `
28
- padding: 8px 16px;
29
31
  background-color: var(--color-red-5);
30
32
  border-radius: 16px 16px 0 0;
33
+
34
+ ${({ $size }) => $size === 'large' ? 'padding: 8px 16px;' : 'padding: 2px 8px;'}
31
35
  `;
32
36
  const DateContainer = styled.div `
33
- padding: 8px 16px;
34
37
  background-color: white;
35
38
  border-radius: 0 0 16px 16px;
36
39
  box-shadow: var(--elevation-3);
40
+
41
+ ${({ $size }) => $size === 'large' ? 'padding: 8px 16px;' : 'padding: 2px 16px;'}
37
42
  `;
38
43
  const TimeContainer = styled.div `
39
44
  margin-top: 16px;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@soul-refiner/design-system",
3
- "version": "1.0.0",
3
+ "version": "1.0.1",
4
4
  "main": "dist/index.js",
5
5
  "license": "MIT",
6
6
  "publishConfig": {
@@ -1,2 +0,0 @@
1
- import React from 'react';
2
- export declare const useClickOutside: (ref: React.Ref<HTMLElement>, cb: (...args: any[]) => unknown) => void;
@@ -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,2 +0,0 @@
1
- import React from 'react';
2
- export declare const useHover: (ref: React.Ref<HTMLElement>) => boolean;
@@ -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,4 +0,0 @@
1
- export { useClickOutside } from './click-outside';
2
- export { useEventListener } from './event-listenter';
3
- export { useHover } from './hover';
4
- export { useWindowSize } from './window-size';
@@ -1,4 +0,0 @@
1
- export { useClickOutside } from './click-outside';
2
- export { useEventListener } from './event-listenter';
3
- export { useHover } from './hover';
4
- export { useWindowSize } from './window-size';
@@ -1,4 +0,0 @@
1
- export declare const useWindowSize: () => {
2
- width: number;
3
- height: number;
4
- };
@@ -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
- };
@@ -1 +0,0 @@
1
- export declare const abbrTimeBeforeDate: (date: Date) => string;
@@ -1,26 +0,0 @@
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
- };