-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
added styled components, logic changes
- Loading branch information
1 parent
3df5b1f
commit f89d3c6
Showing
21 changed files
with
372 additions
and
223 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,7 @@ | ||
# random-randomizer | ||
## Random-randomizer | ||
|
||
A small project to practice React useState. | ||
A small project to practice React! | ||
|
||
## View it live | ||
|
||
https://random-randomizer.netlify.app/ |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,18 +1,41 @@ | ||
import './App.css'; | ||
import YesNo from './components/YesNo'; | ||
import { RandomNumber } from './components/RandomNumber'; | ||
import Header from './components/Header'; | ||
import React, { useState } from 'react' | ||
import { RandomNumber } from './components/RandomNumber' | ||
import Header from './components/Header' | ||
import { Background } from './components/Background' | ||
import TwoChoices from './components/TwoChoices' | ||
import GlobalStyles from './components/GlobalStyle' | ||
|
||
const App = () => { | ||
const [xOrY, setXOrY] = useState(null) | ||
const [loading, setLoading] = useState(false) | ||
console.log(xOrY) | ||
|
||
const handleRandomGenerator = () => { | ||
setLoading(true) | ||
//setTimeout to show the loading for 2 seconds | ||
setTimeout(() => { | ||
//the random generation happens here | ||
const randomGenerator = Math.floor(Math.random() * 2) + 1 | ||
setXOrY(randomGenerator) | ||
//removing loading again | ||
setLoading(false) | ||
}, 2000) | ||
} | ||
|
||
function App() { | ||
return ( | ||
<div className="App"> | ||
<Header /> | ||
<main> | ||
<YesNo /> | ||
<RandomNumber /> | ||
</main> | ||
</div> | ||
); | ||
<> | ||
<GlobalStyles /> | ||
<Background x={xOrY === 1} y={xOrY === 2} loading={loading}> | ||
<Header /> | ||
<TwoChoices | ||
onXOrYChange={setXOrY} | ||
loading={loading} | ||
onRandomGenerator={handleRandomGenerator} | ||
xOrY={xOrY} | ||
/> | ||
<RandomNumber /> | ||
</Background> | ||
</> | ||
) | ||
} | ||
|
||
export default App; | ||
export default App |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
import styled, { css, keyframes } from 'styled-components' | ||
|
||
const GradientAnimation = keyframes` | ||
0% { | ||
background-position: 0% 50%; | ||
} | ||
50% { | ||
background-position: 100% 50%; | ||
} | ||
100% { | ||
background-position: 0% 50%; | ||
} | ||
` | ||
export const Background = styled.div` | ||
display: flex; | ||
flex-direction: column; | ||
gap: 2rem; | ||
align-items: center; | ||
height: 100vh; | ||
width: 100vw; | ||
background: linear-gradient(-45deg, #85ffbd, #fffb7d, #e2ff7d, #3adea6); | ||
background-size: 400% 400%; | ||
animation: ${GradientAnimation} 10s ease infinite; | ||
${(props) => | ||
props.x && | ||
css` | ||
background: linear-gradient( | ||
-45deg, | ||
#19cfc5, | ||
#18a3a0, | ||
#4bdaf3, | ||
#4b8ff3, | ||
#4b63f3 | ||
); | ||
background-size: 400% 400%; | ||
animation: ${GradientAnimation} 10s ease infinite; | ||
`} | ||
${(props) => | ||
props.y && | ||
css` | ||
background: linear-gradient( | ||
-45deg, | ||
#974bf3, | ||
#c94bf3, | ||
#b04bf3, | ||
#693ad6, | ||
#9433c2 | ||
); | ||
background-size: 400% 400%; | ||
animation: ${GradientAnimation} 10s ease infinite; | ||
`} | ||
${(props) => | ||
props.loading && | ||
css` | ||
background: linear-gradient(-45deg, #ffad4d, #ffd55f, #fffa83, #fff); | ||
background-size: 400% 400%; | ||
animation: ${GradientAnimation} 10s ease infinite; | ||
`} | ||
` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
import { createGlobalStyle } from 'styled-components' | ||
|
||
const GlobalStyles = createGlobalStyle` | ||
body { | ||
font-family: 'Archivo', sans-serif; | ||
} | ||
` | ||
export default GlobalStyles |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,44 @@ | ||
import React from "react"; | ||
import React from 'react' | ||
import styled from 'styled-components' | ||
|
||
const StyledHeader = styled.header` | ||
display: flex; | ||
flex-direction: column; | ||
align-items: center; | ||
` | ||
|
||
const StyledH1 = styled.h1` | ||
font-weight: 700; | ||
text-align: center; | ||
margin: 0; | ||
padding-top: 2rem; | ||
` | ||
|
||
const StyledP = styled.p` | ||
font-size: 12px; | ||
margin: 5px; | ||
` | ||
|
||
const StyledSmallP = styled.p` | ||
font-weight: 700; | ||
font-size: 10px; | ||
` | ||
const StyledH2 = styled.h2` | ||
font-weight: 700; | ||
font-size: 14px; | ||
margin: 0; | ||
padding-top: 1rem; | ||
` | ||
|
||
const Header = () => { | ||
return ( | ||
<header> | ||
<h1>Vios random randomizer</h1> | ||
</header> | ||
) | ||
return ( | ||
<StyledHeader> | ||
<StyledH1>Vios random randomizer</StyledH1> | ||
<StyledSmallP>For when choices need to be made.</StyledSmallP> | ||
<StyledH2>Click the circle to generate your choice! </StyledH2> | ||
<StyledP>1 for no. 2 for yes.</StyledP> | ||
</StyledHeader> | ||
) | ||
} | ||
|
||
export default Header; | ||
export default Header |
Oops, something went wrong.