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
[Tabs] M3-4119: Refactor Tabs - Lish #6467
Merged
Merged
Changes from 5 commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
38e46d9
Refactor to Reach UI
tiffwong f01e664
Add keyboardActivation prop
tiffwong 9f28f36
Working on focusing on tabs
tiffwong c92009b
Add ref to tabs
tiffwong 51df808
removing redundant a11y attributes
c77d2dc
Merge branch 'feature/tab-refactor' of github.com:linode/manager into…
tiffwong f1a99fc
Switch to SafeTabPanel
tiffwong 89248f3
Move styles to Lish and get rid of ref
tiffwong c8020ce
Remove TabPanel import
tiffwong File filter
Filter by extension
Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,24 +8,24 @@ const useStyles = makeStyles((theme: Theme) => ({ | |
tab: { | ||
'&[data-reach-tab]': { | ||
// This was copied over from our MuiTab styling in themeFactory. Some of this could probably be cleaned up. | ||
color: theme.color.tableHeaderText, | ||
minWidth: 50, | ||
textTransform: 'inherit', | ||
fontSize: '0.93rem', | ||
padding: '6px 16px', | ||
position: 'relative', | ||
overflow: 'hidden', | ||
maxWidth: 264, | ||
boxSizing: 'border-box', | ||
borderBottom: '2px solid transparent', | ||
minHeight: theme.spacing(1) * 6, | ||
flexShrink: 0, | ||
display: 'inline-flex', | ||
alignItems: 'center', | ||
flexShrink: 0, | ||
verticalAlign: 'middle', | ||
justifyContent: 'center', | ||
appearance: 'none', | ||
borderBottom: '2px solid transparent', | ||
boxSizing: 'border-box', | ||
color: theme.color.tableHeaderText, | ||
fontSize: '0.93rem', | ||
lineHeight: 1.3, | ||
maxWidth: 264, | ||
minHeight: theme.spacing(1) * 6, | ||
minWidth: 50, | ||
overflow: 'hidden', | ||
padding: '6px 16px', | ||
position: 'relative', | ||
textTransform: 'inherit', | ||
[theme.breakpoints.up('md')]: { | ||
minWidth: 75 | ||
}, | ||
|
@@ -40,6 +40,7 @@ const useStyles = makeStyles((theme: Theme) => ({ | |
} | ||
}, | ||
tabList: { | ||
color: theme.color.tableHeaderText, | ||
'&[data-reach-tab-list]': { | ||
background: 'none !important', | ||
boxShadow: `inset 0 -1px 0 ${theme.color.border2}`, | ||
|
@@ -49,6 +50,30 @@ const useStyles = makeStyles((theme: Theme) => ({ | |
padding: 1 | ||
} | ||
} | ||
}, | ||
lishTab: { | ||
backgroundColor: theme.bg.offWhite, | ||
color: theme.color.tableHeaderText, | ||
'&[aria-selected="true"]': { | ||
backgroundColor: theme.palette.primary.main, | ||
borderBottom: 'none !important', | ||
color: 'white !important', | ||
'&:hover': { | ||
backgroundColor: theme.palette.primary.light, | ||
color: 'white' | ||
} | ||
} | ||
}, | ||
lishTabList: { | ||
display: 'flex', | ||
backgroundColor: theme.bg.offWhite, | ||
margin: 0, | ||
overflow: 'hidden', | ||
'& [role="tab"]': { | ||
flexBasis: '50%', | ||
margin: 0, | ||
maxWidth: 'none !important' | ||
} | ||
} | ||
})); | ||
|
||
|
@@ -60,6 +85,7 @@ export interface Tab { | |
interface Props { | ||
tabs: Tab[]; | ||
[index: string]: any; | ||
lish?: boolean; | ||
} | ||
|
||
type CombinedProps = Props; | ||
|
@@ -68,15 +94,24 @@ export const TabLinkList: React.FC<CombinedProps> = props => { | |
const { tabs } = props; | ||
|
||
const classes = useStyles(); | ||
// TODO: Change type 'any' to a more appropriate type | ||
const ref = React.useRef<any>(null); | ||
|
||
React.useEffect(() => { | ||
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. Similarly, if this Ref is only here for Lish (for now), it should be controlled by the parent and passed down as a prop. |
||
if (ref.current !== null) { | ||
ref.current.focus(); | ||
} | ||
}, []); | ||
|
||
return ( | ||
<TabList className={classes.tabList}> | ||
<TabList className={props.lish ? classes.lishTabList : classes.tabList}> | ||
{tabs.map((tab, _index) => ( | ||
<Tab | ||
className={classes.tab} | ||
className={`${classes.tab} ${props.lish ? classes.lishTab : ''}`} | ||
key={`tab-${_index}`} | ||
as={Link} | ||
to={tab.routeName} | ||
ref={props.lish && _index == 0 ? ref : null} | ||
> | ||
{tab.title} | ||
</Tab> | ||
|
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
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Instead of having TabLinkList handle the CSS for Lish, it'd be more scalable if it could accept a CSS classname so it's controllable by the parent. An example can be found here: https://github.com/linode/manager/blob/develop/packages/manager/src/components/PromotionalOfferCard/PromotionalOfferCard.tsx#L91