From 690ba5265ffc60efb53ce79c9017d333a3625ae2 Mon Sep 17 00:00:00 2001 From: hachiojidev Date: Tue, 27 Apr 2021 15:46:56 +0900 Subject: [PATCH 1/2] refactor: Remove toast action, update toast types --- .../pancake-uikit/src/widgets/Toast/Toast.tsx | 14 ++-------- .../src/widgets/Toast/ToastAction.tsx | 27 ------------------- .../pancake-uikit/src/widgets/Toast/types.ts | 10 +++---- 3 files changed, 5 insertions(+), 46 deletions(-) delete mode 100644 packages/pancake-uikit/src/widgets/Toast/ToastAction.tsx diff --git a/packages/pancake-uikit/src/widgets/Toast/Toast.tsx b/packages/pancake-uikit/src/widgets/Toast/Toast.tsx index ffa0af8f7..82d8110f6 100644 --- a/packages/pancake-uikit/src/widgets/Toast/Toast.tsx +++ b/packages/pancake-uikit/src/widgets/Toast/Toast.tsx @@ -3,7 +3,6 @@ import { CSSTransition } from "react-transition-group"; import styled from "styled-components"; import { Alert, alertVariants } from "../../components/Alert"; import { Text } from "../../components/Text"; -import ToastAction from "./ToastAction"; import { ToastProps, types } from "./types"; const alertTypeMap = { @@ -29,7 +28,7 @@ const Toast: React.FC = ({ toast, onRemove, style, ttl, ...props }) const timer = useRef(); const ref = useRef(null); const removeHandler = useRef(onRemove); - const { id, title, description, type, action } = toast; + const { id, title, description, type } = toast; const handleRemove = useCallback(() => removeHandler.current(id), [id, removeHandler]); @@ -65,16 +64,7 @@ const Toast: React.FC = ({ toast, onRemove, style, ttl, ...props }) - {action ? ( - <> - - {description} - - - - ) : ( - description - )} + {description} diff --git a/packages/pancake-uikit/src/widgets/Toast/ToastAction.tsx b/packages/pancake-uikit/src/widgets/Toast/ToastAction.tsx deleted file mode 100644 index 41fa3f1b1..000000000 --- a/packages/pancake-uikit/src/widgets/Toast/ToastAction.tsx +++ /dev/null @@ -1,27 +0,0 @@ -import React from "react"; -import { Link } from "react-router-dom"; -import getExternalLinkProps from "../../util/getExternalLinkProps"; -import { Button } from "../../components/Button"; -import { ToastAction as Action } from "./types"; - -interface ToastActionProps { - action: Action; -} - -const ToastAction: React.FC = ({ action }) => { - if (action.url.startsWith("http")) { - return ( - - ); - } - - return ( - - ); -}; - -export default ToastAction; diff --git a/packages/pancake-uikit/src/widgets/Toast/types.ts b/packages/pancake-uikit/src/widgets/Toast/types.ts index 4de0f1a46..16834ac05 100644 --- a/packages/pancake-uikit/src/widgets/Toast/types.ts +++ b/packages/pancake-uikit/src/widgets/Toast/types.ts @@ -1,3 +1,5 @@ +import { ReactNode } from "react"; + export const types = { SUCCESS: "success", DANGER: "danger", @@ -7,17 +9,11 @@ export const types = { export type Types = typeof types[keyof typeof types]; -export interface ToastAction { - text: string; - url: string; -} - export interface Toast { id: string; type: Types; title: string; - description?: string; - action?: ToastAction; + description?: ReactNode; } export interface ToastContainerProps { From 633da7a9d8cad08a8905e10a495f961eb2a51613 Mon Sep 17 00:00:00 2001 From: hachiojidev Date: Tue, 27 Apr 2021 15:49:20 +0900 Subject: [PATCH 2/2] chore: Remove unused import --- packages/pancake-uikit/src/widgets/Toast/Toast.tsx | 1 - 1 file changed, 1 deletion(-) diff --git a/packages/pancake-uikit/src/widgets/Toast/Toast.tsx b/packages/pancake-uikit/src/widgets/Toast/Toast.tsx index 82d8110f6..cc36e475c 100644 --- a/packages/pancake-uikit/src/widgets/Toast/Toast.tsx +++ b/packages/pancake-uikit/src/widgets/Toast/Toast.tsx @@ -2,7 +2,6 @@ import React, { useCallback, useEffect, useRef } from "react"; import { CSSTransition } from "react-transition-group"; import styled from "styled-components"; import { Alert, alertVariants } from "../../components/Alert"; -import { Text } from "../../components/Text"; import { ToastProps, types } from "./types"; const alertTypeMap = {