Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PR Review 받은것 수정완료 #10

Merged
merged 2 commits into from
Apr 21, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions banchan/src/App.jsx
Original file line number Diff line number Diff line change
@@ -1,14 +1,18 @@
import "./App.css";
import StateProvider from "./components/StateProvider";
import { createGlobalStyle } from "styled-components";
import { ThemeProvider } from "styled-components";
import theme from "./components/utils/theme.js";

export const GlobalStyle = createGlobalStyle`
*{
padding:0;
margin:0;
}
body{
font-family: 'Noto Sans KR';
box-sizing:border-box;

}
ol, ul {
list-style: none;
Expand All @@ -17,10 +21,10 @@ export const GlobalStyle = createGlobalStyle`

function App() {
return (
<>
<ThemeProvider theme={theme}>
<GlobalStyle />
<StateProvider />
</>
</ThemeProvider>
);
}

Expand Down
3 changes: 1 addition & 2 deletions banchan/src/components/StateProvider.jsx
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
import { useState } from "react";
import Header from "./header/Header";
import MainPage from "./main/MainPage";
import styled, { injectGlobal } from "styled-components";

const StateProvider = (props) => {
const StateProvider = () => {
const [loginState, setLoginState] = useState(false);
// login해서 상태값 받아와야 함

Expand Down
12 changes: 6 additions & 6 deletions banchan/src/components/header/Header.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,6 @@ import HeaderLeft from "./headerLeft/HeaderLeft";
import HeaderRight from "./headerRight/HeaderRight";
import styled from "styled-components";

const HeaderContainer = styled.div`
display: flex;
justify-content: space-between;
margin: 32px 80px 20px 80px;
`;

const Header = () => {
return (
<HeaderContainer>
Expand All @@ -17,4 +11,10 @@ const Header = () => {
);
};

const HeaderContainer = styled.div`
display: flex;
justify-content: space-between;
margin: 32px 80px 20px 80px;
`;

export default Header;
25 changes: 10 additions & 15 deletions banchan/src/components/header/headerLeft/HeaderLeft.jsx
Original file line number Diff line number Diff line change
@@ -1,11 +1,18 @@
import styled, { ThemeProvider } from "styled-components";
import theme from "../../utils/constant.js";
import styled from "styled-components";
import HeaderNavbar from "./HeaderNavbar.jsx";

const HeaderLeft = () => {
return (
<HeaderLeftDiv>
<BanchanTitle>BANCHAN</BanchanTitle>
<HeaderNavbar />
</HeaderLeftDiv>
);
};

const HeaderLeftDiv = styled.div`
display: flex;
align-items: center;
font-family: Noto Sans KR;
`;

const BanchanTitle = styled.div`
Expand All @@ -14,16 +21,4 @@ const BanchanTitle = styled.div`
font-weight: 900;
margin-right: 12px;
`;

const HeaderLeft = () => {
return (
<ThemeProvider theme={theme}>
<HeaderLeftDiv>
<BanchanTitle>BANCHAN</BanchanTitle>
<HeaderNavbar />
</HeaderLeftDiv>
</ThemeProvider>
);
};

export default HeaderLeft;
20 changes: 7 additions & 13 deletions banchan/src/components/header/headerLeft/HeaderNavbar.jsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import React from "react";
import styled, { ThemeProvider } from "styled-components";
import theme from "../../utils/constant";
import styled from "styled-components";
import NavListItems from "./NavListItems";

const HeaderNavbar = (props) => {
Expand All @@ -19,21 +18,16 @@ const HeaderNavbar = (props) => {
},
];

const NavUL = styled.ul`
display: flex;
color: ${(props) => props.theme.colors.darkGray};
font-size: ${(props) => props.theme.fontSizes.S};
`;

const navbarList = navLists.map((list, i) => (
<NavListItems key={i} list={list} />
));

return (
<NavUL>
<ThemeProvider theme={theme}>{navbarList}</ThemeProvider>
</NavUL>
);
return <NavUL>{navbarList}</NavUL>;
};
const NavUL = styled.ul`
display: flex;
color: ${(props) => props.theme.colors.darkGray};
font-size: ${(props) => props.theme.fontSizes.S};
`;

export default HeaderNavbar;
79 changes: 39 additions & 40 deletions banchan/src/components/header/headerLeft/NavListItems.jsx
Original file line number Diff line number Diff line change
@@ -1,41 +1,8 @@
import React, { useState } from "react";
import styled, { ThemeProvider } from "styled-components";
import theme from "../../utils/constant";
import styled from "styled-components";

const NavListItems = ({ list }) => {
const NavLITitle = styled.span`
&:hover {
font-weight: bold;
}
`;
const [isMouseOver, setIsMouseOver] = useState(false);
const NavLI = styled.li`
margin: 0 12px;
`;

const NavLIBox = styled.ul`
padding: 5px 7px;
display: flex;
flex-direction: column;
min-width: 100px;
min-height: 86px;
background: #ffffff;
box-shadow: 0px 0px 4px rgba(204, 204, 204, 0.5),
0px 2px 4px rgba(0, 0, 0, 0.25);
position: absolute;
top: 65px;
`;

const SubElementsLI = styled.li`
margin: 3px 0;
&:first-child {
font-weight: bold;
text-decoration: underline;
color: ${(props) => props.theme.colors.darkGray};
}
color: ${(props) => props.theme.colors.gray};
font-weight: "400";
`;

const handleMouseEnter = () => {
setIsMouseOver((isMouseOver) => (isMouseOver = true));
Expand All @@ -50,13 +17,45 @@ const NavListItems = ({ list }) => {
));

return (
<ThemeProvider theme={theme}>
<NavLI onMouseEnter={handleMouseEnter} onMouseLeave={handleMouseLeave}>
<NavLITitle>{list.title}</NavLITitle>
{isMouseOver && <NavLIBox>{listSubElements}</NavLIBox>}
</NavLI>
</ThemeProvider>
<NavLI onMouseEnter={handleMouseEnter} onMouseLeave={handleMouseLeave}>
<NavLITitle>{list.title}</NavLITitle>
{isMouseOver && <NavLIBox>{listSubElements}</NavLIBox>}
</NavLI>
);
};

const NavLITitle = styled.span`
&:hover {
font-weight: bold;
}
`;

const NavLI = styled.li`
margin: 0 12px;
`;

const NavLIBox = styled.ul`
padding: 5px 7px;
display: flex;
flex-direction: column;
min-width: 100px;
min-height: 86px;
background: #ffffff;
box-shadow: 0px 0px 4px rgba(204, 204, 204, 0.5),
0px 2px 4px rgba(0, 0, 0, 0.25);
position: absolute;
top: 65px;
`;

const SubElementsLI = styled.li`
margin: 3px 0;
&:first-child {
font-weight: bold;
text-decoration: underline;
color: ${(props) => props.theme.colors.darkGray};
}
color: ${(props) => props.theme.colors.gray};
font-weight: "400";
`;

export default NavListItems;
40 changes: 18 additions & 22 deletions banchan/src/components/header/headerRight/HeaderRight.jsx
Original file line number Diff line number Diff line change
@@ -1,31 +1,27 @@
import styled, { ThemeProvider } from "styled-components";
import theme from "../../utils/constant";
import styled from "styled-components";

const HeaderRight = (props) => {
const HeaderRightDiv = styled.div`
display: flex;
align-items: center;
`;

const StyledSpan = styled.span`
margin: 0 12px;
font-size: ${(props) => props.theme.fontSizes.S};
font-family: "Noto Sans KR";
cursor: pointer;
&:hover {
font-weight: bold;
}
`;

return (
<HeaderRightDiv>
<ThemeProvider theme={theme}>
<input />
<StyledSpan>로그인</StyledSpan>
<StyledSpan>장바구니</StyledSpan>
</ThemeProvider>
<input />
<StyledSpan>로그인</StyledSpan>
<StyledSpan>장바구니</StyledSpan>
</HeaderRightDiv>
);
};

const HeaderRightDiv = styled.div`
display: flex;
align-items: center;
`;

const StyledSpan = styled.span`
margin: 0 12px;
font-size: ${(props) => props.theme.fontSizes.S};
cursor: pointer;
&:hover {
font-weight: bold;
}
`;

export default HeaderRight;
10 changes: 5 additions & 5 deletions banchan/src/components/main/CarouselSection.jsx
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
import { useEffect, useState } from 'react';
import Card from '../utils/Card';
import theme from '../utils/constant';
import { useEffect, useState } from "react";
import Card from "../utils/Card";
import theme from "../utils/theme";

const CarouselSection = (props) => {
const [products, setProducts] = useState([]);

useEffect(() => {
fetch(
'https://h3rb9c0ugl.execute-api.ap-northeast-2.amazonaws.com/develop/baminchan/main'
"https://h3rb9c0ugl.execute-api.ap-northeast-2.amazonaws.com/develop/baminchan/main"
)
.then((response) => response.json())
.then((result) => setProducts(result.body))
.then((error) => console.log('error', error));
.then((error) => console.log("error", error));
}, []);

return (
Expand Down
16 changes: 5 additions & 11 deletions banchan/src/components/utils/Card.jsx
Original file line number Diff line number Diff line change
@@ -1,24 +1,18 @@
import styled from 'styled-components';
import theme from './constant';
import Price from './Price';
import styled from "styled-components";
import theme from "./theme";
import Price from "./Price";

const Card = ({ product, cardSize }) => {
return (
<StyledLi cardSize={cardSize}>
<StyledImg cardSize={cardSize} src={product.image} alt="card-image" />
<StyledTitle>
<span>{product.title}</span>
</StyledTitle>
<StyledDescription>
<span>{product.description}</span>
</StyledDescription>
<StyledTitle>{product.title}</StyledTitle>
<StyledDescription>{product.description}</StyledDescription>
<Price product={product} />
</StyledLi>
);
};

// ============================= ● Styled components ● =============================

const StyledLi = styled.li`
width: ${(props) => props.cardSize};
`;
Expand Down
8 changes: 6 additions & 2 deletions banchan/src/components/utils/Label.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,18 @@ const LABEL_TYPE = {
LAUNCH: "런칭특가",
};

const Label = ({ type }) => <StyledLabel type={type}>{LABEL_TYPE[type]}</StyledLabel>;
const Label = ({ type }) => (
<StyledLabel type={type}>{LABEL_TYPE[type]}</StyledLabel>
);

const StyledLabel = styled.span`
padding: 4px 16px;
border-radius: ${theme.borders.radius};
color: ${theme.colors.white};
font-size: ${theme.fontSizes.XS};
font-weight: bold;
background: ${({ type }) => (type === "EVENT" ? theme.colors.green : theme.colors.lightBlue)};
background: ${({ type }) =>
type === "EVENT" ? theme.colors.green : theme.colors.lightBlue};
`;

export default Label;
6 changes: 2 additions & 4 deletions banchan/src/components/utils/Price.jsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import styled from 'styled-components';
import theme from './constant';
import styled from "styled-components";
import theme from "./theme";

const Price = ({ product }) => {
const isOnSale = !!product.n_price;
Expand All @@ -14,8 +14,6 @@ const Price = ({ product }) => {
);
};

// ============================= ● Styled components ● =============================

const StyledPriceWrapper = styled.div`
display: flex;
align-items: center;
Expand Down
Loading