Header Component Exercise Proposed Solution
At first I wasnt sure, but now im pretty sure I like style components. Here is my solution.
Header.jsx
import React, { Component } from 'react';
import styled from 'styled-components';
import snowman from '../../snowman.png';
const Heady = styled.header`
background-color: #282c34;
min-height: 20vh;
display: flex;
flex-direction: row;
align-items: center;
justify-content: flex-start;
`;
const DIVAPP = styled.div`
text-align: center;
background-color: darkgrey;
`;
const H1 = styled.h1`
font-size: 4rem;
color: white;
`;
const Logo = styled.img`
height: 8rem;
pointer-events: none;
`;
export default class Header extends Component{
render(){
return(
<DIVAPP>
<Heady>
<Logo src={snowman} alt="logo" />
<H1 className="App-title">
Snow Trap DEX
</H1>
</Heady>
</DIVAPP>
);
}
}
App.js
import AccountBalance from './components/AccountBalance/AccountBalance';
import React from 'react';
import { v4 as uuidv4 } from 'uuid';
import CoinList from './components/CoinList/CoinList.jsx';
import Header from './components/Header/Header.jsx';
class App extends React.Component{
constructor(props){
super(props);
this.state = {
balance: 10000,
coinData: [
{
key: uuidv4(),
name: "Bitcoin" ,
ticker:"BTC",
price: 34103.31
},
{
key: uuidv4(),
name: "Ethereum",
ticker: "ETH",
price: 2157.73
},
{
key: uuidv4(),
name: "Binance Coin",
ticker: "BNB",
price: 319.98
},
{
key: uuidv4(),
name: "Cardano",
ticker: "ADA",
price: 1.35
},
{
key: uuidv4(),
name: "XRP",
ticker: "XRP",
price: 0.634853
},
{
key: uuidv4(),
name: "Dogde Coin",
ticker: "BTC",
price: 0.218369
},
{
key: uuidv4(),
name: "Polkadot",
ticker: "DOT",
price: 15.68
},
{
key: uuidv4(),
name: "Uniswap",
ticker: "UNI",
price: 20.89
},
{
key: uuidv4(),
name: "Bitcoin Cash",
ticker: "BCH",
price: 500.60
},
{
key: uuidv4(),
name: "Litecoin",
ticker: "LTC",
price: 134.79
},
{
key: uuidv4(),
name: "Solana",
ticker: "SOL",
price: 32.92
},
{
key: uuidv4(),
name: "Chainlink",
ticker: "LINK",
price: 18.70
},
{
key: uuidv4(),
name: "Polygon",
ticker: "MATIC",
price: 0.99
},
{
key: uuidv4(),
name: "Ethereum Classic",
ticker: "ETC",
price: 47.43
},
{
key: uuidv4(),
name: "Stellar",
ticker: "XLM",
price: 0.24
},
{
key: uuidv4(),
name: "Theta Network",
ticker: "THETA",
price: 0.24
}
]
};
}
render()
{
return (
<>
<Header />
<AccountBalance amount={this.state.balance} />
<CoinList coinData={this.state.coinData} />
</>
);
}
}
export default App;