Skip to content

Commit

Permalink
feat: 카드 반응형 구현
Browse files Browse the repository at this point in the history
  • Loading branch information
gominzip committed Aug 27, 2024
1 parent b45112c commit 786d610
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 10 deletions.
11 changes: 11 additions & 0 deletions src/components/common/card/Card.styled.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,11 @@ export const CardContainer = styled.div<CardContainerProps>`
border-radius: 8px;
margin: 5px;
box-sizing: border-box;
@media (max-width: 466px) {
width: 100%;
height: 150px;
overflow: hidden;
}
`;

export const CardWrapper = styled.div`
Expand All @@ -35,13 +40,19 @@ export const CardWrapper = styled.div`
margin-bottom: 2rem;
cursor: pointer;
}
@media (max-width: 466px) {
margin-left: 10%;
}
`;

export const TitleWrapper = styled.div`
display: flex;
flex-direction: column;
margin-top: 0.5rem;
gap: 1rem;
@media (max-width: 466px) {
margin-bottom: 1rem;
}
`;

export const CardTitle = styled.div`
Expand Down
5 changes: 4 additions & 1 deletion src/components/common/common.styled.ts
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,10 @@ export const Shelf = styled.img`
@media (max-width: 710px) {
width: 520px;
}
@media (max-width: 519px) {
@media (max-width: 550px) {
width: 420px;
}
@media (max-width: 466px) {
display: none;
}
`;
12 changes: 7 additions & 5 deletions src/components/main/learnMain/learned/Learned.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,16 +8,14 @@ import {
import { LearnedProps } from "@type/card";

import { useEffect, useState } from "react";
import { useMediaQuery } from "react-responsive";
import { useNavigate } from "react-router-dom";

const Learned = () => {
const navigate = useNavigate();
const handleMoreClick = () => {
navigate("/learnTale/moreLearned", { state: { learned } });
};

const isMobile = useMediaQuery({ query: "(max-width: 710px)" });
const [learned, setLearned] = useState<LearnedProps[]>([]);
const sliceLearned = learned.slice(0, 3);
const sliceLearned = learned.slice(0, isMobile ? 2 : 3);

useEffect(() => {
const fetchGetStudiedTales = async () => {
Expand All @@ -27,6 +25,10 @@ const Learned = () => {
fetchGetStudiedTales();
}, []);

const handleMoreClick = () => {
navigate("/learnTale/moreLearned", { state: { learned } });
};

return (
<>
<CommonTitleWrapper>
Expand Down
11 changes: 7 additions & 4 deletions src/components/main/learnMain/unLearned/UnLearned.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,14 @@ import {
} from "@components/common/common.styled";
import { UnLearnedProps } from "@type/card";
import { useEffect, useState } from "react";
import { useMediaQuery } from "react-responsive";
import { useNavigate } from "react-router-dom";

const UnLearned = () => {
const navigate = useNavigate();
const handleMoreClick = () => {
navigate("/learnTale/moreUnLearned", { state: { unLearned } });
};
const isMobile = useMediaQuery({ query: "(max-width: 710px)" });
const [unLearned, setUnLearned] = useState<UnLearnedProps[]>([]);
const sliceUnLearned = unLearned.slice(0, 3);
const sliceUnLearned = unLearned.slice(0, isMobile ? 2 : 3);

useEffect(() => {
const fetchUnLearnTales = async () => {
Expand All @@ -26,6 +25,10 @@ const UnLearned = () => {
fetchUnLearnTales();
}, []);

const handleMoreClick = () => {
navigate("/learnTale/moreUnLearned", { state: { unLearned } });
};

return (
<>
<CommonTitleWrapper>
Expand Down

0 comments on commit 786d610

Please sign in to comment.