이준호

[UPDATE] Card 컴포넌트 모바일 적용

1 import React from "react"; 1 import React from "react";
2 import styled, { css } from "styled-components"; 2 import styled, { css } from "styled-components";
3 import { lighten,darken } from "polished"; 3 import { lighten,darken } from "polished";
4 +const sizes = {
5 + desktop: 102.4,
6 + tablet: 76.8,
7 + phone: 36,
8 +};
9 +
10 +const media = Object.keys(sizes).reduce((acc, label) => {
11 + acc[label] = (...args) => css`
12 + @media (max-width: ${sizes[label]}rem) {
13 + ${css(...args)}
14 + }
15 + `;
16 + return acc;
17 +}, {});
4 18
5 function Card({ question, answer, setAnswer, curIdx, setCurIdx }) { 19 function Card({ question, answer, setAnswer, curIdx, setCurIdx }) {
6 const CardWrap = styled.div` 20 const CardWrap = styled.div`
...@@ -11,6 +25,9 @@ function Card({ question, answer, setAnswer, curIdx, setCurIdx }) { ...@@ -11,6 +25,9 @@ function Card({ question, answer, setAnswer, curIdx, setCurIdx }) {
11 height: 100%; 25 height: 100%;
12 font-size: 20px; 26 font-size: 20px;
13 font-weight: bold; 27 font-weight: bold;
28 + ${media.phone`
29 + min-width: 360px;
30 + `}
14 `; 31 `;
15 32
16 const CardQuest = styled.div` 33 const CardQuest = styled.div`
...@@ -32,7 +49,7 @@ function Card({ question, answer, setAnswer, curIdx, setCurIdx }) { ...@@ -32,7 +49,7 @@ function Card({ question, answer, setAnswer, curIdx, setCurIdx }) {
32 justify-content: center; 49 justify-content: center;
33 align-items: center; 50 align-items: center;
34 &:hover { 51 &:hover {
35 - background: ${lighten(0.1, "#536349")}; // color of card -> theme화 하기 52 + background: ${lighten(0.1, "#536349")};
36 } 53 }
37 &:active { 54 &:active {
38 background: ${darken(0.1, "#536349")}; 55 background: ${darken(0.1, "#536349")};
...@@ -72,6 +89,5 @@ function Card({ question, answer, setAnswer, curIdx, setCurIdx }) { ...@@ -72,6 +89,5 @@ function Card({ question, answer, setAnswer, curIdx, setCurIdx }) {
72 </> 89 </>
73 ); 90 );
74 } 91 }
75 -// 나중에 데이터 넘어오면 넘어온 데이터로 카드 업데이트
76 92
77 export default Card; 93 export default Card;
......