-
Notifications
You must be signed in to change notification settings - Fork 1
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
1 parent
5465797
commit c5ec5a3
Showing
19 changed files
with
251 additions
and
131 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 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 |
---|---|---|
@@ -0,0 +1,34 @@ | ||
'use client' | ||
|
||
import type { DialogVariantProps } from '@giantnodes/theme' | ||
import type { DialogTriggerProps } from 'react-aria-components' | ||
import React from 'react' | ||
import { DialogTrigger } from 'react-aria-components' | ||
|
||
import type * as Polymophic from '~/utilities/polymorphic' | ||
|
||
const __ELEMENT_TYPE__ = 'div' | ||
|
||
type ComponentOwnProps = DialogTriggerProps & DialogVariantProps | ||
|
||
type ComponentProps<TElement extends React.ElementType = typeof __ELEMENT_TYPE__> = Polymophic.ComponentPropsWithRef< | ||
TElement, | ||
ComponentOwnProps | ||
> | ||
|
||
type ComponentType = <TElement extends React.ElementType = typeof __ELEMENT_TYPE__>( | ||
props: ComponentProps<TElement> | ||
) => React.ReactNode | ||
|
||
const Component: ComponentType = <TElement extends React.ElementType = typeof __ELEMENT_TYPE__>( | ||
props: ComponentProps<TElement> | ||
) => { | ||
const { as, children, ...component } = props | ||
|
||
const Element = as ?? DialogTrigger | ||
|
||
return <Element {...component}>{children}</Element> | ||
} | ||
|
||
export type { ComponentOwnProps as DialogTriggerOwnProps, ComponentProps as DialogTriggerProps } | ||
export default Component |
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,2 +1,2 @@ | ||
export { default as Root } from '~/components/dialog/Dialog' | ||
export { default as Content } from '~/components/dialog/DialogContent' | ||
export { default as Trigger } from '~/components/dialog/DialogTrigger' |
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,4 +1,4 @@ | ||
export type * from '~/components/dialog/DialogTrigger' | ||
export type * from '~/components/dialog/Dialog' | ||
export type * from '~/components/dialog/DialogContent' | ||
|
||
export * as Dialog from '~/components/dialog/component.parts' |
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 @@ | ||
'use client' | ||
|
||
import type { ModalVariantProps } from '@giantnodes/theme' | ||
import type { ModalOverlayProps } from 'react-aria-components' | ||
import React from 'react' | ||
import { ModalOverlay } from 'react-aria-components' | ||
|
||
import type * as Polymophic from '~/utilities/polymorphic' | ||
import { ModalContext, useModal } from '~/components/modal/use-modal.hook' | ||
import { cn } from '~/utilities' | ||
|
||
const __ELEMENT_TYPE__ = 'div' | ||
|
||
type ComponentOwnProps = ModalOverlayProps & ModalVariantProps | ||
|
||
type ComponentProps<TElement extends React.ElementType = typeof __ELEMENT_TYPE__> = Polymophic.ComponentPropsWithRef< | ||
TElement, | ||
ComponentOwnProps | ||
> | ||
|
||
type ComponentType = <TElement extends React.ElementType = typeof __ELEMENT_TYPE__>( | ||
props: ComponentProps<TElement> | ||
) => React.ReactNode | ||
|
||
const Component: ComponentType = <TElement extends React.ElementType = typeof __ELEMENT_TYPE__>( | ||
props: ComponentProps<TElement> | ||
) => { | ||
const { as, children, className, blur, placement, position, ...rest } = props | ||
|
||
const Element = as ?? ModalOverlay | ||
|
||
const context = useModal({ blur, placement, position }) | ||
|
||
const component = React.useMemo<ModalOverlayProps>( | ||
() => ({ | ||
className: context.slots.root({ className: cn(className) }), | ||
...rest, | ||
}), | ||
[context.slots, className, rest] | ||
) | ||
|
||
return ( | ||
<ModalContext.Provider value={context}> | ||
<Element {...component}>{children}</Element> | ||
</ModalContext.Provider> | ||
) | ||
} | ||
|
||
export type { ComponentOwnProps as ModalOwnProps, ComponentProps as ModalProps } | ||
export default Component |
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,46 @@ | ||
'use client' | ||
|
||
import type { ModalVariantProps } from '@giantnodes/theme' | ||
import type { ModalOverlayProps } from 'react-aria-components' | ||
import React from 'react' | ||
import { Modal } from 'react-aria-components' | ||
|
||
import type * as Polymophic from '~/utilities/polymorphic' | ||
import { useModalContext } from '~/components/modal/use-modal.hook' | ||
import { cn } from '~/utilities' | ||
|
||
const __ELEMENT_TYPE__ = 'div' | ||
|
||
type ComponentOwnProps = ModalOverlayProps & ModalVariantProps | ||
|
||
type ComponentProps<TElement extends React.ElementType = typeof __ELEMENT_TYPE__> = Polymophic.ComponentPropsWithRef< | ||
TElement, | ||
ComponentOwnProps | ||
> | ||
|
||
type ComponentType = <TElement extends React.ElementType = typeof __ELEMENT_TYPE__>( | ||
props: ComponentProps<TElement> | ||
) => React.ReactNode | ||
|
||
const Component: ComponentType = <TElement extends React.ElementType = typeof __ELEMENT_TYPE__>( | ||
props: ComponentProps<TElement> | ||
) => { | ||
const { as, children, className, ...rest } = props | ||
|
||
const Element = as ?? Modal | ||
|
||
const { slots } = useModalContext() | ||
|
||
const component = React.useMemo<ModalOverlayProps>( | ||
() => ({ | ||
className: slots.content({ className: cn(className) }), | ||
...rest, | ||
}), | ||
[slots, className, rest] | ||
) | ||
|
||
return <Element {...component}>{children}</Element> | ||
} | ||
|
||
export type { ComponentOwnProps as ModalContentOwnProps, ComponentProps as ModalContentProps } | ||
export default Component |
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,2 @@ | ||
export { default as Root } from '~/components/modal/Modal' | ||
export { default as Content } from '~/components/modal/ModalContent' |
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,4 @@ | ||
export type * from '~/components/modal/Modal' | ||
export type * from '~/components/modal/ModalContent' | ||
|
||
export * as Modal from '~/components/modal/component.parts' |
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,27 @@ | ||
'use client' | ||
|
||
import type { ModalVariantProps } from '@giantnodes/theme' | ||
import React from 'react' | ||
import { modal } from '@giantnodes/theme' | ||
|
||
import { createContext } from '~/utilities/context' | ||
|
||
export type UseModalProps = ModalVariantProps | ||
|
||
export type UseModalReturn = ReturnType<typeof useModal> | ||
|
||
export const useModal = (props: UseModalProps) => { | ||
const { blur, placement, position } = props | ||
|
||
const slots = React.useMemo(() => modal({ blur, placement, position }), [blur, placement, position]) | ||
|
||
return { | ||
slots, | ||
} | ||
} | ||
|
||
export const [ModalContext, useModalContext] = createContext<UseModalReturn>({ | ||
name: 'ModalContext', | ||
strict: true, | ||
errorMessage: 'useModalContext: `context` is undefined. Seems you forgot to wrap component within <Modal.Root />', | ||
}) |
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,4 +1,5 @@ | ||
export type * from '~/components/select/Select' | ||
export type * from '~/components/select/SelectOption' | ||
export type * from '~/components/select/SelectValue' | ||
|
||
export * as Select from '~/components/select/component.parts' |
Oops, something went wrong.