@soul-refiner/design-system 0.2.81 → 0.2.83

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.
@@ -0,0 +1,8 @@
1
+ import React from 'react';
2
+ import { ToastTypes } from '../toast/toast';
3
+ export interface AnimatedToastProps {
4
+ message: string;
5
+ onClose: () => void;
6
+ type: ToastTypes;
7
+ }
8
+ export declare const AnimatedToast: ({ message, type, onClose, }: AnimatedToastProps) => React.JSX.Element;
@@ -0,0 +1,50 @@
1
+ 'use client';
2
+ import React from 'react';
3
+ import { styled } from 'styled-components';
4
+ import { Toast } from '../toast';
5
+ export const AnimatedToast = ({ message, type, onClose, }) => {
6
+ const [dismissed, setDismissed] = React.useState(false);
7
+ const handleDismiss = () => {
8
+ setDismissed(true);
9
+ };
10
+ return (React.createElement(Wrapper, null,
11
+ React.createElement(Container, null,
12
+ React.createElement(Toast, { content: message, type: type, onClose: onClose, handleDismiss: handleDismiss }))));
13
+ };
14
+ const Wrapper = styled.div `
15
+ display: flex;
16
+ row-gap: 12px;
17
+ position: fixed;
18
+ z-index: 9999;
19
+ bottom: 16px;
20
+ right: 16px;
21
+ `;
22
+ const Container = styled.div `
23
+ animation: slide-in 0.4s ease-in-out forwards;
24
+
25
+ .toast-dismissed {
26
+ animation: slide-out 0.4s ease-in-out forwards;
27
+ }
28
+
29
+ @keyframes slide-out {
30
+ 0% {
31
+ opacity: 1;
32
+ transform: translateX(0%);
33
+ }
34
+ 100% {
35
+ opacity: 0;
36
+ transform: translateX(100%);
37
+ }
38
+ }
39
+
40
+ @keyframes slide-in {
41
+ 0% {
42
+ opacity: 0;
43
+ transform: translateX(100%);
44
+ }
45
+ 100% {
46
+ opacity: 1;
47
+ transform: translateX(0%);
48
+ }
49
+ }
50
+ `;
@@ -0,0 +1,2 @@
1
+ export { AnimatedToast } from './animated_toast';
2
+ export type { AnimatedToastProps } from './animated_toast';
@@ -0,0 +1 @@
1
+ export { AnimatedToast } from './animated_toast';
@@ -12,3 +12,5 @@ export { Toast } from './toast';
12
12
  export type { ToastProps } from './toast';
13
13
  export { Tooltip } from './tooltip';
14
14
  export type { TooltipProps } from './tooltip';
15
+ export { AnimatedToast } from './animated_toast';
16
+ export type { AnimatedToastProps } from './animated_toast';
@@ -5,3 +5,4 @@ export { Notification } from './notification';
5
5
  export { Progress } from './progress';
6
6
  export { Toast } from './toast';
7
7
  export { Tooltip } from './tooltip';
8
+ export { AnimatedToast } from './animated_toast';
@@ -1,10 +1,10 @@
1
1
  import React from 'react';
2
- type ToastTypes = 'error' | 'info' | 'success' | 'warning';
2
+ export type ToastTypes = 'error' | 'info' | 'success' | 'warning';
3
3
  export interface ToastProps {
4
4
  content: string;
5
5
  href?: string;
6
6
  onClose: () => void;
7
7
  type: ToastTypes;
8
+ handleDismiss?: () => void;
8
9
  }
9
- export declare const Toast: ({ content, href, onClose, type }: ToastProps) => React.JSX.Element;
10
- export {};
10
+ export declare const Toast: ({ content, href, onClose, type, handleDismiss, }: ToastProps) => React.JSX.Element;
@@ -4,23 +4,63 @@ 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 }) => {
7
+ export const Toast = ({ content, href, onClose, type, handleDismiss, }) => {
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 },
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" })));
18
+ React.createElement(Button, { icon: React.createElement(Close, { size: 24 }), onClick: () => {
19
+ !!handleDismiss && handleDismiss();
20
+ onClose();
21
+ }, type: "special" }),
22
+ !!handleDismiss && (React.createElement(ToastProgress, null,
23
+ React.createElement("div", { className: `toast-progress-bar ${type}` })))));
19
24
  };
25
+ const ToastProgress = styled.div `
26
+ position: absolute;
27
+ bottom: 0;
28
+ left: 0;
29
+ width: 100%;
30
+ height: 4px;
31
+ background-color: rgba(0, 0, 0, 0.1);
32
+
33
+ .toast-progress-bar {
34
+ height: 100%;
35
+ animation: progress-bar 4s linear forwards;
36
+ }
37
+
38
+ .toast-progress-bar.success {
39
+ background-color: var(--color-green-3);
40
+ }
41
+
42
+ .toast-progress-bar.info {
43
+ background-color: var(--color-blue-4);
44
+ }
45
+
46
+ .toast-progress-bar.warning {
47
+ background-color: var(--color-orange-5);
48
+ }
49
+
50
+ .toast-progress-bar.error {
51
+ background-color: var(--color-red-4);
52
+ }
53
+
54
+ @keyframes progress-bar {
55
+ 0% {
56
+ width: 100%;
57
+ }
58
+ 100% {
59
+ width: 0%;
60
+ }
61
+ }
62
+ `;
20
63
  const Wrapper = styled.output `
21
- position: fixed;
22
- bottom: 24px;
23
- right: 24px;
24
64
  width: 99vw;
25
65
  max-width: 476px;
26
66
  box-sizing: border-box;
@@ -29,22 +69,6 @@ const Wrapper = styled.output `
29
69
  box-shadow: var(--elevation-2);
30
70
  border-radius: var(--small);
31
71
 
32
- &::before {
33
- position: absolute;
34
- content: '';
35
- left: 0px;
36
- width: 4px;
37
- height: 100%;
38
- background-color: ${({ $type }) => $type === 'error'
39
- ? 'var(--color-red-4)'
40
- : $type === 'info'
41
- ? 'var(--color-blue-4)'
42
- : $type === 'success'
43
- ? 'var(--color-green-3)'
44
- : 'var(--color-orange-5)'};
45
- border-radius: 8px 0px 0px 8px;
46
- }
47
-
48
72
  & > svg {
49
73
  fill: ${({ $type }) => $type === 'error'
50
74
  ? 'var(--color-red-4)'
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@soul-refiner/design-system",
3
- "version": "0.2.81",
3
+ "version": "0.2.83",
4
4
  "main": "dist/index.js",
5
5
  "license": "MIT",
6
6
  "publishConfig": {