forked from mui/material-ui
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Joy] Miscellaneous fixes (mui#33750)
- Loading branch information
1 parent
7133154
commit 118ab7b
Showing
56 changed files
with
1,132 additions
and
338 deletions.
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,25 @@ | ||
import * as React from 'react'; | ||
import JoyVariablesDemo from 'docs/src/modules/components/JoyVariablesDemo'; | ||
import Button from '@mui/joy/Button'; | ||
import FavoriteBorder from '@mui/icons-material/FavoriteBorder'; | ||
|
||
export default function ButtonVariables() { | ||
return ( | ||
<JoyVariablesDemo | ||
componentName="Button" | ||
renderCode={(formattedSx) => `<Button | ||
startIcon={<FavoriteBorder />}${formattedSx ? `${formattedSx}>` : '\n>'}`} | ||
data={[ | ||
{ | ||
var: '--Button-gap', | ||
defaultValue: '8px', | ||
}, | ||
]} | ||
renderDemo={(sx) => ( | ||
<Button sx={sx} startIcon={<FavoriteBorder />}> | ||
Favorite | ||
</Button> | ||
)} | ||
/> | ||
); | ||
} |
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,28 @@ | ||
import * as React from 'react'; | ||
import JoyVariablesDemo from 'docs/src/modules/components/JoyVariablesDemo'; | ||
import IconButton from '@mui/joy/IconButton'; | ||
import FavoriteBorder from '@mui/icons-material/FavoriteBorder'; | ||
|
||
export default function IconButtonVariables() { | ||
return ( | ||
<JoyVariablesDemo | ||
componentName="IconButton" | ||
renderCode={(formattedSx) => | ||
`<IconButton${formattedSx ? `${formattedSx}>` : '\n>'} | ||
<FavoriteBorder /> | ||
</IconButton>` | ||
} | ||
data={[ | ||
{ | ||
var: '--IconButton-size', | ||
defaultValue: '40px', | ||
}, | ||
]} | ||
renderDemo={(sx) => ( | ||
<IconButton sx={sx}> | ||
<FavoriteBorder /> | ||
</IconButton> | ||
)} | ||
/> | ||
); | ||
} |
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
72 changes: 72 additions & 0 deletions
72
docs/data/joy/components/checkbox/ExampleButtonCheckbox.js
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,72 @@ | ||
import * as React from 'react'; | ||
import Checkbox, { checkboxClasses } from '@mui/joy/Checkbox'; | ||
import List from '@mui/joy/List'; | ||
import ListItem from '@mui/joy/ListItem'; | ||
import ListItemDecorator from '@mui/joy/ListItemDecorator'; | ||
import LaptopIcon from '@mui/icons-material/Laptop'; | ||
import TvIcon from '@mui/icons-material/Tv'; | ||
import PhoneAndroidIcon from '@mui/icons-material/PhoneAndroid'; | ||
|
||
export default function ExampleButtonCheckbox() { | ||
const [value, setValue] = React.useState([]); | ||
return ( | ||
<List | ||
variant="soft" | ||
aria-label="Screens" | ||
role="group" | ||
row | ||
sx={{ | ||
flexGrow: 0, | ||
'--List-gap': '8px', | ||
'--List-padding': '8px', | ||
'--List-radius': '8px', | ||
}} | ||
> | ||
{['mobile', 'laptop', 'monitor'].map((item) => ( | ||
<ListItem key={item}> | ||
<ListItemDecorator | ||
sx={{ | ||
zIndex: 2, | ||
pointerEvents: 'none', | ||
...(value.includes(item) && { color: 'text.primary' }), | ||
}} | ||
> | ||
{ | ||
{ | ||
mobile: <PhoneAndroidIcon />, | ||
laptop: <LaptopIcon />, | ||
monitor: <TvIcon />, | ||
}[item] | ||
} | ||
</ListItemDecorator> | ||
<Checkbox | ||
disableIcon | ||
overlay | ||
label={item} | ||
checked={value.includes(item)} | ||
color="neutral" | ||
variant="plain" | ||
onChange={(event) => { | ||
if (event.target.checked) { | ||
setValue((val) => [...val, item]); | ||
} else { | ||
setValue((val) => val.filter((text) => text !== item)); | ||
} | ||
}} | ||
sx={{ | ||
[`& .${checkboxClasses.action}`]: { | ||
bgcolor: value.includes(item) ? 'background.surface' : 'transparent', | ||
boxShadow: value.includes(item) ? 'sm' : 'none', | ||
'&:hover': { | ||
bgcolor: value.includes(item) | ||
? 'background.surface' | ||
: 'transparent', | ||
}, | ||
}, | ||
}} | ||
/> | ||
</ListItem> | ||
))} | ||
</List> | ||
); | ||
} |
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 |
---|---|---|
@@ -0,0 +1,43 @@ | ||
import * as React from 'react'; | ||
import Avatar from '@mui/joy/Avatar'; | ||
import List from '@mui/joy/List'; | ||
import ListDivider from '@mui/joy/ListDivider'; | ||
import ListItem from '@mui/joy/ListItem'; | ||
import ListItemDecorator from '@mui/joy/ListItemDecorator'; | ||
|
||
export default function HorizontalDividedList() { | ||
return ( | ||
<List | ||
row | ||
variant="outlined" | ||
sx={{ | ||
borderRadius: 'sm', | ||
flexGrow: 0, | ||
mx: 'auto', | ||
'--List-decorator-width': '48px', | ||
'--List-item-paddingY': '1rem', | ||
}} | ||
> | ||
<ListItem> | ||
<ListItemDecorator sx={{ alignSelf: 'flex-start' }}> | ||
<Avatar size="sm" src="/static/images/avatar/1.jpg" /> | ||
</ListItemDecorator> | ||
Mabel Boyle | ||
</ListItem> | ||
<ListDivider inset="gutter" /> | ||
<ListItem> | ||
<ListItemDecorator sx={{ alignSelf: 'flex-start' }}> | ||
<Avatar size="sm" src="/static/images/avatar/2.jpg" /> | ||
</ListItemDecorator> | ||
Boyd Burt | ||
</ListItem> | ||
<ListDivider inset="gutter" /> | ||
<ListItem> | ||
<ListItemDecorator sx={{ alignSelf: 'flex-start' }}> | ||
<Avatar size="sm" src="/static/images/avatar/3.jpg" /> | ||
</ListItemDecorator> | ||
Adam Tris | ||
</ListItem> | ||
</List> | ||
); | ||
} |
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 |
---|---|---|
@@ -0,0 +1,90 @@ | ||
import * as React from 'react'; | ||
import Button from '@mui/joy/Button'; | ||
import List from '@mui/joy/List'; | ||
import ListItem from '@mui/joy/ListItem'; | ||
import ListItemDecorator from '@mui/joy/ListItemDecorator'; | ||
import ListDivider from '@mui/joy/ListDivider'; | ||
import Menu from '@mui/joy/Menu'; | ||
import MenuItem from '@mui/joy/MenuItem'; | ||
import ArrowRight from '@mui/icons-material/ArrowRight'; | ||
import ArrowDropDown from '@mui/icons-material/ArrowDropDown'; | ||
|
||
export default function BasicMenu() { | ||
const SIZES = ['X-Small', 'Small', 'Medium', 'Large', 'X-Large']; | ||
const [size, setSize] = React.useState('Medium'); | ||
const [anchorEl, setAnchorEl] = React.useState(null); | ||
const open = Boolean(anchorEl); | ||
const handleClick = (event) => { | ||
setAnchorEl(event.currentTarget); | ||
}; | ||
const handleClose = () => { | ||
setAnchorEl(null); | ||
}; | ||
|
||
return ( | ||
<div> | ||
<Button | ||
id="group-demo-button" | ||
aria-controls={open ? 'group-menu' : undefined} | ||
aria-haspopup="true" | ||
aria-expanded={open ? 'true' : undefined} | ||
variant="outlined" | ||
color="neutral" | ||
onClick={handleClick} | ||
endIcon={<ArrowDropDown />} | ||
> | ||
Size | ||
</Button> | ||
<Menu | ||
id="group-menu" | ||
anchorEl={anchorEl} | ||
open={open} | ||
onClose={handleClose} | ||
aria-labelledby="group-demo-button" | ||
sx={{ minWidth: 160, '--List-decorator-width': '24px' }} | ||
> | ||
<MenuItem | ||
onClick={() => { | ||
const nextIndex = SIZES.indexOf(size) - 1; | ||
const value = nextIndex < 0 ? SIZES[SIZES.length - 1] : SIZES[nextIndex]; | ||
setSize(value); | ||
handleClose(); | ||
}} | ||
> | ||
Smaller | ||
</MenuItem> | ||
<MenuItem | ||
onClick={() => { | ||
const nextIndex = SIZES.indexOf(size) + 1; | ||
const value = nextIndex > SIZES.length - 1 ? SIZES[0] : SIZES[nextIndex]; | ||
setSize(value); | ||
handleClose(); | ||
}} | ||
> | ||
Larger | ||
</MenuItem> | ||
<ListDivider /> | ||
<ListItem nested> | ||
<List aria-label="Font sizes"> | ||
{SIZES.map((item) => ( | ||
<MenuItem | ||
key={item} | ||
role="menuitemradio" | ||
aria-checked={item === size ? 'true' : 'false'} | ||
onClick={() => { | ||
setSize(item); | ||
handleClose(); | ||
}} | ||
> | ||
<ListItemDecorator> | ||
{item === size && <ArrowRight />} | ||
</ListItemDecorator>{' '} | ||
{item} | ||
</MenuItem> | ||
))} | ||
</List> | ||
</ListItem> | ||
</Menu> | ||
</div> | ||
); | ||
} |
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 |
---|---|---|
@@ -0,0 +1,40 @@ | ||
import * as React from 'react'; | ||
import List from '@mui/joy/List'; | ||
import ListItem from '@mui/joy/ListItem'; | ||
import MenuList from '@mui/joy/MenuList'; | ||
import MenuItem from '@mui/joy/MenuItem'; | ||
import Typography from '@mui/joy/Typography'; | ||
|
||
export default function MenuListGroup() { | ||
return ( | ||
<MenuList | ||
variant="outlined" | ||
size="sm" | ||
sx={{ | ||
boxShadow: 'sm', | ||
flexGrow: 0, | ||
minWidth: 200, | ||
maxHeight: 240, | ||
overflow: 'auto', | ||
}} | ||
> | ||
{[...Array(5)].map((_, categoryIndex) => ( | ||
<List role="group" key={categoryIndex}> | ||
<ListItem sticky> | ||
<Typography | ||
id={`sticky-list-demo-${categoryIndex}`} | ||
level="body3" | ||
textTransform="uppercase" | ||
fontWeight="lg" | ||
> | ||
Category {categoryIndex + 1} | ||
</Typography> | ||
</ListItem> | ||
{[...Array(10)].map((__, index) => ( | ||
<MenuItem key={index}>Action {index + 1}</MenuItem> | ||
))} | ||
</List> | ||
))} | ||
</MenuList> | ||
); | ||
} |
Oops, something went wrong.