parent
5baffd02ca
commit
70c3978b45
@ -1,25 +1,55 @@ |
|||||||
import Link from "next/link"; |
/* import Link from "next/link"; */ |
||||||
import * as React from "react"; |
import * as React from "react"; |
||||||
import { SVGProps } from "react"; |
import { SVGProps } from "react"; |
||||||
|
import styled from "styled-components"; |
||||||
|
|
||||||
const ScrollMe = (props: SVGProps<SVGSVGElement> & { href: string }) => ( |
const ScrollMeWrapper = styled.div` |
||||||
<Link href={props.href}> |
position: absolute; |
||||||
<svg |
bottom: 2rem; |
||||||
xmlns="http://www.w3.org/2000/svg" |
left: 50%; |
||||||
height="1em" |
color: var(--fg-faded); |
||||||
viewBox="0 0 38 23" |
|
||||||
stroke="currentColor" |
@media only screen and (max-height: 490px) { |
||||||
fill="none" |
display: none; |
||||||
{...props} |
} |
||||||
> |
|
||||||
<path |
:hover { |
||||||
strokeLinecap="round" |
cursor: pointer; |
||||||
strokeLinejoin="round" |
} |
||||||
strokeWidth={2.8} |
|
||||||
d="m2 2 15.77 17.369a2 2 0 0 0 2.96 0L36.5 2" |
svg { |
||||||
/> |
width: 1.2rem; |
||||||
</svg> |
height: auto; |
||||||
</Link> |
} |
||||||
); |
`;
|
||||||
|
|
||||||
|
const ScrollMe = (props: SVGProps<SVGSVGElement> & { href: string }) => { |
||||||
|
const handleScroll = () => { |
||||||
|
const sectionRef = document.querySelector(props.href); |
||||||
|
if (sectionRef) { |
||||||
|
sectionRef.scrollIntoView({ behavior: "smooth" }); |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
return ( |
||||||
|
<ScrollMeWrapper onClick={handleScroll}> |
||||||
|
<svg |
||||||
|
xmlns="http://www.w3.org/2000/svg" |
||||||
|
height="1em" |
||||||
|
viewBox="0 0 38 23" |
||||||
|
stroke="currentColor" |
||||||
|
fill="none" |
||||||
|
{...props} |
||||||
|
> |
||||||
|
<path |
||||||
|
strokeLinecap="round" |
||||||
|
strokeLinejoin="round" |
||||||
|
strokeWidth={2.8} |
||||||
|
d="m2 2 15.77 17.369a2 2 0 0 0 2.96 0L36.5 2" |
||||||
|
/> |
||||||
|
</svg> |
||||||
|
</ScrollMeWrapper> |
||||||
|
); |
||||||
|
}; |
||||||
|
|
||||||
export default ScrollMe; |
export default ScrollMe; |
||||||
|
Loading…
Reference in new issue