-
-
Notifications
You must be signed in to change notification settings - Fork 105
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add reusable card component workshop (#629)
- Loading branch information
Showing
2 changed files
with
89 additions
and
0 deletions.
There are no files selected for viewing
53 changes: 53 additions & 0 deletions
53
frontend-cert/react-projects/resuable-profile-component/index.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
<!DOCTYPE html> | ||
<html lang="en"> | ||
<head> | ||
<meta charset="UTF-8" /> | ||
<title>Reusable Card component</title> | ||
<script src="https://unpkg.com/react@18/umd/react.development.js"></script> | ||
<script src="https://unpkg.com/react-dom@18/umd/react-dom.development.js"></script> | ||
|
||
<!-- Don't use this in production: --> | ||
<script src="https://unpkg.com/@babel/standalone/babel.min.js"></script> | ||
<link rel="stylesheet" href="./styles.css" /> | ||
</head> | ||
<body> | ||
<div id="root"></div> | ||
<script type="text/babel"> | ||
function Card({ name, title, bio }) { | ||
return ( | ||
<div className="card"> | ||
<h2>{name}</h2> | ||
<p className="card-title">{title}</p> | ||
<p>{bio}</p> | ||
</div> | ||
); | ||
} | ||
|
||
function App() { | ||
return ( | ||
<div className="flex-container"> | ||
<Card | ||
name="Mark" | ||
title="Frontend developer" | ||
bio="I like to work with different frontend technologies and play video games." | ||
/> | ||
<Card | ||
name="Tiffany" | ||
title="Engineering manager" | ||
bio="I have worked in tech for 15 years and love to help people grow in this industry." | ||
/> | ||
<Card | ||
name="Doug" | ||
title="Backend developer" | ||
bio="I have been a software developer for over 20 years and I love working with Go and Rust." | ||
/> | ||
</div> | ||
); | ||
} | ||
|
||
const container = document.getElementById("root"); | ||
const root = ReactDOM.createRoot(container); | ||
root.render(<App />); | ||
</script> | ||
</body> | ||
</html> |
36 changes: 36 additions & 0 deletions
36
frontend-cert/react-projects/resuable-profile-component/styles.css
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
:root { | ||
--dark-grey: #1b1b32; | ||
--light-grey: #f5f6f7; | ||
--dark-orange: #f89808; | ||
} | ||
|
||
body { | ||
background-color: var(--dark-grey); | ||
} | ||
|
||
.flex-container { | ||
display: flex; | ||
flex-wrap: wrap; | ||
justify-content: space-around; | ||
align-items: center; | ||
} | ||
|
||
.card { | ||
border: 5px solid var(--dark-orange); | ||
border-radius: 10px; | ||
width: 100%; | ||
padding: 20px; | ||
margin: 10px 0; | ||
background-color: var(--light-grey); | ||
} | ||
|
||
.card-title { | ||
border-bottom: 4px solid var(--dark-orange); | ||
width: fit-content; | ||
} | ||
|
||
@media (min-width: 768px) { | ||
.card { | ||
width: 300px; | ||
} | ||
} |