Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed up the css #2

Merged
merged 1 commit into from
Dec 11, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
39 changes: 25 additions & 14 deletions src/components/pedestrian.js
Original file line number Diff line number Diff line change
@@ -1,21 +1,32 @@
import React from "react";
import PropTypes from 'prop-types';
import PropTypes from "prop-types";

import Person from '../states/person'
import Person from "../states/person";

export default function Pedestrian ({ pedestrian }) {
if (pedestrian.activity.isWalking) {
return <img className="pedestrian" src="https://media.giphy.com/media/QpWDP1YMziaQw/giphy.gif" alt="walking" />;
}
if (pedestrian.activity.isStanding) {
return <img className="pedestrian" src="https://media.giphy.com/media/ghhynvHS4NbDG/giphy.gif" alt="standing" />;
}
if (pedestrian.activity.isRunning) {
return <img className="pedestrian" src="https://media.giphy.com/media/7kn27lnYSAE9O/giphy.gif" alt="running" />;
}
return null;
export default function Pedestrian({ pedestrian: { activity } }) {

let id = activity.isWalking
? "QpWDP1YMziaQw"
: activity.isStanding
? "ghhynvHS4NbDG"
: activity.isRunning
? "3D0tSwNjVK56z6okJp"
: null;

return (
<div
className="pedestrian"
style={{
margin: "40px",
backgroundPosition: "0 0",
backgroundSize: "contain",
backgroundImage: `url(https://media.giphy.com/media/${id}/giphy.gif)`,
backgroundRepeat: "no-repeat"
}}
/>
);
}

Pedestrian.propTypes = {
pedestrian: PropTypes.instanceOf(Person)
}
};
14 changes: 7 additions & 7 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,14 +24,14 @@ class App extends React.Component {
let intersection = this.state.$;

return (
<div>
<>
<Interval enabled timeout={1000} callback={intersection.tick} />
<TrafficLight light={intersection.light} />
<Pedestrian pedestrian={intersection.pedestrian} />
<div className="footer">
timer: {intersection.light.timer.state}
</div>
</div>
<main>
<TrafficLight light={intersection.light} />
<Pedestrian pedestrian={intersection.pedestrian} />
</main>
<footer>Time left: {intersection.light.timer.state}</footer>{" "}
</>
);
}
}
Expand Down
61 changes: 39 additions & 22 deletions src/style.css
Original file line number Diff line number Diff line change
@@ -1,13 +1,41 @@
html {
background: linear-gradient(#08f, #fff);
padding: 40px;
height: 100%;
margin: 0 auto;
}

body {
height: 100vh;
margin: 0;
}

#root {
display: flex;
flex-direction: column;
height: 100%;
}

main {
display: flex;
flex-grow: 1;
}

.pedestrian {
display: flex;
flex-grow: 1;
padding: 40px;
}

footer {
display: flex;
flex-grow: initial;
font-size: 24px;
font-weight: bold;
font-family: sans-serif;
padding: 40px 60px 40px 300px;
}

.trafficlight {
float: left;
margin-right: 50px;
margin: 40px;
background: #222;
background-image: linear-gradient(
transparent 2%,
Expand All @@ -20,6 +48,7 @@ html {
border-radius: 20px;
position: relative;
border: solid 5px #333;
display: flex;
}

.trafficlight:before {
Expand Down Expand Up @@ -106,11 +135,9 @@ html {
}

.yellow.is-active {
background: yellow;
background: yellow;
}



.green {
background-image: radial-gradient(lime, transparent);
background-size: 5px 5px;
Expand All @@ -129,26 +156,16 @@ html {
}

.is-blinking {
animation: 1.5s blinking infinite;
animation: 1.5s blinking infinite;
}

@keyframes blinking {
50%, 100% {
50%,
100% {
opacity: 0.1;
}
0%, 49% {
0%,
49% {
opacity: 1;
}
}

.pedestrian {
position: relative;
float: left;
min-height: 650px;
}

.footer {
position: absolute;
bottom: 10px;
left: 10px;
}