- 
                Notifications
    You must be signed in to change notification settings 
- Fork 13
Creating Box #481
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
Creating Box #481
Changes from 2 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| 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> | ||
| ); | ||
| } | ||
| 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
    
   There was a problem hiding this comment. Choose a reason for hiding this commentThe 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. There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 | ||
|         
                  DominicS99 marked this conversation as resolved.
              Outdated
          
            Show resolved
            Hide resolved | ||
| }} | ||
| /> | ||
| ); | ||
| } | ||
Uh oh!
There was an error while loading. Please reload this page.