-
Notifications
You must be signed in to change notification settings - Fork 5k
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: new components for network UI #27085
Conversation
CLA Signature Action: All authors have signed the CLA. You may need to manually re-run the blocking PR check if it doesn't pass in a few minutes. |
const renderDropdownList = () => ( | ||
<Box> | ||
{items?.map((item, index) => { | ||
const row = ( | ||
<Box | ||
alignItems={AlignItems.center} | ||
paddingLeft={4} | ||
paddingRight={4} | ||
display={Display.Flex} | ||
justifyContent={JustifyContent.spaceBetween} | ||
key={itemKey(item)} | ||
onClick={() => { | ||
onItemSelected(index); | ||
setIsDropdownOpen(false); | ||
}} | ||
className={classnames('dropdown-editor__item', { | ||
'dropdown-editor__item--selected': index === selectedItemIndex, | ||
})} | ||
> | ||
{index === selectedItemIndex && ( | ||
<Box | ||
className="dropdown-editor__item-selected-pill" | ||
borderRadius={BorderRadius.pill} | ||
backgroundColor={BackgroundColor.primaryDefault} | ||
/> | ||
)} | ||
{renderItem(item, true)} | ||
{itemIsDeletable(item, items) && ( | ||
<ButtonIcon | ||
marginLeft={1} | ||
ariaLabel={t('delete')} | ||
size={ButtonIconSize.Sm} | ||
iconName={IconName.Trash} | ||
color={IconColor.errorDefault} | ||
onClick={(e: React.MouseEvent) => { | ||
e.stopPropagation(); | ||
|
||
// Determine which item should be selected after deletion | ||
let newSelectedIndex; | ||
if (selectedItemIndex === undefined || items.length <= 1) { | ||
newSelectedIndex = undefined; | ||
} else if (index === selectedItemIndex) { | ||
newSelectedIndex = 0; | ||
} else if (index > selectedItemIndex) { | ||
newSelectedIndex = selectedItemIndex; | ||
} else if (index < selectedItemIndex) { | ||
newSelectedIndex = selectedItemIndex - 1; | ||
} | ||
|
||
onItemDeleted(index, newSelectedIndex); | ||
}} | ||
/> | ||
)} | ||
</Box> | ||
); |
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.
Not a dealbreaker, but for testing/reusability purposes I would typically prefer to have this live as it's own component, rather than in a callback within dropdown-editor.tsx
. Maybe something like multichain-dropdown-list.tsx
, and then pass it whatever props it needs.
Doesn't need to block though.
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! Let's consider this as a follow up!
Builds ready [435b3d0]
Page Load Metrics (1726 ± 129 ms)
Bundle size diffs [🚨 Warning! Bundle size has increased!]
|
Builds ready [26a58c4]
Page Load Metrics (1761 ± 137 ms)
Bundle size diffs [🚨 Warning! Bundle size has increased!]
|
Builds ready [6dcaa56]
Page Load Metrics (1806 ± 82 ms)
Bundle size diffs [🚨 Warning! Bundle size has increased!]
|
Quality Gate passedIssues Measures |
Builds ready [7a74433]
Page Load Metrics (1802 ± 140 ms)
Bundle size diffs [🚨 Warning! Bundle size has increased!]
|
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## develop #27085 +/- ##
===========================================
- Coverage 70.12% 70.03% -0.09%
===========================================
Files 1426 1432 +6
Lines 49705 49868 +163
Branches 13905 13966 +61
===========================================
+ Hits 34853 34921 +68
- Misses 14852 14947 +95 ☔ View full report in Codecov by Sentry. |
Description
This PR splits off the new UI components from #26433. They support the new UI for editing networks directly via the network picker.
MultiRpcEditModal
- A modal shown only to users who have multiple networks for a given chain. Allows them to customize via the network form if they don't like how we merged them.DropdownEditor
- A generic dropdown for selecting, adding, and deleting items. Currently shared by the editing experience for RPC endpoints and block explorers.AddBlockExplorerModal
- The sub page within the network form where you add a block explorerAddRpcUrlModal
- The sub page within the network form where you add an RPC urlRpcListItem
- A component representing a single RPC endpoint with a list. Currently shared between selecting via theSelectRpcUrlModal
and editing via the RPCDropdownEditor
SelectRpcUrlModal
- The page used to switch RPC endpoints for a chain.Additionally some actions are modified to support new features used by these components.
Related issues
Manual testing steps
None of these are visible in the product yet, but will be after #26433
Screenshots/Recordings
Before
After
Pre-merge author checklist
Pre-merge reviewer checklist