-
-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Detach SelectDbModal components to avoid useless rendering
- add locales zh: pick_db generic generic_description
- Loading branch information
Showing
4 changed files
with
83 additions
and
61 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
import { memo, useState } from "react"; | ||
import { Modal } from "@douyinfe/semi-ui"; | ||
import { useTranslation } from "react-i18next"; | ||
import { useSettings } from "../../hooks"; | ||
import { databases } from "../../data/databases"; | ||
|
||
const SelectDbModal = (props) => { | ||
Check warning on line 7 in src/components/Modal/SelectDbModal.jsx GitHub Actions / build (18.x)
|
||
const { showSelectDbModal, onOk } = props; | ||
const { t } = useTranslation(); | ||
const { settings } = useSettings(); | ||
const [selectedDb, setSelectedDb] = useState(""); | ||
if (!showSelectDbModal) return null; | ||
return ( | ||
<Modal | ||
centered | ||
size="medium" | ||
closable={false} | ||
hasCancel={false} | ||
title={t("pick_db")} | ||
okText={t("confirm")} | ||
visible={showSelectDbModal} | ||
onOk={() => { | ||
setSelectedDb(selectedDb); | ||
onOk(selectedDb); | ||
}} | ||
okButtonProps={{ disabled: selectedDb === "" }} | ||
> | ||
<div className="grid grid-cols-3 gap-4 place-content-center"> | ||
{Object.values(databases).map((x) => ( | ||
<div | ||
key={x.name} | ||
onClick={() => setSelectedDb(x.label)} | ||
className={`space-y-3 py-3 px-4 rounded-md border-2 select-none ${ | ||
settings.mode === "dark" | ||
? "bg-zinc-700 hover:bg-zinc-600" | ||
: "bg-zinc-100 hover:bg-zinc-200" | ||
} ${selectedDb === x.label ? "border-zinc-400" : "border-transparent"}`} | ||
> | ||
<div className="font-semibold">{x.name}</div> | ||
{x.image && ( | ||
<img | ||
src={x.image} | ||
className="h-10" | ||
style={{ | ||
filter: | ||
"opacity(0.4) drop-shadow(0 0 0 white) drop-shadow(0 0 0 white)", | ||
}} | ||
/> | ||
)} | ||
<div className="text-xs">{x.description}</div> | ||
</div> | ||
))} | ||
</div> | ||
</Modal> | ||
); | ||
}; | ||
|
||
export default memo(SelectDbModal); | ||
Check warning on line 58 in src/components/Modal/SelectDbModal.jsx GitHub Actions / build (18.x)
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters