In my React Project Animation is not working - css

I am new to React
In my React project I wrote a keyframes in app.js and in this project using styled Components
Section.js
import React from "react";
import styled from "styled-components";
function Section() {
return (
<Wrap>
<ItemText>
<h1>Model S</h1>
<p>Order Online</p>
</ItemText>
<Buttons>
<ButtonGroup>
<LeftButton>Custom Order</LeftButton>
<RightButton>Existing Inventory</RightButton>
</ButtonGroup>
<DownArrow src="/images/down-arrow.svg" />
</Buttons>
</Wrap>
);
}
export default Section;
const Wrap = styled.div`
width: 100vw;
height: 100vh;
background-size: cover;
background-image: url("images/model-s.jpg");
background-repeat: no-repeat;
background-position: center;
display: flex;
flex-direction: column;
justify-content: space-between;
align-items: center;
`;
const ItemText = styled.div`
padding: 10vh;
text-align: center;
`;
const LeftButton = styled.div`
cursor: pointer;
background-color: rgba(23, 26, 32, 0.8);
color: white;
height: 40px;
width: 256px;
display: flex;
flex-direction: row;
align-items: center;
justify-content: center;
border-radius: 100px;
opacity: 0.85;
text-transform: uppercase;
font-size: 12px;
`;
const RightButton = styled(LeftButton)`
cursor: pointer;
`;
const ButtonGroup = styled.div`
display: flex;
padding: 15vh;
`;
const DownArrow = styled.img`
margin-top: 20px;
height: 40px;
animation: animateDown infinte 1.5s;
`;
const Buttons = styled.div``;
App.css
* {
box-sizing: border-box;
font-family: "Rubik", sans-serif;
color: #393c41;
margin: 0;
padding: 0;
}
body {
width: 100%;
}
#keyframes animateDown {
0%,
20%,
50%,
80%,
100% {
transform: translateY(0);
}
40% {
transform: translateY(5px);
}
60% {
transform: translateY(3px);
}
}
Check Arrow Down Component I added a Animation on that.
I checked in Chrome it tell in valid property value on webkit I colud not find the Solution
I needed your Help guys
Thanks in Advance <3

Related

Custom react modal getting hidden behind service card

