feat(slick): hide button when not hovered
This commit is contained in:
@@ -19,15 +19,11 @@ const Button = styled.button`
|
|||||||
border: none;
|
border: none;
|
||||||
margin: 0;
|
margin: 0;
|
||||||
padding: 0;
|
padding: 0;
|
||||||
opacity: 0.5;
|
opacity: 0;
|
||||||
transform: translateY(-50%);
|
transform: translateY(-50%);
|
||||||
transition: opacity 0.3s ease-in-out;
|
transition: opacity 0.3s ease-in-out;
|
||||||
cursor: pointer;
|
cursor: pointer;
|
||||||
|
|
||||||
&:hover {
|
|
||||||
opacity: 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
svg {
|
svg {
|
||||||
width: 32px;
|
width: 32px;
|
||||||
height: 32px;
|
height: 32px;
|
||||||
@@ -44,6 +40,17 @@ const StyledButton = ({ to, onClick }) => (
|
|||||||
{to === "prev" ? <LeftArrow /> : <RightArrow />}
|
{to === "prev" ? <LeftArrow /> : <RightArrow />}
|
||||||
</Button>
|
</Button>
|
||||||
);
|
);
|
||||||
|
|
||||||
|
const Container = styled.div`
|
||||||
|
&:hover button {
|
||||||
|
opacity: 0.5;
|
||||||
|
}
|
||||||
|
|
||||||
|
button:hover {
|
||||||
|
opacity: 1;
|
||||||
|
}
|
||||||
|
`;
|
||||||
|
|
||||||
export default function CustomSlick({ children }) {
|
export default function CustomSlick({ children }) {
|
||||||
const slick = useRef();
|
const slick = useRef();
|
||||||
const settings = {
|
const settings = {
|
||||||
@@ -59,8 +66,10 @@ export default function CustomSlick({ children }) {
|
|||||||
slick.current.slickPlay();
|
slick.current.slickPlay();
|
||||||
}, [slick]);
|
}, [slick]);
|
||||||
return (
|
return (
|
||||||
<Slick ref={slick} {...settings}>
|
<Container>
|
||||||
{children}
|
<Slick ref={slick} {...settings}>
|
||||||
</Slick>
|
{children}
|
||||||
|
</Slick>
|
||||||
|
</Container>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user