Browse Source

fix: scroll issues in /experience

master
Muthu Kumar 3 weeks ago
parent
commit
f78e0d8f9b
Failed to extract signature
  1. 5
      src/components/Container.tsx
  2. 102
      src/components/Exp/Story.tsx
  3. 38
      src/pages/main/Exp.tsx
  4. 9
      src/pages/main/data/experience.tsx

5
src/components/Container.tsx

@ -89,8 +89,9 @@ const Container: React.FC<{
} }
useEffect(() => { useEffect(() => {
// scroll back to top when new page is loaded const depth = location.split("/").length;
window.scrollTo({ top: 0 }); // scroll back to top when new page is loaded, only for top-level pages
if (depth === 1) window.scrollTo({ top: 0 });
if (highlightCircle.current) { if (highlightCircle.current) {
highlightCircle.current.classList.add("highlight"); highlightCircle.current.classList.add("highlight");

102
src/components/Exp/Story.tsx

@ -1,4 +1,4 @@
import React from "react"; import React, { useEffect, useRef } from "react";
import { css, cx } from "@emotion/css"; import { css, cx } from "@emotion/css";
import { ReactComponent as Close } from "../../assets/close.svg"; import { ReactComponent as Close } from "../../assets/close.svg";
import { Experience } from "./types"; import { Experience } from "./types";
@ -138,66 +138,70 @@ const story = css`
} }
`; `;
const story_logo = css`
height: 4rem;
width: 4rem;
margin-inline-start: var(--padding);
background: rgba(40, 40, 40);
border-radius: 100%;
& img {
height: 100%;
border-radius: 100%;
}
`;
const closer = css`
display: none;
appearance: none;
border: none;
background: var(--card-active);
color: var(--text-subdued);
width: 1.8rem;
height: 1.8rem;
padding: 0.2rem;
border-radius: 3rem;
& svg {
width: 0.8rem;
height: 0.8rem;
}
/* set in mobile mode */
/* display: flex; */
justify-content: center;
align-items: center;
position: absolute;
top: calc(1rem + var(--padding));
right: var(--padding);
cursor: pointer;
transform: rotate(90deg);
`;
export const Story = ({ title, description, logo, active }: Experience) => { export const Story = ({ title, description, logo, active }: Experience) => {
const ref = useRef<HTMLDivElement>(null);
useEffect(() => {
if (active) setTimeout(() => ref.current?.scrollIntoView(true), 300);
}, [active]);
return ( return (
<div <div
ref={ref}
className={cx(story, "story")} className={cx(story, "story")}
id={active ? "active-story" : undefined}> id={active ? "active-story" : undefined}>
<div aria-hidden className="story-handle" /> <div aria-hidden className="story-handle" />
<div className="story-content"> <div className="story-content">
<picture <picture className={cx("story-logo", story_logo)}>
className={cx(
"story-logo",
css`
height: 4rem;
width: 4rem;
margin-inline-start: var(--padding);
background: rgba(40, 40, 40);
border-radius: 100%;
& img {
height: 100%;
border-radius: 100%;
}
`,
)}>
<source srcSet={`/assets/logos/` + logo + ".avif"} /> <source srcSet={`/assets/logos/` + logo + ".avif"} />
<img alt={title + " logo"} src={`/assets/logos/` + logo + ".png"} /> <img alt={title + " logo"} src={`/assets/logos/` + logo + ".png"} />
</picture> </picture>
<button <button
title="Close story" title="Close story"
className={cx( className={cx("closer", closer)}
"closer",
css`
display: none;
appearance: none;
border: none;
background: var(--card-active);
color: var(--text-subdued);
width: 1.8rem;
height: 1.8rem;
padding: 0.2rem;
border-radius: 3rem;
& svg {
width: 0.8rem;
height: 0.8rem;
}
/* set in mobile mode */
/* display: flex; */
justify-content: center;
align-items: center;
position: absolute;
top: calc(1rem + var(--padding));
right: var(--padding);
cursor: pointer;
transform: rotate(90deg);
`,
)}
onClick={() => window.history.back()}> onClick={() => window.history.back()}>
<Close /> <Close />
</button> </button>

38
src/pages/main/Exp.tsx

@ -8,6 +8,24 @@ import useSearchParams from "../../util/useSearchParams";
import useLocation from "wouter/use-location"; import useLocation from "wouter/use-location";
import { AnimateEntry } from "../../components/AnimateEntry"; import { AnimateEntry } from "../../components/AnimateEntry";
const units = css`
width: 100%;
--item-padding: 1.2rem;
display: grid;
grid-template-columns: repeat(auto-fit, 20rem);
row-gap: 0.5rem;
column-gap: 1rem;
@media screen and (min-width: ${offscreenWidth}) {
transform: translateX(0);
}
& > * {
padding-top: 2.4rem;
}
`;
const exp_route = /^\/experience\/?[^\/]*$/; const exp_route = /^\/experience\/?[^\/]*$/;
const slug_replace = /^\/experience\/?/; const slug_replace = /^\/experience\/?/;
@ -64,25 +82,7 @@ const Exp: React.FC = () => {
<AnimateEntry <AnimateEntry
as="section" as="section"
delay={entryDelay ? 150 : 0} delay={entryDelay ? 150 : 0}
className={cx( className={cx(units)}>
css`
width: 100%;
--item-padding: 1.2rem;
display: grid;
grid-template-columns: repeat(auto-fit, 20rem);
row-gap: 0.5rem;
column-gap: 1rem;
@media screen and (min-width: ${offscreenWidth}) {
transform: translateX(0);
}
& > * {
padding-top: 2.4rem;
}
`,
)}>
{experience {experience
.filter(unit => !tags.size || unit.tags.some(tag => tags.has(tag))) .filter(unit => !tags.size || unit.tags.some(tag => tags.has(tag)))
.map((unit, i) => ( .map((unit, i) => (

9
src/pages/main/data/experience.tsx

@ -258,11 +258,10 @@ export const experience = [
At Hugo's Way, I played a key role in stabilising their currency At Hugo's Way, I played a key role in stabilising their currency
exchange platform, ensuring smooth and reliable operations. exchange platform, ensuring smooth and reliable operations.
Recognising the imperative for scalability and adaptability, I Recognising the imperative for scalability and adaptability, I
spearheaded the transition from a monolithic architecture to a more spearheaded the transition from a monolithic architecture to be more
agile and modular service-oriented one to achieve flexibility to agile and modular service-oriented to achieve flexibility to deploy
deploy as whitelabelled services. This structural overhaul not only whitelabelled services. This structural overhaul not only improved
bolstered performance but also streamlined development cycles and performance but also streamlined development cycles.
maintenance.
</p> </p>
<p> <p>

Loading…
Cancel
Save