Notice
Recent Posts
Recent Comments
Link
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | 2 | 3 | 4 | |||
5 | 6 | 7 | 8 | 9 | 10 | 11 |
12 | 13 | 14 | 15 | 16 | 17 | 18 |
19 | 20 | 21 | 22 | 23 | 24 | 25 |
26 | 27 | 28 | 29 | 30 | 31 |
Tags
- Eventlitener
- 차집합
- useRef()
- includes()
- 교집합
- useEffect()
- getday()
- 소수점 올림내림
- jsx반복문
- isNaN()
- setDate
- sort()
- 3진수
- 항해99솔직후기 #항해99장점 #항해99단점 #부트캠프추천
- parseInt()
- toUpperCase()
- React
- repeat()
- filter()
- Math.sqrt()
- charAt()
- map()
- Math.floor()
- useState()
- new Date()
- Number()
- reat if문
- indexOf()
- slice()
- substring()
Archives
- Today
- Total
개발자로 전향중
React 체크박스 여러개 체크할 때 체크 value 본문
const BuyProductSection = styled.section`
width: 100%;
height: 250px;
.buyProductSection--header {
height: 27px;
border: 1px solid #cecece;
border-radius: 13px;
font-family: "Roobert";
font-style: normal;
font-weight: 400;
font-size: 18.3881px;
display: flex;
align-items: center;
justify-content: center;
color: #000000;
}
`;
const BuyProductWrapper = styled.div`
display: flex;
justify-content: space-between;
margin-top: 10px;
.buyProductSection--product2 {
width: 105px;
height: 105px;
background: #ffffff;
border: 1px solid #cecece;
border-radius: 13.1343px;
margin-right: 2px;
}
.buyProductSection--product3 {
width: 105px;
height: 105px;
background: #ffffff;
border: 1px solid #cecece;
border-radius: 13.1343px;
margin-right: 2px;
}
.buyProductSection--product4 {
width: 105px;
height: 105px;
background: #ffffff;
border: 1px solid #cecece;
border-radius: 13.1343px;
margin-right: 2px;
}
`;
const BuyProduct1 = styled.div`
position: relative;
width: 105px;
height: 105px;
background: #ffffff;
border: 1px solid #cecece;
border-radius: 13.1343px;
margin-right: 2px;
.buyProduct1--selectClothes {
width: 100%;
}
& > input[type="checkbox"] {
position: absolute;
left: 8px;
bottom: 8px;
appearance: none;
width: 16px;
height: 16px;
background: #ffffff;
border: 1px solid #cecece;
border-radius: 3px;
cursor: pointer;
transition: background 0.2s;
}
& > input[type="checkbox"]:checked {
border-color: transparent;
background-image: url("data:image/svg+xml,%3Csvg width='9' height='9' viewBox='0 0 9 9' fill='none' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M1 2.75L3.33333 8L8 1' stroke='%230C8AFF' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E%0A");
background-size: 100% 100%;
// background-position: 50%;
background-repeat: no-repeat;
border: 3px solid #0c8aff;
}
.buyProduct1--name {
font-family: "Roobert";
font-weight: 700;
font-size: 12px;
text-decoration-line: underline;
color: #000000;
margin: 15px 0px 10px 8px;
}
.buyProduct1--price {
width: 50px;
height: 20px;
border: 1px solid #cecece;
border-radius: 13px;
font-family: "Roobert";
font-weight: 400;
font-size: 12px;
color: #000000;
display: flex;
justify-content: center;
margin: 0px 0px 0px 8px;
}
`;
{findBrand?.Top.map((value, index) => {
return (
<BuyProductSection>
<div className="buyProductSection--header">test</div>
<BuyProductWrapper>
<BuyProduct1>
<img
className="buyProduct1--selectClothes"
src={value}
alt="selectClothes"
/>
<SelectProduct
index={index}
checkedItemHandler={checkedItemHandler}
/>
<div className="buyProduct1--name">test</div>
<div className="buyProduct1--price">*200</div>
</BuyProduct1>
</BuyProductWrapper>
</BuyProductSection>
);
})}
import React, { useEffect, useState } from "react";
interface valueProps {
index: number;
checkedItemHandler: (index: number, isChecked: boolean) => void;
}
const SelectProduct = ({ index, checkedItemHandler }: valueProps) => {
// Issue 컴포넌트
const [bChecked, setChecked] = useState(false);
const checkHandler = (index: number, { target }: any) => {
setChecked(!bChecked);
checkedItemHandler(index, target.checked);
};
return (
<>
<input
type="checkbox"
checked={bChecked}
onChange={(e) => checkHandler(index, e)}
/>
</>
);
};
export default SelectProduct;
'React' 카테고리의 다른 글
TypeScript 환경변수 설정하고 싶을때 (0) | 2022.12.02 |
---|---|
Redux-Toolkit TypeScript 여러개의 객체를 배열 추가할때 (0) | 2022.11.24 |
react 표 만들고 싶을 때 참고 (0) | 2022.10.26 |
react hook form 사용 예시 and 자동 전화번호 하이픈 (1) | 2022.10.06 |
UseCountup 자동으로 숫자올라가기 (0) | 2022.10.06 |