-
Notifications
You must be signed in to change notification settings - Fork 152
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Responsive sidebar width and confirmation on "read code" button (#93)
* Move sidebar into its own component * Add a confirmation before clearing editor code * Responsive sidebar widths and hide on mobile * Fix theming of copy button on dark mode
- Loading branch information
Showing
5 changed files
with
280 additions
and
163 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
import { | ||
AlertDialog, | ||
AlertDialogBody, | ||
AlertDialogContent, | ||
AlertDialogFooter, | ||
AlertDialogHeader, | ||
AlertDialogOverlay, | ||
Button, | ||
} from "@chakra-ui/react"; | ||
import { useRef } from "react"; | ||
|
||
export type ReadCodeConfirmProps = { | ||
isOpen: boolean; | ||
onClose: () => void; | ||
onConfirm: () => void; | ||
}; | ||
|
||
/** Dialog for the "read the code" button when it clears the editor. */ | ||
function ReadCodeConfirm({ isOpen, onClose, onConfirm }: ReadCodeConfirmProps) { | ||
const cancelRef = useRef<HTMLButtonElement>(null); | ||
|
||
return ( | ||
<AlertDialog | ||
isOpen={isOpen} | ||
leastDestructiveRef={cancelRef} | ||
onClose={onClose} | ||
> | ||
<AlertDialogOverlay> | ||
<AlertDialogContent> | ||
<AlertDialogHeader>Clear editor</AlertDialogHeader> | ||
|
||
<AlertDialogBody> | ||
Opening Rustpad's source code will clear the existing shared | ||
content. Is this okay? | ||
</AlertDialogBody> | ||
|
||
<AlertDialogFooter> | ||
<Button ref={cancelRef} onClick={onClose}> | ||
Cancel | ||
</Button> | ||
<Button colorScheme="red" onClick={onConfirm} ml={3}> | ||
Clear | ||
</Button> | ||
</AlertDialogFooter> | ||
</AlertDialogContent> | ||
</AlertDialogOverlay> | ||
</AlertDialog> | ||
); | ||
} | ||
|
||
export default ReadCodeConfirm; |
Oops, something went wrong.