mirror of
https://github.com/blitzkit/blitzkit.git
synced 2026-10-24 03:59:50 +02:00
feat: better image alignment and loading performance
This commit is contained in:
1 parent
429049761f
commit
4683de90ba
2 files changed
+57
-6
No files matched your search
+19
-5
@@ -1,9 +1,9 @@
|
|||||||
import { CaretRightIcon } from '@radix-ui/react-icons';
|
import { CaretRightIcon } from '@radix-ui/react-icons';
|
||||||
import { Button, Flex, Grid, Heading, Text } from '@radix-ui/themes';
|
import { Box, Button, Flex, Grid, Heading, Text } from '@radix-ui/themes';
|
||||||
import Link from 'next/link';
|
import Link from 'next/link';
|
||||||
import PageWrapper from '../components/PageWrapper';
|
import PageWrapper from '../components/PageWrapper';
|
||||||
import { TOOLS } from '../constants/tools';
|
import { TOOLS } from '../constants/tools';
|
||||||
import { imgur } from '../core/blitzkit/imgur';
|
import { ImgurSize, imgur } from '../core/blitzkit/imgur';
|
||||||
import { Hero } from './components/Hero';
|
import { Hero } from './components/Hero';
|
||||||
|
|
||||||
export default function Page() {
|
export default function Page() {
|
||||||
@@ -22,6 +22,10 @@ export default function Page() {
|
|||||||
flow="row-dense"
|
flow="row-dense"
|
||||||
>
|
>
|
||||||
{TOOLS.map((tool) => {
|
{TOOLS.map((tool) => {
|
||||||
|
const size = tool.significant
|
||||||
|
? ImgurSize.HugeThumbnail
|
||||||
|
: ImgurSize.LargeThumbnail;
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Flex
|
<Flex
|
||||||
key={tool.id}
|
key={tool.id}
|
||||||
@@ -29,7 +33,7 @@ export default function Page() {
|
|||||||
position: 'relative',
|
position: 'relative',
|
||||||
borderRadius: 'var(--radius-2)',
|
borderRadius: 'var(--radius-2)',
|
||||||
overflow: 'hidden',
|
overflow: 'hidden',
|
||||||
backgroundImage: `url(${imgur(tool.image, { format: 'jpeg' })})`,
|
backgroundImage: `url(${imgur(tool.image, { format: 'jpeg', size })})`,
|
||||||
backgroundSize: 'cover',
|
backgroundSize: 'cover',
|
||||||
backgroundPosition: 'center',
|
backgroundPosition: 'center',
|
||||||
height: tool.significant ? 'min(320px, 50vh)' : '256px',
|
height: tool.significant ? 'min(320px, 50vh)' : '256px',
|
||||||
@@ -45,11 +49,20 @@ export default function Page() {
|
|||||||
display: 'flex',
|
display: 'flex',
|
||||||
width: '100%',
|
width: '100%',
|
||||||
height: '100%',
|
height: '100%',
|
||||||
alignItems: 'end',
|
flexDirection: 'column',
|
||||||
textDecoration: 'none',
|
textDecoration: 'none',
|
||||||
color: 'inherit',
|
color: 'inherit',
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
|
<Box
|
||||||
|
flexGrow="1"
|
||||||
|
style={{
|
||||||
|
backgroundImage: `url(${imgur(tool.image, { format: 'jpeg', size })})`,
|
||||||
|
backgroundSize: 'cover',
|
||||||
|
backgroundPosition: 'center',
|
||||||
|
}}
|
||||||
|
/>
|
||||||
|
|
||||||
<Flex
|
<Flex
|
||||||
px={{
|
px={{
|
||||||
initial: '6',
|
initial: '6',
|
||||||
@@ -66,7 +79,8 @@ export default function Page() {
|
|||||||
}}
|
}}
|
||||||
style={{
|
style={{
|
||||||
backgroundColor: 'var(--color-panel-translucent)',
|
backgroundColor: 'var(--color-panel-translucent)',
|
||||||
backdropFilter: 'blur(16px)',
|
backdropFilter: 'blur(64px)',
|
||||||
|
WebkitBackdropFilter: 'blur(64px)',
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
<Flex
|
<Flex
|
||||||
|
|||||||
@@ -1,13 +1,50 @@
|
|||||||
|
export enum ImgurSize {
|
||||||
|
/**
|
||||||
|
* The default size
|
||||||
|
*/
|
||||||
|
Default = '',
|
||||||
|
/**
|
||||||
|
* Unknown size but really really small
|
||||||
|
*/
|
||||||
|
UltraSmall = 'ss',
|
||||||
|
/**
|
||||||
|
* 90x90
|
||||||
|
*/
|
||||||
|
SmallSquare = 's',
|
||||||
|
/**
|
||||||
|
* 160x160
|
||||||
|
*/
|
||||||
|
BigSquare = 'b',
|
||||||
|
/**
|
||||||
|
* 160x160
|
||||||
|
*/
|
||||||
|
SmallThumbnail = 't',
|
||||||
|
/**
|
||||||
|
* 320x320
|
||||||
|
*/
|
||||||
|
MediumThumbnail = 'm',
|
||||||
|
/**
|
||||||
|
* 640x640
|
||||||
|
*/
|
||||||
|
LargeThumbnail = 'l',
|
||||||
|
/**
|
||||||
|
* 1024x1024
|
||||||
|
*/
|
||||||
|
HugeThumbnail = 'h',
|
||||||
|
}
|
||||||
|
|
||||||
interface ImgurOptions {
|
interface ImgurOptions {
|
||||||
format: 'jpeg' | 'png';
|
format: 'jpeg' | 'png';
|
||||||
|
size: ImgurSize;
|
||||||
}
|
}
|
||||||
|
|
||||||
const defaultImgurOptions: ImgurOptions = {
|
const defaultImgurOptions: ImgurOptions = {
|
||||||
format: 'png',
|
format: 'png',
|
||||||
|
size: ImgurSize.Default,
|
||||||
};
|
};
|
||||||
|
|
||||||
export function imgur(id: string, imgurOptions?: Partial<ImgurOptions>) {
|
export function imgur(id: string, imgurOptions?: Partial<ImgurOptions>) {
|
||||||
const options = { ...defaultImgurOptions, ...imgurOptions };
|
const options = { ...defaultImgurOptions, ...imgurOptions };
|
||||||
|
|
||||||
return `https://i.imgur.com/${id}.${options.format}`;
|
return `https://i.imgur.com/${id}${options.size}.${options.format}`;
|
||||||
}
|
}
|
||||||
Reference in new issue
Block a user