-
Notifications
You must be signed in to change notification settings - Fork 13
/
Copy pathRemark.astro
112 lines (91 loc) · 2.06 KB
/
Remark.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
---
import Icon from "./Icon.astro";
const TYPES = {
note: { displayName: "Note", icon: "note-sticky" },
warning: { displayName: "Warning", icon: "warning" },
important: { displayName: "Important", icon: "exclamation" },
WIP: { displayName: "WIP", icon: "pen-ruler" },
deprecated: { displayName: "Deprecated", icon: "trash-can" },
issue: { displayName: "Issue", icon: "circle-dot" },
};
type RemarkType =
| "note"
| "warning"
| "important"
| "WIP"
| "deprecated"
| "issue";
export interface Props {
type: RemarkType;
display?: "fit" | "block" | "compact";
}
const { type, display } = Astro.props;
const remark = TYPES[type];
if (!remark) {
throw new Error("Invalid remark type: " + type);
}
const classList = [type, "remark", display ?? "block"];
---
<div class:list={classList}>
<div>
<Icon name={remark.icon} group="solid" />
{remark.displayName}
</div>
<slot />
</div>
<style lang="scss">
.remark {
padding: 0.5em 1em;
border-radius: 0.4em;
border-width: 0.3em;
border-style: outset;
margin: 1em auto;
width: fit-content;
box-shadow: var(--remark-color) 1px 1px 0.5em 0px;
border-color: var(--remark-color);
background-color: color-mix(in srgb, var(--remark-color), #071521 80%);
&.block {
width: 90%;
}
&.compact {
display: flex;
align-items: center;
gap: 0.5em;
& > :global(*) {
margin: 0px;
}
}
&.note {
--remark-color: #0099ff;
}
&.warning {
--remark-color: #c47c00;
}
&.important {
--remark-color: #ba0000;
}
&.deprecated {
--remark-color: #9320ff;
}
&.WIP {
--remark-color: #ff20d6;
}
&.issue {
--remark-color: #2ea043;
}
& > div {
font-size: 1.1em;
display: flex;
gap: 0.5em;
align-items: center;
font-weight: bold;
}
:global(i.fa-solid) {
font-size: 1.3em;
color: color-mix(in srgb, var(--remark-color), white 60%);
}
& > :global(p) {
margin: 0.5em auto 0.2em auto;
}
}
</style>