Fixed & added scrollme button

main
E. Almqvist 2 years ago
parent 5baffd02ca
commit 70c3978b45
No known key found for this signature in database
GPG Key ID: E31A99CE3E75A158
  1. 70
      components/scrollme.tsx
  2. 2
      pages/index.tsx
  3. 1
      styles/globals.css

@ -1,25 +1,55 @@
import Link from "next/link";
/* import Link from "next/link"; */
import * as React from "react";
import { SVGProps } from "react";
import styled from "styled-components";
const ScrollMe = (props: SVGProps<SVGSVGElement> & { href: string }) => (
<Link href={props.href}>
<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>
</Link>
);
const ScrollMeWrapper = styled.div`
position: absolute;
bottom: 2rem;
left: 50%;
color: var(--fg-faded);
@media only screen and (max-height: 490px) {
display: none;
}
:hover {
cursor: pointer;
}
svg {
width: 1.2rem;
height: auto;
}
`;
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;

@ -148,7 +148,7 @@ const Page: NextPageWithLayout = () => {
rel="noreferrer"
/>
</LinkList>
{/*<ScrollMe href="#contact" />*/}
<ScrollMe href="#contact" />
</Section>
<Section>

@ -36,7 +36,6 @@
html {
background: var(--bg);
scroll-behavior: smooth;
scroll-snap-type: y mandatory;
}
section {

Loading…
Cancel
Save