diff --git a/apps/www/src/components/playground/alert-dialog-examples.tsx b/apps/www/src/components/playground/alert-dialog-examples.tsx index 603b9039d..7923e9e0c 100644 --- a/apps/www/src/components/playground/alert-dialog-examples.tsx +++ b/apps/www/src/components/playground/alert-dialog-examples.tsx @@ -37,7 +37,7 @@ export function AlertDialogExamples() { }> Discard Changes - + Unsaved Changes diff --git a/apps/www/src/content/docs/components/alert-dialog/demo.ts b/apps/www/src/content/docs/components/alert-dialog/demo.ts index 9fa192183..c2a386eb3 100644 --- a/apps/www/src/content/docs/components/alert-dialog/demo.ts +++ b/apps/www/src/content/docs/components/alert-dialog/demo.ts @@ -7,13 +7,13 @@ export const getCode = (props: { title?: string; description?: string }) => { }> Discard draft - - + + ${title} ${description} - + Cancel} /> Discard} /> @@ -45,7 +45,7 @@ export const controlledDemo = { }> Delete Account - + Delete Account @@ -88,7 +88,7 @@ export const menuDemo = { - + Delete item? @@ -113,7 +113,7 @@ export const discardDemo = { }> Discard Changes - + Unsaved Changes @@ -139,7 +139,7 @@ export const nestedDemo = { }> Delete Workspace - + Delete Workspace @@ -151,7 +151,7 @@ export const nestedDemo = { }> Confirm Delete - + Final Confirmation diff --git a/apps/www/src/content/docs/components/alert-dialog/index.mdx b/apps/www/src/content/docs/components/alert-dialog/index.mdx index 0230cdad6..193ca9870 100644 --- a/apps/www/src/content/docs/components/alert-dialog/index.mdx +++ b/apps/www/src/content/docs/components/alert-dialog/index.mdx @@ -21,10 +21,9 @@ import { AlertDialog } from '@raystack/apsara' - - - + + @@ -76,12 +75,6 @@ Renders the element that opens the alert dialog. -### CloseButton - -Renders a button that closes the alert dialog. - - - ### Footer Renders the alert dialog footer section. diff --git a/apps/www/src/content/docs/components/alert-dialog/props.ts b/apps/www/src/content/docs/components/alert-dialog/props.ts index d2bbf5e1b..9bca5916d 100644 --- a/apps/www/src/content/docs/components/alert-dialog/props.ts +++ b/apps/www/src/content/docs/components/alert-dialog/props.ts @@ -10,12 +10,6 @@ export interface AlertDialogContentProps { /** Controls alert dialog width */ width?: string | number; - /** - * Controls whether to show the close button - * @default false - */ - showCloseButton?: boolean; - /** * Toggle nested dialog animation (scaling and translation) * @default true @@ -73,19 +67,6 @@ export interface AlertDialogTriggerProps { className?: string; } -export interface AlertDialogCloseButtonProps { - /** - * Allows rendering as a different element. - * Accepts a React element or a function that receives props and returns an element. - * - * @remarks `ReactElement | function` - */ - render?: React.ReactElement; - - /** Additional CSS class names */ - className?: string; -} - export interface AlertDialogFooterProps { /** Additional CSS class names */ className?: string; diff --git a/packages/raystack/components/alert-dialog/__tests__/alert-dialog.test.tsx b/packages/raystack/components/alert-dialog/__tests__/alert-dialog.test.tsx index bccb25da7..ba5f1be6f 100644 --- a/packages/raystack/components/alert-dialog/__tests__/alert-dialog.test.tsx +++ b/packages/raystack/components/alert-dialog/__tests__/alert-dialog.test.tsx @@ -22,7 +22,7 @@ const BasicAlertDialog = ({ }) => ( {TRIGGER_TEXT} - + {ALERT_TITLE} @@ -91,20 +91,6 @@ describe('AlertDialog', () => { }); describe('Close Behavior', () => { - it('closes when close button is clicked', async () => { - renderAndOpenAlertDialog(); - - await waitFor(() => { - expect(screen.getByRole('alertdialog')).toBeInTheDocument(); - }); - - fireEvent.click(screen.getByRole('button', { name: 'Close dialog' })); - - await waitFor(() => { - expect(screen.queryByRole('alertdialog')).not.toBeInTheDocument(); - }); - }); - it('closes when AlertDialog.Close is clicked', async () => { renderAndOpenAlertDialog(); diff --git a/packages/raystack/components/alert-dialog/alert-dialog-content.tsx b/packages/raystack/components/alert-dialog/alert-dialog-content.tsx index e659d1307..d3f807e72 100644 --- a/packages/raystack/components/alert-dialog/alert-dialog-content.tsx +++ b/packages/raystack/components/alert-dialog/alert-dialog-content.tsx @@ -3,11 +3,9 @@ import { AlertDialog as AlertDialogPrimitive } from '@base-ui/react'; import { cx } from 'class-variance-authority'; import styles from '../dialog/dialog.module.css'; -import { CloseButton } from './alert-dialog-misc'; export interface AlertDialogContentProps extends AlertDialogPrimitive.Popup.Props { - showCloseButton?: boolean; overlay?: AlertDialogPrimitive.Backdrop.Props & { blur?: boolean }; width?: string | number; /** @@ -20,7 +18,6 @@ export interface AlertDialogContentProps export const AlertDialogContent = ({ className, children, - showCloseButton = false, overlay, width, style, @@ -48,7 +45,6 @@ export const AlertDialogContent = ({ {...props} > {children} - {showCloseButton && } diff --git a/packages/raystack/components/alert-dialog/alert-dialog-misc.tsx b/packages/raystack/components/alert-dialog/alert-dialog-misc.tsx index 00551e110..2dd4a1da2 100644 --- a/packages/raystack/components/alert-dialog/alert-dialog-misc.tsx +++ b/packages/raystack/components/alert-dialog/alert-dialog-misc.tsx @@ -1,7 +1,6 @@ 'use client'; import { AlertDialog as AlertDialogPrimitive } from '@base-ui/react'; -import { Cross1Icon } from '@radix-ui/react-icons'; import { cx } from 'class-variance-authority'; import { type ComponentProps } from 'react'; import styles from '../dialog/dialog.module.css'; @@ -13,9 +12,9 @@ export const AlertDialogHeader = ({ ...props }: ComponentProps) => ( ); @@ -43,30 +42,13 @@ export const AlertDialogBody = ({ ); AlertDialogBody.displayName = 'AlertDialog.Body'; -export const CloseButton = ({ - className, - ...props -}: AlertDialogPrimitive.Close.Props) => { - return ( - - - ); -}; - -CloseButton.displayName = 'AlertDialog.CloseButton'; - export const AlertDialogTitle = ({ className, ...props diff --git a/packages/raystack/components/alert-dialog/alert-dialog.module.css b/packages/raystack/components/alert-dialog/alert-dialog.module.css index 0501f2f89..d66224258 100644 --- a/packages/raystack/components/alert-dialog/alert-dialog.module.css +++ b/packages/raystack/components/alert-dialog/alert-dialog.module.css @@ -1,3 +1,20 @@ +.header { + padding: var(--rs-space-7); + border-bottom: 0; +} + +.header:has(+ .body) { + padding-bottom: var(--rs-space-5); +} + +.body { + padding: 0 var(--rs-space-7) var(--rs-space-5); +} + +.body:first-child { + padding: var(--rs-space-7); +} + .footer { border-top: 0; } diff --git a/packages/raystack/components/alert-dialog/alert-dialog.tsx b/packages/raystack/components/alert-dialog/alert-dialog.tsx index 74eded57e..b3f7be7d3 100644 --- a/packages/raystack/components/alert-dialog/alert-dialog.tsx +++ b/packages/raystack/components/alert-dialog/alert-dialog.tsx @@ -5,8 +5,7 @@ import { AlertDialogDescription, AlertDialogFooter, AlertDialogHeader, - AlertDialogTitle, - CloseButton + AlertDialogTitle } from './alert-dialog-misc'; export const AlertDialog = Object.assign(AlertDialogPrimitive.Root, { @@ -16,7 +15,6 @@ export const AlertDialog = Object.assign(AlertDialogPrimitive.Root, { Trigger: AlertDialogPrimitive.Trigger, Content: AlertDialogContent, Close: AlertDialogPrimitive.Close, - CloseButton: CloseButton, Title: AlertDialogTitle, Description: AlertDialogDescription, createHandle: AlertDialogPrimitive.createHandle diff --git a/packages/raystack/components/dialog/dialog-misc.tsx b/packages/raystack/components/dialog/dialog-misc.tsx index 218948816..bbff676b7 100644 --- a/packages/raystack/components/dialog/dialog-misc.tsx +++ b/packages/raystack/components/dialog/dialog-misc.tsx @@ -5,6 +5,7 @@ import { Cross1Icon } from '@radix-ui/react-icons'; import { cx } from 'class-variance-authority'; import { type ComponentProps } from 'react'; import { Flex } from '../flex'; +import { IconButton } from '../icon-button'; import styles from './dialog.module.css'; export function DialogHeader({ @@ -55,14 +56,11 @@ export function DialogBody({ DialogBody.displayName = 'Dialog.Body'; -export function CloseButton({ - className, - ...props -}: DialogPrimitive.Close.Props) { +export function CloseButton(props: DialogPrimitive.Close.Props) { return ( } {...props} >