-
Notifications
You must be signed in to change notification settings - Fork 0
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
Showing
27 changed files
with
2,823 additions
and
3,006 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,50 @@ | ||
import { | ||
ButtonHTMLAttributes, | ||
cloneElement, | ||
forwardRef, | ||
ReactElement, | ||
ReactNode, | ||
Ref, | ||
} from 'react'; | ||
import { twMerge } from 'tailwind-merge'; | ||
|
||
/** | ||
* Chakra UI の `Button` の移植 | ||
* | ||
* @url https://chakra-ui.com/docs/components/button#button-with-icon | ||
*/ | ||
const ButtonComponent = ( | ||
props: { | ||
leftIcon?: ReactElement; | ||
rightIcon?: ReactElement; | ||
type?: ButtonHTMLAttributes<HTMLButtonElement>['type']; | ||
className?: string; | ||
onClick?: () => void | Promise<void>; | ||
children?: ReactNode; | ||
}, | ||
ref: Ref<HTMLButtonElement> | ||
) => { | ||
return ( | ||
<button | ||
type={props.type ?? 'button'} | ||
onClick={props.onClick} | ||
className={twMerge( | ||
'flex w-full items-center justify-center rounded-md bg-[#edf2f7] p-2 transition-colors duration-150 ease-in-out hover:bg-gray-200 focus:outline-none focus:ring-2 dark:bg-gray-700 dark:text-gray-300 dark:hover:bg-gray-600', | ||
props.className | ||
)} | ||
ref={ref} | ||
> | ||
{props.leftIcon && | ||
cloneElement(props.leftIcon, { | ||
className: 'mr-2 h-5 w-5', | ||
})} | ||
{props.children} | ||
{props.rightIcon && | ||
cloneElement(props.rightIcon, { | ||
className: 'ml-2 h-5 w-5', | ||
})} | ||
</button> | ||
); | ||
}; | ||
|
||
export const Button = forwardRef(ButtonComponent); |
This file was deleted.
Oops, something went wrong.
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 |
---|---|---|
@@ -1,48 +1,52 @@ | ||
import { | ||
AlertDialog, | ||
AlertDialogBody, | ||
AlertDialogFooter, | ||
AlertDialogHeader, | ||
AlertDialogContent, | ||
AlertDialogTitle, | ||
AlertDialogDescription, | ||
AlertDialogAction, | ||
AlertDialogOverlay, | ||
Button, | ||
} from '@chakra-ui/react'; | ||
import { useRef } from 'react'; | ||
AlertDialogPortal, | ||
AlertDialogTrigger, | ||
AlertDialogCancel, | ||
} from '@radix-ui/react-alert-dialog'; | ||
import { ReactElement } from 'react'; | ||
import { Button } from './Button'; | ||
|
||
export const CustomAlertDialog = (props: { | ||
isOpen: boolean; | ||
headerText: string; | ||
onClose: () => void; | ||
triggerButton: ReactElement; | ||
onSubmit: () => void; | ||
}) => { | ||
const cancelRef = useRef(null); | ||
|
||
return ( | ||
<AlertDialog | ||
isOpen={props.isOpen} | ||
leastDestructiveRef={cancelRef} | ||
onClose={props.onClose} | ||
> | ||
<AlertDialogOverlay> | ||
<AlertDialogContent> | ||
<AlertDialogHeader fontSize="lg" fontWeight="bold"> | ||
{props.headerText} | ||
</AlertDialogHeader> | ||
|
||
<AlertDialogBody> | ||
Are you sure? You can not undo this action afterwards. | ||
</AlertDialogBody> | ||
|
||
<AlertDialogFooter> | ||
<Button ref={cancelRef} onClick={props.onClose}> | ||
Cancel | ||
</Button> | ||
<Button colorScheme="red" onClick={props.onSubmit} ml={3}> | ||
Delete | ||
</Button> | ||
</AlertDialogFooter> | ||
</AlertDialogContent> | ||
</AlertDialogOverlay> | ||
<AlertDialog> | ||
<AlertDialogTrigger asChild>{props.triggerButton}</AlertDialogTrigger> | ||
<AlertDialogPortal> | ||
<AlertDialogOverlay className="fixed inset-0 z-40 bg-black bg-opacity-50"> | ||
<AlertDialogContent className="z-50 mx-auto my-10 max-w-md rounded-md bg-white p-6 shadow-md dark:bg-gray-700"> | ||
<AlertDialogTitle className="mb-4 text-xl font-bold dark:text-gray-300"> | ||
{props.headerText} | ||
</AlertDialogTitle> | ||
<AlertDialogDescription className="mb-6 text-gray-600 dark:text-gray-300"> | ||
Are you sure? You cannot undo this action afterwards. | ||
</AlertDialogDescription> | ||
<div className="mt-4 flex justify-end space-x-4"> | ||
<AlertDialogCancel> | ||
<Button className="px-4 dark:bg-gray-600 dark:hover:bg-gray-500"> | ||
Cancel | ||
</Button> | ||
</AlertDialogCancel> | ||
<AlertDialogAction> | ||
<Button | ||
onClick={props.onSubmit} | ||
className="bg-red-500 px-4 text-white hover:bg-red-600 dark:bg-red-600 dark:hover:bg-red-500" | ||
> | ||
Delete | ||
</Button> | ||
</AlertDialogAction> | ||
</div> | ||
</AlertDialogContent> | ||
</AlertDialogOverlay> | ||
</AlertDialogPortal> | ||
</AlertDialog> | ||
); | ||
}; |
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 |
---|---|---|
@@ -1,32 +1,32 @@ | ||
import { | ||
Popover, | ||
PopoverTrigger, | ||
PopoverContent, | ||
PopoverBody, | ||
PopoverArrow, | ||
PopoverCloseButton, | ||
Placement, | ||
Stack, | ||
} from '@chakra-ui/react'; | ||
import { ReactElement, ReactNode } from 'react'; | ||
import { XMarkIcon } from '@heroicons/react/24/solid'; | ||
import { Root, Trigger, Content, Close } from '@radix-ui/react-popover'; | ||
import { IconButton } from './IconButton'; | ||
|
||
export const CustomPopover = (props: { | ||
triggerButton: ReactElement; | ||
children: ReactNode; | ||
type Placement = 'top' | 'right' | 'bottom' | 'left'; | ||
|
||
type CustomPopoverProps = { | ||
triggerButton: React.ReactNode; | ||
children: React.ReactNode; | ||
placement?: Placement; | ||
}) => { | ||
return ( | ||
<Popover placement={props.placement}> | ||
<PopoverTrigger>{props.triggerButton}</PopoverTrigger> | ||
<PopoverContent w={{ base: '90vw', md: 'sm' }}> | ||
<PopoverArrow /> | ||
<PopoverCloseButton /> | ||
<PopoverBody> | ||
<Stack direction="column" spacing={4} px={2} py={4}> | ||
{props.children} | ||
</Stack> | ||
</PopoverBody> | ||
</PopoverContent> | ||
</Popover> | ||
); | ||
}; | ||
|
||
export const CustomPopover = ({ | ||
triggerButton, | ||
children, | ||
placement, | ||
}: CustomPopoverProps) => ( | ||
<Root> | ||
<Trigger className="cursor-pointer">{triggerButton}</Trigger> | ||
<Content | ||
side={placement} | ||
className="transform-gpu rounded border border-gray-200 bg-white p-1 shadow-lg transition duration-200 ease-in-out dark:border-gray-600 dark:bg-gray-800" | ||
> | ||
<Close className="absolute right-0.5 top-0.5 cursor-pointer"> | ||
<IconButton className="h-6 w-6 rounded-full" iconClassName="w-5"> | ||
<XMarkIcon /> | ||
</IconButton> | ||
</Close> | ||
<div className="space-y-4 p-5">{children}</div> | ||
</Content> | ||
</Root> | ||
); |
Oops, something went wrong.
a5b16fb
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Successfully deployed to the following URLs:
manuscript – ./
manuscript-kyonenya.vercel.app
manuscript.vercel.app
manuscript-git-main-kyonenya.vercel.app