feat(slick): hide button when not hovered

This commit is contained in:
2021-01-14 21:55:14 +00:00
parent 86e8a10f72
commit 83c7503d75

View File

@@ -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 (
<Container>
<Slick ref={slick} {...settings}> <Slick ref={slick} {...settings}>
{children} {children}
</Slick> </Slick>
</Container>
); );
} }