-
-
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.
[Snackbar] Match the new specification
- Loading branch information
1 parent
2c2075e
commit b89cf43
Showing
11 changed files
with
159 additions
and
167 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
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 was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
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 React from 'react'; | ||
import Button from '@material-ui/core/Button'; | ||
import Snackbar from '@material-ui/core/Snackbar'; | ||
import Fade from '@material-ui/core/Fade'; | ||
import Slide from '@material-ui/core/Slide'; | ||
|
||
function TransitionSlide(props) { | ||
return <Slide {...props} direction="up" />; | ||
} | ||
|
||
function TransitionsSnackbar() { | ||
const [state, setState] = React.useState({ | ||
open: false, | ||
Transition: Fade, | ||
}); | ||
|
||
const handleClick = Transition => () => { | ||
setState({ | ||
open: true, | ||
Transition, | ||
}); | ||
}; | ||
|
||
function handleClose() { | ||
setState({ | ||
...state, | ||
open: false, | ||
}); | ||
} | ||
|
||
return ( | ||
<div> | ||
<Button onClick={handleClick(Fade)}>Fade Transition</Button> | ||
<Button onClick={handleClick(TransitionSlide)}>Slide Transition</Button> | ||
<Snackbar | ||
open={state.open} | ||
onClose={handleClose} | ||
TransitionComponent={state.Transition} | ||
ContentProps={{ | ||
'aria-describedby': 'message-id', | ||
}} | ||
message={<span id="message-id">I love snacks</span>} | ||
/> | ||
</div> | ||
); | ||
} | ||
|
||
export default TransitionsSnackbar; |
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 React from 'react'; | ||
import Button from '@material-ui/core/Button'; | ||
import Snackbar from '@material-ui/core/Snackbar'; | ||
import Fade from '@material-ui/core/Fade'; | ||
import Slide from '@material-ui/core/Slide'; | ||
import { TransitionProps } from '@material-ui/core/transitions/transition'; | ||
|
||
function TransitionSlide(props: TransitionProps) { | ||
return <Slide {...props} direction="up" />; | ||
} | ||
|
||
function TransitionsSnackbar() { | ||
const [state, setState] = React.useState({ | ||
open: false, | ||
Transition: Fade, | ||
}); | ||
|
||
const handleClick = (Transition: React.ComponentType<TransitionProps>) => () => { | ||
setState({ | ||
open: true, | ||
Transition, | ||
}); | ||
}; | ||
|
||
function handleClose() { | ||
setState({ | ||
...state, | ||
open: false, | ||
}); | ||
} | ||
|
||
return ( | ||
<div> | ||
<Button onClick={handleClick(Fade)}>Fade Transition</Button> | ||
<Button onClick={handleClick(TransitionSlide)}>Slide Transition</Button> | ||
<Snackbar | ||
open={state.open} | ||
onClose={handleClose} | ||
TransitionComponent={state.Transition} | ||
ContentProps={{ | ||
'aria-describedby': 'message-id', | ||
}} | ||
message={<span id="message-id">I love snacks</span>} | ||
/> | ||
</div> | ||
); | ||
} | ||
|
||
export default TransitionsSnackbar; |
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.