Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 4 additions & 24 deletions app/ui/lib/Modal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
import * as Dialog from '@radix-ui/react-dialog'
import { animated, useTransition } from '@react-spring/web'
import cn from 'classnames'
import React, { forwardRef, useId } from 'react'
import type { MergeExclusive } from 'type-fest'

import { Close12Icon } from '@oxide/design-system/icons/react'
Expand Down Expand Up @@ -42,7 +41,6 @@ export function Modal({
narrow,
overlay = true,
}: ModalProps) {
const titleId = useId()
const AnimatedDialogContent = animated(Dialog.Content)

const config = { tension: 650, mass: 0.125 }
Expand Down Expand Up @@ -74,7 +72,7 @@ export function Modal({
'pointer-events-auto fixed left-1/2 top-[min(50%,500px)] z-modal m-0 flex max-h-[min(800px,80vh)] w-full flex-col justify-between rounded-lg border p-0 bg-raise border-secondary elevation-2',
narrow ? 'max-w-[24rem]' : 'max-w-[28rem]'
)}
aria-labelledby={titleId}
aria-describedby={undefined} // radix warns without this
style={{
transform: y.to((value) => `translate3d(-50%, ${-50 + value}%, 0px)`),
}}
Expand All @@ -85,12 +83,12 @@ export function Modal({
// https://github.com/oxidecomputer/console/issues/1745
onFocusOutside={(e) => e.preventDefault()}
>
<Dialog.Title asChild>
<ModalTitle id={titleId}>{title}</ModalTitle>
<Dialog.Title className="border-b px-4 py-4 text-sans-semi-lg bg-secondary border-b-secondary">
{title}
</Dialog.Title>
{children}
<Dialog.Close
className="absolute right-2 top-4 flex items-center justify-center rounded p-2 hover:bg-hover"
className="absolute right-2 top-3.5 flex items-center justify-center rounded p-2 hover:bg-hover"
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It was very slightly too low.

aria-label="Close"
>
<Close12Icon className="text-default" />
Expand All @@ -104,24 +102,6 @@ export function Modal({
)
}

interface ModalTitleProps {
children?: React.ReactNode
id?: string
}

// not exported because we want to use the `title` prop on Modal so the aria
// label gets hooked up properly
const ModalTitle = forwardRef<HTMLDivElement, ModalTitleProps>(({ children, id }, ref) => (
<div
ref={ref}
className="flex items-center justify-between border-b px-4 py-4 bg-secondary border-b-secondary"
>
<h2 className="text-sans-semi-lg" id={id}>
{children}
</h2>
</div>
))

Modal.Body = classed.div`py-2 overflow-y-auto`

Modal.Section = classed.div`p-4 space-y-4 border-b border-secondary text-default last-of-type:border-none text-sans-md`
Expand Down