I'm building info modals for a website on the services page. The services page has 3 cards that have different options, heres that code from the services page.
React JS
<ServicesContainer id='services'>
<ServicesH1>Services</ServicesH1>
<ServicesWrapper>
<ServicesCard>
<ServicesIcon src={Icon1} />
<ServicesH2>Equine Therapy</ServicesH2>
<ServicesP>
Work with horses
</ServicesP>
<Button
to='services'
onClick={openInfoModal}
primary='true'
dark='true'
smooth={true}
duration={500}
spy={true}
exact='true'
offset={-80}
>
modal
</Button>
</ServicesCard>
<ServicesCard>
<ServicesIcon src={Icon2} />
<ServicesH2>Group Therapy</ServicesH2>
<ServicesP>
Group therapy.
</ServicesP>
<InfoModal showInfoModal={showInfoModal} setShowInfoModal={setShowInfoModal}/>
</ServicesCard>
<ServicesCard>
<ServicesIcon src={Icon3} />
<ServicesH2>Individual Therapy</ServicesH2>
<ServicesP>
Individual Therapy.
</ServicesP>
</ServicesCard>
</ServicesWrapper>
</ServicesContainer>
When the modal pops up it's hidden behind the 3rd card, i'm assuming it has something to do with the 3rd card coming after the InfoModal component/ the styling. I've tried setting the z-index to 900, messed with opacity as well with no luck. When I put the InfoModal component under the 3rd card it shows up on the 3rd (far right) column of the page off center which I definitely don't want. I've looked around trying to find a solution by maybe being able to identify the custom InfoModal component as a modal so it shows up in front of everything but was only able to find styled-react-modal, which i tried but it made so many errors about ecma script that I just had to remove it. I'm pretty bad with css but heres the InfoModal styled components code
const Background = styled.div`
width: 100%;
height: 100%;
background: rgba(0, 0, 0, 1);
position: fixed;
display: flex;
justify-content: center;
align-items: center;
z-index: 10;
`;
const ModalWrapper = styled.div`
width: 800px;
height: 500px;
box-shadow: 0 5px 16px rgba(0, 0, 0, 1);
background: #fff;
color: #000;
display: grid;
grid-template-columns: 1fr;
position: relative;
z-index: 10;
border-radius: 10px;
`;
const ModalContent = styled.div`
display: flex;
flex-direction: column;
justify-content: center;
align-items: center;
line-height: 1.8;
color: #141414;
p {
margin-bottom: 1rem;
}
button {
padding: 10px 24px;
background: #141414;
color: #fff;
border: none;
}
`;
const CloseModalButton = styled(MdClose)`
cursor: pointer;
position: absolute;
top: 20px;
right: 20px;
width: 32px;
height: 32px;
padding: 0;
z-index: 10;
`;
the services styled components code
import styled from 'styled-components';
export const ServicesContainer = styled.div`
height: 800px;
display: flex;
flex-direction: column;
justify-content: center;
align-items: center;
background: #189AC0;
z-index: 1;
#media screen and (max-width: 768px) {
height: 1100px;
}
#media screen and (max-width: 480px) {
height: 1300px;
}
`;
export const ServicesWrapper = styled.div`
max-width: 1000px;
margin: 0 auto;
display: grid;
grid-template-columns: 1fr 1fr 1fr;
align-items: center;
grid-gap: 16px;
padding: 0 50px;
z-index: 1;
#media screen and (max-width: 1000px) {
grid-template-columns: 1fr 1fr;
}
#media screen and (max-width: 768px) {
grid-template-columns: 1fr;
padding: 0 20px;
}
`;
export const ServicesCard = styled.div`
background: #fff;
display: flex;
flex-direction: column;
justify-content: flex-start;
align-items: center;
border-radius: 10px;
max-height: 340px;
padding: 30px;
box-shadow: 0 1px 3px rgba(0, 0, 0, 0.2);
transition: all 0.2s ease-in-out;
transform: scale(1.05);
z-index: 0.5;
&:hover {
transform: scale(1.05);
transition: all 0.2s ease-in-out;
cursor: pointer;
}
`;
export const ServicesIcon = styled.img`
height: 160px;
width: 160px;
margin-bottom: 10px;
`;
export const ServicesH1 = styled.h1`
font-size: 2.5rem;
color: #fff;
margin-bottom: 64px;
#media screen and (max-width: 480px) {
font-size: 2rem;
}
`;
export const ServicesH2 = styled.h2`
font-size: 1rem;
margin-bottom: 10px;
`;
export const ServicesP = styled.p`
font-size: 1rem;
text-align: center;
`;
I hope this isn't to much but if anyone is good with styling or react, would appreciate any feedback.

How to make close effect after clicking on close in Styled-components?

