Skip to content

Commit 2736e88

Browse files
authored
Merge pull request #215 from medyo/fix-dynamic-breakpoint-view
Fix card display issue on mobile
2 parents 79183a2 + 4db152e commit 2736e88

8 files changed

Lines changed: 57 additions & 25 deletions

File tree

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,13 +20,13 @@
2020
"prop-types": "^15.0.0-0",
2121
"react": "^17.0.1",
2222
"react-contexify": "^5.0.0",
23-
"react-device-detect": "^1.17.0",
2423
"react-dom": "^17.0.1",
2524
"react-easy-sort": "^1.5.1",
2625
"react-error-boundary": "^3.1.4",
2726
"react-icons": "^5.2.1",
2827
"react-markdown": "^7.0.1",
2928
"react-modal": "^3.12.1",
29+
"react-responsive": "^10.0.1",
3030
"react-router-dom": "^6.21.0",
3131
"react-select": "^5.0.1",
3232
"react-share": "^4.4.1",

src/assets/App.css

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -999,7 +999,7 @@ Producthunt item
999999
*** BREAKPOINTS
10001000
*******************/
10011001
/* Extra small devices (phones, 600px and down) */
1002-
@media (max-width: 600px) {
1002+
@media (max-width: 768px) {
10031003
.bottomNavigation {
10041004
display: flex;
10051005
}
@@ -1192,7 +1192,7 @@ Producthunt item
11921192
}
11931193

11941194
/* Small devices (portrait tablets and large phones, 600px and up) */
1195-
@media only screen and (min-width: 600px) {
1195+
@media only screen and (min-width: 768px) {
11961196
.floatingFilter {
11971197
display: none;
11981198
}

src/components/Elements/Card/Card.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
import React, { useEffect, useState } from 'react'
2-
import { isDesktop } from 'react-device-detect'
32
import { SortableKnob } from 'react-easy-sort'
43
import { BsBoxArrowInUpRight } from 'react-icons/bs'
54
import { MdOutlineDragIndicator } from 'react-icons/md'
65
import { ref } from 'src/config'
76
import { AdvBanner } from 'src/features/adv'
87
import { useRemoteConfigStore } from 'src/features/remoteConfig'
8+
import { DesktopBreakpoint } from 'src/providers/DesktopBreakpoint'
99
import { useUserPreferences } from 'src/stores/preferences'
1010
import { SupportedCardType } from 'src/types'
1111

@@ -59,13 +59,13 @@ export const Card = ({
5959
return (
6060
<div className={'block' + (fullBlock ? ' fullBlock' : '')}>
6161
<div className="blockHeader">
62-
{isDesktop && (
62+
<DesktopBreakpoint>
6363
<SortableKnob>
6464
<button className="blockHeaderDragButton">
6565
<MdOutlineDragIndicator />
6666
</button>
6767
</SortableKnob>
68-
)}
68+
</DesktopBreakpoint>
6969
<span className="blockHeaderIcon">{icon}</span> {titleComponent || label}{' '}
7070
{link && (
7171
<a className="blockHeaderLink" href={link} onClick={handleHeaderLinkClick}>

src/components/Layout/AppContentLayout.tsx

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import { useState } from 'react'
2-
import { isDesktop } from 'react-device-detect'
2+
import { DesktopBreakpoint } from 'src/providers/DesktopBreakpoint'
3+
import { MobileBreakpoint } from 'src/providers/MobileBreakpoint'
34
import { useUserPreferences } from 'src/stores/preferences'
45
import { BottomNavigation } from '../Elements'
56
import { ScrollCardsNavigator } from './'
@@ -14,13 +15,14 @@ export const AppContentLayout = () => {
1415
<>
1516
<main className="AppContent">
1617
<ScrollCardsNavigator />
17-
{isDesktop ? (
18+
<DesktopBreakpoint>
1819
<DesktopCards cards={cards} userCustomCards={userCustomCards} />
19-
) : (
20+
</DesktopBreakpoint>
21+
<MobileBreakpoint>
2022
<div className="Cards HorizontalScroll">
2123
<MobileCards selectedCard={selectedCard} />
2224
</div>
23-
)}
25+
</MobileBreakpoint>
2426
</main>
2527
<BottomNavigation selectedCard={selectedCard} setSelectedCard={setSelectedCard} />
2628
</>

src/features/MarketingBanner/components/MarketingBanner.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import DOMPurify from 'dompurify'
22
import jsonPath from 'jsonpath'
33
import { useEffect, useMemo, useState } from 'react'
4-
import { isMobile } from 'react-device-detect'
4+
import { useMediaQuery } from 'react-responsive'
55
import {
66
trackMarketingCampaignClose,
77
trackMarketingCampaignOpen,
@@ -25,7 +25,7 @@ export const MarketingBanner = () => {
2525
cacheTime: 600000,
2626
},
2727
})
28-
28+
const isMobile = useMediaQuery({ maxWidth: 767 })
2929
const userAtttributes = useMemo(() => {
3030
return {
3131
platform: isWebOrExtensionVersion(),
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
import { useMediaQuery } from 'react-responsive'
2+
3+
export const DesktopBreakpoint = ({ children }: { children: React.ReactNode }) => {
4+
const isDesktop = useMediaQuery({ minWidth: 768 })
5+
return isDesktop ? children : null
6+
}

src/providers/MobileBreakpoint.tsx

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
import { useMediaQuery } from 'react-responsive'
2+
3+
export const MobileBreakpoint = ({ children }: { children: React.ReactNode }) => {
4+
const isMobile = useMediaQuery({ maxWidth: 767 })
5+
return isMobile ? children : null
6+
}

yarn.lock

Lines changed: 31 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -3338,6 +3338,11 @@ crypt@0.0.2:
33383338
resolved "https://registry.yarnpkg.com/crypt/-/crypt-0.0.2.tgz#88d7ff7ec0dfb86f713dc87bbb42d044d3e6c41b"
33393339
integrity sha512-mCxBlsHFYh9C+HVpiEacem8FEBnMXgU9gy4zmNC+SXAZNB/1idgp/aulFJ4FgCi7GPEVbfyng092GqL2k2rmow==
33403340

3341+
css-mediaquery@^0.1.2:
3342+
version "0.1.2"
3343+
resolved "https://registry.yarnpkg.com/css-mediaquery/-/css-mediaquery-0.1.2.tgz#6a2c37344928618631c54bd33cedd301da18bea0"
3344+
integrity sha512-COtn4EROW5dBGlE/4PiKnh6rZpAPxDeFLaEEwt4i10jpDMFt2EhQGS79QmmrO+iKCHv0PU/HrOWEhijFd1x99Q==
3345+
33413346
css.escape@^1.5.1:
33423347
version "1.5.1"
33433348
resolved "https://registry.yarnpkg.com/css.escape/-/css.escape-1.5.1.tgz#42e27d4fa04ae32f931a4b4d4191fa9cddee97cb"
@@ -4319,6 +4324,10 @@ htmlparser2@^8.0.1:
43194324
domutils "^3.0.1"
43204325
entities "^4.4.0"
43214326

4327+
hyphenate-style-name@^1.0.0:
4328+
version "1.1.0"
4329+
resolved "https://registry.yarnpkg.com/hyphenate-style-name/-/hyphenate-style-name-1.1.0.tgz#1797bf50369588b47b72ca6d5e65374607cf4436"
4330+
integrity sha512-WDC/ui2VVRrz3jOVi+XtjqkDjiVjTtFaAGiW37k6b+ohyQ5wYDOGkvCZa8+H0nx3gyvv0+BST9xuOgIyGQ00gw==
43224331
http-parser-js@>=0.5.1:
43234332
version "0.5.9"
43244333
resolved "https://registry.yarnpkg.com/http-parser-js/-/http-parser-js-0.5.9.tgz#b817b3ca0edea6236225000d795378707c169cec"
@@ -4771,6 +4780,12 @@ lz-string@^1.4.4:
47714780
resolved "https://registry.yarnpkg.com/lz-string/-/lz-string-1.5.0.tgz#c1ab50f77887b712621201ba9fd4e3a6ed099941"
47724781
integrity sha512-h5bgJWpxJNswbU7qCrV0tIKQCaS3blPDrqKWx+QxzuzL1zGUzij9XCWLrSLsJPu5t+eWA/ycetzYAO5IOMcWAQ==
47734782

4783+
matchmediaquery@^0.4.2:
4784+
version "0.4.2"
4785+
resolved "https://registry.yarnpkg.com/matchmediaquery/-/matchmediaquery-0.4.2.tgz#22582bd4ae63ad9f54c53001bba80cbed0f7eafa"
4786+
integrity sha512-wrZpoT50ehYOudhDjt/YvUJc6eUzcdFPdmbizfgvswCKNHD1/OBOHYJpHie+HXpu6bSkEGieFMYk6VuutaiRfA==
4787+
dependencies:
4788+
css-mediaquery "^0.1.2"
47744789
math-intrinsics@^1.1.0:
47754790
version "1.1.0"
47764791
resolved "https://registry.yarnpkg.com/math-intrinsics/-/math-intrinsics-1.1.0.tgz#a0dd74be81e2aa5c2f27e65ce283605ee4e2b7f9"
@@ -5304,7 +5319,7 @@ pretty-format@^29.0.0, pretty-format@^29.7.0:
53045319
ansi-styles "^5.0.0"
53055320
react-is "^18.0.0"
53065321

5307-
prop-types@^15.0.0, prop-types@^15.0.0-0, prop-types@^15.5.8, prop-types@^15.6.0, prop-types@^15.6.2, prop-types@^15.7.2, prop-types@^15.8.1:
5322+
prop-types@^15.0.0, prop-types@^15.0.0-0, prop-types@^15.5.8, prop-types@^15.6.0, prop-types@^15.6.1, prop-types@^15.6.2, prop-types@^15.7.2, prop-types@^15.8.1:
53085323
version "15.8.1"
53095324
resolved "https://registry.yarnpkg.com/prop-types/-/prop-types-15.8.1.tgz#67d87bf1a694f48435cf332c24af10214a3140b5"
53105325
integrity sha512-oj87CgZICdulUohogVAR7AjlC0327U4el4L6eAvOqCeudMDVU0NThNaV+b9Df4dXgSP1gXMTnPdhfe/2qDH5cg==
@@ -5353,13 +5368,6 @@ react-contexify@^5.0.0:
53535368
dependencies:
53545369
clsx "^1.1.1"
53555370

5356-
react-device-detect@^1.17.0:
5357-
version "1.17.0"
5358-
resolved "https://registry.yarnpkg.com/react-device-detect/-/react-device-detect-1.17.0.tgz#a00b4fd6880cebfab3fd8a42a79dc0290cdddca9"
5359-
integrity sha512-bBblIStwpHmoS281JFIVqeimcN3LhpoP5YKDWzxQdBIUP8S2xPvHDgizLDhUq2ScguLfVPmwfF5y268EEQR60w==
5360-
dependencies:
5361-
ua-parser-js "^0.7.24"
5362-
53635371
react-dom@^17.0.1:
53645372
version "17.0.2"
53655373
resolved "https://registry.yarnpkg.com/react-dom/-/react-dom-17.0.2.tgz#ecffb6845e3ad8dbfcdc498f0d0a939736502c23"
@@ -5449,6 +5457,16 @@ react-refresh@^0.14.0:
54495457
resolved "https://registry.yarnpkg.com/react-refresh/-/react-refresh-0.14.0.tgz#4e02825378a5f227079554d4284889354e5f553e"
54505458
integrity sha512-wViHqhAd8OHeLS/IRMJjTSDHF3U9eWi62F/MledQGPdJGDhodXJ9PBLNGr6WWL7qlH12Mt3TyTpbS+hGXMjCzQ==
54515459

5460+
react-responsive@^10.0.1:
5461+
version "10.0.1"
5462+
resolved "https://registry.yarnpkg.com/react-responsive/-/react-responsive-10.0.1.tgz#293d4d2562da93409861216f0110d146c5676eb3"
5463+
integrity sha512-OM5/cRvbtUWEX8le8RCT8scA8y2OPtb0Q/IViEyCEM5FBN8lRrkUOZnu87I88A6njxDldvxG+rLBxWiA7/UM9g==
5464+
dependencies:
5465+
hyphenate-style-name "^1.0.0"
5466+
matchmediaquery "^0.4.2"
5467+
prop-types "^15.6.1"
5468+
shallow-equal "^3.1.0"
5469+
54525470
react-router-dom@^6.21.0:
54535471
version "6.21.0"
54545472
resolved "https://registry.yarnpkg.com/react-router-dom/-/react-router-dom-6.21.0.tgz#aa4c6bc046a8e8723095bc09b3c0ab2254532712"
@@ -5789,6 +5807,11 @@ set-function-name@^2.0.0, set-function-name@^2.0.1:
57895807
functions-have-names "^1.2.3"
57905808
has-property-descriptors "^1.0.0"
57915809

5810+
shallow-equal@^3.1.0:
5811+
version "3.1.0"
5812+
resolved "https://registry.yarnpkg.com/shallow-equal/-/shallow-equal-3.1.0.tgz#e7a54bac629c7f248eff6c2f5b63122ba4320bec"
5813+
integrity sha512-pfVOw8QZIXpMbhBWvzBISicvToTiM5WBF1EeAUZDDSb5Dt29yl4AYbyywbJFSEsRUMr7gJaxqCdr4L3tQf9wVg==
5814+
57925815
side-channel@^1.0.4:
57935816
version "1.0.4"
57945817
resolved "https://registry.yarnpkg.com/side-channel/-/side-channel-1.0.4.tgz#efce5c8fdc104ee751b25c58d4290011fa5ea2cf"
@@ -6094,11 +6117,6 @@ typescript@^5.1.6:
60946117
resolved "https://registry.yarnpkg.com/typescript/-/typescript-5.3.3.tgz#b3ce6ba258e72e6305ba66f5c9b452aaee3ffe37"
60956118
integrity sha512-pXWcraxM0uxAS+tN0AG/BF2TyqmHO014Z070UsJ+pFvYuRSq8KH8DmWpnbXe0pEPDHXZV3FcAbJkijJ5oNEnWw==
60966119

6097-
ua-parser-js@^0.7.24:
6098-
version "0.7.37"
6099-
resolved "https://registry.yarnpkg.com/ua-parser-js/-/ua-parser-js-0.7.37.tgz#e464e66dac2d33a7a1251d7d7a99d6157ec27832"
6100-
integrity sha512-xV8kqRKM+jhMvcHWUKthV9fNebIzrNy//2O9ZwWcfiBFR5f25XVZPLlEajk/sf3Ra15V92isyQqnIEXRDaZWEA==
6101-
61026120
unbox-primitive@^1.0.2:
61036121
version "1.0.2"
61046122
resolved "https://registry.yarnpkg.com/unbox-primitive/-/unbox-primitive-1.0.2.tgz#29032021057d5e6cdbd08c5129c226dff8ed6f9e"

0 commit comments

Comments
 (0)