Skip to content

Commit ae42b67

Browse files
authored
Merge pull request #116 from w3bdesign/development
Development
2 parents 59fbb7b + b6024dc commit ae42b67

File tree

2 files changed

+32
-7
lines changed

2 files changed

+32
-7
lines changed

src/components/Index/Hero.component.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ const Hero = ({ content }: IContent) => (
3434
className="relative flex flex-col justify-center text-lg h-[26rem] md:h-[28.125rem] overflow-hidden"
3535
>
3636
<div
37-
className="absolute inset-0 w-full h-full md:hidden bg-cover bg-center bg-no-repeat -mt-2 mb-10"
37+
className="absolute inset-0 w-64 h-full md:hidden bg-cover bg-center bg-no-repeat -mt-2 mb-10"
3838
style={{ backgroundImage: "url('/images/mobilbg.jpg')" }}
3939
></div>
4040
<div className="hidden md:block absolute inset-0 w-full h-full">

src/components/Layout/MobileMenu.component.tsx

Lines changed: 31 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,12 @@ interface IMobileMenuProps {
1919
links: ILink[];
2020
}
2121

22+
/**
23+
* Renders the mobile menu component with animation and navigation links.
24+
*
25+
* @param {IMobileMenuProps} links - Array of navigation links
26+
* @return {JSX.Element} - Rendered mobile menu component
27+
*/
2228
const MobileMenu = ({ links }: IMobileMenuProps) => {
2329
const [isExpanded, setisExpanded] = useCycle<boolean>(false, true);
2430
const ref = useRef(null);
@@ -36,7 +42,7 @@ const MobileMenu = ({ links }: IMobileMenuProps) => {
3642
type: "spring",
3743
stiffness: 400,
3844
damping: 40,
39-
delay: 0.2, // Delay the menu closing to allow text to fade out first
45+
delay: 0.2,
4046
},
4147
},
4248
open: {
@@ -50,6 +56,12 @@ const MobileMenu = ({ links }: IMobileMenuProps) => {
5056
};
5157

5258
const itemVariants = {
59+
/**
60+
* Returns an object with the CSS properties for a closed animation.
61+
*
62+
* @param {number} i - The index of the item being animated.
63+
* @return {Object} An object with CSS properties for the closed animation.
64+
*/
5365
closed: (i: number) => ({
5466
x: i % 2 === 0 ? "-100%" : "100%",
5567
opacity: 0,
@@ -60,6 +72,19 @@ const MobileMenu = ({ links }: IMobileMenuProps) => {
6072
duration: 0.15,
6173
},
6274
}),
75+
/**
76+
* Returns an object representing the animation properties for opening an item.
77+
*
78+
* @param {number} i - The index of the item.
79+
* @return {object} An object with the following properties:
80+
* - x: The x-coordinate of the item.
81+
* - opacity: The opacity of the item.
82+
* - transition: An object representing the animation properties.
83+
* - type: The type of the animation.
84+
* - stiffness: The stiffness of the animation.
85+
* - damping: The damping of the animation.
86+
* - delay: The delay of the animation.
87+
*/
6388
open: (i: number) => ({
6489
x: 0,
6590
opacity: 1,
@@ -93,18 +118,18 @@ const MobileMenu = ({ links }: IMobileMenuProps) => {
93118
variants={menuVariants}
94119
>
95120
<nav aria-label="Navigasjon" className="w-full">
96-
<motion.ul
121+
<motion.ul
97122
className="w-full"
98123
initial="closed"
99124
animate="open"
100125
exit="closed"
101126
variants={{
102127
open: {
103-
transition: { staggerChildren: 0.07, delayChildren: 0.2 }
128+
transition: { staggerChildren: 0.07, delayChildren: 0.2 },
104129
},
105130
closed: {
106-
transition: { staggerChildren: 0.05, staggerDirection: -1 }
107-
}
131+
transition: { staggerChildren: 0.05, staggerDirection: -1 },
132+
},
108133
}}
109134
>
110135
{links.map(({ title, name, hash, href }, index) => (
@@ -145,4 +170,4 @@ const MobileMenu = ({ links }: IMobileMenuProps) => {
145170
);
146171
};
147172

148-
export default MobileMenu;
173+
export default MobileMenu;

0 commit comments

Comments
 (0)