aboutsummaryrefslogtreecommitdiff
path: root/apps/website/src/components/base/Header.astro
blob: 7d24c8fb8bd12b8605679137e87e925504c429c7 (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
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
---
import type { HTMLAttributes } from 'astro/types';

const sizes = {
	xxl: 'h1',
	xl: 'h2',
	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

let className: string | string[] = [];
if (align !== 'inherit')
	className.push(`text-${align}`);

if (size === 'xxl' || size === 'xl')
	className.push('page-header');

if (attr.class)
	className.push(attr.class);

className = className.join(' ');
---

<Element {...attr} class={className}>
	<slot/>
</Element>

<style>
    h1 {
		font-size: theme("fontSize.header-lg");
		&.page-header {
			font-size: theme("fontSize.header-page");
		}
        font-weight: 600;
    }

    h2 {
        font-size: theme("fontSize.header");
		&.page-header {
			font-size: theme("fontSize.header-page");
		}
        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>