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

Add Card component #11

Merged
merged 2 commits into from
Jun 30, 2022
Merged
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
46 changes: 46 additions & 0 deletions src/components/Card.astro
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
---
const { colour, title, description } = Astro.props;
---

<style define:vars={{ colour }}>
Copy link
Member

Choose a reason for hiding this comment

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

This is actually really interesting, I didn't consider how and if astro could handle passing code level variables to the style.

Copy link
Contributor Author

@xxArchitect xxArchitect Jun 15, 2022

Choose a reason for hiding this comment

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

Yeah, I was thinking how to set this up with as little hustle as possible and found this to be the fastest way to do so. Here is the link to Astro docs if you are interested.

* {
font-family: Helvetica, sans-serif;
}

div {
background-color: var(--colour);
border-radius: 0.3rem;
width: 30rem;
height: 15rem;
}

h1 {
padding-top: 2rem;
padding-left: 2rem;
font-weight: 300;
}

p {
padding-top: 0.25rem;
padding-left: 2rem;
}

button {
margin-top: 2.5rem;
margin-left: 2rem;
width: 5.5rem;
height: 2.5rem;
font-size: medium;
border-radius: 5rem;
border: 0rem solid black;
background-color: black;
color: white;
font-weight: 200;
}
</style>

<div>
<h1>{title}</h1>
<p>{description}</p>
<button>Read</button>
</div>