Skip to content

Commit

Permalink
Merge branch 'main' into dependabot/github_actions/treosh/lighthouse-…
Browse files Browse the repository at this point in the history
…ci-action-12
  • Loading branch information
arzafran authored Jul 2, 2024
2 parents 9a776f1 + b681b2e commit c1e0cd8
Show file tree
Hide file tree
Showing 14 changed files with 218 additions and 18 deletions.
21 changes: 21 additions & 0 deletions app/(pages)/(components)/lenis/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
'use client'

import { ReactLenis } from 'libs/lenis'

export function Lenis({ root, options }) {
return (
<ReactLenis
root={root}
options={{
...options,
prevent: (node) => {
console.log(node.id)
return (
node.nodeName === 'VERCEL-LIVE-FEEDBACK' ||
node.id === 'theatrejs-studio-root'
)
},
}}
/>
)
}
2 changes: 1 addition & 1 deletion app/(pages)/(components)/wrapper/index.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import cn from 'clsx'
import { Lenis } from 'libs/lenis'
import { Canvas } from 'libs/webgl/components/canvas'
import { Footer } from '../footer'
import { Lenis } from '../lenis'
import { Navigation } from '../navigation'
import s from './wrapper.module.scss'

Expand Down
4 changes: 2 additions & 2 deletions app/manifest.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ export default function manifest() {
description: AppData.description,
start_url: '/',
display: 'standalone',
background_color: themes.red.primary,
theme_color: themes.red.contrast,
background_color: themes.light.primary,
theme_color: themes.light.contrast,
icons: [
{
src: '/icon',
Expand Down
57 changes: 57 additions & 0 deletions app/storyblok-sitemap.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
// this file is used to generate the sitemap websites using storyblok

import { StoryblokApi } from 'libs/storyblok'

const storyblokApi = new StoryblokApi()

// replace with your website url
const URL = 'https://example.com'

// add your predefined static routes
const predefinedStaticRoutes = ['', '/blog', '/about', '/careers']

async function fetchAllStories() {
let page = 1
let hasMoreStories = true
let allStories = []

while (hasMoreStories) {
try {
const { data } = await storyblokApi.get('cdn/stories', {
version: 'published',
per_page: 100,
page: page,
excluding_fields: 'body',
})

allStories = [...allStories, ...data.stories]

if (data.stories.length < 100) {
hasMoreStories = false
} else {
page++
}
} catch (error) {
console.error('Error fetching stories:', error)
hasMoreStories = false
}
}

return allStories
}

export default async function sitemap() {
const stories = await fetchAllStories()

const routes = stories.map((story) => ({
url: `${URL}/${story.full_slug}`,
lastModified: new Date(story.published_at).toISOString(),
}))

const staticRoutes = predefinedStaticRoutes.map((route) => ({
url: `${URL}${route}`,
lastModified: new Date().toISOString(),
}))

return [...staticRoutes, ...routes]
}
8 changes: 8 additions & 0 deletions components/image/index.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
'use client'

import cn from 'clsx'
import NextImage from 'next/image'
import { forwardRef } from 'react'
Expand All @@ -19,6 +21,8 @@ export const Image = forwardRef(function Image(
mobileSize = '100vw',
desktopSize = '100vw',
sizes = `(max-width: ${parseFloat(variables.breakpoints.mobile)}px) ${mobileSize}, ${desktopSize}`,
src,
unoptimized,
...props
},
ref,
Expand All @@ -38,6 +42,10 @@ export const Image = forwardRef(function Image(
}}
className={cn(className, block && s.block)}
sizes={sizes}
src={src}
unoptimized={unoptimized ?? src?.includes('.svg')}
draggable="false"
onDragStart={(e) => e.preventDefault()}
{...props}
/>
)
Expand Down
82 changes: 82 additions & 0 deletions components/marquee/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
'use client'

import {
useFrame,
useIntersectionObserver,
useResizeObserver,
} from '@darkroom.engineering/hamo'
import cn from 'clsx'
import modulo from 'just-modulo'
import { useLenis } from 'libs/lenis'
import { useRef } from 'react'
import s from './marquee.module.scss'

export function Marquee({
children,
repeat = 2,
className,
speed = 0.1,
reversed,
pauseOnHover = false,
...props
}) {
const [setRectRef, { contentRect: rect }] = useResizeObserver()
const elementsRef = useRef([])
const transformRef = useRef(Math.random() * 1000)
const isHovered = useRef(false)

const [setIntersectionRef, intersection] = useIntersectionObserver()

const lenis = useLenis() // eslint-disable-line react-hooks/exhaustive-deps

useFrame((_, deltaTime) => {
if (!intersection.isIntersecting) return
if (pauseOnHover && isHovered.current) return

if (!rect.width) return

const adjSpeed = speed * (1 + Math.abs(lenis.velocity / 5))

if (reversed) {
transformRef.current -= deltaTime * adjSpeed
} else {
transformRef.current += deltaTime * adjSpeed
}

transformRef.current = modulo(transformRef.current, rect.width)

elementsRef.current.forEach((node) => {
node.style.transform = `translate3d(${-transformRef.current}px,0,0)`
})
})

return (
<div
ref={setIntersectionRef}
className={cn(className, s.marquee)}
{...props}
onMouseEnter={() => {
isHovered.current = true
}}
onMouseLeave={() => {
isHovered.current = false
}}
>
{new Array(repeat).fill(children).map((_, i) => (
<div
key={i}
className={s.inner}
aria-hidden={i !== 0 ?? undefined}
data-nosnippet={i !== 0 ? '' : undefined}
ref={(node) => {
elementsRef.current[i] = node

if (i === 0) setRectRef(node)
}}
>
{children}
</div>
))}
</div>
)
}
14 changes: 14 additions & 0 deletions components/marquee/marquee.module.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
.marquee {
display: flex;
overflow-x: clip;

.inner {
display: flex;
white-space: nowrap;
transform: translate3d(0, 0, 0);

> * {
flex-shrink: 0;
}
}
}
2 changes: 1 addition & 1 deletion libs/lenis/index.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
'use client'

export { Lenis, useLenis } from 'lenis/react'
export { Lenis, ReactLenis, useLenis } from 'lenis/react'
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
"private": true,
"license": "MIT",
"type": "module",
"packageManager": "[email protected]",
"scripts": {
"dev:storyblok": "npm-run-all -p dev https",
"dev": "next dev",
Expand All @@ -29,7 +30,7 @@
"@theatre/studio": "^0.7.2",
"clsx": "^2.1.1",
"gsap": "^3.12.5",
"lenis": "^1.1.3",
"lenis": "1.1.4",
"next": "14.2.4",
"next-sitemap": "^4.2.3",
"postprocessing": "^6.35.5",
Expand Down
10 changes: 5 additions & 5 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion styles/_reset.scss
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@
svg,
video,
audio,
#theatrejs-studio-root
#theatrejs-studio-root,
vercel-live-feedback
):not(svg *, symbol *)
) {
all: unset;
Expand Down
7 changes: 4 additions & 3 deletions styles/_scroll.scss
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,13 @@ html {
}
}

html.lenis {
html.lenis,
html.lenis body {
height: auto;
}

.lenis.lenis-smooth {
scroll-behavior: auto;
scroll-behavior: auto !important;
}

.lenis.lenis-smooth [data-lenis-prevent] {
Expand All @@ -29,6 +30,6 @@ html.lenis {
overflow: hidden;
}

.lenis.lenis-scrolling iframe {
.lenis.lenis-smooth iframe {
pointer-events: none;
}
9 changes: 9 additions & 0 deletions styles/global.scss
Original file line number Diff line number Diff line change
Expand Up @@ -59,3 +59,12 @@ svg.icon {
}
}
}

img {
user-drag: none;
-webkit-user-drag: none;
user-select: none;
-moz-user-select: none;
-webkit-user-select: none;
-ms-user-select: none;
}
14 changes: 10 additions & 4 deletions turbo.json
Original file line number Diff line number Diff line change
@@ -1,10 +1,16 @@
{
"$schema": "https://turbo.build/schema.json",
"pipeline": {
"tasks": {
"build": {
"outputs": [".next/**", "!.next/cache/**"],
"cache": false
"dependsOn": ["^build"],
"outputs": ["dist/**", ".next/**", "!.next/cache/**"],
"cache": false,
"env": ["*"]
},
"lint": {}
"lint": {},
"dev": {
"cache": false,
"persistent": true
}
}
}

0 comments on commit c1e0cd8

Please sign in to comment.