-
-
Notifications
You must be signed in to change notification settings - Fork 30
/
Card.astro
89 lines (77 loc) · 1.48 KB
/
Card.astro
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
---
interface Props {
url?: string
img?: string
title?: string
footer: string
children?: string | HTMLElement | HTMLElement[]
}
const { url = '#', img = 'https://fakeimg.pl/640x360', title = 'Default title', footer = 'Your name' } = Astro.props
---
<div class="card">
<div class="card__image">
<img src={img} alt="" />
</div>
<div class="card__content">
<h3>
<a href={url}>{title}</a>
</h3>
<p>
<slot>Default description.</slot>
</p>
<small>
{footer}
</small>
</div>
</div>
<style is:global>
.card {
display: flex;
flex-direction: column;
border: 2px solid black;
border-radius: 0.5rem;
max-width: 60ch;
min-height: 100%;
position: relative;
overflow: hidden;
transition: box-shadow 0.15s ease-in-out;
}
.card:hover,
.card:focus-within {
box-shadow: 0 0 0 0.25rem;
}
.card:focus-within a:focus {
text-decoration: none;
box-shadow: none;
outline: none;
}
.card__image {
height: 10rem;
}
.card__image img {
height: 100%;
width: 100%;
object-fit: cover;
}
.card__content {
display: flex;
flex-direction: column;
flex-grow: 1;
padding: 1rem;
}
.card__content a {
text-decoration: none;
}
.card__content a:focus {
text-decoration: underline;
}
.card__content a::after {
content: '';
position: absolute;
inset: 0;
}
.card__content:last-child {
margin-top: auto;
padding-top: 2rem;
}
</style>