-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
37 changed files
with
2,024 additions
and
225 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,16 @@ | ||
{ | ||
"semi": false, | ||
"semi": true, | ||
"singleQuote": true, | ||
"trailingComma": "es5", | ||
"tabWidth": 2, | ||
"printWidth": 120 | ||
"printWidth": 120, | ||
"plugins": ["prettier-plugin-astro"], | ||
"overrides": [ | ||
{ | ||
"files": "*.astro", | ||
"options": { | ||
"parser": "astro" | ||
} | ||
} | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.
Binary file not shown.
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,41 +1,49 @@ | ||
--- | ||
import type { ComponentProps } from 'astro/types' | ||
import FullWidthPhoto, { FullWidthPhoto_Query } from '@/components/global/FullWidthPhoto.astro' | ||
import type { ComponentProps } from 'astro/types'; | ||
import FullWidthPhoto, { FullWidthPhoto_Query } from '@/components/global/FullWidthPhoto.astro'; | ||
import CircleSwiper, { CircleSwiper_Query } from '@/components/global/CircleSwiper.astro'; | ||
import SplitContentSection, { SplitContentSection_Query } from './global/SplitContentSection.astro'; | ||
import BlogReference, { BlogReference_Query } from './global/BlogReference.astro'; | ||
const components = { | ||
FullWidthPhoto, | ||
} | ||
CircleSwiper, | ||
SplitContentSection, | ||
BlogReference, | ||
}; | ||
type ComponentsMap = { | ||
[Component in keyof typeof components]: { | ||
_type: Component | ||
} & ComponentProps<(typeof components)[Component]> | ||
} | ||
_type: Component; | ||
} & ComponentProps<(typeof components)[Component]>; | ||
}; | ||
export type ComponentsProps = Array<ComponentsMap[keyof typeof components]> | ||
export type ComponentsProps = Array<ComponentsMap[keyof typeof components]>; | ||
type Props = { | ||
data: ComponentsProps | ||
indexStart?: number | ||
} | ||
data: ComponentsProps; | ||
indexStart?: number; | ||
}; | ||
const { data, indexStart = 0 } = Astro.props | ||
const { data, indexStart = 0 } = Astro.props; | ||
export const Components_Query = /* groq */ ` | ||
components[] { | ||
_type, | ||
sectionId, | ||
${FullWidthPhoto_Query} | ||
${CircleSwiper_Query} | ||
${SplitContentSection_Query} | ||
${BlogReference_Query} | ||
}, | ||
` | ||
`; | ||
--- | ||
|
||
{ | ||
data?.map((item, i) => { | ||
// NOTE: Using 'as any' is not ideal for type safety, but it's used here to simplify | ||
// the implementation and avoid creating separate typed interfaces for each component. | ||
const DynamicComponent = components[item._type] as any | ||
if (!DynamicComponent) return null | ||
return <DynamicComponent {...item} index={indexStart + i} /> | ||
const DynamicComponent = components[item._type] as any; | ||
if (!DynamicComponent) return null; | ||
return <DynamicComponent {...item} index={indexStart + i} />; | ||
}) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,256 @@ | ||
--- | ||
import Image, { ImageDataQuery, type ImageDataProps } from '../ui/image'; | ||
import PortableText, { PortableTextQuery, type PortableTextValue } from '../ui/portable-text'; | ||
import { ButtonDataQuery, type ButtonDataProps } from '../ui/button'; | ||
import Button from '../ui/button/Button.astro'; | ||
export const BlogReference_Query = ` | ||
_type == "BlogReference" => { | ||
${PortableTextQuery('heading')} | ||
${PortableTextQuery('paragraph')} | ||
${ButtonDataQuery('cta')} | ||
highlightedBlogPosts[]->{ | ||
${ImageDataQuery('image')} | ||
name, | ||
slug, | ||
}, | ||
}, | ||
`; | ||
type Props = { | ||
index: number; | ||
heading: PortableTextValue; | ||
paragraph: PortableTextValue; | ||
highlightedBlogPosts: { image: ImageDataProps; name: string; slug: { current: string } }[]; | ||
cta: ButtonDataProps; | ||
sectionId?: string; | ||
}; | ||
const { index, heading, paragraph, highlightedBlogPosts, cta, sectionId } = Astro.props; | ||
--- | ||
|
||
<section class="BlogReference" id={sectionId}> | ||
<div class="container max-width"> | ||
<header> | ||
<PortableText value={heading} heading={index === 0 ? 'h1' : 'h2'} class="heading" /> | ||
<PortableText class="paragraph" value={paragraph} /> | ||
<Button shade="dark" {...cta} /> | ||
</header> | ||
<nav> | ||
{ | ||
highlightedBlogPosts.map(({ image, name, slug }) => ( | ||
<a href={slug.current} class="blogPost"> | ||
<div class="container"> | ||
<Image {...image} sizes="(max-width: 480px) 95vw, 480px" /> | ||
<div class="content"> | ||
{index === 0 ? <h2>{name}</h2> : <h3>{name}</h3>} | ||
{/* TODO Add custom reading time component after completing blog post view */} | ||
<div class="reading"> | ||
<svg xmlns="http://www.w3.org/2000/svg" width="15" height="14" fill="none"> | ||
<path | ||
stroke="#9E9781" | ||
stroke-linecap="round" | ||
stroke-linejoin="round" | ||
stroke-width="1.25" | ||
d="M7.5 3.5V7l2.333 1.167M13.333 7A5.833 5.833 0 1 1 1.666 7a5.833 5.833 0 0 1 11.667 0Z" | ||
/> | ||
</svg> | ||
<span>3 minuty czytania</span> | ||
</div> | ||
</div> | ||
<div class="readMore"> | ||
Przeczytaj | ||
<svg xmlns="http://www.w3.org/2000/svg" width="12" height="12" fill="none"> | ||
<path | ||
stroke="#5F6D62" | ||
stroke-linecap="round" | ||
stroke-linejoin="round" | ||
stroke-width="1.25" | ||
d="M2 6h8m0 0L7 3m3 3L7 9" | ||
/> | ||
</svg> | ||
</div> | ||
</div> | ||
</a> | ||
)) | ||
} | ||
</nav> | ||
</div> | ||
</section> | ||
|
||
<style lang="scss"> | ||
.BlogReference { | ||
background-color: var(--secondary-400, #d2cdbf); | ||
padding: clamp(4rem, calc(4vw / 0.48), 6.5rem) 0; | ||
.container { | ||
display: flex; | ||
justify-content: space-between; | ||
align-items: stretch; | ||
gap: 4px; | ||
|
||
header { | ||
padding: 1.5rem; | ||
max-width: clamp(16rem, calc(18vw / 0.48), 28rem); | ||
text-align: center; | ||
display: flex; | ||
flex-direction: column; | ||
justify-content: center; | ||
align-items: center; | ||
|
||
.heading { | ||
margin-bottom: 4.5rem; | ||
color: var(--secondary-900, #403d33); | ||
strong { | ||
color: var(--neutral-900, #141915); | ||
} | ||
} | ||
|
||
.paragraph { | ||
margin-bottom: auto; | ||
color: var(--neutral-900, #141915); | ||
} | ||
|
||
> a { | ||
margin-top: 2rem; | ||
} | ||
} | ||
|
||
nav { | ||
display: flex; | ||
justify-content: center; | ||
flex-grow: 1; | ||
gap: 0.5rem; | ||
align-self: center; | ||
a { | ||
cursor: none; | ||
padding: 8px; | ||
border-radius: 12px; | ||
background-color: var(--secondary-300, #e3dfd3); | ||
max-width: 437px; | ||
transition: background-color 0.3s var(--easing); | ||
position: relative; | ||
|
||
.container { | ||
display: flex; | ||
flex-direction: column; | ||
background-color: var(--secondary-400, #d2cdbf); | ||
border-radius: 6px; | ||
overflow: hidden; | ||
height: 100%; | ||
position: relative; | ||
gap: 0; | ||
img { | ||
width: 100%; | ||
} | ||
.content { | ||
padding: 1.25rem 1rem; | ||
text-align: center; | ||
height: 100%; | ||
|
||
h2, | ||
h3 { | ||
font-size: var(--typography-body-l, 1.125rem); | ||
font-family: 'Inter', sans-serif; | ||
color: var(--neutral-900, #141915); | ||
font-weight: 400; | ||
margin-bottom: 2.5rem; | ||
} | ||
.reading { | ||
display: flex; | ||
flex-direction: column; | ||
align-items: center; | ||
font-size: var(--typography-body-m, 0.875rem); | ||
|
||
svg { | ||
margin-bottom: 0.375rem; | ||
} | ||
|
||
span { | ||
} | ||
} | ||
} | ||
} | ||
&:focus:not(:focus-visible) { | ||
background-color: transparent; | ||
} | ||
|
||
&:focus-visible { | ||
outline: 3px solid var(--neutral-800, #48514a); | ||
outline-offset: -3px; | ||
} | ||
} | ||
|
||
@media (max-width: 56.25rem) { | ||
flex-direction: column; | ||
} | ||
} | ||
.readMore { | ||
position: absolute; | ||
display: flex; | ||
align-items: center; | ||
gap: 0.5rem; | ||
top: 0; | ||
left: 0; | ||
background-color: var(--neutral-200, #e9f2ed); | ||
padding: 0.375rem 0.625rem; | ||
pointer-events: none; | ||
border-radius: 999px; | ||
font-size: var(--typography-body-m, 0.875rem); | ||
opacity: 0; | ||
transition: opacity 0.2s ease; | ||
} | ||
@media (max-width: 64rem) { | ||
flex-direction: column; | ||
|
||
header { | ||
max-width: 38rem; | ||
margin: 0 auto 4rem; | ||
|
||
.heading { | ||
margin-bottom: 2rem; | ||
} | ||
} | ||
} | ||
} | ||
} | ||
</style> | ||
|
||
<script> | ||
import anime from 'animejs'; | ||
|
||
const blogPosts = document.querySelectorAll('.blogPost') as NodeListOf<HTMLAnchorElement>; | ||
|
||
blogPosts.forEach((blogPost) => { | ||
const readMore = blogPost.querySelector('.readMore') as HTMLElement; | ||
let lastTime = 0; | ||
|
||
blogPost.addEventListener('mouseenter', () => { | ||
readMore.style.opacity = '1'; | ||
}); | ||
|
||
blogPost.addEventListener('mouseleave', () => { | ||
readMore.style.opacity = '0'; | ||
}); | ||
|
||
blogPost.addEventListener('mousemove', (e) => { | ||
const now = Date.now(); | ||
if (now - lastTime < 11) return; | ||
lastTime = now; | ||
|
||
const rect = blogPost.getBoundingClientRect(); | ||
const x = e.clientX - rect.left; | ||
const y = e.clientY - rect.top; | ||
|
||
const offsetX = readMore.offsetWidth / 2; | ||
const offsetY = readMore.offsetHeight / 2; | ||
|
||
anime({ | ||
targets: readMore, | ||
translateX: x - offsetX, | ||
translateY: y - offsetY, | ||
duration: 50, | ||
easing: 'easeOutQuad', | ||
}); | ||
}); | ||
}); | ||
</script> |
Oops, something went wrong.