@soul-refiner/design-system 0.2.120 → 0.2.121

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,12 +1,13 @@
1
1
  'use client';
2
2
  import React from 'react';
3
+ import Image from 'next/image';
3
4
  import styled from 'styled-components';
4
5
  import { Box, H, P } from '../../';
5
6
  export const ActionCard = ({ actions, content, href, image, logo, subtitle, sx, title, }) => {
6
7
  const isAnchor = !!href;
7
8
  return (React.createElement(Wrapper, { as: isAnchor ? 'a' : 'div', href: href },
8
9
  React.createElement(Action, { "$backgroundImage": image, "$sx": sx },
9
- React.createElement("img", { src: image, alt: "" }),
10
+ React.createElement(Image, { alt: "", height: 160, src: image, width: 310 }),
10
11
  React.createElement(Figcaption, null,
11
12
  React.createElement(LogoWrapper, null, logo),
12
13
  React.createElement(H, { as: "span", "$mediumBold": true, "$color": "grey-2", "$fontSize": 18, "$lineHeight": 26 }, title),
@@ -1,5 +1,6 @@
1
1
  'use client';
2
2
  import React from 'react';
3
+ import Image from 'next/image';
3
4
  import styled from 'styled-components';
4
5
  import { Box, H, P, Rate } from '../../';
5
6
  export const AudioEpisodeCard = ({ actions, actionDropdown, content, cta, href, image, logo, numRating, rating, subtitle, supportLabel, sx, title, }) => {
@@ -7,7 +8,7 @@ export const AudioEpisodeCard = ({ actions, actionDropdown, content, cta, href,
7
8
  return (React.createElement(Wrapper, { "$sx": sx, href: href },
8
9
  React.createElement(Figure, null,
9
10
  actionDropdown && React.createElement(DropdownWrapper, null, actionDropdown),
10
- React.createElement("img", { className: "thumbnail", src: image, alt: "" }),
11
+ React.createElement(Image, { alt: "", className: "thumbnail", height: 228, src: image, width: 228 }),
11
12
  React.createElement(Figcaption, null,
12
13
  React.createElement(Box, { "$display": "block", className: "hidden" }, cta),
13
14
  React.createElement(Box, { "$align": "center", "$dir": "row", "$gap": 16 },
@@ -86,6 +87,7 @@ const Figure = styled.figure `
86
87
 
87
88
  .thumbnail {
88
89
  border-radius: 16px;
90
+ object-fit: cover;
89
91
  position: relative;
90
92
  z-index: -1;
91
93
  width: 100%;
@@ -1,5 +1,6 @@
1
1
  'use client';
2
2
  import React from 'react';
3
+ import Image from 'next/image';
3
4
  import styled from 'styled-components';
4
5
  import { Box, Button, Modal } from '../../';
5
6
  import { Camera, Checkmark, Close, Pencil, Trash } from '../../../icons';
@@ -27,7 +28,7 @@ export const FeatureCard = ({ content = '', editable, href, image, onDelete, onS
27
28
  const isLink = !!href;
28
29
  return (React.createElement(Wrapper, { as: isLink ? 'a' : 'div', href: href },
29
30
  React.createElement(Figure, { "$editing": editing, "$isLink": isLink, "$sx": sx },
30
- React.createElement("img", { alt: title, src: image }),
31
+ React.createElement(Image, { alt: title, height: 352, src: image, width: 352 }),
31
32
  !editing && (React.createElement(Title, null,
32
33
  editingTitle,
33
34
  React.createElement("figure", null,
@@ -1,5 +1,6 @@
1
1
  'use client';
2
2
  import React from 'react';
3
+ import Image from 'next/image';
3
4
  import styled from 'styled-components';
4
5
  import { Box, H, P, Modal, Button, Dropdown } from '../..';
5
6
  import { Calendar, GraduationCap, Clock, Pin, ForwardBold, StarFilled, Star, EllipsisHorizontal, } from '../../../icons';
@@ -34,7 +35,7 @@ export const MeetingCard = ({ href, image, sx, title, actions, course, startDate
34
35
  });
35
36
  return (React.createElement(Wrapper, { "$isLink": !!href, "$sx": sx, as: href ? 'a' : 'div', href: href },
36
37
  React.createElement(Figure, null,
37
- React.createElement("img", { src: image, alt: "" }),
38
+ React.createElement(Image, { alt: "", height: 160, src: image, width: 312 }),
38
39
  React.createElement(OverlayTopContainer, { id: "overlayTop" }, dotsActions && !!dotsActions.length && (React.createElement(Dropdown, { hasArrow: true, maintainState: false, options: dotsActions, trigger: React.createElement(Button, { icon: React.createElement(EllipsisHorizontal, null), showChevron: false, type: "outlined", size: "small", className: "icon" }), onClick: (e) => e.preventDefault() }))),
39
40
  React.createElement(OverlayBottomContainer, { id: "overlayBottom" },
40
41
  shareModal && (React.createElement(Modal, null,
@@ -1,5 +1,6 @@
1
1
  'use client';
2
2
  import React from 'react';
3
+ import Image from 'next/image';
3
4
  import styled from 'styled-components';
4
5
  import { Box, Button, Dropdown, H, P } from '../../';
5
6
  import { EllipsisHorizontal } from '../../../icons';
@@ -7,7 +8,7 @@ export const PersonCard = ({ actions, dotsActions, href, image, subtitle, sx, ti
7
8
  return (React.createElement(Wrapper, { "$image": image, as: href ? 'a' : 'div', href: href },
8
9
  React.createElement(Person, { "$sx": sx },
9
10
  dotsActions && !!dotsActions.length && (React.createElement(Dropdown, { containerSx: "", hasArrow: true, maintainState: false, onClick: (e) => e.preventDefault(), options: dotsActions, sx: "position: absolute; top: 8px; right: 8px; z-index: 24; display: none;", trigger: React.createElement(Button, { className: "icon", icon: React.createElement(EllipsisHorizontal, null), onClick: (event) => event.stopPropagation(), showChevron: false, size: "small", type: "outlined" }) })),
10
- React.createElement("img", { src: image, alt: "" }),
11
+ React.createElement(Image, { alt: "", height: 400, src: image, width: 312 }),
11
12
  React.createElement(Shadow, null),
12
13
  React.createElement(Figcaption, null,
13
14
  React.createElement(H, { as: "span", "$bold": true, "$color": "white", "$fontSize": 24, "$lineHeight": 36 }, title),
@@ -1,10 +1,11 @@
1
1
  'use client';
2
2
  import React from 'react';
3
+ import Image from 'next/image';
3
4
  import styled from 'styled-components';
4
5
  import { Box } from '../../';
5
6
  export const RegularCard = ({ children, href, image, sx, }) => {
6
7
  return (React.createElement(Wrapper, { "$isLink": !!href, "$sx": sx, as: href ? 'a' : 'div', href: href },
7
- React.createElement("img", { src: image, alt: "" }),
8
+ React.createElement(Image, { alt: "", height: 352, src: image, width: 352 }),
8
9
  React.createElement(Box, { "$dir": "column", "$padding": 24 }, children)));
9
10
  };
10
11
  const Wrapper = styled.div `
@@ -1,5 +1,6 @@
1
1
  'use client';
2
2
  import React from 'react';
3
+ import Image from 'next/image';
3
4
  import styled from 'styled-components';
4
5
  import { Box, H, P, Rate } from '../../';
5
6
  export const VideoEpisodeCard = ({ actions, actionDropdown, content, cta, href, image, logo, numRating, rating, subtitle, supportLabel, sx, title, }) => {
@@ -7,7 +8,7 @@ export const VideoEpisodeCard = ({ actions, actionDropdown, content, cta, href,
7
8
  return (React.createElement(Wrapper, { "$sx": sx, href: href },
8
9
  React.createElement(Figure, null,
9
10
  actionDropdown && React.createElement(DropdownWrapper, null, actionDropdown),
10
- React.createElement("img", { className: "thumbnail", src: image, alt: "" }),
11
+ React.createElement(Image, { alt: "", className: "thumbnail", height: 228, src: image, width: 314 }),
11
12
  React.createElement(Figcaption, null,
12
13
  React.createElement(Box, { "$display": "block", className: "hidden" }, cta),
13
14
  React.createElement(Box, { "$align": "center", "$dir": "row", "$gap": 16 },
@@ -78,6 +79,7 @@ const Figure = styled.figure `
78
79
 
79
80
  .thumbnail {
80
81
  position: relative;
82
+ object-fit: cover;
81
83
  z-index: -1;
82
84
  width: 100%;
83
85
  aspect-ratio: 379 / 275;
@@ -1,5 +1,6 @@
1
1
  'use client';
2
2
  import React from 'react';
3
+ import Image from 'next/image';
3
4
  import styled from 'styled-components';
4
5
  import { Box, H, P, Rate } from '../../';
5
6
  export const WrittenEpisodeCard = ({ actions, actionDropdown, content, cta, href, image, logo, numRating, rating, subtitle, supportLabel, sx, title, }) => {
@@ -7,7 +8,7 @@ export const WrittenEpisodeCard = ({ actions, actionDropdown, content, cta, href
7
8
  return (React.createElement(Wrapper, { "$sx": sx, href: href },
8
9
  React.createElement(Figure, null,
9
10
  actionDropdown && React.createElement(DropdownWrapper, null, actionDropdown),
10
- React.createElement("img", { className: "thumbnail", src: image, alt: "" }),
11
+ React.createElement(Image, { alt: "", className: "thumbnail", height: 228, src: image, width: 176 }),
11
12
  React.createElement(Figcaption, null,
12
13
  React.createElement(Box, { "$display": "block", className: "hidden" }, cta),
13
14
  React.createElement(Box, { "$align": "center", "$dir": "row", "$gap": 16 },
@@ -87,6 +88,7 @@ const Figure = styled.figure `
87
88
 
88
89
  .thumbnail {
89
90
  border-radius: 16px;
91
+ object-fit: cover;
90
92
  position: relative;
91
93
  z-index: -1;
92
94
  width: 100%;
@@ -6,6 +6,9 @@ export interface BannerProps {
6
6
  onClose?: () => void;
7
7
  title: string;
8
8
  type: BannerTypes;
9
+ setContentInNewLine?: boolean;
10
+ additionalContent?: string;
11
+ sx?: string;
9
12
  }
10
- export declare const Banner: ({ content, href, onClose, title, type, }: BannerProps) => React.JSX.Element;
13
+ export declare const Banner: ({ content, href, onClose, title, type, setContentInNewLine, additionalContent, sx, }: BannerProps) => React.JSX.Element;
11
14
  export {};
@@ -4,18 +4,19 @@ import styled from 'styled-components';
4
4
  import { Styles } from '../../../common';
5
5
  import { Box, Button, P } from '../../';
6
6
  import { AlertCircle, AlertOctogon, AlertTriangle, Close, Information, } from '../../../icons';
7
- export const Banner = ({ content, href, onClose, title, type, }) => {
7
+ export const Banner = ({ content, href, onClose, title, type, setContentInNewLine = false, additionalContent, sx, }) => {
8
8
  const iconLookup = {
9
9
  error: React.createElement(AlertOctogon, { size: 24 }),
10
10
  info: React.createElement(Information, { size: 24 }),
11
11
  success: React.createElement(AlertCircle, { size: 24 }),
12
12
  warning: React.createElement(AlertTriangle, { size: 24 }),
13
13
  };
14
- return (React.createElement(Wrapper, { as: "output", "$align": "center", "$dir": "row", "$gap": 8, "$type": type },
14
+ return (React.createElement(Wrapper, { as: "output", "$dir": "row", "$gap": 8, "$type": type, "$sx": sx },
15
15
  iconLookup[type],
16
- React.createElement(Box, { "$dir": "row", "$gap": 4, "$align": "center" },
16
+ React.createElement(Box, { "$dir": setContentInNewLine ? 'column' : 'row', "$gap": 4 },
17
17
  React.createElement(P, { as: "span", "$semiBold": true }, title),
18
- React.createElement(P, { as: "span" }, content),
18
+ React.createElement(P, { as: "span", sx: setContentInNewLine ? 'margin-top: 12px;' : '' }, content),
19
+ additionalContent && React.createElement(P, { as: "span" }, additionalContent),
19
20
  href && (React.createElement(P, { as: "a", href: href, "$color": "primary-blue-2" }, "Read more"))),
20
21
  onClose && (React.createElement(Button, { icon: React.createElement(Close, { size: 24 }), onClick: onClose, type: "special" }))));
21
22
  };
@@ -74,4 +75,6 @@ const Wrapper = styled.output `
74
75
  }
75
76
 
76
77
  ${Styles.flex}
78
+
79
+ ${({ $sx }) => ($sx ? $sx : '')}
77
80
  `;
@@ -0,0 +1,2 @@
1
+ import React from 'react';
2
+ export declare const useClickOutside: (ref: React.Ref<HTMLElement>, cb: (...args: any[]) => unknown) => void;
@@ -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,2 @@
1
+ import React from 'react';
2
+ export declare const useHover: (ref: React.Ref<HTMLElement>) => boolean;
@@ -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,4 @@
1
+ export { useClickOutside } from './click-outside';
2
+ export { useEventListener } from './event-listenter';
3
+ export { useHover } from './hover';
4
+ export { useWindowSize } from './window-size';
@@ -0,0 +1,4 @@
1
+ export { useClickOutside } from './click-outside';
2
+ export { useEventListener } from './event-listenter';
3
+ export { useHover } from './hover';
4
+ export { useWindowSize } from './window-size';
@@ -0,0 +1,4 @@
1
+ export declare const useWindowSize: () => {
2
+ width: number;
3
+ height: number;
4
+ };
@@ -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,5 +1,6 @@
1
1
  'use client';
2
2
  import React from 'react';
3
+ import Image from 'next/image';
3
4
  import styled from 'styled-components';
4
5
  import { Box, H, P } from '../../';
5
6
  import { Approved, Busy, Declined, Default, Focus, Locked, Offline, Online, Subscribed, } from './icons';
@@ -70,7 +71,7 @@ const Avatar = ({ as = 'button', href, image, size = 64, status, subtitle, sx, t
70
71
  ${sx}
71
72
  `, ...rest },
72
73
  React.createElement(Container, { as: as, "$size": size, href: href },
73
- !displayDefault && (React.createElement("img", { src: image ?? '', onError: () => setDisplayDefault(true) })),
74
+ !displayDefault && (React.createElement(Image, { alt: "avatar image", height: size, onError: () => setDisplayDefault(true), src: image ?? '', width: size })),
74
75
  displayDefault && React.createElement(Default, null),
75
76
  React.createElement("div", null,
76
77
  React.createElement(Icon, null))),
@@ -18,7 +18,7 @@ const Filter = ({ closeOnBlur = true, disabled, graphic, label = '', sx, trigger
18
18
  }
19
19
  }, [disabled]);
20
20
  React.useEffect(() => {
21
- if (triggerType === 'outlined' && !defaultValue) {
21
+ if (triggerType === 'outlined' && defaultValue === undefined) {
22
22
  setSelected(multiple
23
23
  ? [options[0]?.value]
24
24
  : options[0]?.value);
@@ -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
+ };
@@ -1,5 +1,6 @@
1
1
  'use client';
2
2
  import React from 'react';
3
+ import Image from 'next/image';
3
4
  import styled from 'styled-components';
4
5
  import { H, P } from '../../atoms/typography';
5
6
  import { TimeAgo } from '../../atoms/time_ago/time_ago';
@@ -19,7 +20,7 @@ export const Post = ({ actions, author, authorActive, authorHref, authorImage, a
19
20
  React.createElement(P, { "$textClampLines": isPaywalled ? 2 : undefined }, content))),
20
21
  !!images?.length && (React.createElement(ImagesWrapper, { "$numImages": images.length, "$isPaywalled": isPaywalled },
21
22
  images.slice(0, 4).map((url, i) => (React.createElement(ImageWrapper, { key: `${componentId}${url.slice(0, 15)}${i}` },
22
- React.createElement("img", { src: url, alt: "" })))),
23
+ React.createElement(Image, { alt: "", fill: true, src: url })))),
23
24
  images.length > 4 && (React.createElement(H, { as: "p", className: "more-than", "$color": "grey-10", "$fontSize": 28, "$lineHeight": 36, "$semiBold": true },
24
25
  "+",
25
26
  images.length - 4)))),
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@soul-refiner/design-system",
3
- "version": "0.2.120",
3
+ "version": "0.2.121",
4
4
  "main": "dist/index.js",
5
5
  "license": "MIT",
6
6
  "publishConfig": {
@@ -29,25 +29,20 @@
29
29
  "@storybook/addon-links": "^7.2.1",
30
30
  "@storybook/addons": "^7.2.1",
31
31
  "@storybook/blocks": "^7.2.1",
32
+ "@storybook/nextjs": "^7.5.3",
32
33
  "@storybook/react": "^7.2.1",
33
- "@storybook/react-vite": "^7.2.1",
34
34
  "@storybook/testing-library": "^0.2.0",
35
35
  "@types/react-dom": "18.2.0",
36
36
  "@types/styled-components": "^5.1.26",
37
- "@typescript-eslint/eslint-plugin": "^5.59.5",
38
- "@typescript-eslint/parser": "^5.59.5",
39
- "@vitejs/plugin-react": "^4.0.0",
40
37
  "chromatic": "^6.17.4",
41
- "eslint": "^8.40.0",
42
38
  "husky": "^8.0.0",
43
39
  "prettier": "^2.8.8",
44
40
  "pretty-quick": "^3.1.3",
45
41
  "prop-types": "^15.8.1",
46
- "storybook": "^7.2.1",
42
+ "storybook": "^7.5.3",
47
43
  "tsconfig-paths-webpack-plugin": "^4.0.1",
48
44
  "typescript": "^5.0.4",
49
- "vite": "^4.3.5",
50
- "vite-tsconfig-paths": "^4.2.0"
45
+ "webpack": "^5.89.0"
51
46
  },
52
47
  "scripts": {
53
48
  "build": "tsc -p tsconfig.build.json",
@@ -61,6 +56,7 @@
61
56
  "@emoji-mart/react": "^1.1.1",
62
57
  "@udecode/plate": "^22.0.1",
63
58
  "emoji-mart": "^5.5.2",
59
+ "next": "13.4.10",
64
60
  "react": "^18.2.0",
65
61
  "react-dnd": "^16.0.1",
66
62
  "react-dnd-html5-backend": "^16.0.1",
@@ -74,5 +70,5 @@
74
70
  "slate-react": "^0.97.1",
75
71
  "styled-components": "^6.0.0-rc.3"
76
72
  },
77
- "packageManager": "yarn@3.6.1"
73
+ "packageManager": "yarn@3.4.1"
78
74
  }