Skip to content

feat(Dialog): update Dialog according to P+ specs #4805

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 5 commits into from
Jul 16, 2025
Merged
Show file tree
Hide file tree
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
5 changes: 4 additions & 1 deletion packages/core/src/Dialog/Content/Content.styles.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,12 @@ import { theme } from "@hitachivantara/uikit-styles";
export const { staticClasses, useClasses } = createClasses("HvDialog-Content", {
root: {
padding: theme.spacing(0, "sm", "sm"),
borderColor: theme.colors.borderSubtle,
borderTopWidth: "var(--borderW)",
borderBottomWidth: "var(--borderW)",
},
textContent: {
marginLeft: "42px",
paddingLeft: `calc(42px + ${theme.space.sm})`,
paddingRight: "62px",
overflowY: "auto",
},
Expand Down
31 changes: 31 additions & 0 deletions packages/core/src/Dialog/Content/Content.tsx
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
import { useEffect, useRef, useState } from "react";
import MuiDialogContent, {
DialogContentProps as MuiDialogContentProps,
} from "@mui/material/DialogContent";
import {
mergeStyles,
useDefaultProps,
type ExtractNames,
} from "@hitachivantara/uikit-react-utils";
import { theme } from "@hitachivantara/uikit-styles";

import { HvTypography } from "../../Typography";
import { staticClasses, useClasses } from "./Content.styles";
Expand All @@ -27,19 +30,47 @@ export const HvDialogContent = (props: HvDialogContentProps) => {
className,
children,
indentContent = false,
style,
...others
} = useDefaultProps("HvDialogContent", props);

const { classes, cx } = useClasses(classesProp);
const [hasBorder, setHasBorder] = useState(false);
const elRef = useRef<HTMLDivElement>(null);

useEffect(() => {
if (typeof ResizeObserver !== "undefined") {
const resizeObserver = new ResizeObserver(() => {
const el = elRef.current as HTMLElement | null;
if (el) {
const hasOverflow = el.scrollHeight > el.clientHeight;
setHasBorder(hasOverflow);
}
});

if (elRef.current) {
resizeObserver.observe(elRef.current as HTMLElement);
}

return () => {
resizeObserver.disconnect();
};
}
return undefined;
}, []);

return (
<HvTypography
ref={elRef}
component={MuiDialogContent}
className={cx(
classes.root,
{ [classes.textContent]: !!indentContent },
className,
)}
style={mergeStyles(style, {
"--borderW": hasBorder ? "1px" : "0px",
})}
{...others}
>
{children}
Expand Down
5 changes: 4 additions & 1 deletion packages/core/src/Dialog/Dialog.styles.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,10 @@ export const { staticClasses, useClasses } = createClasses("HvDialog", {
borderColor: theme.colors.border,
borderRadius: theme.radii.round,
},
fullscreen: {},
fullscreen: {
borderRadius: 0,
},

fullHeight: {
height: "100%",
},
Expand Down
4 changes: 2 additions & 2 deletions packages/core/src/Dialog/Title/Title.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ import {
type ExtractNames,
} from "@hitachivantara/uikit-react-utils";

import { HvStatusIcon } from "../../StatusIcon";
import { HvTypography } from "../../Typography";
import { iconVariant } from "../../utils/iconVariant";
import { useDialogContext } from "../context";
import { staticClasses, useClasses } from "./Title.styles";

Expand Down Expand Up @@ -48,7 +48,7 @@ export const HvDialogTitle = (props: HvDialogTitleProps) => {
const { classes, cx } = useClasses(classesProp);
const { fullScreen } = useDialogContext();

const icon = customIcon || (showIcon && iconVariant(variant));
const icon = customIcon || (showIcon && <HvStatusIcon variant={variant} />);

return (
<HvTypography
Expand Down
6 changes: 3 additions & 3 deletions packages/core/src/Dialog/stories/FormStory.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -64,12 +64,12 @@ export const FormStory = () => {
</form>
</HvDialogContent>
<HvDialogActions>
<HvButton type="submit" form="create-post">
Create
</HvButton>
<HvButton variant="secondaryGhost" onClick={() => setOpen(false)}>
Cancel
</HvButton>
<HvButton type="submit" form="create-post">
Create
</HvButton>
</HvDialogActions>
</HvDialog>
</>
Expand Down
6 changes: 3 additions & 3 deletions packages/core/src/Dialog/stories/MainStory.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,16 +23,16 @@ export const MainStory = (props: HvDialogProps) => {
visualization. You will need to re-select your fields.
</HvDialogContent>
<HvDialogActions>
<HvButton variant="secondaryGhost" onClick={() => setOpen(false)}>
Apply
</HvButton>
<HvButton
autoFocus
variant="secondaryGhost"
onClick={() => setOpen(false)}
>
Cancel
</HvButton>
<HvButton variant="secondaryGhost" onClick={() => setOpen(false)}>
Apply
</HvButton>
</HvDialogActions>
</HvDialog>
</div>
Expand Down
20 changes: 14 additions & 6 deletions packages/core/src/Dialog/stories/SemanticVariantsStory.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import {
HvDialogContent,
HvDialogProps,
HvDialogTitle,
HvStatusIcon,
} from "@hitachivantara/uikit-react-core";
import { Ungroup } from "@hitachivantara/uikit-react-icons";

Expand Down Expand Up @@ -50,16 +51,16 @@ const SimpleDialog = ({
</HvDialogContent>
<HvDialogActions>
<HvButton
variant={variant ? buttonVariantMap[variant] : "secondaryGhost"}
variant={variant ? "secondarySubtle" : "secondaryGhost"}
onClick={() => setOpen(false)}
>
Apply
Cancel
</HvButton>
<HvButton
variant={variant ? "secondarySubtle" : "secondaryGhost"}
variant={variant ? buttonVariantMap[variant] : "secondaryGhost"}
onClick={() => setOpen(false)}
>
Cancel
Apply
</HvButton>
</HvDialogActions>
</HvDialog>
Expand All @@ -72,7 +73,7 @@ export const SemanticVariantsStory = () => (
<SimpleDialog
buttonMessage="Warning"
variant="warning"
title={<HvDialogTitle variant="error">Warning</HvDialogTitle>}
title={<HvDialogTitle variant="warning">Warning</HvDialogTitle>}
/>
<SimpleDialog
buttonMessage="Success"
Expand All @@ -91,7 +92,14 @@ export const SemanticVariantsStory = () => (
<SimpleDialog
buttonMessage="Custom"
title={
<HvDialogTitle customIcon={<Ungroup iconSize="S" />}>
<HvDialogTitle
customIcon={
<HvStatusIcon
variant="default"
customIcon={<div className="i-ph-tree-structure" />}
/>
}
>
Custom
</HvDialogTitle>
}
Expand Down
6 changes: 5 additions & 1 deletion packages/core/src/Drawer/Drawer.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,11 @@ export const Main: StoryObj<HvDrawerProps> = {
open={open}
{...args}
>
<HvDialogTitle component="div" className={classes.drawerTitle}>
<HvDialogTitle
component="div"
className={classes.drawerTitle}
showIcon={false}
>
Lorem Ipsum
</HvDialogTitle>
<HvDialogContent className={classes.drawerContent}>
Expand Down
2 changes: 1 addition & 1 deletion packages/core/src/FileUploader/FileUploader.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -306,7 +306,7 @@ export const WithPreviewThumbnails: StoryObj<HvFileUploaderProps> = {
}}
/>
<HvDialog open={open} onClose={() => setOpen(false)}>
<HvDialogTitle>{previewTitle}</HvDialogTitle>
<HvDialogTitle showIcon={false}>{previewTitle}</HvDialogTitle>
<HvDialogContent>
<img
alt="Preview of the uploaded file"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,9 @@ export const ConfirmationDialog = ({
firstFocusable="confirmation-dialog-cancel"
buttonTitle={closeButtonTooltip}
>
<HvDialogTitle variant="warning">{title}</HvDialogTitle>
<HvDialogTitle variant="warning" showIcon={false}>
{title}
</HvDialogTitle>
<HvDialogContent indentContent>{message}</HvDialogContent>
<HvDialogActions>
<HvButton variant="primaryGhost" onClick={onConfirm}>
Expand Down
16 changes: 16 additions & 0 deletions packages/core/src/themes/ds3.ts
Original file line number Diff line number Diff line change
Expand Up @@ -507,6 +507,22 @@ export const ds3 = mergeTheme(ds3Base, {
titleText: {
...theme.typography.xxsTitle,
},
root: {
"& .HvStatusIcon-root": {
padding: 0,
},
"& .HvIconContainer-root": {
color: `${theme.colors.secondary}!important`,
},
},
},
},
HvDialogContent: {
classes: {
root: {
borderTop: "none!important",
borderBottom: "none!important",
},
},
},
HvDropdown: {
Expand Down
20 changes: 20 additions & 0 deletions packages/core/src/themes/ds5.ts
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,26 @@ export const ds5 = mergeTheme(ds5Base, {
},
},
},
HvDialogTitle: {
classes: {
root: {
"& .HvStatusIcon-root": {
padding: 0,
},
"& .HvIconContainer-root": {
color: `${theme.colors.secondary}!important`,
},
},
},
},
HvDialogContent: {
classes: {
root: {
borderTop: "none",
borderBottom: "none",
},
},
},
} satisfies Record<
string,
Record<string, any> | { classes?: React.CSSProperties }
Expand Down
19 changes: 19 additions & 0 deletions packages/core/src/themes/pentahoPlus.ts
Original file line number Diff line number Diff line change
Expand Up @@ -452,6 +452,25 @@ export const pentahoPlus = mergeTheme(pentahoPlusBase, {
},
},
},
HvDialog: {
classes: {
paper: {
borderRadius: theme.radii.large,
},
statusBar: {
border: "none",
borderTopLeftRadius: theme.radii.large,
borderTopRightRadius: theme.radii.large,
},
},
},
HvDialogActions: {
classes: {
root: {
borderTop: "none",
},
},
},
HvDropdownButton: {
classes: {
disabled: {
Expand Down
1 change: 1 addition & 0 deletions packages/lab/src/Wizard/WizardTitle/WizardTitle.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,7 @@ export const HvWizardTitle = ({
classes.messageContainer,
classes.titleContainer,
)}
showIcon={false}
>
{title && (
<HvTypography variant="title3" component="div">
Expand Down