-
Notifications
You must be signed in to change notification settings - Fork 0
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
3/media query debugger #25
Closed
Closed
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
f9fc851
Adds gatsby-plugin sass and Sass
J-Byron f9763e9
Adds MediaQueryDebugger
J-Byron 234a8f6
remove log
J-Byron d9e47d8
removes jest to bypass webpack error
J-Byron 8c39527
adds jest to pass netlify
J-Byron db126c7
adds classnames
J-Byron 875928f
resolves test/linter errors
J-Byron File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
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,3 @@ | ||
module.exports = { | ||
plugins: [`gatsby-plugin-sass`] | ||
} |
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 |
---|---|---|
@@ -1,3 +1,2 @@ | ||
import Link from "./src/components/link" | ||
|
||
export { Link } | ||
import MediaQueryDebugger from './src/components/MediaQuerryDebugger/index' | ||
export {MediaQueryDebugger} |
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
14 changes: 14 additions & 0 deletions
14
src/components/MediaQuerryDebugger/__snapshots__/test.spec.js.snap
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,14 @@ | ||
// Jest Snapshot v1, https://goo.gl/fbAQLP | ||
|
||
exports[`MediaQueryDebugger renders correctly 1`] = ` | ||
<div | ||
className="debug" | ||
onKeyDown={[Function]} | ||
role="button" | ||
tabIndex={0} | ||
> | ||
<div | ||
className="debug_media_queries" | ||
/> | ||
</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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
import React, { useState } from 'react' | ||
import classNames from 'classnames/bind' | ||
import propTypes from 'prop-types' | ||
import styles from './styles.module.scss' | ||
|
||
const MediaQueryDebugger = ( props ) => { | ||
|
||
if (props.isVisible != 'true') return null | ||
|
||
const [isOpen, setOpen] = useState(false) | ||
|
||
const classes = classNames(styles.debug, isOpen, { | ||
[styles.is_showing]: isOpen | ||
}) | ||
|
||
return ( | ||
<div role="button" className={classes} tabIndex={0} onKeyDown={() => {setOpen(!isOpen)}} > | ||
<div className={styles.debug_media_queries} /> | ||
</div> | ||
) | ||
} | ||
|
||
MediaQueryDebugger.propTypes = { | ||
// a string determines whether or not the component should be visible | ||
isVisible: propTypes.string | ||
} | ||
|
||
export default MediaQueryDebugger |
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,23 @@ | ||
--- | ||
name: Media Query Debugger | ||
menu: Components | ||
route: /components/MediaQueryDebugger | ||
--- | ||
|
||
import { Playground, Props } from "docz" | ||
import MediaQueryDebugger from "./" | ||
|
||
# Media Query Debugger | ||
|
||
This component provides a quick way to find the current media query for faster local development. | ||
_The media query degugger is located in the bottom left of the browser durning local development_ | ||
|
||
## Usage | ||
|
||
``` | ||
yarn run develop:debug | ||
``` | ||
|
||
## Properties | ||
|
||
<Props of={MediaQueryDebugger} /> |
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,76 @@ | ||
$media-queries: ( | ||
smallest: 0, | ||
x-small-lowest: 360px, | ||
x-small: 400px, | ||
x-small-highest: 480px, | ||
small-lowest: 600px, | ||
small: 720px, | ||
small-highest: 840px, | ||
medium-lowest: 960px, | ||
medium: 1040px, | ||
large-lowest: 1280px, | ||
large: 1440px, | ||
large-highest: 1600px, | ||
x-large-lowest: 1920px, | ||
x-large: 2560px, | ||
x-large-highest: 3360px | ||
); | ||
|
||
// --------------------------------------------------------- | ||
|
||
$background-color: rgba(0, 0, 0, 0.8); | ||
$content-color: #ded; | ||
$size: 44px; | ||
|
||
// --------------------------------------------------------- | ||
|
||
.debug { | ||
align-items: center; | ||
background-color: $background-color; | ||
bottom: 0; | ||
display: flex; | ||
font-family: system-ui; | ||
height: $size; | ||
justify-content: center; | ||
left: 0; | ||
position: fixed; | ||
text-align: center; | ||
transition: width 0.3s ease-in-out; | ||
width: 0; | ||
z-index: 4; | ||
|
||
&:after { | ||
background-color: transparent; | ||
border-color: transparent transparent transparent $background-color; | ||
border-style: solid; | ||
border-width: $size 0 0 $size; | ||
content: ''; | ||
display: block; | ||
position: absolute; | ||
right: -$size; | ||
} | ||
|
||
&.is_showing { | ||
width: 100vw; | ||
} | ||
} | ||
|
||
.debug_media_queries { | ||
font-size: 0; | ||
opacity: 0; | ||
transition: opacity 0.5s 0.1s ease-in-out; | ||
|
||
.is_showing & { | ||
color: $content-color; | ||
font-size: 12px; | ||
opacity: 1; | ||
} | ||
|
||
@each $mq in $media-queries { | ||
@media screen and (min-width: nth($mq, 2)) { | ||
&::after { | ||
content: '#{nth($mq, 1)} - min-width: #{nth($mq, 2)}'; | ||
} | ||
} | ||
} | ||
} |
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,10 @@ | ||
import React from "react" | ||
import renderer from "react-test-renderer" | ||
import MediaQueryDebugger from "./index" | ||
|
||
describe("MediaQueryDebugger", () => { | ||
it("renders correctly", () => { | ||
const tree = renderer.create(<MediaQueryDebugger isVisible={'true'}/>).toJSON() | ||
expect(tree).toMatchSnapshot() | ||
}) | ||
}) |
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
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.
This was previously
process.env.GATSBY_DEBUG_MEDIA_QUERIES !== 'true'
. It was replaced to resolve an eslint error that was blocking the build pipeline.