Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 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
11 changes: 6 additions & 5 deletions workspaces/simon-game/src/app/components/App.tsx
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
import React from "react";

import { Box } from "./Box.tsx";

export function App() {
return (
<div>
<div
style={{ backgroundColor: "lightblue", height: 100, width: 100 }}
></div>
<div style={{ backgroundColor: "orange", height: 100, width: 100 }}></div>
<div style={{ backgroundColor: "green", height: 100, width: 100 }}></div>
<Box color="red" />
<Box color="#0050B5" /> //cobalt blue
<Box color="green" />
<Box color="yellow" />
</div>
);
}
17 changes: 17 additions & 0 deletions workspaces/simon-game/src/app/components/Box.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import React from "react";

type Props = { color?: string; height?: number; width?: number };

export function Box(props: Props) {
return (
<div
style={{
backgroundColor: props.color ?? "lightblue",
height: props.height ?? 100,
width: props.width ?? 100,
Comment on lines +15 to +16
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is fine, but as mentioned in another comment I assume we're not going to vary the box sizes arbitrarily. As such, by making these not props, we can guarantee that every instance of Box is the same size.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(Saw that you did this for practice -- sounds good for now though I think you'll get plenty of practice regardless!)

borderRadius: 20, // rounded corners
margin: 10, // spaces
}}
/>
);
}
Loading