Tell us what’s happening:
Describe your issue in detail here.
The code passed but there is 1 thing i cannot do. I can’t transition smoothly the text of the quote.I tried just adding transition effect but it doesn’t work. (the background-color works fine).
Thank you.
Your code so far
index.js//
import React from "react";
import ReactDOM from "react-dom";
import { FontAwesomeIcon } from "@fortawesome/react-fontawesome";
import { faTwitter } from "@fortawesome/free-brands-svg-icons";
import "./index.css";
import Quote from "./Quotes";
import Button from "./Button";
const App = () => {
const [quote, setQuote] = React.useState([]);
const [color, setColor] = React.useState("#000000");
const fetchQuote = async () => {
const response = await fetch("https://api.quotable.io/random");
const randomQuote = await response.json();
setQuote(randomQuote);
setColor("#" + Math.floor(Math.random() * 16777215).toString(16));
};
React.useEffect(() => {
fetchQuote();
}, []);
const handleClick = () => {
return fetchQuote();
};
return (
<div className="container" style={{ backgroundColor: color }}>
<wrapper id="quote-box">
<Quote
content={quote.content}
author={quote.author}
color={color}
/>
<div id="footer">
<a href="/" id="tweet-quote">
<FontAwesomeIcon icon={faTwitter} />
</a>
<Button handleClick={handleClick} />
</div>
</wrapper>
<p className="comment">Made by me</p>
</div>
);
};
ReactDOM.render(<App />, document.getElementById("root"));
Quotes.js//
import React from "react";
import { FontAwesomeIcon } from "@fortawesome/react-fontawesome";
import { faQuoteLeft } from "@fortawesome/free-solid-svg-icons";
export default function Quote(props) {
return (
<div className="main">
<h1 id="text">
<i className="quote_icon">
<FontAwesomeIcon icon={faQuoteLeft} />
</i>
{props.content}
</h1>
<p style={{ color: props.color }} id="author">
-{props.author}
</p>
</div>
);
}
Button.js//
import React from "react";
export default function Button(props) {
return (
<button onClick={props.handleClick} id="new-quote">
New Quote
</button>
);
}
index.css//
* {
margin: 0;
box-sizing: border-box;
font-family: "Spirax", cursive;
}
.container {
height: 100vh;
display: flex;
justify-content: center;
align-items: center;
flex-direction: column;
transition: background-color 0.5s ease-in-out;
}
#quote-box {
background-color: white;
padding: 25px 50px;
border-radius: 3px;
max-width: 560px;
}
#text {
font-size: x-large;
margin-bottom: 20px;
color: black;
}
#author {
display: flex;
float: right;
}
#footer {
display: flex;
justify-content: space-between;
margin-top: 80px;
}
button {
border-radius: 3px;
border-style: none;
height: 40px;
width: 150px;
background-color: black;
color: antiquewhite;
font-size: large;
cursor: pointer;
}
#tweet-quote {
width: 40px;
height: 40px;
background-color: black;
display: grid;
place-content: center;
color: white;
font-size: large;
border-radius: 3px;
}
#author {
font-size: larger;
}
.comment {
margin-top: 10px;
color: black;
font-weight: 500;
}
.quote_icon {
margin-right: 15px;
}
.main {
transition: opacity 0.5s ease-in-out;
}
Your browser information:
User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/110.0.0.0 Safari/537.36
Challenge: Front End Development Libraries Projects - Build a Random Quote Machine
Link to the challenge: