Skip to content

Commit

Permalink
bug fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
mishalibrahim committed May 13, 2024
1 parent c02acfc commit 4ab0452
Show file tree
Hide file tree
Showing 6 changed files with 130 additions and 27 deletions.
61 changes: 61 additions & 0 deletions components/AnimatedText.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
import React from 'react'
import {motion} from 'framer-motion'
const AnimatedText = ({title,hover}:{title:string,hover:boolean}) => {
return (
<motion.div className='relative overflow-hidden'>
<AnimatedWord title={title} animation={letterAnimation} hover={hover}/>
<div className='absolute top-0'>
<AnimatedWord title={title} animation={letterAnimationTwo} hover={hover}/>
</div>
</motion.div>
)
}
const titleAnimation ={
rest:{
transition:{
staggerChildren:0.003
}
},
hover:{
transition:{
staggerChildren:0.003
}
}
}
const letterAnimation ={
rest:{
y:0,
},hover:{
y:-25,
transition:{
duration:0.3,
ease:[0.6,0.01,0.05,0.95],
type:'tween'
}
}
}
const letterAnimationTwo ={
rest:{
y:25,
},hover:{
y:0,
transition:{
duration:0.3,
ease:[0.6,0.01,0.05,0.95],
type:'tween'
}
}
}
const AnimatedWord =({title,animation,hover}:{title:string,animation:any,hover:boolean})=>{
return(
<motion.span variants={titleAnimation} initial="rest" animate={hover ? 'hover' : 'rest'} className='whitespace-nowrap relative'>
{
title.split("").map((item,index)=>
item === " " ? <span key={index}>&nbsp;</span>
: <motion.span key={index} variants={animation} className='relative inline-block whitespace-nowrap' >{item}</motion.span>
)
}
</motion.span>
)
}
export default AnimatedText
10 changes: 5 additions & 5 deletions components/Hero.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,16 +7,16 @@ const Hero = () => {
<div className='wrapper h-full'>
<div className='flex flex-col lg:flex-row gap-20 lg:gap-0 lg:justify-between h-full md:px-5 py-10 '>
<div className='flex flex-col lg:flex-1 gap-[35px] justify-center '>
<h3 className='font-medium text-primary sm:text-[24px] text-[22px] '>Welcome to {''}<span className='sm:text-[30px] text-[24px] font-medium relative
<h3 className='font-medium text-primary sm:text-[24px] text-[16px] '>Welcome to {''}<span className='sm:text-[30px] text-[20px] font-medium relative
before:content-[""] before:bg-[url("/assets/images/underline.svg")] before:absolute sm:before:bottom-[-40px] before:bottom-[-34px] before:w-full before:h-full before:bg-no-repeat before:bg-cover before:bg-center '>MIZOC LLC </span> </h3>
<h2 className='font-medium md:text-[40px] text-[30px] bg-gradient-to-r from-[#D94791] to-primary bg-clip-text text-transparent'> Your one-stop solutions for all energy needs.</h2>
<h2 className='font-medium md:text-[40px] text-[26px] bg-gradient-to-r from-[#D94791] to-primary bg-clip-text text-transparent'> Your one-stop solutions for all energy needs.</h2>
<div className='flex flex-col sm:flex-row sm:gap-[35px] gap-5 '>
<button className='h-[60px] flex-center hover:shadow-xl transition-all bg-primary rounded-[40px] px-10 text-white uppercase'>contact Us</button>
<button className='h-[60px] flex-center border-black/70 border-2 hover:shadow-xl transition-all rounded-[40px] px-10 text-black uppercase'>our Services</button>
<button className='sm:h-[60px] h-[50px] flex-center hover:shadow-xl transition-all bg-primary rounded-[40px] px-10 text-white uppercase'>contact Us</button>
<button className='sm:h-[60px] h-[50px] flex-center border-black/70 border-2 hover:shadow-xl transition-all rounded-[40px] px-10 text-black uppercase'>our Services</button>
</div>
</div>
<div className='lg:flex-1 flex-center '>
<div className='relative min-h-[600px] w-[300px]'>
<div className='relative min-h-[400px] md:min-h-[600px] w-[300px]'>
<div className='sm:w-[280px] sm:h-[502px] w-[200px] h-[400px] sm:translate-x-[-2.5rem] translate-y-[-2rem] top-0 sm:bottom-0 sm:my-auto left-0 bg-primary rounded-tl-[100px] absolute'></div>
<div className='absolute top-0 sm:bottom-0 sm:my-auto left-0 z-10 sm:w-[330px] sm:h-[490px] w-[250px] h-auto translate-x-10 sm:translate-x-10 translate-y-8'>
<Image className=' object-cover ' src='/assets/images/heroImage.png' width={330} height={490} alt='hero' />
Expand Down
13 changes: 7 additions & 6 deletions components/Nav.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,13 @@ import MobileNav from './MobileNav'

const Nav = () => {
const [isOpen,setisOpen] = useState(false)

return (
<header className='w-full h-full fixed top-0 z-30 max-h-[100px] '>
<div className='wrapper'>
<div className='flex justify-between'>
<div className='w-[40px] h-auto flex-center'>
<Image src='/assets/images/mizocLogo.png' width={50} height={60} alt='logo' className='object-cover w-full ' />
<Image src='/assets/images/miszocLogo.png' width={50} height={60} alt='logo' className='object-cover w-full ' />
</div>
<nav className='md:flex hidden min-h-14'>
<NavItems />
Expand All @@ -24,15 +25,15 @@ const Nav = () => {
<div className='flex flex-col justify-center md:hidden ' onClick={(e)=>{
e.preventDefault();
setisOpen(!isOpen)}}>
<div className='h-[40px] w-full flex flex-col justify-between'>
<span className={`w-[60px] ${isOpen && 'opacity-0' } h-1 bg-primary transition-all rounded-full`} ></span>
<span className={` w-[60px] ${isOpen ? 'ml-0 w-[60px] rotate-[-45deg] relative top-[-3px] z-50 bg-white ':'ml-2' } h-1 duration-700 bg-primary transition-all rounded-full`}></span>
<span className={`w-[60px] ${isOpen && 'w-[60px] rotate-[45deg] relative top-[-20px] z-50 bg-white' } h-1 bg-primary transition-all rounded-full`}></span>
<div className='h-[30px] w-full flex flex-col justify-between'>
<span className={`w-[40px] ${isOpen && 'opacity-0' } h-1 bg-primary transition-all rounded-full`} ></span>
<span className={` w-[40px] ${isOpen ? 'ml-0 w-[60px] rotate-[-45deg] relative top-[-3px] z-50 bg-white ':'ml-2' } h-1 duration-700 bg-primary transition-all rounded-full`}></span>
<span className={`w-[40px] ${isOpen && 'w-[60px] rotate-[45deg] relative top-[-15px] z-50 bg-white' } h-1 bg-primary transition-all rounded-full`}></span>
</div>
</div>
</div>
</div>
<MobileNav active={isOpen} />
<MobileNav active={isOpen} />
</header>
)
}
Expand Down
47 changes: 31 additions & 16 deletions components/NavItems.tsx
Original file line number Diff line number Diff line change
@@ -1,19 +1,34 @@
import { navItems } from '@/constants'
import Link from 'next/link'
import React from 'react'
import { navItems } from '@/constants';
import Link from 'next/link';
import AnimatedText from './AnimatedText';
import { useState } from 'react';

const NavItems: React.FC = () => {
// Initialize an array of hover states, initially all set to false
const [hoverStates, setHoverStates] = useState<boolean[]>(Array(navItems.length).fill(false));

// Function to handle hover state change for a specific item
const handleHoverChange = (index: number, isHovered: boolean): void => {
const newHoverStates = [...hoverStates]; // Create a copy of the array
newHoverStates[index] = isHovered; // Update the hover state for the specific item
setHoverStates(newHoverStates); // Update the state
};

const NavItems = () => {
return (
<div className='bg-gray-200/70 flex rounded-full p-1'>
{
navItems.map((item,index)=>(
<Link className='flex-center text-black px-5 hover:bg-white rounded-full' key={index} href={item.href}>
{item.title}
</Link>
))
}
</div>
)
}
<div className='bg-gray-200/70 flex rounded-full p-1'>
{navItems.map((item, index) => (
<Link
key={index}
href={item.href}
onMouseEnter={() => handleHoverChange(index, true)} // Set hover state to true on mouse enter
onMouseLeave={() => handleHoverChange(index, false)} // Set hover state to false on mouse leave
className='flex-center text-black px-5 hover:bg-white rounded-full'
>
<AnimatedText hover={hoverStates[index]} title={item.title} /> {/* Pass the hover state for the specific item */}
</Link>
))}
</div>
);
};

export default NavItems
export default NavItems;
25 changes: 25 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
},
"dependencies": {
"@gsap/react": "^2.1.1",
"framer-motion": "^11.1.9",
"gsap": "^3.12.5",
"next": "14.2.3",
"react": "^18",
Expand Down

0 comments on commit 4ab0452

Please sign in to comment.