Skip to content
Open
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
192 changes: 98 additions & 94 deletions longkathon/src/components/ColorPalette.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,134 +12,138 @@ import XGray from "../Image/X_gray.png";
import XBlack from "../Image/X_black.png";

const colors = [
{ color: "#EA7E7A", image: XRed },
{ color: "#FBA96F", image: XOrange },
{ color: "#9ED4B6", image: XGreen },
{ color: "#5BA8FB", image: XSkyblue },
{ color: "#002ED1", image: XBlue },
{ color: "#D9A9ED", image: XPink },
{ color: "#927CFF", image: XPurple },
{ color: "#BDBDBD", image: XGray },
{ color: "#424242", image: XBlack },
{ color: "#EA7E7A", image: XRed },
{ color: "#FBA96F", image: XOrange },
{ color: "#9ED4B6", image: XGreen },
{ color: "#5BA8FB", image: XSkyblue },
{ color: "#002ED1", image: XBlue },
{ color: "#D9A9ED", image: XPink },
{ color: "#927CFF", image: XPurple },
{ color: "#BDBDBD", image: XGray },
{ color: "#424242", image: XBlack },
];

//타 페이지에서 사용할 수 있도록 컬러 props로 저장
function ColorPalette({ onColorSelect }) {
const [selectedColor, setSelectedColor] = useState(null);
const [selectedImage, setSelectedImage] = useState(XBlue);

const handleColorClick = (index) => {
setSelectedColor(index);
setSelectedImage(colors[index].image);
onColorSelect(colors[index].color);
};

return (
<Container>
<Title>링크 조각:</Title>
<Content>
<LeftBox>
<XShape src={selectedImage} alt="X Shape" />
</LeftBox>
<ColorWrapper>
<ColorRow>
{colors.slice(0, 5).map((item, index) => (
<ColorContainer
key={index}
onClick={() => handleColorClick(index)}
>
{selectedColor === index && <ColorOuterCircle color={item.color} />}
<ColorCircle color={item.color} />
</ColorContainer>
))}
</ColorRow>
<ColorRow>
{colors.slice(5).map((item, index) => (
<ColorContainer
key={index + 5}
onClick={() => handleColorClick(index + 5)}
>
{selectedColor === index + 5 && <ColorOuterCircle color={item.color} />}
<ColorCircle color={item.color} />
</ColorContainer>
))}
</ColorRow>
</ColorWrapper>
</Content>
</Container>
);
const [selectedColor, setSelectedColor] = useState(null);
const [selectedImage, setSelectedImage] = useState(XBlue);

const handleColorClick = (index) => {
setSelectedColor(index);
setSelectedImage(colors[index].image);
onColorSelect(colors[index].color);
};

return (
<Container>
<Title>링크 조각:</Title>
<Content>
<LeftBox>
<XShape src={selectedImage} alt="X Shape" />
</LeftBox>
<ColorWrapper>
<ColorRow>
{colors.slice(0, 5).map((item, index) => (
<ColorContainer
key={index}
onClick={() => handleColorClick(index)}
>
{selectedColor === index && (
<ColorOuterCircle color={item.color} />
)}
<ColorCircle color={item.color} />
</ColorContainer>
))}
</ColorRow>
<ColorRow>
{colors.slice(5).map((item, index) => (
<ColorContainer
key={index + 5}
onClick={() => handleColorClick(index + 5)}
>
{selectedColor === index + 5 && (
<ColorOuterCircle color={item.color} />
)}
<ColorCircle color={item.color} />
</ColorContainer>
))}
</ColorRow>
</ColorWrapper>
</Content>
</Container>
);
}

const Container = styled.div`
width: 100%;
max-width: 1060px;
// margin: 0 auto;
width: 100%;
max-width: 1060px;
// margin: 0 auto;
`;

const Title = styled.h1`
font-size: 24px;
font-weight: bold;
margin-bottom: 16px;
font-family: "Product Sans", sans-serif;
font-size: 24px;
font-weight: bold;
margin-bottom: 16px;
font-family: "Product Sans", sans-serif;
`;

