From c03c7a2807411f390cd4a83ffb6e083d486612c0 Mon Sep 17 00:00:00 2001 From: scurry222 Date: Mon, 13 Jul 2020 19:14:30 -0700 Subject: [PATCH 1/5] implement dropdown menu --- src/App.css | 9 ++ src/components/UI/Map.tsx | 10 +-- src/components/UI/Menu.tsx | 122 ++++++++++++++------------- src/components/UI/Search.tsx | 62 ++++++++------ src/components/UI/TopBar.tsx | 18 ++-- src/components/common/MenuButton.tsx | 4 +- 6 files changed, 128 insertions(+), 97 deletions(-) diff --git a/src/App.css b/src/App.css index f6579c0..afc7846 100644 --- a/src/App.css +++ b/src/App.css @@ -42,6 +42,8 @@ em { text-decoration: underline; } + + .search-container { position: relative; } @@ -302,3 +304,10 @@ footer { .place__info-contact { margin-bottom: 20px; } + +@media (max-width: 400px) { + .navbar { + padding: 1rem 1rem .5rem !important; + align-items: flex-start !important; + } +} diff --git a/src/components/UI/Map.tsx b/src/components/UI/Map.tsx index 17b5c31..17974c8 100644 --- a/src/components/UI/Map.tsx +++ b/src/components/UI/Map.tsx @@ -18,12 +18,12 @@ import { IconButton as FilterButton } from "../common/Button" const MapContainer = styled.div` height: calc(100vh - 76px); - width: 100vw; + // width: 100vw; @media (min-width: 980px) { position: absolute; right: 0; - top: 76px; + top: 71px; width: calc(100vw - 430px); } ` @@ -42,7 +42,7 @@ const Filter = styled.div` left: 0; position: absolute; padding: 17.5px 30px; - top: 76px; + top: 70px; width: 430px; z-index: 500; } @@ -54,11 +54,11 @@ const ResultsList = styled.div` background: white; box-shadow: 0 8px 8px 0 rgba(0, 0, 0, 0.3); display: block; - height: calc(100vh - (76px + 92px)); + height: calc(100vh - (70px + 92px)); left: 0; overflow: scroll; position: absolute; - top: calc(76px + 92px); + top: calc(70px + 92px); width: 430px; z-index: 500; } diff --git a/src/components/UI/Menu.tsx b/src/components/UI/Menu.tsx index 4ede384..27b536f 100644 --- a/src/components/UI/Menu.tsx +++ b/src/components/UI/Menu.tsx @@ -3,6 +3,7 @@ import styled from "styled-components" import { IoMdMenu } from "react-icons/all" // import InfoPopover from "./InfoPopover" import MenuButton from '../common/MenuButton' +import { Navbar } from 'react-bootstrap' const MenuContainer = styled("div")` display: flex; @@ -10,20 +11,24 @@ const MenuContainer = styled("div")` margin-left: 0px; @media (max-width: 400px) { - top: 80px; + position: absolute; + top: 5px; + right: 0; + padding: .75rem; } ` const MobileMenu = styled("div")` - @media (min-width: 400px) { - display: none; - } + position: absolute; + padding: .5rem .75rem; + right: 0; + top: 0; ` const ButtonsContainer = styled("div")` display: flex; justify-content: space-around; - width: 380px; + right: 0; & button { border: none; @@ -35,11 +40,12 @@ const ButtonsContainer = styled("div")` } @media (max-width: 400px) { - position: fixed; - top: 120px; - left: 0; - width: 100%; - height: 100%; + // display: block; + // top: 7rem; + // left: -18rem; + // width: 300px; + // height: 100%; + bottom: 0; z-index: 1000; background: white; @@ -63,52 +69,54 @@ const ButtonsContainer = styled("div")` // ` export default () => ( - - - - + <> + + + + + - - - - - {/* -

- For over 30 years, the Souper Bowl of Caring campaign has been a local - effort with a collective impact using the energy of the Big Game to - tackle hunger. -

-

- Churches, schools and civic groups around the country join in through - hosting food and donation campaigns each year that benefit local - charities picked by participants. -

-

- Since 1990, over $163 million has been raised for almost 10,000 local - charities around the nation and world. -

-

