Skip to content

Commit

Permalink
chore: repo cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
yocontra committed Mar 29, 2023
1 parent 09c851e commit 5046733
Show file tree
Hide file tree
Showing 23 changed files with 356 additions and 254 deletions.
2 changes: 2 additions & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
dist
docs
12 changes: 4 additions & 8 deletions .eslintrc.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,9 @@
module.exports = {
parser: '@typescript-eslint/parser',
rules: {
...{
'no-extra-parens': 0,
'@typescript-eslint/no-extra-parens': 1,
'quotes': [1, 'single'],
}
'no-extra-parens': 0,
'@typescript-eslint/no-extra-parens': 1,
quotes: [1, 'single']
},
extends: [
'plugin:@typescript-eslint/recommended'
]
extends: ['plugin:@typescript-eslint/recommended']
}
2 changes: 2 additions & 0 deletions .prettierignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
dist
docs
6 changes: 4 additions & 2 deletions .prettierrc
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
{
"singleQuote": true
}
"singleQuote": true,
"trailingComma": "none",
"semi": false
}
42 changes: 41 additions & 1 deletion CHANGELOG.md

Large diffs are not rendered by default.

58 changes: 24 additions & 34 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
<td>Browser Version</td>
<td>>= IE6*</td>
</tr>
</tr>
<tr>
<td colspan='2'><a href='http://contra.io/react-responsive/'>Demo</a></td>
</tr>
Expand Down Expand Up @@ -47,14 +46,16 @@ const Example = () => {
const isPortrait = useMediaQuery({ query: '(orientation: portrait)' })
const isRetina = useMediaQuery({ query: '(min-resolution: 2dppx)' })

return <div>
<h1>Device Test!</h1>
{isDesktopOrLaptop && <p>You are a desktop or laptop</p>}
{isBigScreen && <p>You have a huge screen</p>}
{isTabletOrMobile && <p>You are a tablet or mobile phone</p>}
<p>Your are in {isPortrait ? 'portrait' : 'landscape'} orientation</p>
{isRetina && <p>You are retina</p>}
</div>
return (
<div>
<h1>Device Test!</h1>
{isDesktopOrLaptop && <p>You are a desktop or laptop</p>}
{isBigScreen && <p>You have a huge screen</p>}
{isTabletOrMobile && <p>You are a tablet or mobile phone</p>}
<p>Your are in {isPortrait ? 'portrait' : 'landscape'} orientation</p>
{isRetina && <p>You are retina</p>}
</div>
)
}
```

Expand All @@ -75,9 +76,7 @@ const Example = () => (
<MediaQuery minResolution="2dppx">
{/* You can also use a function (render prop) as a child */}
{(matches) =>
matches
? <p>You are retina</p>
: <p>You are not retina</p>
matches ? <p>You are retina</p> : <p>You are not retina</p>
}
</MediaQuery>
</div>
Expand Down Expand Up @@ -107,11 +106,7 @@ const Example = () => {
const isPortrait = useMediaQuery({ orientation: 'portrait' })
const isRetina = useMediaQuery({ minResolution: '2dppx' })

return (
<div>
...
</div>
)
return <div>...</div>
}
```

Expand All @@ -137,18 +132,18 @@ import { useMediaQuery } from 'react-responsive'

const Example = () => {
const isDesktopOrLaptop = useMediaQuery(
{ minDeviceWidth: 1224 },
{ deviceWidth: 1600 } // `device` prop
{ minDeviceWidth: 1224 },
{ deviceWidth: 1600 } // `device` prop
)

return (
<div>
{isDesktopOrLaptop &&
{isDesktopOrLaptop && (
<p>
this will always get rendered even if device is shorter than 1224px,
that's because we overrode device settings with 'deviceWidth: 1600'.
</p>
}
)}
</div>
)
}
Expand Down Expand Up @@ -213,19 +208,16 @@ import React from 'react'
import { useMediaQuery } from 'react-responsive'
const Example = () => {
const handleMediaQueryChange = (matches) => {
// matches will be true or false based on the value for the media query
}
const isDesktopOrLaptop = useMediaQuery(
{ minWidth: 1224 }, undefined, handleMediaQueryChange
);
return (
<div>
...
</div>
{ minWidth: 1224 },
undefined,
handleMediaQueryChange
)
return <div>...</div>
}
```

Expand All @@ -234,7 +226,6 @@ import React from 'react'
import MediaQuery from 'react-responsive'
const Example = () => {
const handleMediaQueryChange = (matches) => {
// matches will be true or false based on the value for the media query
}
Expand Down Expand Up @@ -286,13 +277,13 @@ export default Example
And if you want a combo (the DRY way):
```js
import { useMediaQuery } from "react-responsive"
import { useMediaQuery } from 'react-responsive'
const useDesktopMediaQuery = () =>
useMediaQuery({ query: "(min-width: 1280px)" })
useMediaQuery({ query: '(min-width: 1280px)' })
const useTabletAndBelowMediaQuery = () =>
useMediaQuery({ query: "(max-width: 1279px)" })
useMediaQuery({ query: '(max-width: 1279px)' })
const Desktop = ({ children }) => {
const isDesktop = useDesktopMediaQuery()
Expand All @@ -307,7 +298,6 @@ const TabletAndBelow = ({ children }) => {
}
```
## Browser Support
### Out of the box
Expand Down
15 changes: 3 additions & 12 deletions dist/cjs/index.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion dist/cjs/index.js.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

15 changes: 3 additions & 12 deletions dist/esm/index.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 5046733

Please sign in to comment.