-
-
Notifications
You must be signed in to change notification settings - Fork 31.8k
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
[Joy] Miscellaneous fixes #33750
Merged
Merged
[Joy] Miscellaneous fixes #33750
Changes from all commits
Commits
Show all changes
28 commits
Select commit
Hold shift + click to select a range
8d0baf2
fix dom mismatch
siriwatknp 7d2f80b
add inset gutter to ListDivider for horizontal list
siriwatknp 06effd8
make IconButton icon scalable
siriwatknp 8b39edb
add default color to Radio and Checkbox
siriwatknp f977c3a
add viewport demo
siriwatknp da11a0d
switch track should not shrink
siriwatknp 1c9a0b7
add vertical slider demo
siriwatknp 21a45dd
revert
siriwatknp bf23e73
fix select bg
siriwatknp 477bb02
don't add negative margin for nested typography
siriwatknp 41bdd9c
fix componentsProps input component
siriwatknp 054df09
add group demo
siriwatknp 2919a34
add stickyTop variable to ListItem
siriwatknp c844615
add MenuListGroup demo
siriwatknp a726adf
move logic to ListProvider
siriwatknp cac3283
add display none to TabPanel
siriwatknp aedcf5c
gap follows orientation
siriwatknp 06c28f7
inherit size
siriwatknp 51587ce
remove scoped prop
siriwatknp 0a02b06
use context to inherit size
siriwatknp 870ce15
update demo
siriwatknp 21b2bc8
reset variables in scope
siriwatknp 6cc6f0c
fix demo
siriwatknp 6e45d38
fix proptype
siriwatknp c64ce94
add radio example
siriwatknp 7b44aa9
fix radio usage
siriwatknp b6ffb34
fix lint
siriwatknp 8dd6ab7
fix demos
siriwatknp File filter
Filter by extension
Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
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,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
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -77,6 +77,10 @@ The `ListDivider` component comes with four `inset` patterns: | |||||
|
||||||
{{"demo": "DividedList.js"}} | ||||||
|
||||||
For horizontal list, only `inset="gutter"` works on list divider. | ||||||
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.
Suggested change
|
||||||
|
||||||
{{"demo": "HorizontalDividedList.js"}} | ||||||
|
||||||
### Sticky item | ||||||
|
||||||
To have a sticky list item, use a `List` as a child of the `Sheet` component. | ||||||
|
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.
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.
Just so we have consistent pages throughout!