-
-
Notifications
You must be signed in to change notification settings - Fork 32.2k
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
[material-next][Select] Refactor to use Base UI's hooks #40210
Closed
Closed
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
f247cce
Replace basic props to use useSelect values
DiegoAndai 9c12c96
Add Option component
DiegoAndai 0ed1339
Refactor SelectInput to use useSelect
DiegoAndai 7dcc2d8
Add experiments page
DiegoAndai 56d7244
Fix tests
DiegoAndai 0f5f676
Remove ripple from combobox button
DiegoAndai d1327d7
Fix tests
DiegoAndai 3e34ad4
Tidy SelectInput prop objects
DiegoAndai 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,96 @@ | ||
import * as React from 'react'; | ||
import { | ||
Box, | ||
Stack, | ||
createTheme, | ||
InputLabel, | ||
FormControl, | ||
ThemeProvider, | ||
Select as MaterialV5Select, | ||
MenuItem, | ||
} from '@mui/material'; | ||
import { Select as MaterialNextSelect, Option, SelectChangeEvent } from '@mui/material-next'; | ||
import Typography from 'docs/src/pages/premium-themes/onepirate/modules/components/Typography'; | ||
|
||
const theme = createTheme({}); | ||
|
||
const options = [ | ||
{ value: 10, label: 'Ten' }, | ||
{ value: 20, label: 'Twenty' }, | ||
{ value: 30, label: 'Thirty' }, | ||
{ value: 40, label: 'Forty' }, | ||
{ value: 50, label: 'Fifty' }, | ||
{ value: 60, label: 'Sixty' }, | ||
{ value: 70, label: 'Seventy' }, | ||
]; | ||
|
||
function MaterialV5Example() { | ||
const [age, setAge] = React.useState(''); | ||
|
||
const handleChange = (event: SelectChangeEvent) => { | ||
setAge(event.target.value); | ||
}; | ||
|
||
return ( | ||
<Box sx={{ pl: 2, width: 320 }}> | ||
<FormControl fullWidth> | ||
<InputLabel id="demo-simple-select-label">Age</InputLabel> | ||
<MaterialV5Select | ||
labelId="demo-simple-select-label" | ||
id="demo-simple-select" | ||
value={age} | ||
onChange={handleChange} | ||
label="Age" | ||
> | ||
{options.map(({ value, label, ...rest }) => ( | ||
<MenuItem {...rest} key={value} value={value}> | ||
{label} | ||
</MenuItem> | ||
))} | ||
</MaterialV5Select> | ||
</FormControl> | ||
</Box> | ||
); | ||
} | ||
|
||
function MaterialNextExample() { | ||
const [age, setAge] = React.useState(''); | ||
|
||
const handleChange = (event: SelectChangeEvent) => { | ||
setAge(event.target.value); | ||
}; | ||
|
||
return ( | ||
<Box sx={{ pl: 2, width: 320 }}> | ||
<FormControl fullWidth> | ||
<InputLabel id="demo-simple-select-label">Age</InputLabel> | ||
<MaterialNextSelect | ||
labelId="demo-simple-select-label" | ||
id="demo-simple-select" | ||
value={age} | ||
onChange={handleChange} | ||
label="Age" | ||
> | ||
{options.map(({ value, label, ...rest }) => ( | ||
<Option {...rest} key={value} value={value}> | ||
{label} | ||
</Option> | ||
))} | ||
</MaterialNextSelect> | ||
</FormControl> | ||
</Box> | ||
); | ||
} | ||
|
||
export default function Experiment() { | ||
return ( | ||
<ThemeProvider theme={theme}> | ||
<Stack mt={4} spacing={4}> | ||
<Typography variant="h4">V5:</Typography> | ||
<MaterialV5Example /> | ||
<Typography variant="h4">Material Next:</Typography> | ||
<MaterialNextExample /> | ||
</Stack> | ||
</ThemeProvider> | ||
); | ||
} |
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
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.
We will need to create a follow-up issue for this one as it will depend on the changes for the Material You design, which we're not doing right now.