-
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.
Create CurrentBreakPoint component w/ docs
- Loading branch information
Justin Campbell
committed
Oct 20, 2020
1 parent
f3d742a
commit fab0719
Showing
3 changed files
with
77 additions
and
0 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,46 @@ | ||
| import React from "react"; | ||
| import PropTypes from "prop-types"; | ||
| import { useTheme, useMediaQuery, makeStyles } from '@material-ui/core'; | ||
|
|
||
| export default function CurrentBreakPoint(){ | ||
| const theme = useTheme(); | ||
| const useStyles = makeStyles({ | ||
| true: { | ||
| color: theme.palette.success.main | ||
| }, | ||
| false: { | ||
| color: theme.palette.error.main | ||
| } | ||
| }); | ||
| const classes = useStyles(); | ||
|
|
||
| const mediaQueries = { | ||
| "xs": useMediaQuery(theme.breakpoints.up('xs')), | ||
| "sm": useMediaQuery(theme.breakpoints.up('sm')), | ||
| "md": useMediaQuery(theme.breakpoints.up('md')), | ||
| "lg": useMediaQuery(theme.breakpoints.up('lg')), | ||
| "xl": useMediaQuery(theme.breakpoints.up('xl')), | ||
| } | ||
|
|
||
| return ( | ||
| <p style={{ margin: "0px" }}> | ||
| { Object.keys(mediaQueries).map( (key) => { | ||
| console.log("Key: ", key) | ||
| console.log("Value: ", mediaQueries.key) | ||
| return( | ||
| <span className={ mediaQueries[key] ? classes.true : classes.false }> | ||
| {`${key.toUpperCase()}: ${ mediaQueries[key] ? "true" : "false"}\n\n\n\n`} | ||
| </span> | ||
| ) | ||
| })} | ||
| </p> | ||
| ); | ||
| } | ||
|
|
||
| CurrentBreakPoint.propTypes = { | ||
|
|
||
| }; | ||
|
|
||
| CurrentBreakPoint.defaultProps = { | ||
|
|
||
| }; |
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,30 @@ | ||
| Displays the MUI theme breakpoints and whether or not they are active. This is a utility component meant to make UI development easier, not as a UI element for production code. | ||
|
|
||
| It must be used under a [ThemeProvider](https://material-ui.com/styles/api/#themeprovider). | ||
|
|
||
| --- | ||
|
|
||
| ```jsx | ||
| import { ThemeProvider } from '@material-ui/core/styles'; | ||
| import { Paper, makeStyles } from '@material-ui/core'; | ||
| import webqueue2Theme from "../../theme.js"; | ||
| import CurrentBreakPoint from "./CurrentBreakPoint"; | ||
|
|
||
| const theme = webqueue2Theme(false); | ||
|
|
||
| const useStyles = makeStyles({ | ||
| paperPadding: { | ||
| padding: theme.spacing(1) | ||
| } | ||
| }); | ||
| const classes = useStyles(); | ||
|
|
||
| <ThemeProvider theme={theme}> | ||
| <Paper classes={{ root: classes.paperPadding }}> | ||
| <CurrentBreakPoint /> | ||
| </Paper> | ||
| </ThemeProvider> | ||
| ``` | ||
| ```jsx static | ||
| <CurrentBreakPoint /> | ||
| ``` |
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 @@ | ||
| export { default } from "./CurrentBreakPoint"; |