January 24, 2020
const moveImg = px => {
if (leftPx <= 0 && (imgList.length - 1) * -714 < leftPx) setLeft(px);
else {
setLeft(0);
}
};
<Wrapper>
<AbsolDiv left={leftPx}>{imgMap}</AbsolDiv>
<MoveBtn onClick={() => moveImg(leftPx + 714)} />
<MoveBtn
onClick={() => moveImg(leftPx - 714)}
first={-935}
second={-332}
left={660}
/>
</Wrapper>
const MoveBtn = styled.div`
position: absolute;
top: 50%;
left: ${({ left }) => left || 0}px;
margin-top: -16px;
cursor: pointer;
background-image: url("https://mp-seoul-image-develop-s3.mangoplate.com/web/resources/2018022864551sprites_desktop.png?fit=around|*:*&crop=*:*;*,*&output-format=png&output-quality=110");
background-position: ${({ first }) => first || -935}px
${({ second }) => second || -281}px;
width: 28px;
height: 45px;
opacity: 0.5;
margin-left: 10px;
&:hover {
opacity: 1;
}
`;
};
const onClick = (key, num) => {
setFilter({
all: "false",
good: "false",
soso: "false",
bad: "false"
});
setFilter({
[key]: "true"
});
setRating([]);
fetchData(`${API_URL}/restaurant/${props.params}/review?taste=${num}`).then(
res => {
setRating(res);
}
);
};
<ButtonFilterBtn
filter={reviewFilter.bad}
onClick={() => onClick("bad", 3)}
last={true}
>
별로<SpanFilterCount>({number.bad_count})</SpanFilterCount>
</ButtonFilterBtn>
useImperativeHandle(ref, () => ({
moreOnClick() {
console.log(ratingReview)
fetchData(
`http://10.58.7.97:8000/restaurant/${
props.params
}/review?taste=${stateCheck()}&offset=${ratingReview.offset + 1}`
).then(res => {
const copy = Object.assign({}, ratingReview)
if (copy.result !== res.result) {
const concatArr = copy.result.concat(res.result)
copy.result = concatArr
copy.offset = res.offset
}
setRating(copy)
})
},
}))
const stateCheck = () => {
if (reviewFilter.all) return 4
else if (reviewFilter.good) return 1
else if (reviewFilter.soso) return 2
else if (reviewFilter.bad) return 3
}
const ratingText = index => {
if (rate[index].rating === 'good') return '맛있다'
else if (rate[index].rating === 'soso') return '괜찮다'
else return '나쁘다'
}
const ToastContainer = toggle => {
return <ToastView toggle={toggle} />
}
const mapStateToProps = state => ({ show: state.showToast.show })
const mapDispatchToProps = dispatch => ({
toggle: () => dispatch(toggle()),
})
export default connect(mapStateToProps, mapDispatchToProps)(ToastContainer)