Skip to content
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
merged 21 commits into from
Apr 20, 2023
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
3eeab1e
add X-components section tweaks
danilo-leal Mar 21, 2023
0e0a370
delete unused commented code
danilo-leal Mar 21, 2023
608dc44
Update main data grid demo with Premium features
joserodolfofreitas Mar 24, 2023
195e56f
Add shortcuts to date range demo
joserodolfofreitas Mar 24, 2023
9145fb2
change label
danilo-leal Mar 28, 2023
6a1cd2c
checkout test error: yarn deduplicate
danilo-leal Mar 28, 2023
e41e893
yarn docs:api
danilo-leal Mar 28, 2023
26a60fe
Merge branch 'master' into x-components-website-section-tweaks
danilo-leal Apr 11, 2023
d2e1f81
Merge remote-tracking branch 'origin/master' into x-components-websit…
danilo-leal Apr 17, 2023
39f30da
Merge branch 'master' into x-components-website-section-tweaks
mnajdova Apr 17, 2023
b345b33
yarn.lock
mnajdova Apr 17, 2023
44d7bfe
Update x packages
joserodolfofreitas Apr 20, 2023
ee76ef0
Less shortcuts so date range demo fits better on the box
joserodolfofreitas Apr 20, 2023
0c3eca1
Fix alignment on date range shortcuts
joserodolfofreitas Apr 20, 2023
ab16fa6
Migrate X components APIs to v6 and fix type issues
joserodolfofreitas Apr 20, 2023
3a76c95
Prettier and traspile
joserodolfofreitas Apr 20, 2023
8482aa5
Display date selection on landing page demo by default. docs:formatted
joserodolfofreitas Apr 20, 2023
afaffc0
Prettier
joserodolfofreitas Apr 20, 2023
1d62eb9
Reorganize date range demo imports
joserodolfofreitas Apr 20, 2023
0c4c8ca
Small polishing on data grid main demo
joserodolfofreitas Apr 20, 2023
0775531
Lint
joserodolfofreitas Apr 20, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions docs/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -44,12 +44,12 @@
"@mui/styles": "^5.11.13",
"@mui/system": "^5.11.13",
"@mui/types": "^7.2.3",
"@mui/x-data-grid": "6.0.0-alpha.14",
"@mui/x-data-grid-generator": "6.0.0-alpha.14",
"@mui/x-data-grid-pro": "6.0.0-alpha.14",
"@mui/x-date-pickers": "6.0.0-alpha.14",
"@mui/x-date-pickers-pro": "6.0.0-alpha.14",
"@mui/x-license-pro": "6.0.0-alpha.14",
"@mui/x-data-grid": "6.0.3",
"@mui/x-data-grid-generator": "6.0.3",
"@mui/x-data-grid-pro": "6.0.3",
"@mui/x-date-pickers": "6.0.3",
"@mui/x-date-pickers-pro": "6.0.3",
"@mui/x-license-pro": "6.0.3",
"@react-spring/web": "^9.7.1",
"@trendmicro/react-interpolate": "^0.5.5",
"@types/autosuggest-highlight": "^3.2.0",
Expand Down
8 changes: 4 additions & 4 deletions docs/src/components/action/Frame.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -49,12 +49,12 @@ function Frame(props: BoxProps) {
display: 'flex',
flexDirection: 'column',
'& > div:first-of-type': {
borderTopLeftRadius: '10px',
borderTopRightRadius: '10px',
borderTopLeftRadius: '12px',
borderTopRightRadius: '12px',
},
'& > div:last-of-type': {
borderBottomLeftRadius: '10px',
borderBottomRightRadius: '10px',
borderBottomLeftRadius: '12px',
borderBottomRightRadius: '12px',
},
...props.sx,
}}
Expand Down
2 changes: 1 addition & 1 deletion docs/src/components/productX/XComponents.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ function PrefetchImages() {
}

