blob: 23f54294faae9f6e6f4cc203a5879bf66c1f6af1 (
plain)
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
|
---
import type { HTMLAttributes } from "astro/types"
const sizes = {
"xl": "h1",
"lg": "h2",
"md": "h3",
"sm": "h4",
"xs": "h5",
"xxs": "h6"
};
type Headers = "h1" | "h2" | "h3" | "h4" | "h5" | "h6";
interface Props extends HTMLAttributes<Headers> {
size?: keyof typeof sizes;
align?: "left" | "center" | "right" | "inherit";
}
const {
size = "lg",
align = "inherit",
...attr
} = Astro.props;
const Element = sizes[size] as any; // Unfortunately gotta do this
const className = (align == "inherit" ? "" : `text-${align} `) + (attr.class ? ` ${attr.class}` : "");
---
<Element {...attr} class={className}>
<slot />
</Element>
<style>
h1 {
font-size: theme("fontSize.header-lg");
font-weight: 600;
}
h2 {
font-size: theme("fontSize.header");
font-weight: 600;
}
h3 {
font-size: theme("fontSize.header-sm");
font-weight: 600;
}
h4 {
font-size: theme("fontSize.body-lg");
font-weight: 500;
}
h5 {
font-size: theme("fontSize.body");
font-weight: 500;
}
h6 {
font-size: theme("fontSize.body-sm");
font-weight: 500;
}
h1, h2, h3, h4, h5, h6 {
& :global(b) {
@apply text-blue-500;
font-weight: inherit;
}
}
</style>
|