From fcafbda2efd6c28240271ee7b39f36aa5a9720e3 Mon Sep 17 00:00:00 2001 From: Charles de Dreuille Date: Fri, 10 Oct 2025 10:06:42 +0100 Subject: [PATCH] Update some CSS on Dialog Signed-off-by: Charles de Dreuille --- .../src/components/Dialog/Dialog.stories.tsx | 19 ++- .../src/components/Dialog/Dialog.styles.css | 16 ++- packages/ui/src/components/Dialog/Dialog.tsx | 134 ++++++++++-------- packages/ui/src/utils/componentDefinitions.ts | 10 ++ 4 files changed, 118 insertions(+), 61 deletions(-) diff --git a/packages/ui/src/components/Dialog/Dialog.stories.tsx b/packages/ui/src/components/Dialog/Dialog.stories.tsx index 031d86a506..5a72102ead 100644 --- a/packages/ui/src/components/Dialog/Dialog.stories.tsx +++ b/packages/ui/src/components/Dialog/Dialog.stories.tsx @@ -25,7 +25,7 @@ import { import { Button, Flex, Text, TextField, Select } from '@backstage/ui'; const meta = { - title: 'Components/Dialog', + title: 'Backstage UI/Dialog', component: Dialog, } satisfies Meta; @@ -50,6 +50,23 @@ export const Default: Story = { ), }; +export const WithNoHeader: Story = { + render: () => ( + + + + + This is a basic dialog example. + + + Close + Save + + + + ), +}; + export const Scrollable: Story = { render: () => ( diff --git a/packages/ui/src/components/Dialog/Dialog.styles.css b/packages/ui/src/components/Dialog/Dialog.styles.css index 820e9ca094..bc000ce218 100644 --- a/packages/ui/src/components/Dialog/Dialog.styles.css +++ b/packages/ui/src/components/Dialog/Dialog.styles.css @@ -5,13 +5,17 @@ left: 0; width: 100%; height: 100%; - background: rgba(0, 0, 0, 0.5); + background: rgba(232, 232, 232, 0.8); display: flex; align-items: center; justify-content: center; z-index: 1000; } +[data-theme='dark'] .bui-Dialog { + background: rgba(0, 0, 0, 0.5); +} + .bui-Dialog[data-entering] { animation: fade-in 200ms ease-out forwards; } @@ -46,12 +50,15 @@ display: flex; justify-content: space-between; align-items: center; - padding: var(--bui-space-3); + padding-inline: var(--bui-space-3); + padding-block: var(--bui-space-2); border-bottom: 1px solid var(--bui-border); } -.bui-Dialog [slot='title'] { +.bui-DialogHeaderTitle { font-size: var(--bui-font-size-3); + font-weight: var(--bui-font-weight-bold); + margin: 0; } .bui-DialogFooter { @@ -59,7 +66,8 @@ align-items: center; justify-content: end; gap: var(--bui-space-2); - padding: var(--bui-space-3); + padding-inline: var(--bui-space-3); + padding-block: var(--bui-space-3); border-top: 1px solid var(--bui-border); } diff --git a/packages/ui/src/components/Dialog/Dialog.tsx b/packages/ui/src/components/Dialog/Dialog.tsx index 2f8bd27c27..fbf14dab98 100644 --- a/packages/ui/src/components/Dialog/Dialog.tsx +++ b/packages/ui/src/components/Dialog/Dialog.tsx @@ -33,6 +33,8 @@ import './Dialog.styles.css'; import { RiCloseLine } from '@remixicon/react'; import { ScrollArea } from '../ScrollArea'; import { Button } from '../Button'; +import { useStyles } from '../../hooks/useStyles'; +import { Flex } from '../Flex'; /** @public */ export const DialogTrigger = (props: DialogTriggerProps) => { @@ -43,82 +45,102 @@ export const DialogTrigger = (props: DialogTriggerProps) => { export const DialogHeader = forwardRef< React.ElementRef<'div'>, DialogHeaderProps ->(({ className, children, ...props }, ref) => ( -
- - {children} - - -
-)); +>(({ className, children, ...props }, ref) => { + const { classNames } = useStyles('Dialog'); + + return ( + + + {children} + + + + ); +}); DialogHeader.displayName = 'DialogHeader'; /** @public */ export const DialogBody = forwardRef, DialogBodyProps>( - ({ className, children, height, ...props }, ref) => ( - - {children} - - - - - ), + ({ className, children, height, ...props }, ref) => { + const { classNames } = useStyles('Dialog'); + + return ( + + {children} + + + + + ); + }, ); + DialogBody.displayName = 'DialogBody'; /** @public */ export const DialogFooter = forwardRef< React.ElementRef<'div'>, React.ComponentPropsWithoutRef<'div'> ->(({ className, children, ...props }, ref) => ( -
- {children} -
-)); +>(({ className, children, ...props }, ref) => { + const { classNames } = useStyles('Dialog'); + + return ( +
+ {children} +
+ ); +}); DialogFooter.displayName = 'DialogFooter'; /** @public */ export const DialogClose = forwardRef< React.ElementRef, DialogCloseProps ->(({ className, variant = 'secondary', children, ...props }, ref) => ( - -)); +>(({ className, variant = 'secondary', children, ...props }, ref) => { + return ( + + ); +}); DialogClose.displayName = 'DialogClose'; /** @public */ export const Dialog = forwardRef, DialogProps>( - ({ className, children, ...props }, ref) => ( - - {children} - - ), + ({ className, children, ...props }, ref) => { + const { classNames } = useStyles('Dialog'); + + return ( + + {children} + + ); + }, ); + Dialog.displayName = 'Dialog'; diff --git a/packages/ui/src/utils/componentDefinitions.ts b/packages/ui/src/utils/componentDefinitions.ts index 5a0e8bdc1a..e21632016e 100644 --- a/packages/ui/src/utils/componentDefinitions.ts +++ b/packages/ui/src/utils/componentDefinitions.ts @@ -85,6 +85,16 @@ export const componentDefinitions = { root: 'bui-Container', }, }, + Dialog: { + classNames: { + root: 'bui-Dialog', + content: 'bui-DialogContent', + header: 'bui-DialogHeader', + headerTitle: 'bui-DialogHeaderTitle', + body: 'bui-DialogBody', + footer: 'bui-DialogFooter', + }, + }, FieldLabel: { classNames: { root: 'bui-FieldLabelWrapper',