-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #56 from brklntmhwk/55-create-card-component
feat(ui): 🆕 create a card component and the remark plugin
- Loading branch information
Showing
60 changed files
with
602 additions
and
92 deletions.
There are no files selected for viewing
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 |
---|---|---|
@@ -1 +1 @@ | ||
{"assets":{"images":{}},"src":{"assets":{"images":{}}}} | ||
{"assets":{"images":{}},"src":{"assets":{"images":{}},"components":{"card":{}},"content":{"page":{"en":{}}}}} |
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
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
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
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
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,67 @@ | ||
--- | ||
import { | ||
type CardBorderType, | ||
type ComponentCardProps, | ||
type ElementCardProps, | ||
isElementCard, | ||
isValidBorderType, | ||
} from './card'; | ||
type Props = ComponentCardProps | ElementCardProps; | ||
let cardBorderType: CardBorderType = 'solid'; | ||
let isAnimated = false; | ||
if (isElementCard(Astro.props)) { | ||
const { 'data-border-type': dataBorderType } = Astro.props; | ||
if (isValidBorderType(dataBorderType)) { | ||
cardBorderType = dataBorderType; | ||
} | ||
} else { | ||
const { borderType, isAnimated: animation } = Astro.props; | ||
cardBorderType = borderType; | ||
isAnimated = animation; | ||
} | ||
--- | ||
|
||
<div class:list={["card", `${cardBorderType}-border`, { "fade-in-up": isAnimated }]}> | ||
<slot name="image" /> | ||
<slot name="content" /> | ||
</div> | ||
<style> | ||
.card { | ||
background-color: var(--bg); | ||
max-width: 100%; | ||
height: 15rem; | ||
display: flex; | ||
flex-direction: column; | ||
gap: 0.525rem; | ||
break-inside: avoid; | ||
&:hover { | ||
background-color: var(--bg-hover); | ||
} | ||
& :global(.card-image) { | ||
max-height: 8.75rem; | ||
min-height: 6.75rem; | ||
padding: 0.25rem; | ||
display: flex; | ||
justify-content: center; | ||
& :global(img) { | ||
object-fit: contain; | ||
width: 100%; | ||
height: 100%; | ||
} | ||
} | ||
& :global(.card-content) { | ||
font-size: 0.925rem; | ||
padding: 0.175rem 0.325rem; | ||
overflow-y: auto; | ||
} | ||
@media (min-width: 320px) { | ||
max-width: 18rem; | ||
} | ||
@media (min-width: 1280px) { | ||
max-width: 20rem; | ||
} | ||
} | ||
</style> |
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,25 @@ | ||
--- | ||
--- | ||
|
||
<div class="card-grid"> | ||
<slot /> | ||
</div> | ||
<style> | ||
.card-grid { | ||
display: grid; | ||
align-items: flex-start; | ||
grid-template-columns: repeat(auto-fit, minmax(7.875rem, 1fr)); | ||
grid-auto-flow: row dense; | ||
gap: 1.5rem; | ||
@media (min-width: 640px) { | ||
grid-template-columns: repeat(auto-fit, minmax(9.675rem, 1fr)); | ||
} | ||
@media (min-width: 768px) { | ||
grid-template-columns: repeat(3, 1fr); | ||
} | ||
@media (min-width: 1280px) { | ||
grid-template-columns: repeat(4, 1fr); | ||
} | ||
} | ||
</style> |
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,18 @@ | ||
const cardBorderTypes = ['pixel', 'double', 'solid'] as const; | ||
|
||
export type CardBorderType = (typeof cardBorderTypes)[number]; | ||
|
||
export type ElementCardProps = { | ||
'data-border-type': string; | ||
}; | ||
|
||
export type ComponentCardProps = { | ||
borderType: CardBorderType; | ||
isAnimated: boolean; | ||
}; | ||
|
||
export const isElementCard = (props: object): props is ElementCardProps => | ||
Object.hasOwn(props, 'data-border-type'); | ||
|
||
export const isValidBorderType = (type: string): type is CardBorderType => | ||
cardBorderTypes.some((borderType) => borderType === type); |
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,2 @@ | ||
export { default as Card } from './Card.astro'; | ||
export { default as CardGrid } from './CardGrid.astro'; |
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
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
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
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
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
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
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
Oops, something went wrong.