From 37f916f7c33469fe314a45e4b11a768601e0e080 Mon Sep 17 00:00:00 2001 From: Tristan Yang Date: Thu, 19 Jan 2023 23:05:06 +0800 Subject: [PATCH] refactor: tailwind --- src/common/component/styled/Modal.tsx | 54 +++------------------ src/routes/setting/APIConfig.tsx | 70 +++++---------------------- 2 files changed, 20 insertions(+), 104 deletions(-) diff --git a/src/common/component/styled/Modal.tsx b/src/common/component/styled/Modal.tsx index 21ab8995..61f3d585 100644 --- a/src/common/component/styled/Modal.tsx +++ b/src/common/component/styled/Modal.tsx @@ -1,44 +1,5 @@ +import clsx from "clsx"; import { FC, ReactNode } from "react"; -import styled from "styled-components"; - -const Styled = styled.div` - padding: 32px; - filter: drop-shadow(0px 25px 50px rgba(31, 41, 55, 0.25)); - border-radius: 8px; - background-color: #fff; - min-width: 440px; - &.compact { - padding: 16px; - min-width: 406px; - .title, - .desc { - text-align: left; - } - } - .title { - text-align: center; - font-weight: 600; - font-size: 20px; - color: #374151; - margin-bottom: 16px; - } - .desc { - text-align: center; - font-weight: normal; - font-size: 14px; - line-height: 20px; - color: #6b7280; - margin-bottom: 8px; - } - .btns { - padding-top: 16px; - width: 100%; - display: flex; - justify-content: flex-end; - gap: 16px; - align-items: center; - } -`; interface Props { title?: string; @@ -46,16 +7,17 @@ interface Props { buttons?: ReactNode; children?: ReactNode; className?: string; + compact?: boolean } -const StyledModal: FC = ({ title = "", description = "", buttons, children, ...props }) => { +const StyledModal: FC = ({ compact = false, title = "", description = "", buttons, children, className }) => { return ( - - {title &&

{title}

} - {description &&

{description}

} +
+ {title &&

{title}

} + {description &&

{description}

} {children} - {buttons &&
{buttons}
} - + {buttons &&
{buttons}
} +
); }; diff --git a/src/routes/setting/APIConfig.tsx b/src/routes/setting/APIConfig.tsx index ca097fac..1d37afdd 100644 --- a/src/routes/setting/APIConfig.tsx +++ b/src/routes/setting/APIConfig.tsx @@ -1,5 +1,4 @@ import { useEffect } from "react"; -import styled from "styled-components"; import Tippy from "@tippyjs/react"; import toast from "react-hot-toast"; import { hideAll } from "tippy.js"; @@ -14,52 +13,6 @@ import useConfig from "../../common/hook/useConfig"; import { LoginConfig } from "../../types/server"; import { useTranslation } from "react-i18next"; -const StyledConfirm = styled.div` - padding: 12px; - border-radius: 10px; - border: 1px solid orange; - background-color: #fff; - display: flex; - flex-direction: column; - gap: 10px; - width: 250px; - .tip { - color: orange; - font-size: 12px; - line-height: 1.5; - } - .btns { - display: flex; - width: 100%; - justify-content: flex-end; - gap: 14px; - } -`; -const Styled = styled.div` - max-width: 500px; - display: flex; - flex-direction: column; - justify-content: flex-start; - align-items: flex-start; - gap: 15px; - > .input { - width: 100%; - display: flex; - flex-direction: column; - align-items: flex-start; - gap: 8px; - label { - white-space: nowrap; - font-size: 14px; - color: #555; - } - } - > .tip { - font-size: 12px; - color: #999; - line-height: 1.5; - } -`; export default function APIConfig() { const { t } = useTranslation("setting"); @@ -79,14 +32,15 @@ export default function APIConfig() { updateConfig({ ...values, ...val }); }; const thirdParty = (values as LoginConfig)?.third_party; + return ( - +
-
- +
+
-
+
+
{t("third_app.update_tip")}
-
- -
- +
} > -
+
{t("third_app.key_tip")}
- +
); }