I'm trying to make an in and out animation for my comment -
import {
Popup,
Overlay,
NavBarPopupHeader,
NavBarPopupContainer,
NavBarPopupImg,
NavBarPopupClose,
NavBarPopupContent,
NavBarPopupTitle,
NavBarPopupInfo,
NavBarPopupContentImg,
NavBarPopupFooter,
NavBarPopupSignOut,
} from "./styled.js";
function NavBarPopup(props) {
const { isPopupOpen } = props;
return (
<Overlay>
<Popup active={false}>
<NavBarPopupHeader>
<NavBarPopupClose
src="./popup_close.svg"
alt="close"
onClick={() => isPopupOpen(false)}
active={true}
/>
<NavBarPopupContainer>
<NavBarPopupImg />
</NavBarPopupContainer>
</NavBarPopupHeader>
<NavBarPopupContent>
<NavBarPopupTitle>You are logged as</NavBarPopupTitle>
<NavBarPopupInfo>'UserName'</NavBarPopupInfo>
<NavBarPopupInfo>'Email'</NavBarPopupInfo>
<NavBarPopupContentImg src="./popup_img.png" />
</NavBarPopupContent>
<NavBarPopupFooter>
<NavBarPopupSignOut>Sign Out...</NavBarPopupSignOut>
</NavBarPopupFooter>
</Popup>
</Overlay>
);
}
export default NavBarPopup;
I am using styled-components :
import styled, { keyframes, css } from "styled-components";
import { fadeIn, bounceInRight, bounceInLeft } from 'react-animations';
const fader = keyframes`${fadeIn}`;
const bounceIn = keyframes`${bounceInRight}`;
const bounceOut = keyframes`${bounceInLeft}`;
const Popup = styled.div`
position: fixed;
top: 0;
right: 0;
height: 100vh;
width: 400px;
background-color: #ffffff;
transition: ${(active) =>
active
? css`
${bounceIn} 0.5s linear
`
: css`${bounceOut} 0.5s`};
`;
const Overlay = styled.div`
position: fixed;
top: 0;
left: 0;
width: 100%;
height: 100vh;
background-color: rgba(0, 0, 0, 0.8);
animation: 0.2s ${fader};
`;
const NavBarPopupHeader = styled.div`
width: 100%;
height: 15%;
background-color: #000000;
`;
const NavBarPopupContainer = styled.p`
text-align: center;
margin: 0;
padding: 30px 0 0 0;
`;
const NavBarPopupImg = styled.img`
width: 80px;
height: 80px;
border-radius: 50px;
border: none;
background-color: white;
color: black;
font-size: 25px;
`;
const NavBarPopupClose = styled.img`
position: absolute;
top: 5px;
left: 5px;
cursor: pointer;
`;
const NavBarPopupContent = styled.div`
height: 75%;
`;
const NavBarPopupTitle = styled.h3`
margin:0;
padding: 10px 0 10px 0;
text-align: center;
font-size: 30px;
`
const NavBarPopupInfo = styled.h4`
width: 80%;
margin: 10px auto;
padding:5px;
text-align: center;
font-size: 25px;
background-color: black;
color:white;
border-radius: 15px;
`
const NavBarPopupContentImg = styled.img`
width:100%;
margin-top:90px;
`
const NavBarPopupFooter = styled.div`
width: 100%;
height: 10%;
background-color: #000000;
`;
const NavBarPopupSignOut = styled.p`
width:200px;
text-align: center;
margin: 0 auto;
padding: 15px 0 0 0;
font-weight: 700;
font-size: 32px;
color: white;
text-decoration: underline;
cursor: pointer;
`;
export {
Popup,
Overlay,
NavBarPopupHeader,
NavBarPopupContainer,
NavBarPopupImg,
NavBarPopupClose,
NavBarPopupContent,
NavBarPopupTitle,
NavBarPopupInfo,
NavBarPopupContentImg,
NavBarPopupFooter,
NavBarPopupSignOut
};
I want my popup to be animated with $bounceIn when it appears, and disappear with $bounceOut when it closes. I tried to do it by passing an attribute to styled-components but now it only works when my Popup appears. Perhaps I chose the wrong approach, in which case please guide me in the right direction.

Struggling to navigate styling on React

