-
Notifications
You must be signed in to change notification settings - Fork 4
Componentize image card #427
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
base: main
Are you sure you want to change the base?
Changes from all 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 |
|---|---|---|
| @@ -0,0 +1,57 @@ | ||
| --- | ||
| import { Image } from "astro:assets"; | ||
| import type { ImageMetadata } from "astro"; | ||
|
|
||
| interface Props { | ||
| image: ImageMetadata; | ||
| alt?: string | null; | ||
| title: string; | ||
| theme: string; | ||
| href: string; | ||
| buttonText: string; | ||
| borderClass?: string; | ||
| titleClass?: string; | ||
| colClass?: string; | ||
| } | ||
|
|
||
| const { | ||
| image, | ||
| alt, | ||
| title, | ||
| theme, | ||
| href, | ||
| buttonText, | ||
|
Contributor
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. Thoughts @brian-montgomery on button vs link text? We are making an anchor tag but we use btn bootstrap styling classes
Contributor
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. I don't have a strong opinion. It looks like a button with the styling, but there's not a form or anything, so it more functions more like a link.
Contributor
Author
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. Since it takes the user to another route, I thought of keeping it as an anchor semantically -- please let me know if we need to discuss further -- I'll resolve this comment for now |
||
| colClass = "col" | ||
| } = Astro.props; | ||
|
|
||
| const { | ||
| borderClass = `border-${theme}-subtle`, | ||
| titleClass = `text-${theme}`, | ||
| } = Astro.props; | ||
| --- | ||
|
|
||
| <div class={colClass}> | ||
| <div class={`card border ${borderClass}`}> | ||
| <Image | ||
| src={image} | ||
| class="card-img-top" | ||
| alt={alt || null} | ||
| /> | ||
| <div class="card-body"> | ||
| <h3 class={`card-title ${titleClass}`} set:text={title} /> | ||
| <slot /> | ||
| <a | ||
| href={href} | ||
| class={`btn btn-${theme}`} | ||
| set:text={buttonText} | ||
| /> | ||
| </div> | ||
| </div> | ||
| </div> | ||
|
|
||
| <style> | ||
| .card-img-top { | ||
| height: auto; | ||
| } | ||
| </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.
What are your thoughts of instead of having all the individual classes for border, title, col, we create variants of this ImageCard? I would maybe need to check the visuals so we could see what to call them/how to group them but in a Design System there is a balance for sure of allowing anything to go and having some constraints by saying like hey we have these 2-3 variants, please use one of those
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.
Oh yeah, I've seen that approach in systems like MUI, where a predefined set of styles is applied to the component based on use cases that the D/S has already identified, but unsure if we have done that exercise yet -- I'll resolve this now and create a new issue to track this suggestion to discuss / implement next.