mirror of
https://github.com/Spythere/spythere-portfolio.git
synced 2026-05-03 21:48:18 +00:00
smooth scrolling
This commit is contained in:
@@ -13,13 +13,14 @@ function AboutSection() {
|
|||||||
</span>
|
</span>
|
||||||
</StyledSectionHeader>
|
</StyledSectionHeader>
|
||||||
|
|
||||||
<div style={{ display: 'flex' }}>
|
<div>
|
||||||
<StyledAboutItem>
|
<StyledAboutItem>
|
||||||
<img src="question.svg" alt="" />
|
<img src="question.svg" alt="" />
|
||||||
<h2>MYSELF</h2>
|
<h2>MYSELF</h2>
|
||||||
</StyledAboutItem>
|
</StyledAboutItem>
|
||||||
|
|
||||||
|
<div>test</div>
|
||||||
</div>
|
</div>
|
||||||
<p>test</p>
|
|
||||||
</StyledAbout>
|
</StyledAbout>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ import { StyledBrandName, StyledLanding, StyledLandingWrapper } from './styles/L
|
|||||||
|
|
||||||
export default function LandingSection() {
|
export default function LandingSection() {
|
||||||
return (
|
return (
|
||||||
<StyledLanding>
|
<StyledLanding id="landing">
|
||||||
<StyledLandingWrapper>
|
<StyledLandingWrapper>
|
||||||
<Logo />
|
<Logo />
|
||||||
|
|
||||||
|
|||||||
@@ -12,6 +12,14 @@ interface NavLink {
|
|||||||
href: string;
|
href: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function scrollToSection(e: React.MouseEvent, href: string) {
|
||||||
|
e.preventDefault();
|
||||||
|
|
||||||
|
document.querySelector(href)!.scrollIntoView({
|
||||||
|
behavior: 'smooth',
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
function NavlinkList(props: { navlinks: NavLink[] }) {
|
function NavlinkList(props: { navlinks: NavLink[] }) {
|
||||||
const { t } = useTranslation();
|
const { t } = useTranslation();
|
||||||
|
|
||||||
@@ -19,7 +27,7 @@ function NavlinkList(props: { navlinks: NavLink[] }) {
|
|||||||
<>
|
<>
|
||||||
<StyledNavlinkList>
|
<StyledNavlinkList>
|
||||||
{props.navlinks.map((navlink) => (
|
{props.navlinks.map((navlink) => (
|
||||||
<StyledNavlink key={navlink.title} href={navlink.href}>
|
<StyledNavlink key={navlink.title} href={navlink.href} onClick={(e) => scrollToSection(e, navlink.href)}>
|
||||||
{t(`navbar.${navlink.title}`)}
|
{t(`navbar.${navlink.title}`)}
|
||||||
</StyledNavlink>
|
</StyledNavlink>
|
||||||
))}
|
))}
|
||||||
@@ -68,7 +76,9 @@ export default function Navbar() {
|
|||||||
|
|
||||||
return (
|
return (
|
||||||
<StyledNavbar>
|
<StyledNavbar>
|
||||||
<StyledNavlinkBrand>{t('navbar.title')}</StyledNavlinkBrand>
|
<StyledNavlinkBrand href="#" onClick={(e) => scrollToSection(e, '#landing')}>
|
||||||
|
{t('navbar.title')}
|
||||||
|
</StyledNavlinkBrand>
|
||||||
<NavlinkList navlinks={navlinks} />
|
<NavlinkList navlinks={navlinks} />
|
||||||
</StyledNavbar>
|
</StyledNavbar>
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -32,7 +32,7 @@ export const GlobalStyles = createGlobalStyle`
|
|||||||
|
|
||||||
section {
|
section {
|
||||||
min-height: 100vh;
|
min-height: 100vh;
|
||||||
padding: 1em 2em;
|
padding: 3.5em 2em;
|
||||||
}
|
}
|
||||||
|
|
||||||
a {
|
a {
|
||||||
|
|||||||
@@ -1,16 +1,20 @@
|
|||||||
import { styled } from 'styled-components';
|
import { styled } from 'styled-components';
|
||||||
|
|
||||||
export const StyledNavbar = styled.nav`
|
export const StyledNavbar = styled.nav`
|
||||||
|
position: sticky;
|
||||||
|
top: 0;
|
||||||
|
|
||||||
display: flex;
|
display: flex;
|
||||||
justify-content: space-between;
|
justify-content: space-between;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
height: 3.5em;
|
height: 3.5em;
|
||||||
|
|
||||||
color: white;
|
color: white;
|
||||||
|
background-color: ${({ theme }) => theme.colors.nav};
|
||||||
padding: 0.75em 2em;
|
padding: 0.75em 2em;
|
||||||
`;
|
`;
|
||||||
|
|
||||||
export const StyledNavlinkBrand = styled.div`
|
export const StyledNavlinkBrand = styled.a`
|
||||||
opacity: 0.85;
|
opacity: 0.85;
|
||||||
font-weight: 700;
|
font-weight: 700;
|
||||||
color: ${({ theme }) => theme.colors.primary};
|
color: ${({ theme }) => theme.colors.primary};
|
||||||
|
|||||||
@@ -2,6 +2,7 @@ export const theme = {
|
|||||||
colors: {
|
colors: {
|
||||||
primary: 'lightseagreen',
|
primary: 'lightseagreen',
|
||||||
bg: '#242424',
|
bg: '#242424',
|
||||||
|
nav: '#1b1b1b',
|
||||||
},
|
},
|
||||||
fonts: {
|
fonts: {
|
||||||
primary: 'Inter, system-ui, Arial, sans-serif',
|
primary: 'Inter, system-ui, Arial, sans-serif',
|
||||||
|
|||||||
Reference in New Issue
Block a user