Skip to content

Commit

Permalink
changed the header image to be dynamically updated within sanity studio
Browse files Browse the repository at this point in the history
  • Loading branch information
Mabast1 committed May 28, 2022
1 parent e345dd9 commit 72167b8
Show file tree
Hide file tree
Showing 4 changed files with 80 additions and 50 deletions.
6 changes: 3 additions & 3 deletions backend_sanity/sanity.json
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
{
"root": true,
"project": {
"name": "Portfolio"
},
"api": {
"projectId": "rrns9j1f",
"dataset": "production"
},
"project": {
"name": "Portfolio"
},
"plugins": [
"@sanity/base",
"@sanity/default-layout",
Expand Down
14 changes: 14 additions & 0 deletions backend_sanity/schemas/profile.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
export default {
name: "profile",
title: "Profile",
type: "document",
fields: [
{ name: "title", title: "Title", type: "string" },
{
name: "image",
title: "Image",
type: "image",
options: { hotspot: true },
},
],
};
2 changes: 2 additions & 0 deletions backend_sanity/schemas/schema.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import experiences from "./experiences";
import skills from "./skills";
import workExperience from "./workExperience";
import contact from "./contact";
import profile from "./profile";

// Then we give our schema to the builder and provide the result to Sanity
export default createSchema({
Expand All @@ -19,6 +20,7 @@ export default createSchema({
// Then proceed to concatenate our document type
// to the ones provided by any plugins that are installed
types: schemaTypes.concat([
profile,
works,
testimonials,
brands,
Expand Down
108 changes: 61 additions & 47 deletions src/container/Header/Header.jsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import React from "react";
import React, { useState, useEffect } from "react";
import { motion } from "framer-motion";

import { urlFor, client } from "../../client";
import { AppWrap } from "../../wrapper";
import { images } from "../../constants";
import "./Header.scss";
Expand All @@ -16,56 +17,69 @@ const scaleVariants = {
},
};

const Header = () => (
<div className="app__header app__flex">
<motion.div
whileInView={{ x: [-100, 0], opacity: [0, 1] }}
transition={{ duration: 0.5 }}
className="app__header-info"
>
<div className="app__header-badge">
<div className="badge-cmp app__flex">
<span>👋</span>
<div style={{ marginLeft: 20 }}>
<p className="p-text">Hello, I am</p>
<h1 className="head-text">Mabast</h1>
const Header = () => {
const [profile, setProfile] = useState([]);

useEffect(() => {
const query = '*[_type == "profile"]';

client.fetch(query).then((data) => setProfile(data));
}, []);

return (
<div className="app__header app__flex">
<motion.div
whileInView={{ x: [-100, 0], opacity: [0, 1] }}
transition={{ duration: 0.5 }}
className="app__header-info"
>
<div className="app__header-badge">
<div className="badge-cmp app__flex">
<span>👋</span>
<div style={{ marginLeft: 20 }}>
<p className="p-text">Hello, I am</p>
<h1 className="head-text">Mabast</h1>
</div>
</div>
</div>

<div className="tag-cmp app__flex">
<p className="p-text">Full Stack</p>
<p className="p-text">Software Engineer</p>
<div className="tag-cmp app__flex">
<p className="p-text">Full Stack</p>
<p className="p-text">Software Engineer</p>
</div>
</div>
</div>
</motion.div>
</motion.div>

<motion.div
whileInView={{ opacity: [0, 1] }}
transition={{ duration: 0.5, delayChildren: 0.5 }}
className="app__header-img"
>
<img src={images.profile1} alt="profile_bg" />
<motion.img
whileInView={{ scale: [0, 1] }}
transition={{ duration: 1, ease: "easeInOut" }}
src={images.circle}
alt="profile_circle"
className="overlay_circle"
/>
</motion.div>
<motion.div
whileInView={{ opacity: [0, 1] }}
transition={{ duration: 0.5, delayChildren: 0.5 }}
className="app__header-img"
>
{profile.map((profile) => (
<img src={urlFor(profile.image)} alt="profile_bg" />
))}

<motion.div
variants={scaleVariants}
whileInView={scaleVariants.whileInView}
className="app__header-circles"
>
{[images.react, images.javascript, images.sass].map((circle, index) => (
<div className="circle-cmp app__flex" key={`circle-${index}`}>
<img src={circle} alt="profile_bg" />
</div>
))}
</motion.div>
</div>
);
<motion.img
whileInView={{ scale: [0, 1] }}
transition={{ duration: 1, ease: "easeInOut" }}
src={images.circle}
alt="profile_circle"
className="overlay_circle"
/>
</motion.div>

<motion.div
variants={scaleVariants}
whileInView={scaleVariants.whileInView}
className="app__header-circles"
>
{[images.react, images.javascript, images.sass].map((circle, index) => (
<div className="circle-cmp app__flex" key={`circle-${index}`}>
<img src={circle} alt="profile_bg" />
</div>
))}
</motion.div>
</div>
);
};

export default AppWrap(Header, "home");

0 comments on commit 72167b8

Please sign in to comment.