Issue
I am developing a website using react. I want to add a divider for all sections. But I can't set its position at bottom 0. It seems like this:
I am using some wrappers. And maybe it's the reason.
I want to add a divider to the "work" section. Here are the files:
work.jsx:
import React, { useState, useEffect } from 'react';
import { AiFillEye, AiFillGithub } from 'react-icons/ai';
import { motion } from 'framer-motion';
import { AppWrap, MotionWrap } from '../../wrapper';
import { urlFor, client } from '../../client';
import './Work.scss';
function Work() {
const [activeFilter, setActiveFilter] = useState('All');
const [animateCard, setAnimateCard] = useState({ y:0, opacity: 1 });
const [works, setWorks] = useState([]);
const [filterWork, setFilterWork] = useState([]);
useEffect(() => {
const query = '*[_type == "works"]'
client.fetch(query).then((data) => {
setWorks(data);
setFilterWork(data);
})
}, [])
const handleWorkFilter = (item) => {
setActiveFilter(item);
setAnimateCard([{ y:100, opacity:0 }])
setTimeout (() => {
setAnimateCard([{ y:0, opacity: 1}])
if(item === 'All') {
setFilterWork(works)
} else {
setFilterWork(works.filter((work) => work.tags.includes(item)))
}
},500)
}
return (
<>
<h2 className="head-text-green">MY PROJECTS</h2>
<div className='app__work-filter'>
{['UI/UX', 'REACT JS', 'HTML', 'JAVACRIPT', 'CSS', 'SCSS', 'ALL'].map((item, index) =>
<div
className={`app__work-filter-item app__flex p-text-green ${activeFilter === item ? "item-active" : ""}`}
key={index}
onClick={() => handleWorkFilter(item)}
>
{item}
</div>
)}
</div>
<motion.div
animate = {animateCard}
transition = {{ duration: 0.5, delayChildren: 0.5 }}
className = 'app__work-portfolio'
>
{filterWork.map((work, index) =>
<div className='app__work-item app__flex' key={index}>
<div className='app__work-img app__flex'>
<img src={urlFor(work.imgUrl)} alt={work.name} />
<motion.div
whileHover={{ opacity: [0,1]}}
transition={{ duration: 0.25, ease: 'easeInOut', staggerChildren: 0.5 }}
className='app__work-hover app__flex'
>
<a href={work.projectLink} target='_blank' rel='noreferrer'>
<motion.div
whileInView={{ scale: [0, 1]}}
whileHover={{ scale: [1, 0.9]}}
transition={{ duration: 0.25 }}
className='app__flex'
>
<AiFillEye />
</motion.div>
</a>
<a href={work.codeLink} target='_blank' rel='noreferrer'>
<motion.div
whileInView={{ scale: [0, 1]}}
whileHover={{ scale: [1, 0.9]}}
transition={{ duration: 0.25 }}
className='app__flex'
>
<AiFillGithub />
</motion.div>
</a>
</motion.div>
</div>
<div className='app__work-content app__flex'>
<h4 className='bold-text-green'>{work.title}</h4>
<p className='p-text' style={{marginTop: 10}}>{work.description}</p>
<div className='app__work-tag app__flex'>
<p className='p-text'>{work.tags[0]}</p>
</div>
</div>
</div>
)}
</motion.div>
<div class="custom-shape-divider-bottom-1657991521">
<svg data-name="Layer 1" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 1200 120" preserveAspectRatio="none">
<path d="M602.45,3.86h0S572.9,116.24,281.94,120H923C632,116.24,602.45,3.86,602.45,3.86Z" class="shape-fill"></path>
</svg>
</div>
</>
)
}
export default AppWrap(
MotionWrap(Work, 'app__works'),
'work',
'app__grey1bg'
);
work.scss:
.app__works {
flex: 1;
width: 100%;
flex-direction: column;
}
.app__work-filter {
display: flex;
flex-direction: row;
justify-content: flex-start;
align-items: center;
flex-wrap: wrap;
margin: 4rem 0 2rem;
.app__work-filter-item {
padding: 0.5rem 1rem;
border-radius: 0.5rem;
background-color: #fff;
font-weight: 800;
cursor: pointer;
transition: all 0.3s ease;
margin: 0.5rem;
&:hover {
background-color: var(--secondary-color);
color: #fff;
}
@media screen and (min-width: 2000px) {
padding: 1rem 2rem;
border-radius: 0.85rem;
}
}
.item-active {
background-color: var(--secondary-color);
color: #fff;
}
}
.app__work-portfolio {
display: flex;
flex-wrap: wrap;
justify-content: center;
align-items: center;
.app__work-item{
width: 270px;
flex-direction: column;
margin: 2rem;
padding: 1rem;
border-radius: 0.5rem;
background-color: #fff;
color: #000;
cursor: pointer;
transition: all 0.3s ease;
&:hover {
box-shadow: 0 0 25px rgba(0,0,0,0.2);
}
@media screen and (min-width: 2000px) {
width: 470px;
padding: 1.25rem;
border-radius: 0.75rem;
}
@media screen and (max-width: 300px) {
width: 100%;
margin: 1rem;
}
}
}
.app__work-img {
width: 100%;
height: 230px;
position: relative;
img {
width: 100%;
height: 100%;
border-radius: 0.5rem;
object-fit: cover;
}
@media screen and (min-width: 2000px) {
height: 350px;
}
}
.app__work-hover {
position: absolute;
top: 0;
left: 0;
bottom: 0;
right: 0;
width: 100%;
height: 100%;
background-color: rgba(0,0,0,0.5);
border-radius: 0.5rem;
opacity: 0;
transition: all 0.3s ease;
div {
width: 50px;
height: 50px;
border-radius: 50%;
background-color: rgba(0,0,0,0.5);
color: white;
margin: 1rem;
font-family: var(--font-base);
font-weight: 800;
cursor: pointer;
transition: all 0.3s ease;
svg {
width: 50%;
height: 50%;
color: var(--white-color);
}
}
}
.app__work-content {
padding: 0.5rem;
width: 100%;
position: relative;
flex-direction: column;
h4 {
margin-top: 1rem;
line-height: 1.5;
}
.app__work-tag {
position: absolute;
padding: 0.5rem 1rem;
border-radius: 10px;
background-color: #fff;
top: -25px;
}
}
.custom-shape-divider-bottom-1657991521 {
position: relative;
bottom: 0;
left: 0;
width: 100%;
overflow: hidden;
line-height: 0;
}
.custom-shape-divider-bottom-1657991521 svg {
position: relative;
display: block;
width: calc(100% + 1.3px);
height: 58px;
}
.custom-shape-divider-bottom-1657991521 .shape-fill {
fill: #BDD2B6;
}
appWrap.js (it use NavigationDots.jsx with classname="app__navigation" and SocialMedia.jsx with class name= "app__social" ):
import { color } from '@mui/system';
import React from 'react';
import { NavigationDots, SocialMedia } from '../components';
const AppWrap = (Component, idName, classNames) => function HOC() {
return (
<div id={idName} className={`app__container ${classNames}`}>
<SocialMedia />
<div className='app__wrapper app__flex'>
<Component />
<div className='copyright'>
<p className='p-text'>@2022 AYGEN</p>
<p className='p-text'>All rights reserved</p>
</div>
</div>
<NavigationDots active={idName} />
</div>
)
}
export default AppWrap;
MotionWrap.js:
import React from 'react';
import { motion } from 'framer-motion';
const MotionWrap = (Component, classNames) => function HOC() {
return (
<motion.div
whileInView={{ y: [100, 50, 0], opacity: [0, 0, 1] }}
transition={{ duration: 0.5 }}
className={`${classNames} app__flex`}
>
<Component />
</motion.div>
)
}
export default MotionWrap
a part of app.scss file:
.app__social {
display: flex;
justify-content: flex-end;
align-items: center;
flex-direction: column;
padding: 1rem;
position: initial;
div {
z-index: 5;
width: 40px;
height: 40px;
border-radius: 50%;
background-color: rgb(255, 255, 255);
margin: 0.25rem 0;
border: 1px solid var(--lightGray-color);
display: flex;
justify-content: center;
align-items: center;
transition: all 0.3s ease-in-out;
svg {
width: 15px;
height: 15px;
color: var(--green5-color);
}
&:hover {
background-color: var(--secondary-color);
border-color: var(--secondary-color);
svg {
color: var(--white-color);
}
}
@media screen and (min-width: 2000px) {
width: 70px;
height: 70px;
margin: 0.5rem 0;
svg {
width: 30px;
height: 30px;
}
}
}
@media screen and (max-width: 600px) {
justify-content: center;
}
}
.app__navigation {
display: flex;
justify-content: center;
align-items: center;
flex-direction: column;
padding: 1rem;
.app__navigation-dot {
width: 10px;
height: 10px;
border-radius: 50%;
background-color: #cbcbcb;
margin: 0.5rem;
transition: background-color 0.2s ease-in-out;
z-index: 5;
&:hover {
background-color: var(--secondary-color);
}
@media screen and (min-width: 2000px) {
width: 20px;
height: 20px;
}
}
}
@media screen and (max-width: 500px) {
.app__navigation,
.app__social {
display: none;
}
.copyright {
padding: 2rem;
}
}
I don't know if any other file is necessary to solve. Thanks in advance.
Solution
import { color } from "@mui/system";
import React from "react";
import { NavigationDots, SocialMedia } from "../components";
const AppWrap = (Component, idName, classNames) =>
function HOC() {
return (
<div id={idName} className={`app__container ${classNames}`}>
<SocialMedia />
<div className="app__wrapper app__flex">
<Component />
<div className="copyright">
<p className="p-text">@2022 AYGEN</p>
<p className="p-text">All rights reserved</p>
</div>
<div class="custom-shape-divider-bottom-1657991521">
<svg
data-name="Layer 1"
xmlns="http://www.w3.org/2000/svg"
viewBox="0 0 1200 120"
preserveAspectRatio="none"
>
<path
d="M602.45,3.86h0S572.9,116.24,281.94,120H923C632,116.24,602.45,3.86,602.45,3.86Z"
class="shape-fill"
></path>
</svg>
</div>
</div>
<NavigationDots active={idName} />
</div>
);
};
export default AppWrap;
Answered By - Pratik Wadekar
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.