Skip to content

Commit

Permalink
animated portfolio section added (#8)
Browse files Browse the repository at this point in the history
  • Loading branch information
tmanundercover authored Nov 28, 2023
1 parent d25d643 commit 5e51e92
Show file tree
Hide file tree
Showing 8 changed files with 415 additions and 1 deletion.
1 change: 1 addition & 0 deletions sanityIo/schemas/contentContainer.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ export default {
{name: 'Resume Feedback Section', title: 'Resume Feedback Section',type: 'reference', to: [{type: 'ResumeFeedbackSection'}]},
{name: 'Resume ContactUs Section', title: 'Resume ContactUs Section',type: 'reference', to: [{type: 'ResumeContactUsSection'}]},
{name: 'Resume Portfolio Section', title: 'Resume Portfolio Section',type: 'reference', to: [{type: 'ResumePortfolioSection'}]},
{name: 'Animated Portfolio Section', title: 'Animated Portfolio Section',type: 'reference', to: [{type: 'AnimatedPortfolioSection'}]},
{name: 'WebDevHeroContentSection', title: "Web Dev Hero Image + Content section",type: 'reference', to: [{type: 'WebDevHeroContentSection'}]},
{name: 'WebDevStatsCounterSection', title: "Web Dev Stats Counter section",type: 'reference', to: [{type: 'WebDevStatsCounterSection'}]},
{name: 'WebDevAboutUsSection', title: "Web Dev About Us section",type: 'reference', to: [{type: 'WebDevAboutUsSection'}]},
Expand Down
4 changes: 4 additions & 0 deletions sanityIo/schemas/schema.js
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,8 @@ import AnimatedAboutUsSection from "./services/AnimatedAboutUsSection";
import AnimatedServicesSection from "./services/AnimatedServicesSection";
import MuiFontFace from "./mui/MuiFontFace";
import MuiMediaQuery from "./mui/MuiMediaQuery";
import AnimatedPortfolioItem from "./sections/animated/AnimatedPortfolioItem";
import AnimatedPortfolioSection from "./sections/animated/AnimatedPortfolioSection";

// Then we give our schema to the builder and provide the result to Sanity
export default [
Expand Down Expand Up @@ -181,5 +183,7 @@ export default [
AnimatedHeroContentSection,
AnimatedAboutUsSection,
AnimatedServicesSection,
AnimatedPortfolioItem,
AnimatedPortfolioSection,
HeroSlideContent
]
78 changes: 78 additions & 0 deletions sanityIo/schemas/sections/animated/AnimatedPortfolioItem.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@

export default {
name: 'AnimatedPortfolioItem',
title: 'Animated Portfolio Item',
type: 'document',
fields: [
{
name: 'name',
title: 'Name',
type: 'string',
},
{
name: 'preTitle',
title: 'Pre Title',
type: 'string',
},
{
name: 'title',
title: 'Title',
type: 'string',
},
{
name: 'coverImage',
title: 'Cover Image',
type: 'image',
options: {
hotspot: true,
},
},
{
name: 'inceptionDate',
title: 'Inception Date',
type: 'date',
},
{
name: 'slug',
title: 'Slug',
type: 'slug',
options: {
source: 'title',
maxLength: 96,
},
},
{
name: 'skillsHighlighted',
title: 'Skill Used',
type: 'array',
of: [{type: 'reference', to: {type: 'ResumeSkill'}}],
options: { layout: 'tags' }
},
{
name: 'detailTitle',
title: 'Detail Title',
type: 'string'
},
{
name: 'detailDescription',
title: 'Detail Description',
type: 'text',
},
{
name: 'linkToProd',
title: 'Prod link',
type: 'url',
},
{
name: 'linkToDev',
title: 'Dev Link',
type: 'string',
},
{
name: 'imageGallery',
title: 'Image Gallery',
type: 'array',
of:[{type: 'image'}]
},
]
}
49 changes: 49 additions & 0 deletions sanityIo/schemas/sections/animated/AnimatedPortfolioSection.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
export default {
name: 'AnimatedPortfolioSection',
title: 'Animated Portfolio Section',
type: 'document',
fields: [
{
name: 'name',
title: 'Name',
type: 'string',
},
{
name: 'heroBullet',
title: 'Hero Bullet',
type: 'image',
},
{
name: 'preTitle',
title: 'Pre Title',
type: 'string',
},
{
name: 'title',
title: 'Title of Section',
type: 'string',
},
{
name: 'theme',
title: 'Theme',
type: 'reference',
to:[{type: 'MuiTheme'}]
},
// {
// name: 'introduction',
// title: 'Introduction',
// type: 'text',
// },
{
name: 'portfolioEntries',
title: 'Portfolio Entries',
type: "array",
of: [
{type: "reference",
to:
[{type: "AnimatedPortfolioItem"}],
}
]
},
]
}
14 changes: 13 additions & 1 deletion src/components/BlockContentLayoutContainer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import {Card, Grid, Link, useTheme} from '@mui/material'
import sanityClient from '../sanityClient'
import {blockSerializers} from '../common/sanityIo/BlockContentRenderer'
import {
AnimatedAboutUsSectionType, AnimatedServicesSectionType,
AnimatedAboutUsSectionType, AnimatedPortfolioSectionType, AnimatedServicesSectionType,
HeroAnimatedContentSectionType,
HowItWorksSectionType,
PortfolioSectionType,
Expand Down Expand Up @@ -55,6 +55,7 @@ import WebDevHowItWorksSection from "./templates/web-dev-site/WebDevHowItWorksSe
import HeroAnimatedContentSection from "./animated/HeroAnimatedContentSection";
import AnimatedAboutUsSection from "./animated/AnimatedAboutUsSection";
import AnimatedServicesSection from './animated/AnimatedServicesSection'
import AnimatedPortfolioSection from "./animated/AnimatedPortfolioSection";

export type BlockContentLayoutContainerProps = {
content?: any,
Expand Down Expand Up @@ -437,6 +438,17 @@ const BlockContentLayoutContainer: FunctionComponent<BlockContentLayoutContainer
/>
</Grid>
);
case 'AnimatedPortfolioSection':
const animatedPortfolioSection: AnimatedPortfolioSectionType = columnLayoutContainer
return (
<Grid key={'animated-portfolio'} container item xs={12}>
<Link id={"ANIMATED_PORTFOLIO"} underline="hover"><></>
</Link>
<AnimatedPortfolioSection
sectionData={animatedPortfolioSection}
/>
</Grid>
);
default:
return <Grid container item></Grid>
// return <span key={index}>Undefined section {columnLayoutContainer._type}</span>
Expand Down
23 changes: 23 additions & 0 deletions src/components/BlockContentTypes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -455,6 +455,21 @@ export type ResumePortfolioItem = {
linkToDev?: string
imageGallery?: SanityImageAsset[]
}
export type AnimatedPortfolioItemType = {
_type?: "AnimatedPortfolioItem"
name?: string
preTitle?:string
title?: string
coverImage?: SanityImageAsset
inceptionDate?: Date | string
slug?: SanitySlug
skillsHighlighted?: ResumeSkill[]
detailTitle?: string
detailDescription?: string
linkToProd?: string
linkToDev?: string
imageGallery?: SanityImageAsset[]
}

export type ResumePortfolioSectionType = {
name?: string
Expand All @@ -464,6 +479,14 @@ export type ResumePortfolioSectionType = {
introduction?: string
portfolioEntries?: ResumePortfolioItem[]
}
export type AnimatedPortfolioSectionType = {
name?: string
_type?: "AnimatedPortfolioSection"
preTitle?: string
heroBullet?: SanityImageAsset
title?: string
portfolioEntries?: AnimatedPortfolioItemType[]
}


export type ResumeContactUsSectionType = {
Expand Down
117 changes: 117 additions & 0 deletions src/components/animated/AnimatedPortfolioItem.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,117 @@
import React, {FunctionComponent} from 'react'
import {Box, Button, Grid, IconButton, Typography, useTheme} from "@mui/material";
import {urlFor} from "../block-content-ui/static-pages/cmsStaticPagesClient";
import {ArrowRightAlt} from "@mui/icons-material";
import makeStyles from "@mui/styles/makeStyles";
import {Theme} from "@mui/material/styles";
import {AnimatedPortfolioItemType} from "../BlockContentTypes";
import {motion, useAnimationControls} from 'framer-motion';

export const useStyles = makeStyles((theme: Theme) => ({
root: {
},
}))

interface IProps { portfolioItem?:AnimatedPortfolioItemType, action:(item:AnimatedPortfolioItemType|undefined)=>void }

const AnimatedPortfolioItem: FunctionComponent<IProps> = (props:IProps) => {
const classes = useStyles()
const theme = useTheme()

const controls = useAnimationControls()

const animateServiceHover = async () => {
controls.start({scale: 1.01, opacity:1}, {duration: .5})
}

const animateServiceNoHover = async () => {
controls.start({scale: 1, opacity:.9}, {duration: .25})
}

React.useEffect(()=>{
}, [])

return (<Grid
role='portfoliobutton'
container item xs={12} md={6} lg={4} alignContent='flex-start'
justifyContent='center' overflow='hidden' borderRadius={theme.shape.borderRadius}>
<motion.div initial={{scale:1}} animate={controls} style={{width: "100%"}} onHoverStart={async () => {
animateServiceHover()
console.log("hovering")
}} onHoverEnd={async () => {
console.log("not hovering")
animateServiceNoHover()
}}><Button style={{
backgroundImage: `url(${urlFor(props.portfolioItem?.coverImage ?? "").url() ?? ""})`,
backgroundSize: "cover",
backgroundPosition: "top center",
backgroundRepeat: "no-repeat",
width: "100%",
margin: "8px",
height: "500px"
}} fullWidth onClick={(e) => props.action(props.portfolioItem)}>
<Grid item container style={{position: "relative", height: "100%"}}>
{/*{portfolioItem?.inceptionDate && <Grid container item justifyContent='center'>*/}
{/* <Typography display='inline'*/}
{/* variant='body1'*/}
{/* >{dateUtils.MonthYear(portfolioItem?.inceptionDate)}</Typography>*/}
{/*</Grid>}*/}
<Grid container item sx={{position: "absolute", bottom: -20}}
justifyContent='center'>
<Grid item xs={11} container justifyContent='space-between' sx={{
backgroundColor: theme.palette.background.paper,
marginBottom: "16px",
padding: theme.spacing(4, 3),
borderRadius: "4px"
}}>
<Grid container item xs={10}>
<Grid container item alignItems='center'>
<Box sx={{
height: 3,
width: 26,
marginRight: "2px",
backgroundColor: theme.palette.primary.main
}}>

</Box>
<Typography
fontSize={'large'}
textTransform={'uppercase'}
variant='h6'
align='left'>{props.portfolioItem?.preTitle}</Typography>
</Grid>
<Grid container item>
<Typography color='textPrimary'
fontSize={'large'}
variant='body2' align='left'
gutterBottom>{props.portfolioItem?.title}</Typography>
</Grid>
<Grid container item style={{paddingRight: "8px"}}>
<Typography fontSize={'medium'} color='textPrimary'
variant='body1' align='left'
gutterBottom>{props.portfolioItem?.detailDescription}</Typography>
</Grid>
</Grid>
<Grid container item xs={2} sm={2} justifyContent='flex-end'
alignContent='center' alignItems='center'>
<IconButton
color='primary'
sx={{
backgroundColor: theme.palette.primary.main,
'&:hover': {
backgroundColor: theme.palette.primary.dark
},
width: "50px",
height: "50px",
border: "1px solid black",
}}><ArrowRightAlt color='secondary'/></IconButton>
</Grid>

</Grid>
</Grid>
</Grid>
</Button></motion.div>
</Grid>)
}

export default AnimatedPortfolioItem
Loading

0 comments on commit 5e51e92

Please sign in to comment.