-
Notifications
You must be signed in to change notification settings - Fork 4.9k
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
feat: design changes in signature paged message section #28038
Changes from all commits
8a24413
c68d6fb
1181b8d
a699c9e
73f7b71
7a59656
94000e3
f2ed1c6
4af935c
b834e33
a9f7d46
440a8d3
c95f82d
c2aef7b
b6b4d59
8d31dad
f389d57
cd2c82f
ac11fc3
44ec97d
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
import React, { createContext } from 'react'; | ||
import React, { createContext, useState } from 'react'; | ||
import Tooltip from '../../../../ui/tooltip/tooltip'; | ||
import { | ||
Box, | ||
|
@@ -40,6 +40,7 @@ export type ConfirmInfoRowProps = { | |
copyEnabled?: boolean; | ||
copyText?: string; | ||
'data-testid'?: string; | ||
collapsed?: boolean; | ||
}; | ||
|
||
const BACKGROUND_COLORS = { | ||
|
@@ -79,71 +80,100 @@ export const ConfirmInfoRow: React.FC<ConfirmInfoRowProps> = ({ | |
labelChildren, | ||
color, | ||
copyEnabled = false, | ||
copyText = undefined, | ||
copyText, | ||
'data-testid': dataTestId, | ||
}) => ( | ||
<ConfirmInfoRowContext.Provider value={{ variant }}> | ||
<Box | ||
data-testid={dataTestId} | ||
className="confirm-info-row" | ||
display={Display.Flex} | ||
flexDirection={FlexDirection.Row} | ||
justifyContent={JustifyContent.spaceBetween} | ||
flexWrap={FlexWrap.Wrap} | ||
alignItems={AlignItems.center} | ||
backgroundColor={BACKGROUND_COLORS[variant]} | ||
borderRadius={BorderRadius.LG} | ||
marginTop={2} | ||
marginBottom={2} | ||
paddingLeft={2} | ||
paddingRight={copyEnabled ? 5 : 2} | ||
color={TEXT_COLORS[variant] as TextColor} | ||
style={{ | ||
overflowWrap: OverflowWrap.Anywhere, | ||
minHeight: '24px', | ||
position: 'relative', | ||
...style, | ||
}} | ||
> | ||
{copyEnabled && <CopyIcon copyText={copyText ?? ''} />} | ||
collapsed, | ||
}) => { | ||
const [expanded, setExpanded] = useState(!collapsed); | ||
|
||
const isCollapsible = collapsed !== undefined; | ||
|
||
return ( | ||
<ConfirmInfoRowContext.Provider value={{ variant }}> | ||
<Box | ||
data-testid={dataTestId} | ||
className="confirm-info-row" | ||
display={Display.Flex} | ||
flexDirection={FlexDirection.Row} | ||
justifyContent={JustifyContent.center} | ||
alignItems={AlignItems.flexStart} | ||
color={color} | ||
flexDirection={isCollapsible ? FlexDirection.Column : FlexDirection.Row} | ||
justifyContent={JustifyContent.spaceBetween} | ||
flexWrap={FlexWrap.Wrap} | ||
alignItems={isCollapsible ? AlignItems.flexStart : AlignItems.center} | ||
backgroundColor={BACKGROUND_COLORS[variant]} | ||
borderRadius={BorderRadius.LG} | ||
marginTop={2} | ||
marginBottom={2} | ||
paddingLeft={2} | ||
paddingRight={copyEnabled ? 5 : 2} | ||
color={TEXT_COLORS[variant] as TextColor} | ||
style={{ | ||
overflowWrap: OverflowWrap.Anywhere, | ||
minHeight: '24px', | ||
position: 'relative', | ||
...style, | ||
}} | ||
> | ||
<Box display={Display.Flex} alignItems={AlignItems.center}> | ||
<Text variant={TextVariant.bodyMdMedium} color={TextColor.inherit}> | ||
{label} | ||
</Text> | ||
{labelChildren} | ||
{!labelChildren && tooltip?.length && ( | ||
<Tooltip | ||
position="bottom" | ||
title={tooltip} | ||
style={{ display: 'flex' }} | ||
> | ||
<Icon | ||
name={TOOLTIP_ICONS[variant]} | ||
marginLeft={1} | ||
color={TOOLTIP_ICON_COLORS[variant] as unknown as IconColor} | ||
size={IconSize.Sm} | ||
{...(dataTestId | ||
? { 'data-testid': `${dataTestId}-tooltip` } | ||
: {})} | ||
/> | ||
</Tooltip> | ||
)} | ||
{copyEnabled && ( | ||
<CopyIcon | ||
copyText={copyText ?? ''} | ||
style={{ right: isCollapsible ? 32 : 0, top: 4 }} | ||
color={IconColor.iconMuted} | ||
/> | ||
)} | ||
{isCollapsible && ( | ||
<Icon | ||
color={IconColor.iconMuted} | ||
name={expanded ? IconName.Collapse : IconName.Expand} | ||
size={IconSize.Sm} | ||
style={{ | ||
cursor: 'pointer', | ||
position: 'absolute', | ||
right: 8, | ||
top: 4, | ||
}} | ||
onClick={() => setExpanded(!expanded)} | ||
data-testid="sectionCollapseButton" | ||
/> | ||
)} | ||
<Box | ||
display={Display.Flex} | ||
flexDirection={FlexDirection.Row} | ||
justifyContent={JustifyContent.center} | ||
alignItems={AlignItems.flexStart} | ||
color={color} | ||
> | ||
<Box display={Display.Flex} alignItems={AlignItems.center}> | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Assuming this behaviour is different to the expandable row, while it's nice to add configuration to the core row, this adds a lot of logic and complexity, so would it be better to create an alternate component that potentially inherits the same properties of row? Or a wrapper component? Or at the very least, should we break this very large schema up with local components? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Changes are required in info row requires to support collapsible row, it is hard to only wrap into row and make it collapsible. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. In that case, could we split this for readability into some local components (in this file) such as There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yep, let me create a followup PR to do that, and avoid in this PR to change the scope here. |
||
<Text variant={TextVariant.bodyMdMedium} color={TextColor.inherit}> | ||
{label} | ||
</Text> | ||
{labelChildren} | ||
{!labelChildren && tooltip?.length && ( | ||
<Tooltip | ||
position="bottom" | ||
title={tooltip} | ||
style={{ display: 'flex' }} | ||
> | ||
<Icon | ||
name={TOOLTIP_ICONS[variant]} | ||
marginLeft={1} | ||
color={TOOLTIP_ICON_COLORS[variant] as unknown as IconColor} | ||
size={IconSize.Sm} | ||
{...(dataTestId | ||
? { 'data-testid': `${dataTestId}-tooltip` } | ||
: {})} | ||
/> | ||
</Tooltip> | ||
)} | ||
</Box> | ||
</Box> | ||
{expanded && | ||
(typeof children === 'string' ? ( | ||
<Text marginRight={copyEnabled ? 3 : 0} color={TextColor.inherit}> | ||
{children} | ||
</Text> | ||
) : ( | ||
children | ||
))} | ||
</Box> | ||
{typeof children === 'string' ? ( | ||
<Text marginRight={copyEnabled ? 3 : 0} color={TextColor.inherit}> | ||
{children} | ||
</Text> | ||
) : ( | ||
children | ||
)} | ||
</Box> | ||
</ConfirmInfoRowContext.Provider> | ||
); | ||
</ConfirmInfoRowContext.Provider> | ||
); | ||
}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
non-blocking: Is there any reason we aren't using the
ButtonIcon
component here? The current implementation has poor accessibility as it renders aspan
instead of abutton
, and it lacks anaria-label
, making it inaccessible for screen reader users.cc @matthewwalsh0
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I agree button icon is good idea. Let me create separate PR for this as it would need lot of snapshot updates in confirmation pages.