-
-
Notifications
You must be signed in to change notification settings - Fork 32.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
0d5173e
commit 5850daa
Showing
4 changed files
with
117 additions
and
4 deletions.
There are no files selected for viewing
49 changes: 49 additions & 0 deletions
49
docs/data/joy/components/snackbar/SnackbarWithDecorators.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,49 @@ | ||
import * as React from 'react'; | ||
import PropTypes from 'prop-types'; | ||
import Button from '@mui/joy/Button'; | ||
import Snackbar from '@mui/joy/Snackbar'; | ||
import PlaylistAddCheckCircleRoundedIcon from '@mui/icons-material/PlaylistAddCheckCircleRounded'; | ||
|
||
function CloseButton(props) { | ||
const { onClose } = props; | ||
return ( | ||
<Button onClick={onClose} size="sm" variant="solid" color="success"> | ||
Close | ||
</Button> | ||
); | ||
} | ||
|
||
CloseButton.propTypes = { | ||
onClose: PropTypes.func.isRequired, | ||
}; | ||
|
||
export default function SnackbarWithDecorators() { | ||
const [open, setOpen] = React.useState(false); | ||
|
||
const handleOpen = () => setOpen(true); | ||
|
||
const handleClose = () => setOpen(false); | ||
|
||
return ( | ||
<React.Fragment> | ||
<Button onClick={handleOpen}>Show Snackbar</Button> | ||
<Snackbar | ||
variant="soft" | ||
color="success" | ||
open={open} | ||
onClose={handleClose} | ||
slots={{ | ||
startDecorator: PlaylistAddCheckCircleRoundedIcon, | ||
endDecorator: CloseButton, | ||
}} | ||
slotProps={{ | ||
endDecorator: { | ||
onClose: handleClose, | ||
}, | ||
}} | ||
> | ||
Your message was sent successfully. | ||
</Snackbar> | ||
</React.Fragment> | ||
); | ||
} |
48 changes: 48 additions & 0 deletions
48
docs/data/joy/components/snackbar/SnackbarWithDecorators.tsx
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,48 @@ | ||
import * as React from 'react'; | ||
import Button from '@mui/joy/Button'; | ||
import Snackbar from '@mui/joy/Snackbar'; | ||
import PlaylistAddCheckCircleRoundedIcon from '@mui/icons-material/PlaylistAddCheckCircleRounded'; | ||
|
||
interface CloseButtonProps { | ||
onClose: () => React.Dispatch<React.SetStateAction<boolean>>; | ||
} | ||
|
||
function CloseButton(props: CloseButtonProps) { | ||
const { onClose } = props; | ||
return ( | ||
<Button onClick={onClose} size="sm" variant="solid" color="success"> | ||
Close | ||
</Button> | ||
); | ||
} | ||
|
||
export default function SnackbarWithDecorators() { | ||
const [open, setOpen] = React.useState(false); | ||
|
||
const handleOpen = () => setOpen(true); | ||
|
||
const handleClose = () => setOpen(false); | ||
|
||
return ( | ||
<React.Fragment> | ||
<Button onClick={handleOpen}>Show Snackbar</Button> | ||
<Snackbar | ||
variant="soft" | ||
color="success" | ||
open={open} | ||
onClose={handleClose} | ||
slots={{ | ||
startDecorator: PlaylistAddCheckCircleRoundedIcon, | ||
endDecorator: CloseButton, | ||
}} | ||
slotProps={{ | ||
endDecorator: { | ||
onClose: handleClose, | ||
}, | ||
}} | ||
> | ||
Your message was sent successfully. | ||
</Snackbar> | ||
</React.Fragment> | ||
); | ||
} |
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