This repository has been archived by the owner on Feb 5, 2025. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 563
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
pompurin404
committed
Sep 21, 2024
1 parent
bce9d24
commit 67a4a3a
Showing
5 changed files
with
111 additions
and
5 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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
import { Modal, ModalContent, ModalHeader, ModalBody, ModalFooter, Button } from '@nextui-org/react' | ||
import { BaseEditor } from '@renderer/components/base/base-editor' | ||
import { readTheme } from '@renderer/utils/ipc' | ||
import React, { useEffect, useState } from 'react' | ||
interface Props { | ||
theme: string | ||
onCancel: () => void | ||
onConfirm: (script: string) => void | ||
} | ||
const CSSEditorModal: React.FC<Props> = (props) => { | ||
const { theme, onCancel, onConfirm } = props | ||
const [currData, setCurrData] = useState('') | ||
|
||
useEffect(() => { | ||
if (theme) { | ||
readTheme(theme).then((css) => { | ||
setCurrData(css) | ||
}) | ||
} | ||
}, [theme]) | ||
|
||
return ( | ||
<Modal | ||
backdrop="blur" | ||
classNames={{ backdrop: 'top-[48px]' }} | ||
size="5xl" | ||
hideCloseButton | ||
isOpen={true} | ||
onOpenChange={onCancel} | ||
scrollBehavior="inside" | ||
> | ||
<ModalContent className="h-full w-[calc(100%-100px)]"> | ||
<ModalHeader className="flex pb-0">编辑主题</ModalHeader> | ||
<ModalBody className="h-full"> | ||
<BaseEditor | ||
language="css" | ||
value={currData} | ||
onChange={(value) => setCurrData(value || '')} | ||
/> | ||
</ModalBody> | ||
<ModalFooter className="pt-0"> | ||
<Button size="sm" variant="light" onPress={onCancel}> | ||
取消 | ||
</Button> | ||
<Button size="sm" color="primary" onPress={() => onConfirm(currData)}> | ||
确认 | ||
</Button> | ||
</ModalFooter> | ||
</ModalContent> | ||
</Modal> | ||
) | ||
} | ||
|
||
export default CSSEditorModal |
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