-
Notifications
You must be signed in to change notification settings - Fork 4
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
Changes from 1 commit
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 |
---|---|---|
@@ -0,0 +1,51 @@ | ||
--- | ||
const { colour, title, description } = Astro.props; | ||
--- | ||
|
||
<style define:vars={{ colour }}> | ||
* { | ||
font-family: Helvetica, sans-serif; | ||
} | ||
|
||
div { | ||
background-color: var(--colour); | ||
border-radius: 0.3em; | ||
width: 30em; | ||
height: 15em; | ||
} | ||
|
||
h1, p, button { | ||
position: relative; | ||
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. Instead of using position relative and super positioning everything using top, left, and right units I'd recommend using margin and padding. You'll save a lot of lines by having a padding of 1 rem. 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. Very good point! I will update it to use margins/padding instead of positioning. |
||
} | ||
|
||
h1 { | ||
left: 1em; | ||
top: 1em; | ||
left: 1em; | ||
font-weight: 300; | ||
} | ||
|
||
p { | ||
top: 2em; | ||
left: 2.2em; | ||
} | ||
|
||
button { | ||
bottom: -5.5rem; | ||
left: 2.5em; | ||
width: 5.5em; | ||
height: 2.5em; | ||
font-size: medium; | ||
border-radius: 5em; | ||
border: 0em solid black; | ||
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. Is there a reason why you use em instead of rem for most of the units? 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. Not sure... I can fix it to have to rem instead of em. |
||
background-color: black; | ||
color: white; | ||
font-weight: 200; | ||
} | ||
</style> | ||
|
||
<div> | ||
<h1>{title}</h1> | ||
<p>{description}</p> | ||
<button>Read</button> | ||
</div> |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.