aboutsummaryrefslogtreecommitdiff
path: root/src/components/Alert.astro
blob: 0cb5fa29a585ec8986f47a7fc019094c509c94c7 (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
---
import { Icon } from "astro-icon/components";

interface Props {
  type: "note" | "warning";
}

const { type } = Astro.props;

const icon = {
  note: "ph:info",
  warning: "ph:warning",
}[type];
---

<div role="alert" class={type}>
  <Icon name={icon} />
  <slot />
</div>

<style lang="scss" is:global>
  @use "../../styles/shared.scss" as *;

  div[role="alert"] {
    display: flex;
    align-items: center;
    justify-content: flex-start;

    padding: 1rem;
    margin-block: 1rem;
    border-radius: 0.5rem;

    &.note {
      background-color: $noteBackground;
      color: $noteText;
      box-shadow: 0 0 0 1px $noteText;
    }

    &.warning {
      background-color: $warningBackground;
      color: $warningText;
      box-shadow: 0 0 0 1px $warningText;
    }
  }

  div[role="alert"] svg {
    width: 1.5em;
    height: 1.5em;
    margin-inline-end: 0.5rem;
    color: inherit;
    vertical-align: middle;
  }

  div[role="alert"] p {
    margin-block: 0;
  }
</style>