Skip to content

Commit f8ef517

Browse files
FireGiantDocsrobmen
authored andcommitted
Fix header spacing so "Docs" displays correctly
1 parent 4a45d5a commit f8ef517

4 files changed

Lines changed: 110 additions & 5 deletions

File tree

astro.config.mjs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ export default defineConfig({
4545
components: {
4646
// Override the default `Head` component to add our page tracking.
4747
Head: './src/components/starlight/Head.astro',
48+
Header: './src/components/starlight/Header.astro',
4849
// Boost schema reference pages in Pagefind results.
4950
MarkdownContent: './src/components/starlight/MarkdownContent.astro',
5051
PageTitle: './src/components/starlight/PageTitle.astro',
Lines changed: 88 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,88 @@
1+
---
2+
import config from 'virtual:starlight/user-config';
3+
4+
import LanguageSelect from 'virtual:starlight/components/LanguageSelect';
5+
import Search from 'virtual:starlight/components/Search';
6+
import SiteTitle from 'virtual:starlight/components/SiteTitle';
7+
import SocialIcons from 'virtual:starlight/components/SocialIcons';
8+
import ThemeSelect from 'virtual:starlight/components/ThemeSelect';
9+
10+
const shouldRenderSearch =
11+
config.pagefind || config.components.Search !== '@astrojs/starlight/components/Search.astro';
12+
---
13+
14+
<div class="fg-header">
15+
<div class="fg-title sl-flex">
16+
<SiteTitle />
17+
</div>
18+
<div class="fg-search sl-flex print:hidden">
19+
{shouldRenderSearch && <Search class="fg-search-control" />}
20+
</div>
21+
<div class="fg-right sl-hidden md:sl-flex print:hidden">
22+
<div class="fg-social sl-flex">
23+
<SocialIcons />
24+
</div>
25+
<ThemeSelect />
26+
<LanguageSelect />
27+
</div>
28+
</div>
29+
30+
<style>
31+
.fg-header {
32+
display: flex;
33+
align-items: center;
34+
gap: var(--sl-nav-gap);
35+
min-width: 0;
36+
width: 100%;
37+
}
38+
39+
.fg-title {
40+
flex: 0 0 auto;
41+
min-width: max-content;
42+
overflow: visible;
43+
}
44+
45+
.fg-search {
46+
flex: 1 1 16rem;
47+
min-width: 0;
48+
}
49+
50+
.fg-search :global(site-search) {
51+
display: block;
52+
width: 100%;
53+
}
54+
55+
.fg-search :global(button[data-open-modal]) {
56+
max-width: 22rem;
57+
}
58+
59+
.fg-right,
60+
.fg-social {
61+
align-items: center;
62+
gap: 1rem;
63+
}
64+
65+
.fg-right {
66+
flex: 0 0 auto;
67+
margin-inline-start: auto;
68+
min-width: max-content;
69+
}
70+
71+
.fg-social::after {
72+
content: '';
73+
height: 2rem;
74+
border-inline-end: 1px solid var(--sl-color-gray-5);
75+
}
76+
77+
@media (max-width: 63.999rem) {
78+
.fg-search {
79+
flex-basis: 14rem;
80+
}
81+
}
82+
83+
@media (max-width: 50rem) {
84+
.fg-search :global(button[data-open-modal]) {
85+
max-width: 100%;
86+
}
87+
}
88+
</style>

src/components/starlight/SiteTitle.astro

Lines changed: 21 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,14 +14,24 @@ const docsHref = 'https://docs.firegiant.com/';
1414

1515
<style>
1616
.site-title {
17+
--logo-height: calc(var(--sl-nav-height) - 2 * var(--sl-nav-pad-y));
18+
align-items: center;
1719
gap: 1rem;
20+
min-width: max-content;
21+
flex-shrink: 0;
22+
white-space: nowrap;
1823
}
24+
1925
.site-title a {
2026
display: flex;
27+
align-items: center;
28+
flex-shrink: 0;
2129
}
30+
2231
.firegiant-logo {
2332
color: var(--sl-color-white);
2433
}
34+
2535
.docs-logo {
2636
color: var(--sl-color-text-accent);
2737
}
@@ -37,15 +47,22 @@ const docsHref = 'https://docs.firegiant.com/';
3747
}
3848
/* Adjust svg sizes to full nav height */
3949
.site-title :global(svg) {
40-
--display-height: 1.75rem;
41-
/* `auto` ensures the `<svg>` scales down on really narrow viewports */
50+
display: block;
4251
width: auto;
43-
height: auto;
44-
margin-block: calc((var(--sl-nav-height) - var(--display-height)) / 2);
52+
height: var(--logo-height);
53+
max-width: none;
4554
transition: transform 0.18s cubic-bezier(0.23, 1, 0.32, 1);
4655
}
56+
4757
.site-title a:hover :global(svg) {
4858
--hover-offset: 0.15rem;
4959
transform: translateY(calc(var(--hover-offset) * -1));
5060
}
61+
62+
@media (max-width: 64rem) {
63+
.site-title {
64+
--logo-height: 1.625rem;
65+
gap: 0.75rem;
66+
}
67+
}
5168
</style>

src/styles/custom.css

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,6 @@ body {
6060
font-family: Plex, var(--__sl-font);
6161
}
6262

63-
6463
/* Home
6564
============================= */
6665

0 commit comments

Comments
 (0)