-
-
Notifications
You must be signed in to change notification settings - Fork 32.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
[website] X component section improvements #36598
Merged
+319
−165
Merged
Changes from all commits
Commits
Show all changes
21 commits
Select commit
Hold shift + click to select a range
3eeab1e
add X-components section tweaks
danilo-leal 0e0a370
delete unused commented code
danilo-leal 608dc44
Update main data grid demo with Premium features
joserodolfofreitas 195e56f
Add shortcuts to date range demo
joserodolfofreitas 9145fb2
change label
danilo-leal 6a1cd2c
checkout test error: yarn deduplicate
danilo-leal e41e893
yarn docs:api
danilo-leal 26a60fe
Merge branch 'master' into x-components-website-section-tweaks
danilo-leal d2e1f81
Merge remote-tracking branch 'origin/master' into x-components-websit…
danilo-leal 39f30da
Merge branch 'master' into x-components-website-section-tweaks
mnajdova b345b33
yarn.lock
mnajdova 44d7bfe
Update x packages
joserodolfofreitas ee76ef0
Less shortcuts so date range demo fits better on the box
joserodolfofreitas 0c3eca1
Fix alignment on date range shortcuts
joserodolfofreitas ab16fa6
Migrate X components APIs to v6 and fix type issues
joserodolfofreitas 3a76c95
Prettier and traspile
joserodolfofreitas 8482aa5
Display date selection on landing page demo by default. docs:formatted
joserodolfofreitas afaffc0
Prettier
joserodolfofreitas 1d62eb9
Reorganize date range demo imports
joserodolfofreitas 0c4c8ca
Small polishing on data grid main demo
joserodolfofreitas 0775531
Lint
joserodolfofreitas 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 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
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 |
---|---|---|
@@ -1,7 +1,6 @@ | ||
<DataGrid | ||
rows={rows} | ||
columns={columns} | ||
pageSize={5} | ||
rowsPerPageOptions={[5]} | ||
paginationModel={{ page: 0, pageSize: 5 }} | ||
checkboxSelection | ||
/> |
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,22 +1,99 @@ | ||
import * as React from 'react'; | ||
import Box from '@mui/material/Box'; | ||
import Chip from '@mui/material/Chip'; | ||
import Button from '@mui/material/Button'; | ||
import Paper from '@mui/material/Paper'; | ||
import Typography from '@mui/material/Typography'; | ||
import TextField from '@mui/material/TextField'; | ||
import { DateRange } from '@mui/x-date-pickers-pro/DateRangePicker'; | ||
import Chip from '@mui/material/Chip'; | ||
import Divider from '@mui/material/Divider'; | ||
import List from '@mui/material/List'; | ||
import ListItem from '@mui/material/ListItem'; | ||
import Frame from 'docs/src/components/action/Frame'; | ||
import { StaticDateRangePicker } from '@mui/x-date-pickers-pro/StaticDateRangePicker'; | ||
import { PickersShortcutsItem, PickersShortcutsProps, DateRange } from '@mui/x-date-pickers-pro'; | ||
import { AdapterDateFns } from '@mui/x-date-pickers/AdapterDateFns'; | ||
import { LocalizationProvider } from '@mui/x-date-pickers/LocalizationProvider'; | ||
import Frame from 'docs/src/components/action/Frame'; | ||
import { startOfWeek, endOfWeek, subDays } from 'date-fns'; | ||
|
||
const startDate = new Date(); | ||
startDate.setDate(10); | ||
const endDate = new Date(); | ||
endDate.setDate(endDate.getDate() + 28); | ||
|
||
function CustomRangeShortcuts(props: PickersShortcutsProps<DateRange<Date>>) { | ||
const { items, onChange, isValid } = props; | ||
|
||
if (items == null || items.length === 0) { | ||
return null; | ||
} | ||
|
||
const resolvedItems = items.map((item: PickersShortcutsItem<DateRange<Date>>) => { | ||
const newValue = item.getValue({ isValid }); | ||
|
||
return { | ||
label: item.label, | ||
onClick: () => { | ||
onChange(newValue); | ||
}, | ||
disabled: !isValid(newValue), | ||
}; | ||
}); | ||
|
||
return ( | ||
<Box | ||
sx={{ | ||
gridRow: 1, | ||
gridColumn: 2, | ||
}} | ||
> | ||
<List | ||
dense | ||
sx={(theme) => ({ | ||
display: 'flex', | ||
px: theme.spacing(4), | ||
'& .MuiListItem-root': { | ||
py: 2, | ||
pr: theme.spacing(1), | ||
}, | ||
})} | ||
> | ||
{resolvedItems.map((item) => { | ||
return ( | ||
<ListItem key={item.label}> | ||
<Chip {...item} /> | ||
</ListItem> | ||
); | ||
})} | ||
</List> | ||
<Divider /> | ||
</Box> | ||
); | ||
} | ||
|
||
export default function XDateRangeDemo() { | ||
const [value, setValue] = React.useState<DateRange<Date>>([startDate, endDate]); | ||
const today = new Date(); | ||
const shortcutsItems: PickersShortcutsItem<DateRange<Date>>[] = [ | ||
{ | ||
label: 'This Week', | ||
getValue: () => { | ||
return [startOfWeek(today), endOfWeek(today)]; | ||
}, | ||
}, | ||
{ | ||
label: 'Last Week', | ||
getValue: () => { | ||
const prevWeek = subDays(today, 7); | ||
return [startOfWeek(prevWeek), endOfWeek(prevWeek)]; | ||
}, | ||
}, | ||
{ | ||
label: 'Last 7 Days', | ||
getValue: () => { | ||
return [subDays(today, 7), today]; | ||
}, | ||
}, | ||
{ label: 'Reset', getValue: () => [null, null] }, | ||
]; | ||
|
||
return ( | ||
<Frame> | ||
<Frame.Demo sx={{ p: 2 }}> | ||
|
@@ -67,17 +144,15 @@ export default function XDateRangeDemo() { | |
<LocalizationProvider dateAdapter={AdapterDateFns}> | ||
<StaticDateRangePicker | ||
displayStaticWrapperAs="desktop" | ||
value={value} | ||
onChange={(newValue) => { | ||
setValue(newValue); | ||
value={[startDate, endDate]} | ||
slots={{ | ||
shortcuts: CustomRangeShortcuts, | ||
}} | ||
slotProps={{ | ||
shortcuts: { | ||
items: shortcutsItems, | ||
}, | ||
}} | ||
renderInput={(startProps, endProps) => ( | ||
<React.Fragment> | ||
<TextField {...startProps} /> | ||
<Box sx={{ mx: 2 }}> to </Box> | ||
<TextField {...endProps} /> | ||
</React.Fragment> | ||
)} | ||
/> | ||
</LocalizationProvider> | ||
</Paper> | ||
|
@@ -87,20 +162,20 @@ export default function XDateRangeDemo() { | |
sx={{ | ||
display: 'flex', | ||
alignItems: 'center', | ||
lineHeight: 1, | ||
mb: 0.5, | ||
justifyContent: 'space-between', | ||
}} | ||
> | ||
<Typography variant="body2" fontWeight="bold" sx={{ mr: 1 }}> | ||
Available now for your project. | ||
🎉 Stable version available now for your project! | ||
danilo-leal marked this conversation as resolved.
Show resolved
Hide resolved
|
||
</Typography> | ||
<Chip | ||
label="See docs" | ||
size="small" | ||
href="/x/react-date-pickers/date-range-picker/" | ||
<Button | ||
variant="outlined" | ||
href="/x/react-Date-pickers/Date-range-picker/" | ||
Comment on lines
-100
to
+173
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. Fixed in 5530804 |
||
component="a" | ||
sx={{ fontWeight: 500, cursor: 'pointer' }} | ||
/> | ||
sx={{ mt: { xs: 2, sm: 0 }, color: 'primary.300' }} | ||
> | ||
View more demos | ||
</Button> | ||
</Box> | ||
</Frame.Info> | ||
</Frame> | ||
|
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.
Are we sure about this change? Clicking on the page button no longer work: https://deploy-preview-36598--material-ui.netlify.app/material-ui/react-table/#data-table
I'm coming from: https://mui-org.slack.com/archives/C041SDSF32L/p1682708252800599 cc @cherniavskii for guidance.
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.
Right, I'll submit a PR 👍 #37114