Skip to content

Commit

Permalink
day 5
Browse files Browse the repository at this point in the history
  • Loading branch information
phptuts committed May 17, 2022
1 parent 4c21a2d commit f0f7c19
Show file tree
Hide file tree
Showing 5 changed files with 34 additions and 10 deletions.
4 changes: 1 addition & 3 deletions src/components/LedStrip/Led.js
Expand Up @@ -8,9 +8,7 @@ const Led = ({ color, position, connectionClass = '' }) => {
backgroundColor: color,
}}
className="light"
>
{position}
</div>
></div>
</div>
);
};
Expand Down
17 changes: 16 additions & 1 deletion src/components/LedStrip/Leds.js
@@ -1,12 +1,27 @@
import React from 'react';
import Strip from './Strip';
import config from '../../config';

const Leds = ({ leds }) => {
return (
<div id="leds">
<Strip leds={leds} direction="left" />
<Strip
leds={leds.slice(0, 2).map((l) => {
leds={leds.slice(0, 3).map((l) => {
return { ...l, color: '#00AA00' };
})}
direction="right-down"
/>
<Strip leds={leds} direction="right" />
<Strip
leds={leds.slice(0, 3).map((l) => {
return { ...l, color: '#00AA00' };
})}
direction="left-down"
/>
<Strip leds={leds} direction="left" />
<Strip
leds={leds.slice(0, 3).map((l) => {
return { ...l, color: '#00AA00' };
})}
direction="right-down"
Expand Down
6 changes: 6 additions & 0 deletions src/config.js
@@ -0,0 +1,6 @@
const config = {
ledsHorizontal: 50,
ledsVertical: 3,
};

export default config;
15 changes: 10 additions & 5 deletions src/index.css
Expand Up @@ -5,21 +5,22 @@
left: 50%;
top: 50%;
transform: translateX(-50%) translateY(-50%);
width: 30px;
height: 30px;
width: 15px;
height: 15px;
}

/** this is the container that our led lives in **/
.led {
background-color: #f8fbd9;
position: relative;
border: solid black 1px;
width: 50px;
height: 50px;
width: 20px;
height: 20px;
}
#leds {
position: relative;
width: 1000px;
margin: 10px auto;
}

/** Strip controls a row of leds **/
Expand All @@ -34,5 +35,9 @@

.strip.right-down {
flex-direction: column;
margin-left: 950px;
margin-left: 980px;
}

.strip.left-down {
flex-direction: column;
}
2 changes: 1 addition & 1 deletion src/pages/Home.js
Expand Up @@ -5,7 +5,7 @@ import { generateLeds } from '../leds';

const Home = () => {
const [currentFrameIndex, setCurrentFrameIndex] = useState(1);
const [numberLeds, setNumberLeds] = useState(20);
const [numberLeds, setNumberLeds] = useState(50);
const [leds, setLeds] = useState(generateLeds(numberLeds));

function setNumberOfLeds(e) {
Expand Down

0 comments on commit f0f7c19

Please sign in to comment.