Skip to content
This repository has been archived by the owner on Feb 4, 2025. It is now read-only.

Fix basic copy outline breakpoint issue #51

Merged
merged 2 commits into from
Jul 22, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .nvmrc
Original file line number Diff line number Diff line change
@@ -1 +1 @@
20.12.2
22.2.0
1 change: 1 addition & 0 deletions components/AnimatedComponent/AnimatedComponent.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ export type AllowedElement =
| 'ul'
| 'li'
| 'legend'
| 'aside'
| 'main';

export const AnimatedElement = ({
Expand Down
16 changes: 0 additions & 16 deletions components/Basic Copy/BasicCopy.module.sass
Original file line number Diff line number Diff line change
@@ -1,9 +1,4 @@
.Outer
margin-top: 100px
grid-template-columns: 1fr 320px
gap: 120px
margin-bottom: 200px

main
&>*:first-child
margin-top: 0px
Expand Down Expand Up @@ -43,11 +38,8 @@
aspect-ratio: 16/9

aside > div
position: sticky
top: 80px

ul li
margin: 10px 0px

button
display: block
Expand All @@ -59,11 +51,3 @@
&:hover
opacity: 1

@media(max-width: 1024px)
.Outer
display: block
margin-top: 50px
margin-bottom: 50px

aside
display: none
55 changes: 29 additions & 26 deletions components/Basic Copy/BasicCopy.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -26,44 +26,47 @@ export default function BasicCopy({
<section
className={clsx(
s.Outer,
'post-content flex w-full',
allH2s.length > 0 && showOutline && 'md:grid'
'post-content flex w-full gap-12 mt-24 mb-48'
)}
>
<AnimatedElement innerRef={mainRef} type="main" delay={250}>
<PortableText value={copy} />
</AnimatedElement>
{allH2s.length > 0 && showOutline ? (
<aside>
<AnimatedElement type="div" delay={300}>
<h5>{outlineHeading}</h5>
<ul>
{allH2s.map(({ _key, children }, index) => {
<AnimatedElement
type="aside"
delay={100}
className={clsx('wrap hidden w-max max-w-[25vw]', 'lg:block')}
>
<div className="sticky top-12">
<h5 className="text-nowrap text-xl font-medium tracking-wider uppercase">{outlineHeading}</h5>
<ul className="mt-2 flex flex-col gap-1">
{allH2s.map(({_key, children}, index) => {
const textContent = children[0]?.text;

return (
<li key={_key}>
<button
className="hover:text-primary"
onClick={() => {
const target = mainRef.current?.querySelector(
`h2:nth-of-type(${index + 1})`
);
target?.scrollIntoView({
behavior: 'smooth',
offsetTop: 100,
});
}}
>
{textContent}
</button>
</li>
<li key={_key}>
<button
className="hover:text-primary"
onClick={() => {
const target = mainRef.current?.querySelector(
`h2:nth-of-type(${index + 1})`
);
target?.scrollIntoView({
behavior: 'smooth',
offsetTop: 100,
});
}}
>
{textContent}
</button>
</li>
);
})}
</ul>
</AnimatedElement>
</aside>
) : null}
</div>
</AnimatedElement>
) : null}
</section>
);
}