const Content = styled.div`
display: flex;
gap: 28px;
align-items: center;
display: flex;
gap: 28px;
align-items: center;
`;

const LeftBox = styled.div`
width: 153px;
height: 124px;
border: 1px solid #dcdcdc;
border-radius: 20px;
display: flex;
align-items: center;
justify-content: center;
background-color: #ffffff;
width: 153px;
height: 124px;
border: 1px solid #dcdcdc;
border-radius: 20px;
display: flex;
align-items: center;
justify-content: center;
background-color: #ffffff;
`;

const XShape = styled.img`
width: 304px; //크기 수정 필요!!!//
height: 170px;
object-fit: contain;
border-radius: 20%;
width: 304px; //크기 수정 필요!!!//
height: 170px;
object-fit: contain;
border-radius: 20%;
`;

const ColorWrapper = styled.div`
display: flex;
flex-direction: column;
gap: 28px;
display: flex;
flex-direction: column;
gap: 28px;
`;

const ColorRow = styled.div`
display: flex;
gap: 28px;
display: flex;
gap: 28px;
`;

const ColorContainer = styled.div`
position: relative;
display: flex;
align-items: center;
justify-content: center;
position: relative;
display: flex;
align-items: center;
justify-content: center;
`;

const ColorOuterCircle = styled.div`
width: 56px;
height: 56px;
position: absolute;
border-radius: 50%;
border: 2px solid ${(props) => props.color};
box-sizing: border-box;
width: 56px;
height: 56px;
position: absolute;
border-radius: 50%;
border: 2px solid ${(props) => props.color};
box-sizing: border-box;
`;

const ColorCircle = styled.div`
width: 48px;
height: 48px;
border-radius: 50%;
background-color: ${(props) => props.color};
cursor: pointer;
width: 48px;
height: 48px;
border-radius: 50%;
background-color: ${(props) => props.color};
cursor: pointer;
`;

export default ColorPalette;
27 changes: 22 additions & 5 deletions longkathon/src/components/HamburgerButton.js
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,16 @@ export const HamburgerIcon = () => {
onClick={handleIconClick}
></LordIcon>
<BannersContainer show={showBanners}>
<LordiconBox>
<LordIcon
src="https://cdn.lordicon.com/lqxfrxad.json"
trigger="hover"
colors="#040404"
width="40px"
height="40px"
onClick={handleIconClick}
></LordIcon>
</LordiconBox>
{["마이 페이지", "진행 중 링크", "로그아웃"].map((category, index) => (
<Banner
key={index}
Expand Down Expand Up @@ -80,6 +90,11 @@ const Container = styled.div`
position: relative;
`;

const LordiconBox = styled.div`
margin-top: 16px;
margin-left: 100px;
`;

const LordIcon = styled.div.attrs((props) => ({
as: "lord-icon",
style: {
Expand All @@ -95,19 +110,20 @@ const LordIcon = styled.div.attrs((props) => ({
const BannersContainer = styled.div`
font-family: "Product Sans", sans-serif;
font-size: 16px;
width: 300px;
height: 162px;
width: 322px;
height: 864px;
border: ${(props) => (props.show ? "1px solid #AFB8C1" : "none")};
border-radius: 20px;
border-top-right-radius: 20px;
border-bottom-right-radius: 20px;
background-color: #ffffff;
display: ${(props) =>
props.show ? "flex" : "none"}; /* 드롭박스 표시 여부 */
flex-direction: column;
overflow: hidden;
box-shadow: 2px 2px 4px 0px rgba(217, 217, 217, 1),
-2px -2px 4px 0px rgba(217, 217, 217, 1);
position: absolute;
top: 45px;
position: fixed;
top: 0px;
left: 0px;
z-index: 999;
`;
Expand All @@ -121,6 +137,7 @@ const Banner = styled.div`
display: flex;
align-items: center;
cursor: pointer;
margin-left: 80px;

&:hover {
border: 0.5px solid #afb8c1;
Expand Down
Loading