-
Notifications
You must be signed in to change notification settings - Fork 5.1k
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
chore: tab component refactor #30143
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. |
4ff32f5
to
8dfe92f
Compare
8dfe92f
to
44a77ae
Compare
BLOCK_SIZES, | ||
DISPLAY, | ||
BlockSize, | ||
Display, |
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.
Replacing deprecated constants for enums
import Box from '../../box'; | ||
import { Text } from '../../../component-library'; | ||
import { Text, Box } from '../../../component-library'; |
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.
Replacing deprecated Box
component with component-library version
children: PropTypes.node, // required, but we are not rendering it explicitly | ||
textProps: PropTypes.object, // props to spread to the Text component |
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.
- Fixing spelling:
explictly
=>explicitly
- Adding PropType for textProps
@@ -0,0 +1,100 @@ | |||
import React from 'react'; |
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.
Adding comprehensive unit test coverage for tab
import Box from '../box'; | ||
import { Box } from '../../component-library'; |
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.
Replacing deprecated Box
component with component-library version
import { | ||
BackgroundColor, | ||
DISPLAY, | ||
Display, |
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.
Replacing deprecated consts with enum
ui/components/ui/tabs/tabs.test.js
Outdated
@@ -0,0 +1,117 @@ | |||
import React from 'react'; |
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.
Adding unit test coverage for tabs component
44a77ae
to
bba6cf6
Compare
{...tabListProps} | ||
className={classnames( | ||
'tabs__list', | ||
tabsClassName, | ||
tabListProps.className, | ||
)} |
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.
Prevents all classNames being overridden if tabListProps contains a className
Builds ready [b248779]
Page Load Metrics (1665 ± 38 ms)
Bundle size diffs
|
ui/components/multichain/account-overview/account-overview-tabs.tsx
Outdated
Show resolved
Hide resolved
ui/components/multichain/asset-picker-amount/asset-picker-modal/asset-picker-modal-tabs.tsx
Outdated
Show resolved
Hide resolved
onTabClick={() => null} | ||
tabsClassName="" | ||
subHeader={null} |
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.
Builds ready [e4b889b]
Page Load Metrics (1539 ± 37 ms)
Bundle size diffs
|
…ents and adding testing coverage
…ents and adding testing coverage
adc06fd
to
fbe3743
Compare
fbe3743
to
1420e31
Compare
@@ -202,7 +202,7 @@ export default function Notifications() { | |||
{hasNotifySnaps && ( | |||
<Tabs | |||
defaultActiveTabKey={activeTab} | |||
onTabClick={(tab) => setActiveTab(tab)} | |||
onTabClick={(tab: string) => setActiveTab(tab as TAB_KEYS)} |
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.
1420e31
to
7663a36
Compare
tabsClassName, | ||
subHeader, | ||
tabsClassName = '', | ||
subHeader = null, | ||
tabListProps = {}, | ||
tabContentProps = {}, | ||
...props |
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.
Adding prop objects to access children components and setting defaults to prevent typescript errors where possible.
@@ -32,6 +32,7 @@ export const AssetPickerModalTabs = ({ | |||
<Tabs | |||
defaultActiveTabKey={defaultActiveTabKey} | |||
tabsClassName="modal-tab__tabs" | |||
onTabClick={() => null} |
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.
Tried a few approaches to avoid setting onTabClick={() => null}
here, including setting defaults in the JavaScript component, but couldn’t resolve the issue without refactoring the Tabs
component to TypeScript. The @MetaMask/design-system team is working on Tabs this quarter, so this is a temporary fix until the design-system-react component is ready.
Builds ready [7663a36]
Page Load Metrics (1704 ± 60 ms)
Bundle size diffs
|
Description
This PR adds prop objects to access the children components inside the
Tabs
andTab
components, along with test coverage. This allows for the Tabs and Tab component to be further customized. There are no visual updates, so these components should remain unchanged with no visual regressions.Tabs
props
to the rootBox
componenttabListProps
to the child tab listul
Box
componenttabContentProps
to the child tabs contentBox
componentTab
props
to the root componenttextProps
to the childText
componentRelated issues
Fixes: #30138
Manual testing steps
To check no visual regressions
yarn storybook
main
branch storybook for no visual regressionsTo check prop objects run tests
yarn jest ui/components/ui/tabs
Screenshots/Recordings
Screen recordings show no visual regressions or changes to UI
Before
before.mov
After
after.mov
Pre-merge author checklist