Skip to content

Commit e2eb37a

Browse files
committed
feat(home): adds gif & lottie
1 parent 87fbe07 commit e2eb37a

File tree

9 files changed

+30
-16
lines changed

9 files changed

+30
-16
lines changed

src/assets/gif/synology_demo.gif

7.81 MB
Loading

src/assets/lottie/64643-receive-a-new-email.json

Lines changed: 1 addition & 0 deletions
Large diffs are not rendered by default.

src/assets/lottie/70229-contact-us.json

Lines changed: 0 additions & 1 deletion
This file was deleted.

src/components/common/layout/image-card.tsx

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,18 @@
11
import { Card, CardActionArea, CardContent, CardMedia, Typography } from '@suid/material';
22

3-
import { splitProps } from 'solid-js';
3+
import { Show, splitProps } from 'solid-js';
44

55
import type CardProps from '@suid/material/Card/CardProps';
66
import type { CardActionsProps } from '@suid/material/CardActions';
77
import type { CardMediaProps } from '@suid/material/CardMedia';
88
import type { JSX, ParentComponent } from 'solid-js';
99

10+
import type { LottiePlayerProps } from '~/components';
11+
1012
import type { ResponsiveStyleValue } from '~/themes';
1113

14+
import { LottiePlayer } from '~/components';
15+
1216
type ImageCardMediaProps = CardMediaProps & {
1317
component?: keyof JSX.IntrinsicElements;
1418
height?: ResponsiveStyleValue<string | number>;
@@ -17,6 +21,7 @@ export type ImageCardProps = {
1721
title?: string | JSX.Element;
1822
description?: string | JSX.Element;
1923
imageProps?: ImageCardMediaProps & { alt?: string };
24+
lottieProps?: LottiePlayerProps;
2025
actionProps?: CardActionsProps;
2126
} & CardProps;
2227
export const ImageCard: ParentComponent<ImageCardProps> = props => {
@@ -26,8 +31,6 @@ export const ImageCard: ParentComponent<ImageCardProps> = props => {
2631
<Card
2732
{...cardProps}
2833
sx={{
29-
height: '100%',
30-
width: '100%',
3134
whiteSpace: 'pre-line',
3235
...cardProps.sx,
3336
}}
@@ -39,7 +42,11 @@ export const ImageCard: ParentComponent<ImageCardProps> = props => {
3942
..._props.actionProps?.sx,
4043
}}
4144
>
42-
<CardMedia component="img" {..._props.imageProps} />
45+
<CardMedia {..._props.imageProps}>
46+
<Show when={props.lottieProps}>
47+
<LottiePlayer autoplay loop mode="normal" {...props.lottieProps} />
48+
</Show>
49+
</CardMedia>
4350
<CardContent>
4451
<Typography gutterBottom variant="h6" component="div">
4552
{_props.title}

src/components/common/lottie/lottie-player.tsx

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,9 @@ import type { Component } from 'solid-js';
22

33
import type { LottiePlayerComponent } from '~/apps/lottie/entry';
44

5+
import type { PropsWithRef } from '~/utils';
6+
7+
export type LottiePlayerProps = PropsWithRef<LottiePlayerComponent>;
58
export const LottiePlayer: Component<LottiePlayerComponent & { ref?: LottiePlayerComponent | ((el: LottiePlayerComponent) => void) }> = props => {
69
import('~/apps/lottie/entry').catch(() => console.error('Failed to define lottie web components'));
710

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
11
export * from './particles-container';
2+
export * from './triangle.particles';

src/components/pages/contact/contact-form.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -155,7 +155,7 @@ export const ContactForm: Component<ContactFormProps> = props => {
155155
fieldProps: {
156156
required: true,
157157
multiline: true,
158-
rows: Math.ceil(window.innerHeight / 100),
158+
rows: Math.ceil(2 + window.innerHeight / 100),
159159
},
160160
ref: setBodyRef,
161161
},

src/components/pages/contact/contact.tsx

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import { ContactForm } from './contact-form';
88

99
import type { Component } from 'solid-js';
1010

11-
import ContactLottie from '~/assets/lottie/70229-contact-us.json?url';
11+
import ContactLottie from '~/assets/lottie/64643-receive-a-new-email.json?url';
1212
import { HoverScale, LottiePlayer, Page, PageHeader } from '~/components';
1313
import { RoutesMeta } from '~/services';
1414
import { BreakPointsStop } from '~/themes';
@@ -96,7 +96,6 @@ export const Contact: Component = () => {
9696
setTimeout(() => {
9797
const _card = cardRef();
9898
if (!_card || !_card.clientWidth || !_card.clientHeight) return;
99-
console.info({ _card, width: _card.clientWidth });
10099
setBorders({
101100
width: _card.clientWidth / 2,
102101
height: _card.clientHeight / 2,

src/components/pages/home/home.tsx

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,11 @@ import type { Component } from 'solid-js';
88

99
import type { ImageCardProps } from '~/components';
1010

11+
import SynologyDemoGif from '~/assets/gif/synology_demo.gif?url';
1112
import SolidSvg from '~/assets/logo/solid.svg?url';
12-
import { HoverScale, ImageCard, Page, ParticlesContainer } from '~/components';
13+
import ContactLottie from '~/assets/lottie/64643-receive-a-new-email.json?url';
14+
import { HoverScale, ImageCard, Page, ParticlesContainer, TriangleParticles } from '~/components';
1315

14-
import { TriangleParticles } from '~/components/common/particles/triangle.particles';
1516
import { RoutesMeta } from '~/services';
1617
import { BreakPointsStop } from '~/themes';
1718
import { camelToSnakeCase } from '~/utils';
@@ -25,23 +26,24 @@ export const Home: Component = () => {
2526
{
2627
path: RoutesMeta.SynologyDemo.path,
2728
title: RoutesMeta.SynologyDemo.name,
28-
imageProps: { image: SolidSvg },
29+
imageProps: { component: 'img', image: SynologyDemoGif, sx: { background: 'black' } },
2930
},
3031

3132
{
3233
path: RoutesMeta.AboutMe.path,
3334
title: RoutesMeta.AboutMe.name,
34-
imageProps: { image: SolidSvg },
35+
imageProps: { component: 'img', image: SolidSvg },
3536
},
3637
{
3738
path: RoutesMeta.Trakt.path,
3839
title: RoutesMeta.Trakt.name,
39-
imageProps: { image: SolidSvg },
40+
imageProps: { component: 'img', image: SolidSvg },
4041
},
4142
{
4243
path: RoutesMeta.Contact.path,
4344
title: RoutesMeta.Contact.name,
44-
imageProps: { image: SolidSvg },
45+
imageProps: { sx: { background: 'maroon' } },
46+
lottieProps: { src: ContactLottie },
4547
},
4648
];
4749
return (
@@ -67,23 +69,25 @@ export const Home: Component = () => {
6769
}}
6870
>
6971
<For each={cards}>
70-
{({ path, title, imageProps }) => (
72+
{({ path, title, imageProps, ..._props }) => (
7173
<Grid item xs={12} sm={6}>
7274
<HoverScale>
7375
<ImageCard
7476
title={t(`routes.${camelToSnakeCase(title)}`)}
7577
description={t(`home.${camelToSnakeCase(title)}`)}
7678
imageProps={{
79+
...imageProps,
7780
alt: `cover image for ${title}`,
7881
sx: {
7982
height: {
8083
[BreakPointsStop.default]: 200,
8184
[BreakPointsStop.tablet]: 300,
8285
[BreakPointsStop.fhd]: 400,
8386
},
87+
...imageProps?.sx,
8488
},
85-
...imageProps,
8689
}}
90+
{..._props}
8791
onclick={() => navigate(path)}
8892
/>
8993
</HoverScale>

0 commit comments

Comments
 (0)