-
Notifications
You must be signed in to change notification settings - Fork 4
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
18 changed files
with
269 additions
and
89 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,100 @@ | ||
.modal { | ||
position: fixed; | ||
top: 0; | ||
right: 0; | ||
bottom: 0; | ||
left: 0; | ||
z-index: var(--z-index-modal); | ||
overflow-y: auto; | ||
} | ||
|
||
.overlay { | ||
position: fixed; | ||
top: 0; | ||
right: 0; | ||
bottom: 0; | ||
left: 0; | ||
} | ||
|
||
.normalOverlay { | ||
background: rgb(0 0 0 / 50%); | ||
} | ||
|
||
.darkerOverlay { | ||
background: rgb(0 0 0 / 80%); | ||
} | ||
|
||
.modalContainer { | ||
display: flex; | ||
align-items: center; | ||
justify-content: center; | ||
min-height: 100vh; | ||
} | ||
|
||
.modalBody { | ||
position: relative; | ||
display: flex; | ||
flex-direction: column; | ||
gap: var(--size-spacing-lg); | ||
width: calc(100% - 32px); | ||
max-width: 450px; | ||
max-height: 90vh; | ||
padding: 40px 16px 24px; | ||
margin: 0 auto; | ||
overflow-y: auto; | ||
background: #fff; | ||
border-radius: 12px; | ||
} | ||
|
||
.modalBody.fullscreen { | ||
display: flex; | ||
flex-direction: column; | ||
justify-content: space-between; | ||
width: 100vh; | ||
max-width: 100vh; | ||
height: 100vh; | ||
max-height: 100vh; | ||
padding: calc(env(safe-area-inset-top) + 40px) 32px calc(env(safe-area-inset-bottom) + 24px) 32px; | ||
margin: 0; | ||
overflow-y: hidden; | ||
border-radius: 0; | ||
} | ||
|
||
.header { | ||
font-size: var(--text-heading-xs-size); | ||
font-weight: bold; | ||
line-height: var(--text-heading-xs-line); | ||
text-align: center; | ||
white-space: pre-wrap; | ||
} | ||
|
||
.content { | ||
text-align: center; | ||
} | ||
|
||
.panelEnter { | ||
transition-timing-function: ease-out; | ||
transition-duration: 250ms; | ||
transition-property: opacity; | ||
} | ||
|
||
.panelEnterFrom { | ||
opacity: 0; | ||
} | ||
|
||
.panelEnterTo { | ||
opacity: 1; | ||
} | ||
|
||
.panelLeave { | ||
transition-timing-function: ease-in; | ||
transition-duration: 200ms; | ||
} | ||
|
||
.panelLeaveFrom { | ||
opacity: 1; | ||
} | ||
|
||
.panelLeaveTo { | ||
opacity: 0; | ||
} |
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,57 @@ | ||
import { Dialog, Transition } from '@headlessui/react'; | ||
import clsx from 'clsx'; | ||
import { FC, Fragment, PropsWithChildren } from 'react'; | ||
import styles from './MessageModal.module.css'; | ||
import { Button } from '../../'; | ||
import { opacityToClassName } from '../../utils/style'; | ||
|
||
type Opacity = 'normal' | 'darker'; | ||
|
||
type Props = { | ||
header?: string; | ||
onClose: () => void; | ||
closeLabel?: string; | ||
overlayOpacity?: Opacity; | ||
fullscreen?: boolean; | ||
open?: boolean; | ||
isStatic?: boolean; | ||
} & PropsWithChildren; | ||
|
||
export const MessageModal: FC<Props> = ({ | ||
header, | ||
children, | ||
onClose, | ||
overlayOpacity = 'normal', | ||
closeLabel = '閉じる', | ||
fullscreen = false, | ||
open = true, | ||
isStatic = false, | ||
}) => { | ||
const opacityClassName = opacityToClassName(overlayOpacity); | ||
|
||
return ( | ||
<Transition | ||
show={open} | ||
as={Fragment} | ||
enter={styles.panelEnter} | ||
enterFrom={styles.panelEnterFrom} | ||
enterTo={styles.panelEnterTo} | ||
leave={styles.panelLeave} | ||
leaveFrom={styles.panelLeaveFrom} | ||
leaveTo={styles.panelLeaveTo} | ||
> | ||
<Dialog static={isStatic} onClose={onClose} className={styles.modal}> | ||
<div className={styles.modalContainer}> | ||
<Dialog.Overlay className={clsx(styles.overlay, styles[opacityClassName])} /> | ||
<div className={clsx(styles.modalBody, fullscreen && styles.fullscreen)}> | ||
{header && <Dialog.Title className={styles.header}>{header}</Dialog.Title>} | ||
<div className={styles.content}>{children}</div> | ||
<Button block onClick={onClose} aria-label={closeLabel}> | ||
{closeLabel} | ||
</Button> | ||
</div> | ||
</div> | ||
</Dialog> | ||
</Transition> | ||
); | ||
}; |
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
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 |
---|---|---|
@@ -1,15 +1,15 @@ | ||
import { ComponentMeta, ComponentStoryObj } from '@storybook/react'; | ||
import { Meta, StoryObj } from '@storybook/react'; | ||
import { Checkbox } from '../'; | ||
|
||
export default { | ||
component: Checkbox, | ||
} as ComponentMeta<typeof Checkbox>; | ||
} as Meta<typeof Checkbox>; | ||
|
||
const defaultArgs = { | ||
children: 'Checkbox', | ||
}; | ||
|
||
export const Default: ComponentStoryObj<typeof Checkbox> = { | ||
export const Default: StoryObj<typeof Checkbox> = { | ||
render: (args) => <Checkbox {...args} />, | ||
args: defaultArgs, | ||
}; |
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
Oops, something went wrong.