Skip to content

Commit

Permalink
image & link
Browse files Browse the repository at this point in the history
  • Loading branch information
clementroche committed Mar 13, 2024
1 parent 4e6d957 commit 2687b57
Show file tree
Hide file tree
Showing 10 changed files with 74 additions and 73 deletions.
7 changes: 5 additions & 2 deletions app/(pages)/(components)/footer/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,13 @@ import s from './footer.module.scss'
export function Footer() {
return (
<footer className={s.footer}>
<Link href="https://darkroom.engineering/" target="_blank">
<Link href="https://darkroom.engineering/" className="link">
darkroom.engineering
</Link>
<Link href="https://github.com/darkroomengineering/satus" target="_blank">
<Link
href="https://github.com/darkroomengineering/satus"
className="link"
>
github
</Link>
</footer>
Expand Down
2 changes: 2 additions & 0 deletions app/(pages)/(components)/navigation/navigation.module.scss
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
.nav {
display: flex;
flex-direction: column;
position: fixed;
z-index: 2;

.title {
display: inline-flex;
Expand Down
23 changes: 0 additions & 23 deletions components/footer/footer.module.scss

This file was deleted.

19 changes: 0 additions & 19 deletions components/footer/index.js

This file was deleted.

4 changes: 4 additions & 0 deletions components/image/image.module.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
.block {
width: unset;
height: unset;
}
42 changes: 40 additions & 2 deletions components/image/index.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,44 @@
import cn from 'clsx'
import NextImage from 'next/image'
import { forwardRef } from 'react'
import variables from 'styles/config'
import s from './image.module.scss'

export const Image = forwardRef(function Image({ ...props }, ref) {
return <NextImage ref={ref} {...props} />
export const Image = forwardRef(function Image(
{
style,
className,
loading = 'eager',
objectFit = 'cover',
quality = 90,
alt = '',
block,
width = block && 1,
height = block && 1,
fill = typeof width === 'undefined' || typeof height === 'undefined',
mobileSize = '100vw',
desktopSize = '100vw',
sizes = `(max-width: ${parseFloat(variables.breakpoints.mobile)}px) ${mobileSize}, ${desktopSize}`,
...props
},
ref,
) {
return (
<NextImage
ref={ref}
fill={fill}
width={width}
height={height}
loading={loading}
quality={quality}
alt={alt}
style={{
objectFit,
...style,
}}
className={cn(className, block && s.block)}
sizes={sizes}
{...props}
/>
)
})
26 changes: 23 additions & 3 deletions components/link/index.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
'use client'

import { useLenis } from 'components/lenis'
import NextLink from 'next/link'
import { forwardRef } from 'react'

export const Link = forwardRef(function Link(
{ href, fallback = 'div', ...props },
{ href, fallback = 'div', onClick, ...props },
ref,
) {
if (typeof href !== 'string') {
Expand All @@ -13,10 +14,29 @@ export const Link = forwardRef(function Link(
return <Tag ref={ref} {...props} href={href} />
}

if (href.startsWith('http')) {
const isExternal = href.startsWith('http')

if (isExternal) {
props.target = '_blank'
props.rel = 'noopener noreferrer'
}

return <NextLink ref={ref} {...props} href={href} />
const isAnchor = href.startsWith('#')

const lenis = useLenis() // eslint-disable-line

return (
<NextLink
ref={ref}
onClick={(e) => {
if (isAnchor) {
e.preventDefault()
lenis?.scrollTo(href)
}
onClick?.(e)
}}
{...props}
href={href}
/>
)
})
1 change: 0 additions & 1 deletion next.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ const sassVars = require(__dirname + '/styles/config.js')

const nextConfig = {
reactStrictMode: true,
transpilePackages: ['@studio-freight/compono'],
experimental: {
optimizeCss: true,
nextScriptWorkers: true,
Expand Down
Binary file added public/images/placeholder.webp
Binary file not shown.
23 changes: 0 additions & 23 deletions styles/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,27 +38,4 @@ const viewports = {
},
}

// function getCSSColors() {
// return Object.entries(colors).reduce(
// (acc, [key, value]) => acc + `--${key}: ${value};`,
// '',
// )
// }

// function getCSSThemes() {
// return Object.entries(themes).reduce(
// (acc, [key, colors]) =>
// acc +
// `.theme-${key}:{${Object.entries(colors).reduce(
// (acc, [key, value]) => acc + `--${key}: ${value};`,
// '',
// )}}`,
// '',
// )
// }

// export function getStyle() {
// return `:root{${getCSSColors()}}${getCSSThemes()}`
// }

module.exports = { breakpoints, colors, themes, viewports }

0 comments on commit 2687b57

Please sign in to comment.