aboutsummaryrefslogtreecommitdiff
path: root/website/src/components/SiteTitle.astro
blob: 04839c3896ddd2677a7d7bdf5472f32cef17f826 (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
89
90
91
92
93
94
95
96
97
98
99
100
101
102
---
import { logos } from 'virtual:starlight/user-images';
import config from 'virtual:starlight/user-config';

const { siteTitle, siteTitleHref } = Astro.locals.starlightRoute;
---

<div class="title-row sl-flex">
  <a href={siteTitleHref} class="site-title sl-flex">
    {
      config.logo && logos.dark && (
        <>
          <img
            class:list={{ 'light:sl-hidden print:hidden': !('src' in config.logo) }}
            alt={config.logo.alt}
            src={logos.dark.src}
            width={logos.dark.width}
            height={logos.dark.height}
          />
          {!('src' in config.logo) && (
            <img
              class="dark:sl-hidden print:block"
              alt={config.logo.alt}
              src={logos.light?.src}
              width={logos.light?.width}
              height={logos.light?.height}
            />
          )}
        </>
      )
    }
    <span class:list={{ 'sr-only': config.logo?.replacesTitle }} translate="no">
      {siteTitle}
    </span>
  </a>
  <nav class="title-nav" aria-label="Primary">
    <a href="/docs/">Docs</a>
  </nav>
</div>

<style>
  @layer starlight.core {
    .title-row {
      align-items: baseline;
      gap: 1rem;
      min-width: 0;
    }

    .site-title {
      align-items: baseline;
      gap: var(--sl-nav-gap);
      font-size: var(--sl-text-h4);
      font-weight: 600;
      color: var(--sl-color-text-accent);
      text-decoration: none;
      white-space: nowrap;
      min-width: 0;
    }

    span {
      overflow: hidden;
    }

    img {
      height: calc(var(--sl-nav-height) - 2 * var(--sl-nav-pad-y));
      width: auto;
      max-width: 100%;
      object-fit: contain;
      object-position: 0 50%;
    }

    .title-nav {
      display: flex;
      align-items: baseline;
      gap: 0.75rem;
      font-size: var(--sl-text-sm);
      font-weight: 600;
      line-height: 1;
    }

    .title-nav a {
      color: var(--sl-color-text-accent);
      text-decoration: none;
      transition: color 120ms ease;
    }

    .site-title {
      transition: color 120ms ease;
    }

    .site-title:hover,
    .title-nav a:hover {
      color: var(--sl-color-accent-high);
    }

    @media (max-width: 35rem) {
      .title-nav {
        display: none;
      }
    }
  }
</style>