Skip to content

Commit

Permalink
#50 Add popular travelers to mobile and reduce to 4
Browse files Browse the repository at this point in the history
  • Loading branch information
SandraBergstrom committed Jun 28, 2023
1 parent 1ebd1ed commit cfd24c7
Showing 1 changed file with 18 additions and 6 deletions.
24 changes: 18 additions & 6 deletions src/pages/travelers/PopularTravelers.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { axiosReq } from "../../api/axiosDefaults";
import { useCurrentUser } from "../../contexts/CurrentUserContext";
import Asset from "../../components/Asset";

const PopularTravelers = () => {
const PopularTravelers = ({ mobile }) => {
const [travelerData, setTravelerData] = useState({
pageTraveler: { results: [] },
popularTravelers: { results: [] },
Expand All @@ -32,13 +32,25 @@ const PopularTravelers = () => {
}, [currentUser]);

return (
<Container className={appStyles.Container}>
<Container
className={`${appStyles.Content} ${
mobile && "d-lg-none text-center mb-3"
}`}
>
{popularTravelers.results.length ? (
<>
<p>Most followed travelers</p>
{popularTravelers.results.map((traveler) => (
<p key={traveler.id}>{traveler.owner}</p>
))}
<p className="d-flex justify-content-center">Most followed travelers</p>
{mobile ? (
<div className="d-flex justify-content-around">
{popularTravelers.results.slice(0, 4).map((traveler) => (
<p key={traveler.id}>{traveler.owner}</p>
))}
</div>
) : (
popularTravelers.results
.slice(0, 4)
.map((traveler) => <p key={traveler.id}>{traveler.owner}</p>)
)}
</>
) : (
<Asset spinner />
Expand Down

0 comments on commit cfd24c7

Please sign in to comment.