-
-
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
16 changed files
with
173 additions
and
82 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
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,2 +1,9 @@ | ||
export const SITE_TITLE = 'Bianca Fiore'; | ||
export const SITE_DESCRIPTION = 'Welcome to my website!'; | ||
|
||
export const DEFAULT_DATE_OPTIONS: Intl.DateTimeFormatOptions = { | ||
weekday: 'long', | ||
year: 'numeric', | ||
month: 'long', | ||
day: 'numeric', | ||
}; |
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
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
--- | ||
import { getCollection } from 'astro:content'; | ||
import BaseLayout from 'src/ui/components/templates/baseLayout/BaseLayout.astro'; | ||
import ArticleLayout from 'src/ui/components/templates/articleLayout/ArticleLayout.astro'; | ||
export async function getStaticPaths() { | ||
const allPosts = await getCollection('articles'); | ||
const uniqueTags = [...new Set(allPosts.map((post) => post.data.tags)?.flat())]; | ||
return uniqueTags?.map((tag) => { | ||
const filteredPosts = allPosts.filter((post) => | ||
post.data.tags.includes(tag), | ||
); | ||
return { | ||
params: { tag }, | ||
props: { posts: filteredPosts }, | ||
}; | ||
}); | ||
} | ||
const { tag = '' } = Astro.params; | ||
const { posts } = Astro.props; | ||
--- | ||
|
||
<BaseLayout title={tag}> | ||
<p>Posts tagged with {tag}</p> | ||
<ul> | ||
{posts?.map((post) => | ||
<ArticleLayout title={post.data.title} />, | ||
)} | ||
</ul> | ||
</BaseLayout> |
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,7 @@ | ||
--- | ||
import BaseLayout from '@components/templates/baseLayout/BaseLayout.astro'; | ||
--- | ||
|
||
<BaseLayout title="" description=""> | ||
<h1>Hello, blog!</h1> | ||
</BaseLayout> |
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 |
---|---|---|
|
@@ -12,7 +12,7 @@ | |
svg { | ||
transition: | ||
scale 0.2s, | ||
fill 0.2s; | ||
fill 0.3s; | ||
} | ||
|
||
&.--is-scrolling:not(.--is-menu-open) svg { | ||
|
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
86 changes: 50 additions & 36 deletions
86
src/ui/components/organisms/header/utils/intersectionObserver/intersectionObserver.ts
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,39 +1,53 @@ | ||
const SELECTORS = { | ||
HEADER: '.header', | ||
LATEST_ARTICLES: '.latest-articles__wrapper', | ||
SITE_LOGO_SVG: '.site__logo svg', | ||
HEADER_MENU_TEXT: '.header', | ||
HEADER_MENU_OUTLINES: '.header__menu-button__outline', | ||
}; | ||
|
||
const getComputedStyleValue = (property: string): string => | ||
getComputedStyle(document.documentElement).getPropertyValue(property); | ||
|
||
function isIntersecting(element: HTMLElement): boolean { | ||
const { HEADER: HEADER_SELECTOR } = SELECTORS; | ||
const headerOffsetHeight = (document.querySelector(HEADER_SELECTOR) as HTMLElement).offsetHeight / 2; | ||
const threshold = element.offsetTop - headerOffsetHeight; | ||
const sectionBottom = element.offsetTop + element.offsetHeight - headerOffsetHeight; | ||
|
||
return window.scrollY >= threshold && window.scrollY < sectionBottom; | ||
} | ||
|
||
export function intersectionObserver(): void { | ||
function handleScroll() { | ||
let hasIntersected = false; | ||
const WHITE = getComputedStyle(document.documentElement).getPropertyValue('--white'); | ||
const BLACK = getComputedStyle(document.documentElement).getPropertyValue("--neutral-main'"); | ||
const HEADER = document.querySelector('.header') as HTMLElement; | ||
const LATEST_ARTICLES = document.querySelector('.latest-articles__wrapper') as HTMLElement; | ||
const SITE_LOGO_SVG = document.querySelector('.site__logo svg') as HTMLElement; | ||
const HEADER_MENU_TEXT = document.querySelector('.header__menu-text') as HTMLElement; | ||
const HEADER_MENU_OUTLINES = document.querySelectorAll( | ||
'.header__menu-button__outline' | ||
) as unknown as HTMLElement[]; | ||
const ELEMENTS_TO_INTERSECT: HTMLElement[] = [LATEST_ARTICLES]; | ||
|
||
if (!HEADER || !LATEST_ARTICLES) return; | ||
|
||
ELEMENTS_TO_INTERSECT.forEach(({ offsetTop, offsetHeight }) => { | ||
const headerOffsetHeight = HEADER.offsetHeight / 2; | ||
const threshold = offsetTop - headerOffsetHeight; | ||
const sectionBottom = offsetTop + offsetHeight - headerOffsetHeight; | ||
|
||
if (window.scrollY >= threshold && window.scrollY < sectionBottom) hasIntersected = true; | ||
}); | ||
|
||
if (hasIntersected) { | ||
HEADER.classList.add('--hue-change'); | ||
SITE_LOGO_SVG.style.fill = WHITE; | ||
HEADER_MENU_TEXT.style.color = WHITE; | ||
HEADER_MENU_OUTLINES.forEach((element) => (element.style.borderColor = WHITE)); | ||
} else { | ||
HEADER.classList.remove('--hue-change'); | ||
SITE_LOGO_SVG.style.fill = BLACK; | ||
HEADER_MENU_TEXT.style.color = BLACK; | ||
HEADER_MENU_OUTLINES.forEach((element) => (element.style.borderColor = BLACK)); | ||
} | ||
} | ||
const WHITE = getComputedStyleValue('--white'); | ||
const BLACK = getComputedStyleValue('--neutral-main'); | ||
const { | ||
HEADER: HEADER_SELECTOR, | ||
LATEST_ARTICLES: LATEST_ARTICLES_SELECTOR, | ||
SITE_LOGO_SVG: SITE_LOGO_SVG_SELECTOR, | ||
HEADER_MENU_TEXT: HEADER_MENU_TEXT_SELECTOR, | ||
HEADER_MENU_OUTLINES: HEADER_MENU_OUTLINES_SELECTOR, | ||
} = SELECTORS; | ||
|
||
window.addEventListener('scroll', handleScroll); | ||
const HEADER = document.querySelector(HEADER_SELECTOR) as HTMLElement; | ||
const LATEST_ARTICLES = document.querySelector(LATEST_ARTICLES_SELECTOR) as HTMLElement; | ||
const SITE_LOGO_SVG = document.querySelector(SITE_LOGO_SVG_SELECTOR) as HTMLElement; | ||
const HEADER_MENU_TEXT = document.querySelector(HEADER_MENU_TEXT_SELECTOR) as HTMLElement; | ||
const HEADER_MENU_OUTLINES = document.querySelectorAll(HEADER_MENU_OUTLINES_SELECTOR) as unknown as HTMLElement[]; | ||
|
||
if (!HEADER || !LATEST_ARTICLES) return; | ||
|
||
const hasIntersected = isIntersecting(LATEST_ARTICLES); | ||
|
||
if (hasIntersected) { | ||
SITE_LOGO_SVG.style.fill = WHITE; | ||
HEADER_MENU_TEXT.style.color = WHITE; | ||
HEADER_MENU_OUTLINES.forEach((element) => (element.style.borderColor = WHITE)); | ||
} else { | ||
SITE_LOGO_SVG.style.fill = BLACK; | ||
HEADER_MENU_TEXT.style.color = BLACK; | ||
HEADER_MENU_OUTLINES.forEach((element) => (element.style.borderColor = BLACK)); | ||
} | ||
} | ||
|
||
window.addEventListener('scroll', intersectionObserver); |
Oops, something went wrong.