forked from markteekman/accessible-astro-components
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Card.astro
86 lines (75 loc) · 1.36 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
---
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 lang="scss" 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;
&:hover,
&:focus-within {
box-shadow: 0 0 0 0.25rem;
}
&:focus-within a:focus {
text-decoration: none;
box-shadow: none;
outline: none;
}
}
.card__image {
height: 10rem;
img {
height: 100%;
width: 100%;
object-fit: cover;
}
}
.card__content {
display: flex;
flex-direction: column;
flex-grow: 1;
padding: 1rem;
a {
text-decoration: none;
&:focus {
text-decoration: underline;
}
&::after {
content: '';
position: absolute;
inset: 0;
}
}
:last-child {
margin-top: auto;
padding-top: 2rem;
}
}
</style>