/
Figure.astro
118 lines (103 loc) · 2.58 KB
/
Figure.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
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
---
import type { ImageProps } from '@integration/images/types';
import { resolveFigureProps } from '@integration/images/utils/props';
import Image from './Image.astro';
export type Props = ImageProps;
const { src, alt, profile } = Astro.props;
const { title, attribution, width, height, dominant } = await resolveFigureProps(Astro.props);
const showLabel = !!title || !!attribution;
const imageProps = {
src,
alt: alt || '',
profile,
width,
height,
};
---
<figure class="figure">
<span class="block">
<span class="frame" style={{ 'background-color': dominant }}>
<Image {...imageProps} />
</span>
</span>
{
showLabel && (
<figcaption class="cs-primary">
{title}
{attribution && (
<span>
{attribution.text}
{attribution?.link && (
<a data-external href={attribution.link}>
Visit site
</a>
)}
</span>
)}
</figcaption>
)
}
</figure>
<style>
.figure {
display: flex;
flex-direction: column;
}
.block {
display: flex;
position: relative;
}
.frame {
width: 100%;
}
figcaption {
display: flex;
flex-direction: column;
align-self: start;
}
figcaption span {
padding-top: var(--layout-s-quarter);
font-size: var(--t-type-size--2);
font-style: italic;
}
@media screen {
figcaption {
background: var(--scheme-muted);
color: var(--scheme-fg);
padding: var(--layout-s-quarter);
}
.frame::before {
z-index: 0;
position: absolute;
display: block;
content: ' ';
width: 100%;
height: 100%;
border: var(--layout-shift) solid var(--scheme-muted);
}
}
@media print {
.figure {
break-inside: avoid;
padding: var(--layout-unit);
border: var(--layout-shift) solid var(--print-edge);
}
figcaption {
}
}
</style>
<style is:global>
.figure picture {
position: relative;
z-index: 1;
width: 100%;
min-height: 100%;
}
.figure picture img {
width: 100%;
min-height: 100%;
height: 100%;
color: transparent;
background-color: transparent;
}
</style>