forked from LuaLS/LuaLS.github.io
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Heading.astro
104 lines (90 loc) · 1.87 KB
/
Heading.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
---
const { id, level } = Astro.props;
const Element = `h${level}`;
export interface Props {
id: string;
level: 1 | 2 | 3 | 4 | 5 | 6;
}
import Icon from "../common/Icon.astro";
---
<div class="heading" id={id}>
<a href={`#${id}`}><Icon name="link" group="solid" /></a>
<Element><slot /></Element>
</div>
<style lang="scss">
:global(details.accordion > summary div.heading) {
margin: 0px;
}
div.heading {
width: calc(100% + 3em);
margin: 2em 0px 0px -3em;
display: flex;
align-items: center;
& > a {
color: white;
opacity: 0;
font-size: 1.25em;
padding: 0.25em 0.5em;
transition: opacity 0.3s ease-in-out;
}
:global(h1),
:global(h2),
:global(h3),
:global(h4),
:global(h5),
:global(h6) {
width: 100%;
margin: 0px;
text-align: left;
position: relative;
word-break: break-word;
&::after {
content: "";
display: block;
width: 0.1em;
height: 100%;
background-color: var(--link-color);
position: absolute;
bottom: 0px;
border-radius: 99em;
left: -0.15em;
z-index: -1;
padding: 0px;
clip-path: polygon(0 0, 0 0, 0 100%, 0% 100%);
transition: clip-path cubic-bezier(0.65, 0.05, 0.36, 1) 0.75s;
}
}
&:hover {
a {
opacity: 1;
}
}
&:target {
:global(h1),
:global(h2),
:global(h3),
:global(h4),
:global(h5),
:global(h6) {
&::after {
clip-path: polygon(0 0, 100% 0%, 100% 100%, 0% 100%);
}
}
a {
opacity: 1;
}
}
&:global(+ p) {
margin-top: 0.25em;
}
}
@media screen and (max-width: 800px) {
div.heading {
width: 100%;
margin: 2em auto 0px -1.5em;
& > a {
font-size: 0.9em;
}
}
}
</style>