mirror of
https://github.com/vercel/commerce.git
synced 2025-07-22 20:26:49 +00:00
Modal Stable / Login View
This commit is contained in:
4
components/ui/Input/Input.module.css
Normal file
4
components/ui/Input/Input.module.css
Normal file
@@ -0,0 +1,4 @@
|
||||
.root {
|
||||
@apply focus:outline-none bg-primary focus:shadow-outline-gray border-none py-2
|
||||
px-6 w-full appearance-none transition duration-150 ease-in-out placeholder-accents-5 pr-10;
|
||||
}
|
25
components/ui/Input/Input.tsx
Normal file
25
components/ui/Input/Input.tsx
Normal file
@@ -0,0 +1,25 @@
|
||||
import cn from 'classnames'
|
||||
import s from './Input.module.css'
|
||||
import React, { InputHTMLAttributes } from 'react'
|
||||
|
||||
export interface Props extends InputHTMLAttributes<HTMLInputElement> {
|
||||
className?: string
|
||||
onChange?: (...args: any[]) => any
|
||||
}
|
||||
|
||||
const Input: React.FC<Props> = (props) => {
|
||||
const { className, children, onChange, ...rest } = props
|
||||
|
||||
const rootClassName = cn(s.root, {}, className)
|
||||
|
||||
const handleOnChange = (e: any) => {
|
||||
if (onChange) {
|
||||
onChange(e.target.value)
|
||||
}
|
||||
return null
|
||||
}
|
||||
|
||||
return <input className={rootClassName} onChange={handleOnChange} {...rest} />
|
||||
}
|
||||
|
||||
export default Input
|
1
components/ui/Input/index.ts
Normal file
1
components/ui/Input/index.ts
Normal file
@@ -0,0 +1 @@
|
||||
export { default } from './Input'
|
@@ -8,7 +8,7 @@ import { useOverlay, useModal, OverlayContainer } from '@react-aria/overlays'
|
||||
interface Props {
|
||||
className?: string
|
||||
children?: any
|
||||
open?: boolean
|
||||
open: boolean
|
||||
onClose?: () => void
|
||||
}
|
||||
|
||||
@@ -22,14 +22,22 @@ const Modal: FC<Props> = ({
|
||||
const rootClassName = cn(s.root, className)
|
||||
let ref = useRef() as React.MutableRefObject<HTMLInputElement>
|
||||
let { modalProps } = useModal()
|
||||
let { overlayProps } = useOverlay(props, ref)
|
||||
let { dialogProps } = useDialog(props, ref)
|
||||
let { dialogProps } = useDialog({}, ref)
|
||||
let { overlayProps } = useOverlay(
|
||||
{
|
||||
isOpen: open,
|
||||
isDismissable: true,
|
||||
onClose: onClose,
|
||||
...props,
|
||||
},
|
||||
ref
|
||||
)
|
||||
|
||||
return (
|
||||
<Transition show={open}>
|
||||
<OverlayContainer>
|
||||
<div className={rootClassName} onClick={onClose}>
|
||||
<FocusScope contain restoreFocus autoFocus>
|
||||
<FocusScope contain restoreFocus autoFocus>
|
||||
<div className={rootClassName}>
|
||||
<Transition.Child
|
||||
enter="transition-opacity ease-linear duration-300"
|
||||
enterFrom="opacity-0"
|
||||
@@ -39,17 +47,17 @@ const Modal: FC<Props> = ({
|
||||
leaveTo="opacity-0"
|
||||
>
|
||||
<div
|
||||
className={s.modal}
|
||||
{...overlayProps}
|
||||
{...dialogProps}
|
||||
{...modalProps}
|
||||
ref={ref}
|
||||
className={s.modal}
|
||||
>
|
||||
{children}
|
||||
</div>
|
||||
</Transition.Child>
|
||||
</FocusScope>
|
||||
</div>
|
||||
</div>
|
||||
</FocusScope>
|
||||
</OverlayContainer>
|
||||
</Transition>
|
||||
)
|
||||
|
@@ -101,8 +101,6 @@ export const UIProvider: FC = (props) => {
|
||||
closeModal,
|
||||
}
|
||||
|
||||
console.log('state', state)
|
||||
|
||||
return <UIContext.Provider value={value} {...props} />
|
||||
}
|
||||
|
||||
|
@@ -9,3 +9,4 @@ export { default as LoadingDots } from './LoadingDots'
|
||||
export { default as Skeleton } from './Skeleton'
|
||||
export { default as Modal } from './Modal'
|
||||
export { default as Text } from './Text'
|
||||
export { default as Input } from './Input'
|
||||
|
Reference in New Issue
Block a user