Skip to content

Commit 49baff0

Browse files
sergicalclaude
andcommitted
style(docs): polish sidebar, header, focus, and code block UX
- Sidebar: purple highlight on active/hover, remove left border - Header: full-width on docs pages, constrained on homepage - Header: Docs link non-clickable when already on docs pages - Focus: strip background-color changes on focus, only show purple outline ring on keyboard focus-visible - Skip to content: purple background on focus - Code blocks: reduce header padding for less dead space - Copy button: focus ring tightly wraps icon only (Copied! text positioned absolutely so it doesn't inflate button size) Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent 3ada0ad commit 49baff0

File tree

3 files changed

+60
-10
lines changed

3 files changed

+60
-10
lines changed

docs/src/components/Header.astro

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,14 +12,15 @@ const baseUrl = import.meta.env.BASE_URL;
1212
const base = baseUrl.endsWith('/') ? baseUrl : baseUrl + '/';
1313
---
1414

15-
<div class="header sl-flex">
15+
<div class:list={["header", "sl-flex", { "header-homepage": isHomepage }]}>
1616
<div class="sl-flex header-left">
1717
<SiteTitle {...Astro.props} />
1818
</div>
1919

2020
<div class="sl-flex header-right">
2121
{!isHomepage && <Search {...Astro.props} />}
22-
<a href={`${base}getting-started/`} class="header-nav-link">Docs</a>
22+
{isHomepage && <a href={`${base}getting-started/`} class="header-nav-link">Docs</a>}
23+
{!isHomepage && <span class="header-nav-link header-nav-active">Docs</span>}
2324
<SocialIcons {...Astro.props} />
2425
</div>
2526
</div>
@@ -31,9 +32,12 @@ const base = baseUrl.endsWith('/') ? baseUrl : baseUrl + '/';
3132
align-items: center;
3233
height: 100%;
3334
width: 100%;
35+
padding: 0;
36+
}
37+
38+
.header-homepage {
3439
max-width: var(--sl-content-width);
3540
margin: 0 auto;
36-
padding: 0;
3741
}
3842

3943
.header-left {
@@ -62,4 +66,13 @@ const base = baseUrl.endsWith('/') ? baseUrl : baseUrl + '/';
6266
opacity: 1;
6367
background: rgba(255, 255, 255, 0.1);
6468
}
69+
70+
.header-nav-active {
71+
opacity: 1;
72+
cursor: default;
73+
}
74+
75+
.header-nav-active:hover {
76+
background: none;
77+
}
6578
</style>

docs/src/components/PackageManagerCode.astro

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ const id = `pm-${Math.random().toString(36).substr(2, 9)}`;
4040
overflow: hidden;
4141
margin: 1rem 0;
4242
background: rgba(255, 255, 255, 0.04);
43-
padding: 0.5rem;
43+
padding: 0 0.5rem 0.5rem;
4444
}
4545

4646
.pm-header {
@@ -56,7 +56,7 @@ const id = `pm-${Math.random().toString(36).substr(2, 9)}`;
5656
}
5757

5858
.pm-tab {
59-
padding: 0.5rem 0.75rem;
59+
padding: 0.35rem 0.75rem;
6060
font-size: 0.8rem;
6161
font-weight: 500;
6262
color: rgba(255, 255, 255, 0.4);
@@ -87,9 +87,9 @@ const id = `pm-${Math.random().toString(36).substr(2, 9)}`;
8787
}
8888

8989
.pm-copy {
90+
position: relative;
9091
display: flex;
9192
align-items: center;
92-
gap: 0.5rem;
9393
background: none;
9494
border: none;
9595
color: rgba(255, 255, 255, 0.4);
@@ -102,12 +102,23 @@ const id = `pm-${Math.random().toString(36).substr(2, 9)}`;
102102
color: rgba(255, 255, 255, 0.8);
103103
}
104104

105+
.pm-copy:focus-visible {
106+
color: rgba(255, 255, 255, 0.8);
107+
outline: 2px solid rgba(139, 92, 246, 0.5);
108+
outline-offset: 2px;
109+
border-radius: 4px;
110+
}
111+
105112
.pm-copied {
113+
position: absolute;
114+
right: 100%;
115+
margin-right: 0.5rem;
106116
font-size: 0.75rem;
107117
color: #22c55e;
108118
opacity: 0;
109119
transform: translateY(0.25rem);
110120
transition: opacity 0.2s ease-in-out, transform 0.2s ease-in-out;
121+
white-space: nowrap;
111122
}
112123

113124
.pm-copy.copied .pm-copied {

docs/src/styles/custom.css

Lines changed: 30 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,26 @@ body {
6262
background: var(--sl-color-bg);
6363
}
6464

65+
/* Strip all focus side effects — only our outline should show */
66+
:focus {
67+
outline: none !important;
68+
background-color: inherit !important;
69+
}
70+
71+
/* Re-add purple outline for keyboard focus */
72+
:focus-visible {
73+
outline: 2px solid rgba(139, 92, 246, 0.5) !important;
74+
outline-offset: 2px !important;
75+
border-radius: 4px;
76+
}
77+
78+
/* Skip to content link — visible on any focus (keyboard only element) */
79+
a[href="#_top"]:focus {
80+
background: rgba(139, 92, 246, 0.9) !important;
81+
color: #fff !important;
82+
outline: none !important;
83+
}
84+
6585
/* Subtle background gradient */
6686
.sl-layout::before {
6787
content: "";
@@ -1059,7 +1079,7 @@ code {
10591079
/* Header */
10601080
.expressive-code .header {
10611081
background: rgba(255, 255, 255, 0.03) !important;
1062-
padding: 0.7rem 1rem !important;
1082+
padding: 0.35rem 1rem !important;
10631083
border: none !important;
10641084
}
10651085

@@ -1250,6 +1270,13 @@ code {
12501270
color: rgba(255, 255, 255, 0.8) !important;
12511271
}
12521272

1273+
.expressive-code .copy button:focus-visible {
1274+
color: rgba(255, 255, 255, 0.8) !important;
1275+
outline: 2px solid rgba(139, 92, 246, 0.5) !important;
1276+
outline-offset: 2px !important;
1277+
border-radius: 4px !important;
1278+
}
1279+
12531280
/* Hide the default div background effect */
12541281
.expressive-code .copy button div {
12551282
display: none !important;
@@ -1569,21 +1596,20 @@ starlight-toc nav h2 {
15691596

15701597
nav.sidebar a {
15711598
color: rgba(255, 255, 255, 0.75);
1572-
transition: all 0.15s ease;
1599+
transition: color 0.15s ease, background 0.15s ease;
15731600
padding: 0.5rem 0.75rem;
15741601
border-radius: 6px;
15751602
margin: 1px 0;
15761603
}
15771604

15781605
nav.sidebar a:hover {
15791606
color: #fff;
1580-
background: rgba(255, 255, 255, 0.05);
1607+
background: rgba(139, 92, 246, 0.1);
15811608
}
15821609

15831610
nav.sidebar a[aria-current="page"] {
15841611
color: #fff;
15851612
background: rgba(139, 92, 246, 0.2);
1586-
border-left: 2px solid var(--sl-color-accent);
15871613
}
15881614

15891615
/* Sidebar group labels - "GETTING STARTED", "COMMANDS", etc. */

0 commit comments

Comments
 (0)