From 660dc5d4ca27eb5bde76b2629f3f3c4ed02018d5 Mon Sep 17 00:00:00 2001 From: m-tartari <37861893+m-tartari@users.noreply.github.com> Date: Wed, 14 Feb 2024 17:51:30 +0100 Subject: [PATCH] =?UTF-8?q?=E2=9C=A8=20feat(molecules):=20add=20`ProjectSp?= =?UTF-8?q?otlight`?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ProjectSpotlight/ProjectSpotlight.tsx | 174 ++++++++++++++++++ .../molecules/ProjectSpotlight/index.ts | 1 + src/components/molecules/index.ts | 1 + 3 files changed, 176 insertions(+) create mode 100644 src/components/molecules/ProjectSpotlight/ProjectSpotlight.tsx create mode 100644 src/components/molecules/ProjectSpotlight/index.ts diff --git a/src/components/molecules/ProjectSpotlight/ProjectSpotlight.tsx b/src/components/molecules/ProjectSpotlight/ProjectSpotlight.tsx new file mode 100644 index 0000000..f3d01c7 --- /dev/null +++ b/src/components/molecules/ProjectSpotlight/ProjectSpotlight.tsx @@ -0,0 +1,174 @@ +import React from 'react' +import { ParallaxBanner, ParallaxProvider } from 'react-scroll-parallax' +import { Box, Grid, IconButton, Typography, useTheme } from '@mui/material' +import { ExpandMore } from '@mui/icons-material' + +type AnchorType = 'left' | 'top' | 'right' | 'bottom' + +type Props = { + image: string + title: string + caption: React.ReactNode + children: React.ReactNode + ref?: React.ForwardedRef + anchor?: AnchorType + scrollTarget?: React.ForwardedRef +} + +const Description = (props: Props) => { + const theme = useTheme() + + switch (props.anchor) { + case 'bottom': + return ( + + + + {props.title} + {props.caption} + + + {props.children} + + + + ) + case 'top': + return ( + + + + {props.title} + {props.caption} + + + {props.children} + + + + ) + case 'right': + return ( + + {props.title} + {props.caption} + {props.children} + + ) + case 'left': + return ( + + {props.title} + {props.caption} + {props.children} + + ) + } +} + +const ProjectSpotlight = React.forwardRef((props, ref) => { + const executeScroll = () => { + if (typeof props.scrollTarget !== 'undefined') { + const target = props.scrollTarget as React.MutableRefObject + target.current?.scrollIntoView() + } + } + // run this function from an event handler or an effect to execute scroll + + return ( +
+ + + + {props.scrollTarget && ( + + + + )} + + +
+ ) +}) + +export default ProjectSpotlight diff --git a/src/components/molecules/ProjectSpotlight/index.ts b/src/components/molecules/ProjectSpotlight/index.ts new file mode 100644 index 0000000..b12c4ad --- /dev/null +++ b/src/components/molecules/ProjectSpotlight/index.ts @@ -0,0 +1 @@ +export { default } from './ProjectSpotlight' diff --git a/src/components/molecules/index.ts b/src/components/molecules/index.ts index f3bf9ae..fa95ed1 100644 --- a/src/components/molecules/index.ts +++ b/src/components/molecules/index.ts @@ -2,4 +2,5 @@ export { default as Toobar } from './Toobar' export { default as Footer } from './Footer' export { default as CurriculumItem } from './CurriculumItem' +export { default as ProjectSpotlight } from './ProjectSpotlight' export { default as Project } from './Project'