- The Souper Bowl of Caring illustrates the importance of a collective - impact from local grassroots efforts to tackle hunger. -

- Learn more about our history -
- -

- Contributing, Branching, & Forking While we actively accept help, as - well as encourage you to fork this repo and build it out for your - city, we do not take pull requests directly to this repo - please - contact us before you plan to do so. Reach out to:
- Repo - Github - {" "} -
- Twitter @dariceshelter -

-
- -

Coming soon

-
*/} -
-
+ + + + {/* +

+ For over 30 years, the Souper Bowl of Caring campaign has been a local + effort with a collective impact using the energy of the Big Game to + tackle hunger. +

+

+ Churches, schools and civic groups around the country join in through + hosting food and donation campaigns each year that benefit local + charities picked by participants. +

+

+ Since 1990, over $163 million has been raised for almost 10,000 local + charities around the nation and world. +

+

+ The Souper Bowl of Caring illustrates the importance of a collective + impact from local grassroots efforts to tackle hunger. +

+ Learn more about our history +
+ +

+ Contributing, Branching, & Forking While we actively accept help, as + well as encourage you to fork this repo and build it out for your + city, we do not take pull requests directly to this repo - please + contact us before you plan to do so. Reach out to:
+ Repo + Github + {" "} +
+ Twitter @dariceshelter +

+
+ +

Coming soon

+
*/} + + + ) diff --git a/src/components/UI/Search.tsx b/src/components/UI/Search.tsx index 519d32e..e2dc15f 100644 --- a/src/components/UI/Search.tsx +++ b/src/components/UI/Search.tsx @@ -2,13 +2,14 @@ import styled from "styled-components"; import React, { useState } from "react"; import { Form, InputGroup, FormControl } from "react-bootstrap"; import PlacesAutocomplete, { geocodeByAddress, getLatLng } from "react-places-autocomplete"; +import { Navbar } from 'react-bootstrap' import { SetLocation } from "./types"; import searchIcon from "../../assets/images/search@3x.png"; const Suggestions = styled.div` border-radius: 0 0 10px 10px; - position: absolute; + // position: absolute; z-index: 1000; background: white; width: 100%; @@ -32,12 +33,19 @@ const Container = styled.div` justify-content: center; z-index: 1000; height: 48px; + min-width: 300px; + + @media (max-width: 575px) { + margin: 15px 0 0 0; + } @media (max-width: 400px) { position: relative; - top: 50px; + margin-top: 50px; min-width: 100%; + } + `; const SearchBar = styled.div` @@ -54,6 +62,8 @@ const SearchIcon = styled.img` top: 13px; width: 24px; z-index: 999; + + `; type SearchProps = { @@ -77,30 +87,30 @@ export default ({ setLocation }: SearchProps) => { > {({ getInputProps, suggestions, getSuggestionItemProps, loading }) => ( - - -
- - - - - - {!loading && - suggestions.map((suggestion) => ( - - {suggestion.description} - - ))} - -
-
+ + +
+ + + + + + {!loading && + suggestions.map((suggestion) => ( + + {suggestion.description} + + ))} + +
+
)} diff --git a/src/components/UI/TopBar.tsx b/src/components/UI/TopBar.tsx index 9819719..e9183de 100644 --- a/src/components/UI/TopBar.tsx +++ b/src/components/UI/TopBar.tsx @@ -6,19 +6,21 @@ import Search from "./Search"; import { SetLocation } from "./types"; import BrandLogo from "../common/BrandLogo"; import "bootstrap/dist/css/bootstrap.min.css"; +import { Navbar } from "react-bootstrap"; const Container = styled("div")` background-color: #ffffff; - box-shadow: 0 2px 4px 0 rgba(0, 0, 0, 0.2); + box-shadow: 0 2px 4px 0 rgba(0, 0, 0, 0.2) !important; display: flex; - padding: 14px 25px; - position: absolute; + padding: 5px 0 0; + // position: absolute; top: 0; width: 100%; + // height: 75px; z-index: 1000; @media (max-width: 400px) { - height: 120px; + // height: 150px; } `; @@ -29,9 +31,11 @@ type TopBarProps = { export default ({ setLocation }: TopBarProps) => { return ( - - - + + + + + ); }; diff --git a/src/components/common/MenuButton.tsx b/src/components/common/MenuButton.tsx index fbe58a7..23fe127 100644 --- a/src/components/common/MenuButton.tsx +++ b/src/components/common/MenuButton.tsx @@ -13,7 +13,7 @@ const ButtonLink = styled.a` color: #171b50; font-weight: bold; letter-spacing: 0.8px; - padding-top: 12px; + padding: 12px; text-transform: uppercase; width: auto; text-decoration: none; @@ -27,7 +27,7 @@ const ButtonLink = styled.a` @media (max-width: 400px) { width: 100%; - margin-bottom: 20px; + padding: .2rem; } ` From 71b8755ceae78cc6d0f681c6c6178db2bafcd464 Mon Sep 17 00:00:00 2001 From: scurry222 Date: Mon, 20 Jul 2020 15:24:36 -0700 Subject: [PATCH 2/5] change marker popover style on small media screens --- package.json | 2 ++ src/App.css | 10 ++++------ src/App.tsx | 2 +- src/components/UI/Map.tsx | 5 ++++- src/components/UI/Marker.tsx | 22 +++++++++++++++++++--- src/components/UI/Menu.tsx | 14 -------------- src/components/UI/Search.tsx | 1 - 7 files changed, 30 insertions(+), 26 deletions(-) diff --git a/package.json b/package.json index 1a90b36..0ba7722 100644 --- a/package.json +++ b/package.json @@ -24,7 +24,9 @@ "react-icons": "^3.10.0", "react-instantsearch": "^6.4.0", "react-instantsearch-dom-maps": "^6.4.0", + "react-native-elements": "^2.0.4", "react-places-autocomplete": "^7.2.1", + "react-responsive": "^8.1.0", "react-scripts": "^3.4.1", "styled-components": "^5.1.0", "typescript": "^3.9.5" diff --git a/src/App.css b/src/App.css index afc7846..abc6970 100644 --- a/src/App.css +++ b/src/App.css @@ -212,7 +212,6 @@ footer { #popover-contained { background-color: #ffffff; box-shadow: 0 2px 15px 0 rgba(0, 0, 0, 0.4); - height: 490px; max-width: 532px; padding: 40px 40px; } @@ -223,7 +222,6 @@ footer { line-height: 1.15; font-size: 15px; font-weight: 400; - height: 509px; max-width: 410px; text-align: justify; width: 410px; @@ -234,7 +232,6 @@ footer { } .map-popover__address { - height: 23px; font-size: 15px; font-weight: normal; font-stretch: normal; @@ -251,7 +248,6 @@ footer { font-stretch: normal; font-style: normal; font-weight: bold; - height: 23px; margin-bottom: 12px; letter-spacing: 0.75px; line-height: normal; @@ -265,7 +261,6 @@ footer { font-stretch: normal; font-style: normal; font-weight: normal; - height: 23px; letter-spacing: 0.75px; line-height: normal; margin-bottom: 34px; @@ -282,7 +277,6 @@ footer { font-stretch: normal; font-style: normal; font-weight: bold; - height: 23px; letter-spacing: 0.8px; line-height: normal; text-transform: uppercase; @@ -310,4 +304,8 @@ footer { padding: 1rem 1rem .5rem !important; align-items: flex-start !important; } + #map-popover { + left: -5px!important; + max-width: 100%; + } } diff --git a/src/App.tsx b/src/App.tsx index 65f8e90..45d3b5e 100644 --- a/src/App.tsx +++ b/src/App.tsx @@ -8,7 +8,7 @@ function App() {
diff --git a/src/components/UI/Map.tsx b/src/components/UI/Map.tsx index 17974c8..d64d22e 100644 --- a/src/components/UI/Map.tsx +++ b/src/components/UI/Map.tsx @@ -17,7 +17,7 @@ import LocationProvider from "../../contexts/LocationContext" import { IconButton as FilterButton } from "../common/Button" const MapContainer = styled.div` - height: calc(100vh - 76px); + height: calc(100vh - 71px); // width: 100vw; @media (min-width: 980px) { @@ -26,6 +26,9 @@ const MapContainer = styled.div` top: 71px; width: calc(100vw - 430px); } + @media (max-width: 575px) { + height: calc(96vh - 76px); + } ` const Filter = styled.div` diff --git a/src/components/UI/Marker.tsx b/src/components/UI/Marker.tsx index e040c84..583a890 100644 --- a/src/components/UI/Marker.tsx +++ b/src/components/UI/Marker.tsx @@ -1,7 +1,10 @@ import styled from "styled-components" -import { Overlay, Popover } from "react-bootstrap" +import { Popover, Overlay } from "react-bootstrap" +// import { Overlay } from 'react-native' import React, { useContext, useRef, useState } from "react" import { CustomMarker } from "react-instantsearch-dom-maps" +import MediaQuery from 'react-responsive'; +import mediaQuery from 'css-mediaquery'; import { Pin } from "../common/Pin" import { GmapsTypeIcon } from "../common/GmapsType" @@ -34,10 +37,17 @@ const Title = styled.div` font-stretch: normal; font-style: normal; font-weight: bold; - height: 23px; margin-bottom: 5px; line-height: normal; ` +const MarkerContainer = styled.div` + width: 375px; + height: 517px; + border-radius: 5px; + box-shadow: 0 2px 15px 0 rgba(0, 0, 0, 0.4); + background-color: #ffffff; +` + const Marker: React.FC = (props) => { const ref = useRef(null) @@ -83,6 +93,12 @@ const Marker: React.FC = (props) => { selectHit(true) } + const direction = () => { + const smallScreen = window.matchMedia('(min-width: 400px)') + return smallScreen.matches ? "right" : "bottom-end" + } + + return (
@@ -94,7 +110,7 @@ const Marker: React.FC = (props) => { rootClose show={open} target={target} - placement="right" + placement={direction()} transition={false} onHide={handleClose} container={ref.current}> diff --git a/src/components/UI/Menu.tsx b/src/components/UI/Menu.tsx index 27b536f..c1589dc 100644 --- a/src/components/UI/Menu.tsx +++ b/src/components/UI/Menu.tsx @@ -1,23 +1,9 @@ import React from "react" import styled from "styled-components" -import { IoMdMenu } from "react-icons/all" // import InfoPopover from "./InfoPopover" import MenuButton from '../common/MenuButton' import { Navbar } from 'react-bootstrap' -const MenuContainer = styled("div")` - display: flex; - justify-content: space-between; - margin-left: 0px; - - @media (max-width: 400px) { - position: absolute; - top: 5px; - right: 0; - padding: .75rem; - } -` - const MobileMenu = styled("div")` position: absolute; padding: .5rem .75rem; diff --git a/src/components/UI/Search.tsx b/src/components/UI/Search.tsx index e2dc15f..b4af1fc 100644 --- a/src/components/UI/Search.tsx +++ b/src/components/UI/Search.tsx @@ -2,7 +2,6 @@ import styled from "styled-components"; import React, { useState } from "react"; import { Form, InputGroup, FormControl } from "react-bootstrap"; import PlacesAutocomplete, { geocodeByAddress, getLatLng } from "react-places-autocomplete"; -import { Navbar } from 'react-bootstrap' import { SetLocation } from "./types"; import searchIcon from "../../assets/images/search@3x.png"; From ae2024504d6d471ef644dd34153269fac9c7deb1 Mon Sep 17 00:00:00 2001 From: scurry222 Date: Sun, 26 Jul 2020 16:42:02 -0700 Subject: [PATCH 3/5] implement map/list toggle button --- src/assets/genericPinSelected.png | Bin 0 -> 15062 bytes src/assets/list.png | Bin 0 -> 154 bytes src/assets/map.png | Bin 0 -> 261 bytes src/components/UI/ButtonExample.tsx | 7 ++- src/components/UI/Map.tsx | 92 +++++++++++++++++----------- src/components/UI/Marker.tsx | 3 - src/components/common/Button.tsx | 27 +++++++- 7 files changed, 86 insertions(+), 43 deletions(-) create mode 100644 src/assets/genericPinSelected.png create mode 100644 src/assets/list.png create mode 100644 src/assets/map.png diff --git a/src/assets/genericPinSelected.png b/src/assets/genericPinSelected.png new file mode 100644 index 0000000000000000000000000000000000000000..6532ccefdd90ca7ec27311392b3ac704679c54f1 GIT binary patch literal 15062 zcmeI3hgVZs+xE{%0tvl0X#r;dkzzm*g2GWoL`6_^1VoAn0v14ehl7k1L5O1`DjLUv z2#TNrQUsL}B|>ZnQdEj`klx9+Pndb0_kI6?Z#`>0S&QX;+CKN$r|kW^ugjD@cH6~- zR|!K9B(}rmHwOq3M6f>+9;}gnAA1q}0|z;5-wHi!Q0WH?1n(`ow?I%qhREV!0SLlF zdu;b_1MC0){fr^V3xb#s#DO3l1eT1AA!9Gdmp5&QSOz~1lgYz65?miREm-1km>eGHS8%x? z3$T&N<1l%kA3;xp4gh(9-9bl#s|8&N`U9j1jt1QUasn3&t`KAm8Usm#BSBgq4{&18 zHfWlM-6Cvnuo*0a9}nCy(2?N!z-hq}hsVQiApiDbS@7>Dc0c(y2}_FK@7V3-cO{l1 zzjv^^&A(tQW&Sl_H=mytb_M)1fu_OZ0PY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?_K=&baKq2-fIToR7z@U^7vm7VRI?G+bwMIZO5*f~w|I6TsnPE6~*P zUKQMJE-+)7>?c_FJwDgD7S0J$0M^ZWAGVW$!LA_$drC49Rg#T{`z?G=`U*eU0e-rl zM_ZmGlP_)(fX__LC;z;N?x&`^K=)+12BO%fWcaqVx&^}*1R>~JkOE(fb+&+K~MbwX!74xi-qWB=c z__ssq)uuTZI=#6iN%sH58_LK4=u}dg){39qST7Y9Q!dRI4mcd8_w9zOS}iFDNKoC} z8yZ!Wrpi-wb(lFXqvy9X?f4>F^-5I?(Jlx`tB+)oy8A~g{ zd5wBKE4Q?yR-{uX*U%Fc+ZNr?;lj+X8Na&7_@h}xnP2T}yWAr1nSa(Srq`IK-@!jh zsc{A0{pM4S3Xqlur7~ubZ@8mWx~>EPvj150#w7o@GjC+Yr1yWEdD)ni!Ke~lspipQ z zRh}{`Rzc|g#d=Wh8h?Bo-1Ptqq2Is%J)8!8dAAhv2|6*fft*1(T7HwTKj+e*i$@8T@%`91x z_4EeLsKqs6h87QI8~ZTr=%jY7ayc}-q{5gAN^9FOCPYPul|VaEvI^Tebd$uFn?`Gz zv(hdqJc1&z{}-_~8TjVL0Lb(LGti3(3Dgd_gf0|?h9&DGh5(+H6uZKD=a%uTtC&Bp zGzIwcRJM?~jdd`yda!(2Fr>J)i~wj{f!dn^JU--9BWW> zC@EYpK>Xt{171a1O1aBQ!G08W&X*Xa>x`zwjJm=5XDiY2MZ?fzNgZW%CBD%7JP$25 zZ9ezPZzdzXD;<>d_rVbXkESe-v>$3Vkz#SZfq(Dk(c`NNqo?cTkOIJPxiwuiJ?$nj zwD6#~$#3T+P^DKRuLTHbi;N`XKp>#9FihTtKsHkU lUHorv{PQq4<@500;EU&E()S$3{&(GuZFavs-0E@a{{d}i9a{hZ literal 0 HcmV?d00001 diff --git a/src/assets/list.png b/src/assets/list.png new file mode 100644 index 0000000000000000000000000000000000000000..befcd180278534204598bdcaad058a65d4ba639d GIT binary patch literal 154 zcmeAS@N?(olHy`uVBq!ia0vp^5+KaM1|%Pp+x`GjY)RhkE)4%caKYZ?lYt`so-U3d z9-YYv60FR;5(`a)nVFqMrtF>4*!a+Xt8Q1L)UWxCjfzs9f9zQ$-WAPaa#OM5%KBWy xCdG2`0_)a@!#Wm+-#=&kRPOZN1H1k0JvoYA^dxaK>$o*vd{ED}vEOXPL2h=PdPC*)CuZeJ z-L`)&72=e;{_FP4;M+4#g=U=WH7K|x!n?WMpeN|oM4NrTI3n_XSp|gweZk=A>gTe~ HDWM4fU*c;q literal 0 HcmV?d00001 diff --git a/src/components/UI/ButtonExample.tsx b/src/components/UI/ButtonExample.tsx index 57a95d8..d70a32e 100644 --- a/src/components/UI/ButtonExample.tsx +++ b/src/components/UI/ButtonExample.tsx @@ -1,4 +1,4 @@ -import React from 'react'; +import React, { Component } from 'react'; interface IProps { buttonStyle?: object; @@ -18,3 +18,8 @@ const Button: React.FC = props => { }; export default Button; + + +// access state => Callback in parent Component +// toggles state +// 2. Set state variable in parent component, pass it to child as prop diff --git a/src/components/UI/Map.tsx b/src/components/UI/Map.tsx index d64d22e..f4821e6 100644 --- a/src/components/UI/Map.tsx +++ b/src/components/UI/Map.tsx @@ -13,10 +13,12 @@ import Marker from "./Marker" import { Location } from "./types" import { HitComponent } from "../common/Hit" import filterIcon from "../../assets/filter.png" +import mapIcon from "../../assets/map.png" +import listIcon from "../../assets/list.png" import LocationProvider from "../../contexts/LocationContext" -import { IconButton as FilterButton } from "../common/Button" +import { IconButton as FilterButton, MapListButton } from "../common/Button" -const MapContainer = styled.div` +export const MapContainer = styled.div` height: calc(100vh - 71px); // width: 100vw; @@ -32,38 +34,38 @@ const MapContainer = styled.div` ` const Filter = styled.div` - display: none; + align-content: center; + align-items: center; + background: white; + border-bottom: 1px solid lightgray; + box-shadow: 0 8px 8px 0 rgba(0, 0, 0, 0.3); + display: flex; + height: 92px; + // position: absolute; + padding: 17.5px 30px; + top: 70px; + width: 430px; + z-index: 500; + justify-content: space-between; - @media (min-width: 980px) { - align-content: center; - align-items: center; - background: white; - border-bottom: 1px solid lightgray; - box-shadow: 0 8px 8px 0 rgba(0, 0, 0, 0.3); - display: flex; - height: 92px; - left: 0; - position: absolute; - padding: 17.5px 30px; - top: 70px; - width: 430px; - z-index: 500; + @media (max-width: 575px) { + width: 100%; } ` -const ResultsList = styled.div` - display: none; +export const ResultsList = styled.div` + background: white; + box-shadow: 0 8px 8px 0 rgba(0, 0, 0, 0.3); + display: block; + height: calc(100vh - (70px + 92px)); + overflow: scroll; + top: calc(70px + 92px); + width: 414px; + z-index: 1000; + + @media (max-width: 575px) { + width: 100%; + height: calc(100vh - (70px + 150px)); - @media (min-width: 980px) { - background: white; - box-shadow: 0 8px 8px 0 rgba(0, 0, 0, 0.3); - display: block; - height: calc(100vh - (70px + 92px)); - left: 0; - overflow: scroll; - position: absolute; - top: calc(70px + 92px); - width: 430px; - z-index: 500; } ` @@ -88,6 +90,11 @@ export default ({ defaultLocation }: Map) => { defaultLocation || US_LOCATION ) + const mq = window.matchMedia("(max-width: 575px)") + + let [show, setShow] = useState('both') + if (mq.matches) [show, setShow] = useState('list') + return ( { src={filterIcon}> Filter + {mq.matches ? setShow(show === 'map' ? 'list' : 'map')} + toggle={show} > + {show === 'map' ? 'list' : 'map'} + + :
} - - - - - + { show === 'both' || show === 'map' ? + { )} + :
} + { show === 'both' || show === 'list' ? + + + :
}
)} ) -} +} \ No newline at end of file diff --git a/src/components/UI/Marker.tsx b/src/components/UI/Marker.tsx index 583a890..8c9f527 100644 --- a/src/components/UI/Marker.tsx +++ b/src/components/UI/Marker.tsx @@ -1,10 +1,7 @@ import styled from "styled-components" import { Popover, Overlay } from "react-bootstrap" -// import { Overlay } from 'react-native' import React, { useContext, useRef, useState } from "react" import { CustomMarker } from "react-instantsearch-dom-maps" -import MediaQuery from 'react-responsive'; -import mediaQuery from 'css-mediaquery'; import { Pin } from "../common/Pin" import { GmapsTypeIcon } from "../common/GmapsType" diff --git a/src/components/common/Button.tsx b/src/components/common/Button.tsx index 6187e7a..8bba91a 100644 --- a/src/components/common/Button.tsx +++ b/src/components/common/Button.tsx @@ -4,11 +4,12 @@ import styled from "styled-components" const getWidth = (size = "medium") => ({ small: "53.5px", medium: "107px", large: "244px" }[size] || "107px") -interface ButtonProps { +interface ButtonProps extends React.ButtonHTMLAttributes{ border?: boolean - size?: string primary?: boolean width?: string + size?: string + toggle?: string } const Button = styled.button` @@ -38,7 +39,6 @@ const Button = styled.button` interface IconButtonProps extends ButtonProps { alt?: string - children: React.ReactNode src: string } @@ -61,4 +61,25 @@ export const IconButton = ({ ) } +interface MapListButtonProps extends ButtonProps { + alt?: string + src: string +} + +export const MapListButton = ({ + alt, + children, + src, + toggle, + ...buttonProps +}: MapListButtonProps) => { + console.log(toggle) + return ( + + ) +} + export default Button From 90f7f7372f5a7e56596ee1798d6be940f5628423 Mon Sep 17 00:00:00 2001 From: scurry222 Date: Sun, 26 Jul 2020 18:39:03 -0700 Subject: [PATCH 4/5] replace matchMedia method with custom media query hook --- src/components/UI/Map.tsx | 22 ++++++++++---------- src/components/common/Button.tsx | 3 +-- src/components/common/MediaQuery.tsx | 30 ++++++++++++++++++++++++++++ 3 files changed, 41 insertions(+), 14 deletions(-) create mode 100644 src/components/common/MediaQuery.tsx diff --git a/src/components/UI/Map.tsx b/src/components/UI/Map.tsx index f4821e6..89e2590 100644 --- a/src/components/UI/Map.tsx +++ b/src/components/UI/Map.tsx @@ -17,10 +17,10 @@ import mapIcon from "../../assets/map.png" import listIcon from "../../assets/list.png" import LocationProvider from "../../contexts/LocationContext" import { IconButton as FilterButton, MapListButton } from "../common/Button" +import { useWindowSize } from '../common/MediaQuery'; export const MapContainer = styled.div` height: calc(100vh - 71px); - // width: 100vw; @media (min-width: 980px) { position: absolute; @@ -89,11 +89,9 @@ export default ({ defaultLocation }: Map) => { const [location, setLocation] = useState( defaultLocation || US_LOCATION ) - - const mq = window.matchMedia("(max-width: 575px)") - - let [show, setShow] = useState('both') - if (mq.matches) [show, setShow] = useState('list') + const mq = useWindowSize(); + const mdScreen = mq.width < 575 + let [show, setShow] = useState(true) return ( @@ -125,19 +123,19 @@ export default ({ defaultLocation }: Map) => { src={filterIcon}> Filter - {mq.matches ? setShow(show === 'map' ? 'list' : 'map')} + src={show === true ? listIcon : mapIcon} + onClick={() => setShow(!show)} toggle={show} > - {show === 'map' ? 'list' : 'map'} + {show ? 'map' : 'list'} :
} - { show === 'both' || show === 'map' ? + { !mdScreen || show ? { :
} - { show === 'both' || show === 'list' ? + { !mdScreen || !show ? :
} diff --git a/src/components/common/Button.tsx b/src/components/common/Button.tsx index 8bba91a..b9ce0ca 100644 --- a/src/components/common/Button.tsx +++ b/src/components/common/Button.tsx @@ -9,7 +9,7 @@ interface ButtonProps extends React.ButtonHTMLAttributes{ primary?: boolean width?: string size?: string - toggle?: string + toggle?: boolean } const Button = styled.button` @@ -73,7 +73,6 @@ export const MapListButton = ({ toggle, ...buttonProps }: MapListButtonProps) => { - console.log(toggle) return (