-
Notifications
You must be signed in to change notification settings - Fork 30
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add Popover, Underlay and ProgressBar. Changes to Dialog, Modal…
… and Overlay. (#1236)
- Loading branch information
1 parent
918e944
commit aca4e7d
Showing
58 changed files
with
1,302 additions
and
258 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
Large diffs are not rendered by default.
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,53 @@ | ||
import styled from 'styled-components'; | ||
|
||
import { CTA } from '../CTA'; | ||
import { Divider } from '../Divider'; | ||
import { Flex } from '../Flex'; | ||
import { H3 } from '../Text'; | ||
import { theme } from '../theme'; | ||
import { Sizes } from '../utils/prop-types'; | ||
|
||
type StyledDialogProps = { | ||
$size: Sizes; | ||
}; | ||
|
||
const StyledDialog = styled.section<StyledDialogProps>` | ||
background: ${theme.colors.bgPrimary}; | ||
border: ${theme.border.default}; | ||
border-radius: ${theme.rounded.md}; | ||
color: ${theme.colors.textPrimary}; | ||
width: ${({ $size }) => theme.dialog[$size].width}; | ||
display: flex; | ||
flex-direction: column; | ||
position: relative; | ||
outline: none; | ||
`; | ||
|
||
const StyledCloseCTA = styled(CTA)` | ||
position: absolute; | ||
top: ${theme.spacing.spacing2}; | ||
right: ${theme.spacing.spacing2}; | ||
z-index: ${theme.dialog.closeBtn.zIndex}; | ||
`; | ||
|
||
const StyledDialogHeader = styled(H3)<StyledDialogProps>` | ||
padding: ${({ $size }) => theme.dialog[$size].header.padding}; | ||
overflow: hidden; | ||
flex-shrink: 0; | ||
`; | ||
|
||
const StyledDialogDivider = styled(Divider)<StyledDialogProps>` | ||
margin: ${({ $size }) => `0 ${theme.dialog[$size].divider.marginX} ${theme.dialog[$size].divider.marginBottom}`}; | ||
flex-shrink: 0; | ||
`; | ||
|
||
const StyledDialogBody = styled(Flex)<StyledDialogProps>` | ||
padding: ${({ $size }) => `${theme.dialog[$size].body.paddingY} ${theme.dialog[$size].body.paddingX}`}; | ||
flex: 1 1 auto; | ||
`; | ||
|
||
const StyledDialogFooter = styled(Flex)<StyledDialogProps>` | ||
padding: ${({ $size }) => theme.dialog[$size].footer.padding}; | ||
`; | ||
|
||
export { StyledCloseCTA, StyledDialog, StyledDialogBody, StyledDialogDivider, StyledDialogFooter, StyledDialogHeader }; |
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,52 @@ | ||
import { AriaDialogProps, useDialog } from '@react-aria/dialog'; | ||
import { mergeProps } from '@react-aria/utils'; | ||
import { PressEvent } from '@react-types/shared'; | ||
import { forwardRef, ReactNode } from 'react'; | ||
|
||
import { XMark } from '@/assets/icons'; | ||
|
||
import { useDOMRef } from '../utils/dom'; | ||
import { CTASizes, Sizes } from '../utils/prop-types'; | ||
import { StyledCloseCTA, StyledDialog } from './Dialog.style'; | ||
import { DialogContext } from './DialogContext'; | ||
|
||
const closeCTASizeMap: Record<Sizes, CTASizes> = { small: 'x-small', medium: 'small', large: 'small' }; | ||
|
||
type Props = { | ||
children?: ReactNode; | ||
onClose?: (e: PressEvent) => void; | ||
size?: Sizes; | ||
}; | ||
|
||
type InheritAttrs = Omit<AriaDialogProps, keyof Props>; | ||
|
||
type DialogProps = Props & InheritAttrs; | ||
|
||
const Dialog = forwardRef<HTMLDivElement, DialogProps>( | ||
({ children, onClose, size = 'medium', ...props }, ref): JSX.Element => { | ||
const dialogRef = useDOMRef(ref); | ||
|
||
// Get props for the dialog and its title | ||
const { dialogProps, titleProps } = useDialog(props, dialogRef); | ||
|
||
const closeCTASize = closeCTASizeMap[size]; | ||
|
||
return ( | ||
<DialogContext.Provider value={{ titleProps, size }}> | ||
<StyledDialog ref={dialogRef} $size={size} {...mergeProps(props, dialogProps)}> | ||
{onClose && ( | ||
<StyledCloseCTA size={closeCTASize} variant='text' aria-label='Dismiss' onPress={onClose}> | ||
<XMark /> | ||
</StyledCloseCTA> | ||
)} | ||
{children} | ||
</StyledDialog> | ||
</DialogContext.Provider> | ||
); | ||
} | ||
); | ||
|
||
Dialog.displayName = 'Dialog'; | ||
|
||
export { Dialog }; | ||
export type { DialogProps }; |
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,14 @@ | ||
import { FlexProps } from '../Flex'; | ||
import { StyledDialogBody } from './Dialog.style'; | ||
import { useDialogContext } from './DialogContext'; | ||
|
||
type DialogBodyProps = FlexProps; | ||
|
||
const DialogBody = ({ direction = 'column', ...props }: DialogBodyProps): JSX.Element => { | ||
const { size } = useDialogContext(); | ||
|
||
return <StyledDialogBody {...props} $size={size} direction={direction} />; | ||
}; | ||
|
||
export { DialogBody }; | ||
export type { DialogBodyProps }; |
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,18 @@ | ||
import { DOMAttributes } from '@react-types/shared'; | ||
import React from 'react'; | ||
|
||
import { Sizes } from '../utils/prop-types'; | ||
|
||
interface DialogConfig { | ||
titleProps?: DOMAttributes; | ||
size: Sizes; | ||
} | ||
|
||
const defaultContext: DialogConfig = { size: 'medium' }; | ||
|
||
const DialogContext = React.createContext<DialogConfig>(defaultContext); | ||
|
||
const useDialogContext = (): DialogConfig => React.useContext<DialogConfig>(DialogContext); | ||
|
||
export { DialogContext, useDialogContext }; | ||
export type { DialogConfig }; |
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,14 @@ | ||
import { DividerProps } from '../Divider'; | ||
import { StyledDialogDivider } from './Dialog.style'; | ||
import { useDialogContext } from './DialogContext'; | ||
|
||
type DialogDividerProps = Omit<DividerProps, 'orientation'>; | ||
|
||
const DialogDivider = (props: DialogDividerProps): JSX.Element => { | ||
const { size } = useDialogContext(); | ||
|
||
return <StyledDialogDivider orientation='horizontal' $size={size} {...props} />; | ||
}; | ||
|
||
export { DialogDivider }; | ||
export type { DialogDividerProps }; |
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,16 @@ | ||
import { FlexProps } from '../Flex'; | ||
import { StyledDialogFooter } from './Dialog.style'; | ||
import { useDialogContext } from './DialogContext'; | ||
|
||
type InheritAttrs = FlexProps; | ||
|
||
type DialogFooterProps = InheritAttrs; | ||
|
||
const DialogFooter = (props: DialogFooterProps): JSX.Element => { | ||
const { size } = useDialogContext(); | ||
|
||
return <StyledDialogFooter $size={size} {...props} />; | ||
}; | ||
|
||
export { DialogFooter }; | ||
export type { DialogFooterProps }; |
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 @@ | ||
import { mergeProps } from '@react-aria/utils'; | ||
import { ElementType } from 'react'; | ||
|
||
import { TextProps } from '../Text'; | ||
import { FontSize, Sizes } from '../utils/prop-types'; | ||
import { StyledDialogHeader } from './Dialog.style'; | ||
import { useDialogContext } from './DialogContext'; | ||
|
||
const sizeMap: Record<Sizes, FontSize> = { | ||
small: 'base', | ||
medium: 'xl', | ||
large: 'xl' | ||
}; | ||
|
||
type Props = { | ||
elementType?: ElementType; | ||
}; | ||
|
||
type InheritAttrs = Omit<TextProps, keyof Props>; | ||
|
||
type DialogHeaderProps = Props & InheritAttrs; | ||
|
||
const DialogHeader = ({ elementType, children, ...props }: DialogHeaderProps): JSX.Element => { | ||
const { titleProps, size } = useDialogContext(); | ||
|
||
return ( | ||
<StyledDialogHeader as={elementType} $size={size} size={sizeMap[size]} {...mergeProps(titleProps || {}, props)}> | ||
{children} | ||
</StyledDialogHeader> | ||
); | ||
}; | ||
|
||
export { DialogHeader }; | ||
export type { DialogHeaderProps }; |
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,10 @@ | ||
export type { DialogProps } from './Dialog'; | ||
export { Dialog } from './Dialog'; | ||
export type { DialogBodyProps } from './DialogBody'; | ||
export { DialogBody } from './DialogBody'; | ||
export type { DialogDividerProps } from './DialogDivider'; | ||
export { DialogDivider } from './DialogDivider'; | ||
export type { DialogFooterProps } from './DialogFooter'; | ||
export { DialogFooter } from './DialogFooter'; | ||
export type { DialogHeaderProps } from './DialogHeader'; | ||
export { DialogHeader } from './DialogHeader'; |
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.
Oops, something went wrong.
aca4e7d
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:
interbtc-ui-kintsugi-testnet – ./
interbtc-ui-kintsugi-testnet-git-master-interlay.vercel.app
interbtc-ui-kintsugi-testnet-interlay.vercel.app
interbtc-ui.vercel.app
kintnet.interlay.io
aca4e7d
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:
interbtc-ui-interlay-testnet – ./
interbtc-ui-interlay-testnet-git-master-interlay.vercel.app
interbtc-ui-interlay-testnet-interlay.vercel.app
interbtc-ui-interlay-testnet.vercel.app
testnet.interlay.io