diff --git a/.changeset/early-baboons-roll.md b/.changeset/early-baboons-roll.md new file mode 100644 index 0000000000..bdd55ec507 --- /dev/null +++ b/.changeset/early-baboons-roll.md @@ -0,0 +1,16 @@ +--- +'@backstage/ui': minor +--- + +**BREAKING**: Removed `--bui-bg-popover` CSS token. Popover, Tooltip, Menu, and Dialog now use `--bui-bg-app` for their outer shell and `Box bg="neutral-1"` for content areas, providing better theme consistency and eliminating a redundant token. + +**Migration:** + +Replace any usage of `--bui-bg-popover` with `--bui-bg-neutral-1` (for content surfaces) or `--bui-bg-app` (for outer shells): + +```diff +- background: var(--bui-bg-popover); ++ background: var(--bui-bg-neutral-1); +``` + +**Affected components:** Popover, Tooltip, Menu, Dialog diff --git a/docs/conf/user-interface/index.md b/docs/conf/user-interface/index.md index cb53ebe81c..107fde3d57 100644 --- a/docs/conf/user-interface/index.md +++ b/docs/conf/user-interface/index.md @@ -156,7 +156,6 @@ These colors form a layered neutral scale for your application backgrounds. `--b | Token Name | Description | | ----------------------------- | ------------------------------------------------------------ | | `--bui-bg-app` | The base background color of your Backstage instance. | -| `--bui-bg-popover` | The background color used for popovers, tooltips, and menus. | | `--bui-bg-neutral-1` | First elevated layer. Use for cards, dialogs, and panels. | | `--bui-bg-neutral-1-hover` | Hover state for elements on neutral-1. | | `--bui-bg-neutral-1-pressed` | Pressed state for elements on neutral-1. | diff --git a/packages/ui/report.api.md b/packages/ui/report.api.md index 5922155e93..25522f1825 100644 --- a/packages/ui/report.api.md +++ b/packages/ui/report.api.md @@ -897,6 +897,7 @@ export const DialogDefinition: { readonly classNames: { readonly overlay: 'bui-DialogOverlay'; readonly dialog: 'bui-Dialog'; + readonly content: 'bui-DialogContent'; readonly header: 'bui-DialogHeader'; readonly headerTitle: 'bui-DialogHeaderTitle'; readonly body: 'bui-DialogBody'; @@ -1331,6 +1332,7 @@ export const MenuDefinition: { readonly classNames: { readonly root: 'bui-Menu'; readonly popover: 'bui-MenuPopover'; + readonly inner: 'bui-MenuInner'; readonly content: 'bui-MenuContent'; readonly section: 'bui-MenuSection'; readonly sectionHeader: 'bui-MenuSectionHeader'; @@ -2218,6 +2220,7 @@ export const Tooltip: ForwardRefExoticComponent< export const TooltipDefinition: { readonly classNames: { readonly tooltip: 'bui-Tooltip'; + readonly content: 'bui-TooltipContent'; readonly arrow: 'bui-TooltipArrow'; }; }; diff --git a/packages/ui/src/components/Dialog/Dialog.module.css b/packages/ui/src/components/Dialog/Dialog.module.css index f5968820a2..da82509134 100644 --- a/packages/ui/src/components/Dialog/Dialog.module.css +++ b/packages/ui/src/components/Dialog/Dialog.module.css @@ -43,8 +43,10 @@ } .bui-Dialog { - background: var(--bui-bg-popover); - border-radius: 0.5rem; + --dialog-border-radius: 0.5rem; + background: var(--bui-bg-app); + box-shadow: var(--bui-shadow); + border-radius: var(--dialog-border-radius); border: 1px solid var(--bui-border-1); color: var(--bui-fg-primary); position: relative; @@ -52,9 +54,14 @@ max-width: calc(100vw - 3rem); height: min(var(--bui-dialog-min-height, auto), calc(100vh - 3rem)); max-height: calc(100vh - 3rem); + outline: none; + } + + .bui-DialogContent { display: flex; flex-direction: column; - outline: none; + border-radius: var(--dialog-border-radius); + height: 100%; } /* Dialog entering animation */ diff --git a/packages/ui/src/components/Dialog/Dialog.stories.tsx b/packages/ui/src/components/Dialog/Dialog.stories.tsx index 0392959a59..9084bfa7e4 100644 --- a/packages/ui/src/components/Dialog/Dialog.stories.tsx +++ b/packages/ui/src/components/Dialog/Dialog.stories.tsx @@ -63,6 +63,24 @@ export const Default = meta.story({ }); export const Open = Default.extend({ + parameters: { layout: 'fullscreen' }, + decorators: [ + Story => ( +
+ +
+ ), + ], args: { defaultOpen: true, }, diff --git a/packages/ui/src/components/Dialog/Dialog.tsx b/packages/ui/src/components/Dialog/Dialog.tsx index 1c33588306..efdc6c4567 100644 --- a/packages/ui/src/components/Dialog/Dialog.tsx +++ b/packages/ui/src/components/Dialog/Dialog.tsx @@ -33,6 +33,7 @@ import { Button } from '../Button'; import { useStyles } from '../../hooks/useStyles'; import { DialogDefinition } from './definition'; import { Flex } from '../Flex'; +import { Box } from '../Box'; import styles from './Dialog.module.css'; /** @public */ @@ -71,7 +72,12 @@ export const Dialog = forwardRef, DialogProps>( ...style, }} > - {children} + + {children} + ); diff --git a/packages/ui/src/components/Dialog/definition.ts b/packages/ui/src/components/Dialog/definition.ts index d2fcb7bb4d..f9aadc9147 100644 --- a/packages/ui/src/components/Dialog/definition.ts +++ b/packages/ui/src/components/Dialog/definition.ts @@ -24,6 +24,7 @@ export const DialogDefinition = { classNames: { overlay: 'bui-DialogOverlay', dialog: 'bui-Dialog', + content: 'bui-DialogContent', header: 'bui-DialogHeader', headerTitle: 'bui-DialogHeaderTitle', body: 'bui-DialogBody', diff --git a/packages/ui/src/components/Menu/Menu.module.css b/packages/ui/src/components/Menu/Menu.module.css index 6dca183395..0717a9468d 100644 --- a/packages/ui/src/components/Menu/Menu.module.css +++ b/packages/ui/src/components/Menu/Menu.module.css @@ -18,12 +18,13 @@ @layer components { .bui-MenuPopover { + --menu-border-radius: var(--bui-radius-2); display: flex; flex-direction: column; box-shadow: var(--bui-shadow); border: 1px solid var(--bui-border-1); - border-radius: var(--bui-radius-2); - background: var(--bui-bg-popover); + border-radius: var(--menu-border-radius); + background: var(--bui-bg-app); color: var(--bui-fg-primary); outline: none; transition: transform 200ms, opacity 200ms; @@ -55,6 +56,10 @@ } } + .bui-MenuInner { + border-radius: var(--menu-border-radius); + } + .bui-MenuContent { max-height: inherit; box-sizing: border-box; diff --git a/packages/ui/src/components/Menu/Menu.stories.tsx b/packages/ui/src/components/Menu/Menu.stories.tsx index ffe184d4ae..982055ade1 100644 --- a/packages/ui/src/components/Menu/Menu.stories.tsx +++ b/packages/ui/src/components/Menu/Menu.stories.tsx @@ -198,6 +198,24 @@ export const PreviewLinks = meta.story({ }); export const Opened = meta.story({ + parameters: { layout: 'fullscreen' }, + decorators: [ + Story => ( +
+ +
+ ), + ], args: { ...Preview.input.args, }, diff --git a/packages/ui/src/components/Menu/Menu.tsx b/packages/ui/src/components/Menu/Menu.tsx index e02292ba44..da4243f643 100644 --- a/packages/ui/src/components/Menu/Menu.tsx +++ b/packages/ui/src/components/Menu/Menu.tsx @@ -58,6 +58,7 @@ import { } from '../InternalLinkProvider'; import styles from './Menu.module.css'; import clsx from 'clsx'; +import { Box } from '../Box'; const { RoutingProvider, useRoutingRegistrationEffect } = createRoutingRegistration(); @@ -119,18 +120,23 @@ export const Menu = (props: MenuProps) => { )} placement={placement} > - {virtualized ? ( - - {menuContent} - - ) : ( - menuContent - )} + + {virtualized ? ( + + {menuContent} + + ) : ( + menuContent + )} + ); @@ -169,18 +175,23 @@ export const MenuListBox = (props: MenuListBoxProps) => { )} placement={placement} > - {virtualized ? ( - - {listBoxContent} - - ) : ( - listBoxContent - )} + + {virtualized ? ( + + {listBoxContent} + + ) : ( + listBoxContent + )} + ); }; @@ -219,43 +230,48 @@ export const MenuAutocomplete = (props: MenuAutocompleteProps) => { )} placement={placement} > - - + + + + + + + + {virtualized ? ( + + {menuContent} + + ) : ( + menuContent )} - aria-label={props.placeholder || 'Search'} - > - - - - - - {virtualized ? ( - - {menuContent} - - ) : ( - menuContent - )} - + + ); @@ -298,43 +314,48 @@ export const MenuAutocompleteListbox = ( )} placement={placement} > - - + + + + + + + + {virtualized ? ( + + {listBoxContent} + + ) : ( + listBoxContent )} - aria-label={props.placeholder || 'Search'} - > - - - - - - {virtualized ? ( - - {listBoxContent} - - ) : ( - listBoxContent - )} - + + ); }; diff --git a/packages/ui/src/components/Menu/definition.ts b/packages/ui/src/components/Menu/definition.ts index e4ba0d83ab..860ad1d729 100644 --- a/packages/ui/src/components/Menu/definition.ts +++ b/packages/ui/src/components/Menu/definition.ts @@ -24,6 +24,7 @@ export const MenuDefinition = { classNames: { root: 'bui-Menu', popover: 'bui-MenuPopover', + inner: 'bui-MenuInner', content: 'bui-MenuContent', section: 'bui-MenuSection', sectionHeader: 'bui-MenuSectionHeader', diff --git a/packages/ui/src/components/Popover/Popover.module.css b/packages/ui/src/components/Popover/Popover.module.css index 69d2acffcf..cdd323817c 100644 --- a/packages/ui/src/components/Popover/Popover.module.css +++ b/packages/ui/src/components/Popover/Popover.module.css @@ -18,9 +18,10 @@ @layer components { .bui-Popover { + --popover-border-radius: var(--bui-radius-3); box-shadow: var(--bui-shadow); - border-radius: var(--bui-radius-3); - background: var(--bui-bg-popover); + border-radius: var(--popover-border-radius); + background: var(--bui-bg-app); border: 1px solid var(--bui-border-1); forced-color-adjust: none; outline: none; @@ -76,6 +77,7 @@ padding: var(--bui-space-4); flex: 1 1 auto; min-height: 0; + border-radius: var(--popover-border-radius); } .bui-PopoverArrow { @@ -89,11 +91,14 @@ we split the stroke and fill across separate elements in order to guarantee that the stroke is always overlaying a consistent color. */ - path:nth-child(1) { - fill: var(--bui-bg-popover); + use:nth-of-type(1) { + fill: var(--bui-bg-app); + } + use:nth-of-type(2) { + fill: var(--bui-bg-neutral-1); } - path:nth-child(2) { + path { fill: var(--bui-border-1); } diff --git a/packages/ui/src/components/Popover/Popover.stories.tsx b/packages/ui/src/components/Popover/Popover.stories.tsx index ea92bf9d5c..e05b352fc9 100644 --- a/packages/ui/src/components/Popover/Popover.stories.tsx +++ b/packages/ui/src/components/Popover/Popover.stories.tsx @@ -19,6 +19,7 @@ import { Button } from '../Button/Button'; import { DialogTrigger } from '../Dialog/Dialog'; import { Text } from '../Text/Text'; import { Flex } from '../Flex/Flex'; +import { Box } from '../Box'; const meta = preview.meta({ title: 'Backstage UI/Popover', @@ -74,6 +75,24 @@ export const Default = meta.story({ }); export const IsOpen = Default.extend({ + parameters: { layout: 'fullscreen' }, + decorators: [ + Story => ( +
+ +
+ ), + ], args: { isOpen: true, }, @@ -189,6 +208,9 @@ export const WithRichContent = Default.extend({ This is a popover with rich content. It can contain multiple elements and formatted text. + + You can also use the automatic bg system inside it. +