export default function XComponents() {
const [demo, setDemo] = React.useState(DEMOS[0]);
const [demo, setDemo] = React.useState(DEMOS[1]);
const icons = {
[DEMOS[0]]: <TableChartRounded fontSize="small" />,
[DEMOS[1]]: <DateRangeRounded fontSize="small" />,
Expand Down
128 changes: 109 additions & 19 deletions docs/src/components/productX/XDateRangeDemo.tsx
Original file line number Diff line number Diff line change
@@ -1,22 +1,111 @@
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 { PickersShortcutsItem, DateRange } from '@mui/x-date-pickers-pro';
import { StaticDateRangePicker } from '@mui/x-date-pickers-pro/StaticDateRangePicker';
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, startOfMonth, endOfMonth, addMonths } from 'date-fns';
import { Chip, Divider, List, ListItem } from '@mui/material';

const startDate = new Date();
startDate.setDate(10);
const endDate = new Date();
endDate.setDate(endDate.getDate() + 28);

function CustomRangeShortcuts(props: PickersShortcutsProps<DateRange<Dayjs>>) {
const { items, onChange, isValid } = props;

if (items == null || items.length === 0) {
return null;
}

const resolvedItems = items.map((item) => {
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,
pl: 0,
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: 'Current Month',
getValue: () => {
return [startOfMonth(today), endOfMonth(today)];
},
},
{
label: 'Next Month',
getValue: () => {
const nextMonth = addMonths(today, 1);
return [startOfMonth(nextMonth), endOfMonth(nextMonth)];
},
},
{ label: 'Reset', getValue: () => [null, null] },
];

return (
<Frame>
<Frame.Demo sx={{ p: 2 }}>
Expand Down Expand Up @@ -71,13 +160,14 @@ export default function XDateRangeDemo() {
onChange={(newValue) => {
setValue(newValue);
}}
renderInput={(startProps, endProps) => (
<React.Fragment>
<TextField {...startProps} />
<Box sx={{ mx: 2 }}> to </Box>
<TextField {...endProps} />
</React.Fragment>
)}
slots={{
shortcuts: CustomRangeShortcuts,
}}
slotProps={{
shortcuts: {
items: shortcutsItems,
},
}}
/>
</LocalizationProvider>
</Paper>
Expand All @@ -87,20 +177,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.
🎉&nbsp;&nbsp;&nbsp;Stable version available now for your project!
</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
Copy link
Member

Choose a reason for hiding this comment

The 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' }}
>
Check the docs
</Button>
</Box>
</Frame.Info>
</Frame>
Expand Down
9 changes: 7 additions & 2 deletions docs/src/components/productX/XGridFullDemo.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ function SettingsPanel(props: GridToolbarContainerProps) {
sx={{
flexDirection: { xs: 'column', sm: 'row' },
alignContent: { xs: 'start', sm: 'center' },
alignItems: { xs: 'start', sm: 'center' },
'& > *': {
'&:not(:first-child)': { ml: { xs: 0, sm: 1 } },
'&:last-child': { ml: 'auto' },
Expand Down Expand Up @@ -102,7 +103,11 @@ function SettingsPanel(props: GridToolbarContainerProps) {
<MenuItem value={1000}>{Number(1000).toLocaleString()}</MenuItem>
</Select>
</FormControl>
<Button onClick={handleApplyChanges} sx={{ mt: { xs: 2, sm: 0 } }}>
<Button
variant="outlined"
onClick={handleApplyChanges}
sx={{ mt: { xs: 2, sm: 0 }, color: 'primary.300', height: 'fit-content' }}
>
Apply changes
</Button>
</FormGroup>
Expand Down Expand Up @@ -222,7 +227,7 @@ export default function XGridFullDemo() {
/>
</Paper>
</Frame.Demo>
<Frame.Info data-mui-color-scheme="dark" sx={{ p: 1 }}>
<Frame.Info data-mui-color-scheme="dark" sx={{ pl: 1, pr: 2, py: 2 }}>
<SettingsPanel onApply={handleApplyClick} size={size} type={type} />
</Frame.Info>
</Frame>
Expand Down
Loading