From 98e0edd3312ad7cb94336a7d3465034b61cfd380 Mon Sep 17 00:00:00 2001 From: Paul Date: Tue, 6 Jul 2021 11:34:36 +0100 Subject: [PATCH] Re-write types for modal actions. --- src/components/ui/Button.tsx | 2 ++ src/components/ui/Modal.tsx | 22 +++++----------- src/context/intermediate/modals/Clipboard.tsx | 2 +- src/context/intermediate/modals/Error.tsx | 4 +-- src/context/intermediate/modals/Input.tsx | 6 ++--- src/context/intermediate/modals/Prompt.tsx | 25 ++++++++++--------- src/context/intermediate/modals/SignedOut.tsx | 2 +- .../intermediate/popovers/ModifyAccount.tsx | 4 +-- .../intermediate/popovers/UserPicker.tsx | 2 +- 9 files changed, 31 insertions(+), 38 deletions(-) diff --git a/src/components/ui/Button.tsx b/src/components/ui/Button.tsx index ecd4e799..2b72e4ef 100644 --- a/src/components/ui/Button.tsx +++ b/src/components/ui/Button.tsx @@ -6,6 +6,8 @@ interface Props { readonly error?: boolean; } +export type ButtonProps = Props & Omit, 'as'>; + export default styled.button` z-index: 1; display: flex; diff --git a/src/components/ui/Modal.tsx b/src/components/ui/Modal.tsx index 15f47e82..df77a07a 100644 --- a/src/components/ui/Modal.tsx +++ b/src/components/ui/Modal.tsx @@ -1,10 +1,9 @@ import styled, { css, keyframes } from "styled-components"; -import classNames from "classnames"; import { createPortal, useEffect } from "preact/compat"; import { Children } from "../../types/Preact"; -import Button from "./Button"; +import Button, { ButtonProps } from "./Button"; const open = keyframes` 0% {opacity: 0;} @@ -100,12 +99,9 @@ const ModalActions = styled.div` background: var(--secondary-background); `; -export interface Action { - text: Children; - onClick: () => void; +export type Action = Omit & { confirmation?: boolean; - contrast?: boolean; - error?: boolean; + onClick: () => void; } interface Props { @@ -181,15 +177,9 @@ export default function Modal(props: Props) { {content} {props.actions && ( - {props.actions.map((x) => ( - - ))} + {props.actions.map((x) => +