@soul-refiner/design-system 0.2.84 → 0.2.85

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.
@@ -4,5 +4,6 @@ export interface AnimatedToastProps {
4
4
  message: string;
5
5
  onClose?: () => void;
6
6
  type: ToastTypes;
7
+ animationDuration?: number;
7
8
  }
8
- export declare const AnimatedToast: ({ message, type, onClose, }: AnimatedToastProps) => React.JSX.Element;
9
+ export declare const AnimatedToast: ({ message, type, onClose, animationDuration, }: AnimatedToastProps) => React.JSX.Element;
@@ -2,27 +2,23 @@
2
2
  import React from 'react';
3
3
  import { styled } from 'styled-components';
4
4
  import { Toast } from '../toast';
5
- export const AnimatedToast = ({ message, type, onClose, }) => {
5
+ export const AnimatedToast = ({ message, type, onClose, animationDuration = 4, }) => {
6
6
  const [toastIsClosed, setToastIsClosed] = React.useState(false);
7
7
  const timer = React.useRef(null);
8
8
  React.useEffect(() => {
9
9
  timer.current = setTimeout(() => {
10
10
  setToastIsClosed(true);
11
- }, 4000);
11
+ !!onClose && onClose();
12
+ }, animationDuration * 1000);
12
13
  return () => {
13
14
  clearTimeout(timer.current);
14
15
  };
15
- }, []);
16
+ }, [animationDuration, onClose]);
16
17
  return (React.createElement(Container, null,
17
18
  React.createElement(ToastAnimation, { className: `${toastIsClosed ? 'toast-closed' : ''}` },
18
- React.createElement(Toast, { content: message, type: type, onClose: () => {
19
- !!onClose && onClose();
20
- setToastIsClosed(true);
21
- }, isAnimated: true }))));
19
+ React.createElement(Toast, { content: message, type: type, isAnimated: true, animationDuration: animationDuration }))));
22
20
  };
23
21
  const Container = styled.div `
24
- display: flex;
25
- row-gap: 12px;
26
22
  position: fixed;
27
23
  z-index: 9999;
28
24
  bottom: 16px;
@@ -31,7 +27,7 @@ const Container = styled.div `
31
27
  const ToastAnimation = styled.div `
32
28
  animation: slide-in 0.4s ease-in-out forwards;
33
29
 
34
- .toast-closed {
30
+ &.toast-closed {
35
31
  animation: slide-out 0.4s ease-in-out forwards;
36
32
  }
37
33
 
@@ -3,8 +3,9 @@ export type ToastTypes = 'error' | 'info' | 'success' | 'warning';
3
3
  export interface ToastProps {
4
4
  content: string;
5
5
  href?: string;
6
- onClose: () => void;
6
+ onClose?: () => void;
7
7
  type: ToastTypes;
8
8
  isAnimated?: boolean;
9
+ animationDuration?: number;
9
10
  }
10
- export declare const Toast: ({ content, href, onClose, type, isAnimated, }: ToastProps) => React.JSX.Element;
11
+ export declare const Toast: ({ content, href, onClose, type, isAnimated, animationDuration, }: ToastProps) => React.JSX.Element;
@@ -4,7 +4,7 @@ import styled from 'styled-components';
4
4
  import { Styles } from '../../../common';
5
5
  import { Button, P } from '../../';
6
6
  import { AlertCircle, AlertOctogon, AlertTriangle, Close, Information, } from '../../../icons';
7
- export const Toast = ({ content, href, onClose, type, isAnimated = false, }) => {
7
+ export const Toast = ({ content, href, onClose, type, isAnimated = false, animationDuration, }) => {
8
8
  const iconLookup = {
9
9
  error: React.createElement(AlertOctogon, { size: 24 }),
10
10
  info: React.createElement(Information, { size: 24 }),
@@ -15,8 +15,8 @@ export const Toast = ({ content, href, onClose, type, isAnimated = false, }) =>
15
15
  iconLookup[type],
16
16
  React.createElement(P, { as: "span" }, content),
17
17
  href && (React.createElement(P, { sx: "padding-left: 8px;", as: "a", href: href, "$color": "primary-blue-2" }, "View")),
18
- React.createElement(Button, { icon: React.createElement(Close, { size: 24 }), onClick: onClose, type: "special" }),
19
- isAnimated && (React.createElement(ToastProgress, null,
18
+ !isAnimated && (React.createElement(Button, { icon: React.createElement(Close, { size: 24 }), onClick: onClose, type: "special" })),
19
+ isAnimated && (React.createElement(ToastProgress, { "$animationDuration": animationDuration || 4 },
20
20
  React.createElement("div", { className: `toast-progress-bar ${type}` })))));
21
21
  };
22
22
  const ToastProgress = styled.div `
@@ -29,7 +29,7 @@ const ToastProgress = styled.div `
29
29
 
30
30
  .toast-progress-bar {
31
31
  height: 100%;
32
- animation: progress-bar 4s linear forwards;
32
+ ${({ $animationDuration }) => `animation: progress-bar ${$animationDuration}s linear forwards`};
33
33
  }
34
34
 
35
35
  .toast-progress-bar.success {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@soul-refiner/design-system",
3
- "version": "0.2.84",
3
+ "version": "0.2.85",
4
4
  "main": "dist/index.js",
5
5
  "license": "MIT",
6
6
  "publishConfig": {