I'm extremely new to this stuff, so please don't judge.
I'm trying to build a website and now I'm at the css part of it. My text is showing up in a different color than what I chose, its in the middle and its supposed to be on the left, I added a Menu icon but that's nowhere to be seen and I've added sections in the menu, also nothing.
I feel like crying.
I'm following an instructional and the code is exactly the same, but its showing up different on my side.
import styled from 'styled-components'
import {Link as LinkR} from 'react-router-dom'
import { findByLabelText } from '#testing-library/dom';
import {Link as LinkS} from 'react-scroll'
export const Nav = styled.nav`
background: #000;
height: 80px;
/*margin-top: -80px; */
display: flex;
justify-content: center;
align-items: center;
font-size: 1rem;
position: sticky;
top: 0;
z-index: 1;
#media screen and (max-width: 960px) {
transition: 0.8s all ease;
}
`
export const NavbarContainer = styled.div`
display: flex;
justify-content: space-between;
height: 80px;
z-index: 1'
width: 100%;
padding: 0 24px;
max-width: 1100px;
`
export const NavLogo = styled(LinkR)`
color: red;
justify-self: flex-start;
cursor: pointer;
font-size: 1.5rem;
display: flex;
align-items: center;
margin-left: 24px;
font-weight: bold;
text-decoration: none;
`;
export const MobileIcon = styled.div`
display:none;
#media screen and (max-width: 768px) {
display: block;
position: absolute;
top: o;
right: 0;
transfrom: translate(-100%, 60%);
font-size: 1.8rem;
cursor: pointer;
color: #000;
}
`
export const NavMenu = styled.ul`
display: flex;
align-itens: center;
list-style: none;
text-align: center;
margin-right: -22px;
#media screen and (max-width: 768px) {
display: none;
}
`
export const NavItem = styled.li`
height: 80px;
`
export const NavLinks = styled (LinkS)`
color: #fff;
display: flex;
align-items: center;
text-decoration: none;
padding: 0 1rem;
height: 100%;
cursor: pointer;
&.active {
border-bottom: 3px solid #01bf71;
}
`
I don't know if it solves your problem, but:
In your code at the NavbarContainer after you set the z-index you have a quote instead of a semicolon.
And also at the NavMenu you wrote align-itens instead of align-items.
If you are using VSCode then install the following extension: vscode-styled-components

DropDown Positioning absolute element outside of the relative parent container

