forked from deephaven/deephaven-plugins
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: icons in illustrated message (deephaven#575)
Closes deephaven#558
- Loading branch information
1 parent
41c7f7e
commit 1623ff5
Showing
8 changed files
with
58 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 <DHCIllustratedMessage {...props} />; | ||
|
||
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 */ | ||
<DHCIllustratedMessage {...otherProps}>{newChildren}</DHCIllustratedMessage> | ||
); | ||
} | ||
|
||
export default IllustratedMessage; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file modified
BIN
+2.88 KB
(100%)
tests/ui.spec.ts-snapshots/UI-all-components-render-1-chromium-linux.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified
BIN
+3.65 KB
(100%)
tests/ui.spec.ts-snapshots/UI-all-components-render-1-firefox-linux.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified
BIN
+3.36 KB
(100%)
tests/ui.spec.ts-snapshots/UI-all-components-render-1-webkit-linux.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.