-
Notifications
You must be signed in to change notification settings - Fork 1
DT-1110: Migrate away from @mui/styles Part 1 #1730
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
Merged
Merged
Changes from all commits
Commits
Show all changes
38 commits
Select commit
Hold shift + click to select a range
4e16bbd
HomeView - converted with copilot
snf2ye 9ff762b
DatasetView - upgrade by copilot
snf2ye 08016b8
DatasetView - Copilot decided to go rouge and just add a title??
snf2ye 841ade9
DatasetView: Copilot dropped the mixins css
snf2ye 6eab2ee
SnapshotView: Prep for copilot changes
snf2ye 390d32a
Snapshot View: Update by copilot
snf2ye 49d2f7c
SnapshotView: copilot dropped the mixins css
snf2ye aa6caf9
JobView - prep for copilot - remove unused styles
snf2ye ef996c4
JobView - upgrade by copilot
snf2ye 2612ace
JobView: cleanup
snf2ye ac262ac
SnapshotAccessRequestTable
snf2ye fb6d70e
DatasetOverview: Remove unused styles
snf2ye cd86d3f
DatasetOverview - Copilot update
snf2ye 02041ab
DatasetOverviewPanel - update with copilot
snf2ye 9ce17e2
DatasetOverviewPanel.jsx - set the Drawer to temporary so it doesn't …
snf2ye 817e72f
Index
snf2ye 4ee461c
DatasetOverviewPanel.jsx - clean up references
snf2ye 5b7460a
DatasetAccess - remove styles, not referenced in component
snf2ye bc1313e
UserList - remove unused styles
snf2ye 849618b
UserList - update by copilot
snf2ye 2358483
JobView - switch back to more specific type
snf2ye 5e3e9c1
HomeView
snf2ye cc59308
UserList - updated by claude copilot
snf2ye 8570011
DatasetView
snf2ye 89aabed
SnapshotView
snf2ye d676ced
Job View
snf2ye b6062e3
DatasetOverview
snf2ye 552e01b
DatasetOverviewPanel
snf2ye 640e7b1
Remove styles
snf2ye 5df0310
SnapshotAccessRequestTable.tsx
snf2ye 504225e
Use styled from @mui/system, move mixins to be styled components
snf2ye f3d2436
Fix bug in DatasetOverviewPanel.jsx
snf2ye a5f2e25
needed component=span
snf2ye 1fe3370
Getting typescript to recognize that we're using our extended CustomT…
snf2ye 5148d72
Move to common component
snf2ye 2ceceb6
On second thought, let's remove containerWidth
snf2ye ad32ffd
Move away from shorthand to more verbose css styling
snf2ye 335319e
Add px; update one more test reference
snf2ye File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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 |
---|---|---|
|
@@ -2,13 +2,10 @@ import React, { Dispatch, useState } from 'react'; | |
import { connect } from 'react-redux'; | ||
import { Link } from 'react-router-dom'; | ||
import { Action } from 'redux'; | ||
|
||
import { Button } from '@mui/material'; | ||
import { Button, Box } from '@mui/material'; | ||
import { styled } from '@mui/material/styles'; | ||
import { AddCircle, Refresh } from '@mui/icons-material'; | ||
import { createStyles, WithStyles, withStyles } from '@mui/styles'; | ||
import { CustomTheme } from '@mui/material/styles'; | ||
import { RouterLocation, RouterRootState } from 'connected-react-router'; | ||
import { LocationState } from 'history'; | ||
import { | ||
getSnapshotAccessRequests, | ||
refreshDatasets, | ||
|
@@ -18,76 +15,42 @@ import { | |
} from 'src/actions'; | ||
import { TdrState } from 'reducers'; | ||
import { useOnMount } from 'libs/utils'; | ||
import { LocationState } from 'history'; | ||
import DatasetView from './DatasetView'; | ||
import SnapshotView from './SnapshotView'; | ||
import JobView from './JobView'; | ||
import SearchTable from './table/SearchTable'; | ||
import SnapshotAccessRequestView from './SnapshotAccessRequestView'; | ||
|
||
const styles = (theme: CustomTheme) => | ||
createStyles({ | ||
pageRoot: { | ||
padding: '16px 24px', | ||
display: 'flex', | ||
flexDirection: 'column', | ||
height: '100%', | ||
}, | ||
header: { | ||
alignItems: 'center', | ||
color: theme.typography.color, | ||
display: 'flex', | ||
fontWeight: 500, | ||
fontSize: 16, | ||
height: 21, | ||
letterSpacing: 1, | ||
}, | ||
jadeTableSpacer: { | ||
paddingBottom: theme.spacing(12), | ||
}, | ||
jadeLink: { | ||
...theme.mixins.jadeLink, | ||
float: 'right', | ||
fontSize: 16, | ||
fontWeight: 500, | ||
height: 20, | ||
letterSpacing: 0.3, | ||
paddingLeft: theme.spacing(4), | ||
paddingTop: theme.spacing(4), | ||
}, | ||
title: { | ||
color: theme.palette.secondary.dark, | ||
fontSize: '1.5rem', | ||
fontWeight: 700, | ||
flex: '1 1 0', | ||
'padding-right': '2em', | ||
display: 'flex', | ||
}, | ||
titleText: { | ||
width: '150px', | ||
}, | ||
titleAndSearch: { | ||
display: 'flex', | ||
'margin-top': '1.25em', | ||
'margin-bottom': '1.25em', | ||
}, | ||
headerButton: { | ||
padding: 10, | ||
marginLeft: theme.spacing(2), | ||
height: '45px', | ||
textTransform: 'none', | ||
}, | ||
buttonIcon: { | ||
marginRight: 6, | ||
fontSize: '1.5rem', | ||
}, | ||
}); | ||
const RootContainer = styled(Box)({ | ||
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. I really like this approach - very clean. |
||
padding: '16px 24px', | ||
display: 'flex', | ||
flexDirection: 'column', | ||
height: '100%', | ||
}); | ||
|
||
const TitleContainer = styled(Box)(({ theme }) => ({ | ||
color: theme.palette.secondary.dark, | ||
fontSize: '1.5rem', | ||
fontWeight: 700, | ||
flex: '1 1 0', | ||
paddingRight: '2em', | ||
display: 'flex', | ||
})); | ||
|
||
const HeaderButton = styled(Button)({ | ||
padding: '10px', | ||
marginLeft: '16px', | ||
height: '45px', | ||
textTransform: 'none', | ||
}); | ||
|
||
interface IProps extends WithStyles<typeof styles> { | ||
interface IProps { | ||
dispatch: Dispatch<Action>; | ||
location: RouterLocation<LocationState>; | ||
} | ||
|
||
function HomeView({ classes, dispatch, location }: IProps) { | ||
function HomeView({ dispatch, location }: IProps) { | ||
const [searchString, setSearchString] = useState(''); | ||
const prefixMatcher = /\/[^/]*/; | ||
const tabValue = prefixMatcher.exec(location.pathname)?.[0]; | ||
|
@@ -115,48 +78,41 @@ function HomeView({ classes, dispatch, location }: IProps) { | |
refresh = () => dispatch(refreshSnapshotAccessRequests()); | ||
} | ||
const refreshButton = ( | ||
<Button | ||
<HeaderButton | ||
aria-label="refresh page" | ||
size="medium" | ||
className={classes.headerButton} | ||
onClick={refresh} | ||
variant="outlined" | ||
startIcon={<Refresh />} | ||
> | ||
Refresh | ||
</Button> | ||
</HeaderButton> | ||
); | ||
const pageHeader = | ||
tabValue === '/datasets' ? ( | ||
<div className={classes.title}> | ||
<span className={classes.titleText}>{pageTitle}</span> | ||
<TitleContainer> | ||
<Box sx={{ width: '150px' }}>{pageTitle}</Box> | ||
{refreshButton} | ||
<Link to="datasets/new" data-cy="create-dataset-link"> | ||
<Button | ||
className={classes.headerButton} | ||
color="primary" | ||
variant="outlined" | ||
disableElevation | ||
size="medium" | ||
> | ||
<AddCircle className={classes.buttonIcon} /> Create Dataset | ||
</Button> | ||
<HeaderButton color="primary" variant="outlined" disableElevation size="medium"> | ||
<AddCircle sx={{ marginRight: '6px', fontSize: '1.5rem' }} /> Create Dataset | ||
</HeaderButton> | ||
</Link> | ||
</div> | ||
</TitleContainer> | ||
) : ( | ||
<div className={classes.title}> | ||
<span className={classes.titleText}>{pageTitle}</span> | ||
<TitleContainer> | ||
<Box sx={{ width: '150px' }}>{pageTitle}</Box> | ||
{refreshButton} | ||
</div> | ||
</TitleContainer> | ||
); | ||
|
||
useOnMount(() => { | ||
dispatch(getSnapshotAccessRequests()); | ||
}); | ||
|
||
return ( | ||
<div className={classes.pageRoot}> | ||
<div className={classes.titleAndSearch}> | ||
<RootContainer> | ||
<Box sx={{ display: 'flex', marginTop: '1.25em', marginBottom: '1.25em' }}> | ||
{pageHeader} | ||
{searchable && ( | ||
<SearchTable | ||
|
@@ -165,9 +121,9 @@ function HomeView({ classes, dispatch, location }: IProps) { | |
clearSearchString={() => setSearchString('')} | ||
/> | ||
)} | ||
</div> | ||
</Box> | ||
{tableValue} | ||
</div> | ||
</RootContainer> | ||
); | ||
} | ||
|
||
|
@@ -177,4 +133,4 @@ function mapStateToProps(state: TdrState & RouterRootState) { | |
}; | ||
} | ||
|
||
export default connect(mapStateToProps)(withStyles(styles)(HomeView)); | ||
export default connect(mapStateToProps)(HomeView); |
Oops, something went wrong.
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.
so just a general comment, this is moving us away from having separate style objects and towards inline styling. Is that the principle that we want to follow? I thought that separate objects were preferred because they are reusable and easier to maintain. But maybe that isn't the case. What are the guidelines from the UI working group on this?
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.
My goal in this PR is to use best practices for Material UI. We're moving from an old Material UI concept (@mui/styles), to a new one - sx prop + styled components. I don't think Terra UI uses Material UI, but I'm glad to still run this by them.
RE: separate objects that are reusable/easier to maintain: We should use styled components for this case. The "sx prop" should be used for styles that are used in one spot, styled components are reusable and then we use the global theme to share styling variables. I think this is a helpful guide here: https://mui.com/material-ui/customization/how-to-customize