I'm using ReactJs and Emotion, but I know the problem is related to my CSS
I have a Header structure
main (
sidebar
content
)
That's why I'm having trouble positioning an <ul> tag correctly with position absolute and this error happens:
problem gif:
I know it is related to the position: relative of my components or my page structure I already tried everything and I couldn't solve it
basically i need my <ul> dropdown to be next to my sidebar like this:
My JSX:
const Tags = () => {
const [menuItems, setMenuItems] = useState(SideBarTags);
const showHideDropItem = tag => {
setMenuItems(items =>
items.map(item => ({
...item,
Active:
item.Name === tag.Name ? (tag.Active === true ? false : true) : false
}))
);
};
return (
<SideBar.MenuList>
{menuItems.map((item, index) => (
<SideBar.ListItem>
<SideBar.ListWrap>
<a>
<item.Icon size={24} />
<span className="li-name">{item.Name}</span>
</a>
</SideBar.ListWrap>
{item.DropdownItems && (
<SideBar.ClosedStyled>
{item.DropdownItems.map(item => (
<li className="li-closed" key={item.Name}>
<FaGhost size={18} />
<a onClick={() => console.log(item.Name)}>{item.Name}</a>
</li>
))}
</SideBar.ClosedStyled>
)}
</SideBar.ListItem>
))}
</SideBar.MenuList>
);
};
export default function App() {
return (
<Global.Container>
<Header.NavBar>
<Header.LogoSide>
<img src={Logo} alt="elo Ghost" />
</Header.LogoSide>
<div style={{ width: "100%", background: "#eee" }} />
</Header.NavBar>
<Global.Main>
<SideBar.SideBodyWrap>
<SideBar.DashMenu>
<Tags />
</SideBar.DashMenu>
</SideBar.SideBodyWrap>
<Content>a</Content>
</Global.Main>
</Global.Container>
);
}
my CSS in Js:
import styled from "#emotion/styled/macro";
import { shade } from "polished";
import { css } from "#emotion/core";
// Global Containers
const Container = styled.div`
height: 100%;
`;
const Main = styled.div`
display: flex;
height: calc(100% - 55px);
position: relative;
z-index: 0;
`;
// Global Containers
export const Global = {
Container,
Main
};
// header Nav
export const NavBar = styled.div`
height: 55px;
background: #3c8dbc;
display: flex;
box-shadow: 0 2px 2px rgba(0, 0, 0, 0.05), 0 1px 0 rgba(0, 0, 0, 0.05);
position: relative;
z-index: 1;
`;
export const LogoSide = styled.div`
display: flex;
background: red;
justify-content: center;
background: #3c8dbc;
padding: 10px;
width: 100%;
max-width: 250px;
height: 55px;
img {
height: 35px;
transition: all 0.2s ease;
}
`;
// header Nav
export const Header = {
NavBar,
LogoSide
};
// SideBar
const SideBodyWrap = styled.nav`
overflow-y: auto;
height: 100%;
max-width: 250px;
width: 100%;
color: #009688;
background: #3c8dbc;
transition: all 0.2s ease;
::-webkit-scrollbar {
width: 5px;
}
::-webkit-scrollbar-track {
-webkit-box-shadow: inset 0 0 6px rgba(0, 0, 0, 0.3);
}
::-webkit-scrollbar-thumb {
background: rgba(255, 0, 0, 0.8);
-webkit-box-shadow: inset 0 0 6px rgba(0, 0, 0, 0.5);
}
::-webkit-scrollbar-thumb:window-inactive {
background: rgba(255, 0, 0, 0.4);
}
`;
const MenuList = styled.ul`
font-family: "Ubuntu";
font-size: 14px;
font-weight: 300;
text-decoration: none;
color: #fff;
padding-top: 10px;
`;
export const ListItem = styled.li`
display: flex;
flex-direction: column;
justify-content: center;
cursor: pointer;
position: relative;
`;
export const ListWrap = styled.div`
padding: 12px 20px 12px 20px;
display: flex;
transition: all 0.5s cubic-bezier(0, 1, 0, 1);
justify-content: center;
align-items: center;
a {
display: flex;
align-items: center;
svg {
margin-right: 15px;
transition: all 0.5s cubic-bezier(0, 1, 0, 1);
}
}
& .icon-li {
margin-right: 10px;
}
& .down-up_svg,
.li-name {
display: none;
}
`;
export const ClosedStyled = styled.ul`
${ListItem}:hover & {
max-width: 400px !important;
max-height: 400px !important;
}
max-height: 0px !important;
overflow: hidden;
-webkit-transition: all 0.2s;
-moz-transition: all 0.2s;
-ms-transition: all 0.2s;
-o-transition: all 0.2s;
transition: all 0.2s;
list-style-type: none;
margin: 0;
padding: 0;
top: 0;
left: 70%;
font-weight: 400;
position: absolute;
padding: 0px;
z-index: 2;
background: ${shade(0.4, "#3c8dbc")};
border-top-right-radius: 5px;
border-bottom-right-radius: 5px;
& .li-closed {
white-space: nowrap;
padding: 10px 20px;
:hover > svg {
color: orange;
}
svg {
margin-right: 10px;
}
}
a {
font-family: "Ubuntu";
font-size: 14px;
font-weight: 300;
text-decoration: none;
color: #8aa4af;
}
`;
const DashMenu = styled.div`
display: flex;
flex-direction: column;
`;
export const SideBar = {
SideBodyWrap,
DashMenu,
ClosedStyled,
ListItem,
ListWrap,
MenuList
};
// SideBar
export const Content = styled.div`
height: 100%;
width: 100%;
background: #eee;
`;
example:
https://codesandbox.io/s/cranky-hamilton-oy47v?file=/src/App.js
and :
https://oy47v.csb.app/
If I'm understanding what you're wanting to achieve correctly, I was able to do it by removing overflow-y:auto from .sidebodywrap and changing left:70% to left:100% in .closedstyled

React native, how to make a shape

i'm trying to made this in react native,
I tried to had a square and an oval, i tried to have border radius in a singular square, but everytime i cannot reach this result.
This is what i tried, but as i said i don't know how to reach this
export const StyledText = styled.Text`
text-align: center;
font-family: ${FONTS.fontFamily.bold};
font-size: 29px;
color: white;
`;
export const StyledContainer = styled.View`
align-items: center;
justify-content: center;
height: 250px;
`;
export const StyledOval = styled.View`
width: 110%;
height: 150px;
border-radius: 100-5;
border-width: 10;
background-color: red;
border-color: black;
position: absolute;
top: 50;
z-index: 10;
`;
export const StyledSquare = styled.View`
flex: 1;
align-content: center;
justify-content: center;
width: 100%;
height: 100px;
background-color: red;
position: absolute;
top: 0;
z-index: 11;
`;

Resources