diff --git a/plugins/ui/src/deephaven/ui/components/illustrated_message.py b/plugins/ui/src/deephaven/ui/components/illustrated_message.py index 92c625057..ac99d327b 100644 --- a/plugins/ui/src/deephaven/ui/components/illustrated_message.py +++ b/plugins/ui/src/deephaven/ui/components/illustrated_message.py @@ -99,20 +99,21 @@ def illustrated_message( UNSAFE_style: Set the inline style for the element. Only use as a last resort. Use style props instead. Examples: - prompt = ui.illustrated_message( - ui.heading("Enter URL above"), - ui.content("Enter a URL of a CSV above and click 'Load' to load it"), + no_results = ui.illustrated_message( + ui.heading("No Results"), + ui.content("Try another search"), ) warning = ui.illustrated_message( ui.icon("vsWarning"), - ui.heading("Warning"), - ui.content("This is a warning message."), + ui.heading("Invalid input"), + ui.content("No special characters allowed."), ) error_message = ui.illustrated_message( - ui.icon("vsWarning", size="XXL", margin_bottom="size-10"), - ui.heading("Invalid Input"), - ui.content("Please enter 'Sym' and 'Exchange' above"), + ui.icon("vsError"), + ui.heading("Access denied"), + ui.content("You do not have permissions to access this page."), ) + """ return component_element( "IllustratedMessage", diff --git a/plugins/ui/src/js/src/elements/IllustratedMessage.tsx b/plugins/ui/src/js/src/elements/IllustratedMessage.tsx new file mode 100644 index 000000000..ba75de9e4 --- /dev/null +++ b/plugins/ui/src/js/src/elements/IllustratedMessage.tsx @@ -0,0 +1,42 @@ +import React from 'react'; +import { + IllustratedMessage as DHCIllustratedMessage, + IllustratedMessageProps as DHCIllustratedMessageProps, + Icon, +} from '@deephaven/components'; +import { isElementOfType } from '@deephaven/react-hooks'; + +export function IllustratedMessage( + props: DHCIllustratedMessageProps +): JSX.Element { + const { children, ...otherProps } = props; + + /* eslint-disable-next-line react/jsx-props-no-spreading */ + if (children === undefined) return ; + + const newChildren = React.Children.map(children, element => { + if (isElementOfType(element, Icon) === true) { + const size = element.props.size ?? 'XXL'; + const marginBottom = + element.props.margin ?? + element.props.marginY ?? + element.props.marginBottom ?? + 'size-10'; + + return React.cloneElement(element, { + ...element.props, + size, + marginBottom, + }); + } + + return element; + }); + + return ( + /* eslint-disable-next-line react/jsx-props-no-spreading */ + {newChildren} + ); +} + +export default IllustratedMessage; diff --git a/plugins/ui/src/js/src/elements/index.ts b/plugins/ui/src/js/src/elements/index.ts index d05cabf01..8302b4719 100644 --- a/plugins/ui/src/js/src/elements/index.ts +++ b/plugins/ui/src/js/src/elements/index.ts @@ -5,6 +5,7 @@ export * from './Form'; export * from './hooks'; export * from './HTMLElementView'; export * from './IconElementView'; +export * from './IllustratedMessage'; export * from './ListView'; export * from './model'; export * from './ObjectView'; diff --git a/plugins/ui/src/js/src/widget/WidgetUtils.tsx b/plugins/ui/src/js/src/widget/WidgetUtils.tsx index ebec26892..ffee67c26 100644 --- a/plugins/ui/src/js/src/widget/WidgetUtils.tsx +++ b/plugins/ui/src/js/src/widget/WidgetUtils.tsx @@ -13,7 +13,6 @@ import { Flex, Grid, Heading, - IllustratedMessage, Item, ListActionGroup, ListActionMenu, @@ -53,6 +52,7 @@ import { ActionGroup, Button, Form, + IllustratedMessage, ListView, Picker, Radio, diff --git a/tests/app.d/ui_render_all.py b/tests/app.d/ui_render_all.py index 3d138a3c5..1d82022f3 100644 --- a/tests/app.d/ui_render_all.py +++ b/tests/app.d/ui_render_all.py @@ -64,7 +64,11 @@ def ui_components(): ui.heading("Heading"), ui.icon("vsSymbolMisc"), # TODO: #526 ui.icon_wrapper("TODO: fix this"), - ui.illustrated_message(ui.icon("vsSymbolMisc"), "Illustrated Message"), + ui.illustrated_message( + ui.icon("vsWarning"), + ui.heading("Warning"), + ui.content("This is a warning message."), + ), ui.list_view( _item_table_source_with_action_group, aria_label="List View - List action group", diff --git a/tests/ui.spec.ts-snapshots/UI-all-components-render-1-chromium-linux.png b/tests/ui.spec.ts-snapshots/UI-all-components-render-1-chromium-linux.png index 497c29423..9cf9ed48f 100644 Binary files a/tests/ui.spec.ts-snapshots/UI-all-components-render-1-chromium-linux.png and b/tests/ui.spec.ts-snapshots/UI-all-components-render-1-chromium-linux.png differ diff --git a/tests/ui.spec.ts-snapshots/UI-all-components-render-1-firefox-linux.png b/tests/ui.spec.ts-snapshots/UI-all-components-render-1-firefox-linux.png index 84b32377c..a317fac6e 100644 Binary files a/tests/ui.spec.ts-snapshots/UI-all-components-render-1-firefox-linux.png and b/tests/ui.spec.ts-snapshots/UI-all-components-render-1-firefox-linux.png differ diff --git a/tests/ui.spec.ts-snapshots/UI-all-components-render-1-webkit-linux.png b/tests/ui.spec.ts-snapshots/UI-all-components-render-1-webkit-linux.png index 456fb28df..8c9f65732 100644 Binary files a/tests/ui.spec.ts-snapshots/UI-all-components-render-1-webkit-linux.png and b/tests/ui.spec.ts-snapshots/UI-all-components-render-1-webkit-linux.png differ