Skip to content

Commit

Permalink
merge dev
Browse files Browse the repository at this point in the history
  • Loading branch information
OliwierSellig committed Jan 2, 2025
2 parents 8548104 + 88d61e8 commit 43a8c06
Show file tree
Hide file tree
Showing 37 changed files with 2,024 additions and 225 deletions.
13 changes: 11 additions & 2 deletions .prettierrc.json
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"
}
}
]
}
23 changes: 10 additions & 13 deletions apps/astro/astro.config.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
import { defineConfig } from 'astro/config'
import vercel from '@astrojs/vercel/serverless'
import sitemap from '@astrojs/sitemap'
import { DOMAIN } from './src/global/constants'
import { isPreviewDeployment } from './src/utils/is-preview-deployment'
import redirects from './redirects'
import preact from '@astrojs/preact';
import sitemap from '@astrojs/sitemap';
import vercel from '@astrojs/vercel/serverless';
import { defineConfig } from 'astro/config';
import redirects from './redirects';
import { DOMAIN } from './src/global/constants';
import { isPreviewDeployment } from './src/utils/is-preview-deployment';

export default defineConfig({
site: DOMAIN,
integrations: [sitemap()],
integrations: [sitemap(), preact({ compat: true })],
image: {
remotePatterns: [
{
Expand All @@ -30,9 +31,5 @@ export default defineConfig({
},
redirects: redirects,
output: isPreviewDeployment ? 'server' : 'hybrid',
adapter: vercel({
isr: {
bypassToken: process.env.VERCEL_DEPLOYMENT_ID,
},
}),
})
adapter: vercel(),
});
3 changes: 3 additions & 0 deletions apps/astro/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,11 @@
},
"dependencies": {
"@astrojs/check": "^0.9.3",
"@astrojs/preact": "^4.0.1",
"@astrojs/sitemap": "^3.1.6",
"@astrojs/vercel": "^8.0.1",
"@sanity/client": "^6.21.3",
"animejs": "^3.2.2",
"astro": "^4.15.5",
"astro-portabletext": "^0.10.0",
"autoprefixer": "^10.4.20",
Expand All @@ -25,6 +27,7 @@
"devDependencies": {
"@typescript-eslint/parser": "^8.5.0",
"eslint": "^9.10.0",
"prettier-plugin-astro": "^0.14.1",
"eslint-plugin-astro": "^1.2.4",
"eslint-plugin-jsx-a11y": "^6.10.0",
"sass": "^1.78.0"
Expand Down
Binary file modified apps/astro/public/fonts/Inter-Regular.woff
Binary file not shown.
Binary file modified apps/astro/public/fonts/Inter-Regular.woff2
Binary file not shown.
Binary file added apps/astro/src/assets/texture.webp
Binary file not shown.
40 changes: 24 additions & 16 deletions apps/astro/src/components/Components.astro
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} />;
})
}
256 changes: 256 additions & 0 deletions apps/astro/src/components/global/BlogReference.astro
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>
Loading

0 comments on commit 43a8c06

Please sign in to comment.