From 11edb5893dbe0506d956445f256030c7f1f49355 Mon Sep 17 00:00:00 2001 From: Chef Hachioji <72719739+hachiojidev@users.noreply.github.com> Date: Tue, 27 Apr 2021 16:00:21 +0900 Subject: [PATCH] refactor: Remove toast action, update toast types (#86) * refactor: Remove toast action, update toast types * chore: Remove unused import --- .../pancake-uikit/src/widgets/Toast/Toast.tsx | 15 ++--------- .../src/widgets/Toast/ToastAction.tsx | 27 ------------------- .../pancake-uikit/src/widgets/Toast/types.ts | 10 +++---- 3 files changed, 5 insertions(+), 47 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..cc36e475c 100644 --- a/packages/pancake-uikit/src/widgets/Toast/Toast.tsx +++ b/packages/pancake-uikit/src/widgets/Toast/Toast.tsx @@ -2,8 +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 ToastAction from "./ToastAction"; import { ToastProps, types } from "./types"; const alertTypeMap = { @@ -29,7 +27,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 +63,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 {