Skip to content

Commit c28fb2c

Browse files
committed
refactor(docs): extract accent purple into CSS custom property
Define --sl-color-accent-rgb (139 92 246) alongside --sl-color-accent and replace all 12 hardcoded rgba(139, 92, 246, ...) occurrences with rgb(var(--sl-color-accent-rgb) / alpha). This makes the accent color a single source of truth across custom.css, PackageManagerCode.astro, and Terminal.astro.
1 parent 1502bf4 commit c28fb2c

File tree

3 files changed

+13
-12
lines changed

3 files changed

+13
-12
lines changed

docs/src/components/PackageManagerCode.astro

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ const id = `pm-${Math.random().toString(36).substr(2, 9)}`;
104104

105105
.pm-copy:focus-visible {
106106
color: rgba(255, 255, 255, 0.8);
107-
outline: 2px solid rgba(139, 92, 246, 0.5);
107+
outline: 2px solid rgb(var(--sl-color-accent-rgb) / 0.5);
108108
outline-offset: 2px;
109109
border-radius: 4px;
110110
}

docs/src/components/Terminal.astro

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ if (background) {
106106
position: absolute;
107107
inset: 0;
108108
background:
109-
radial-gradient(ellipse at 20% 20%, rgba(139, 92, 246, 0.15) 0%, transparent 50%),
109+
radial-gradient(ellipse at 20% 20%, rgb(var(--sl-color-accent-rgb) / 0.15) 0%, transparent 50%),
110110
radial-gradient(ellipse at 80% 80%, rgba(59, 130, 246, 0.15) 0%, transparent 50%);
111111
pointer-events: none;
112112
}

docs/src/styles/custom.css

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,9 @@ html,
2323

2424
/* Accent colors - Purple theme */
2525
--sl-color-accent: #8b5cf6;
26+
--sl-color-accent-rgb: 139 92 246;
2627
--sl-color-accent-high: #a78bfa;
27-
--sl-color-accent-low: rgba(139, 92, 246, 0.2);
28+
--sl-color-accent-low: rgb(var(--sl-color-accent-rgb) / 0.2);
2829

2930
/* Text colors - BOOSTED CONTRAST */
3031
--sl-color-white: #ffffff;
@@ -42,7 +43,7 @@ html,
4243
--sl-color-hairline-light: rgba(255, 255, 255, 0.06);
4344

4445
/* Inline code - accent-tinted */
45-
--sl-color-bg-inline-code: rgba(139, 92, 246, 0.15);
46+
--sl-color-bg-inline-code: rgb(var(--sl-color-accent-rgb) / 0.15);
4647

4748
/* Typography */
4849
--sl-font: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
@@ -72,14 +73,14 @@ body {
7273

7374
/* Re-add purple outline for keyboard focus */
7475
:focus-visible {
75-
outline: 2px solid rgba(139, 92, 246, 0.5) !important;
76+
outline: 2px solid rgb(var(--sl-color-accent-rgb) / 0.5) !important;
7677
outline-offset: 2px !important;
7778
border-radius: 4px;
7879
}
7980

8081
/* Skip to content link — visible on any focus (keyboard only element) */
8182
a[href="#_top"]:focus {
82-
background: rgba(139, 92, 246, 0.9) !important;
83+
background: rgb(var(--sl-color-accent-rgb) / 0.9) !important;
8384
color: #fff !important;
8485
outline: none !important;
8586
}
@@ -95,7 +96,7 @@ a[href="#_top"]:focus {
9596
background:
9697
radial-gradient(
9798
ellipse 80% 50% at 50% -20%,
98-
rgba(139, 92, 246, 0.12) 0%,
99+
rgb(var(--sl-color-accent-rgb) / 0.12) 0%,
99100
transparent 50%
100101
),
101102
radial-gradient(
@@ -1274,7 +1275,7 @@ code {
12741275

12751276
.expressive-code .copy button:focus-visible {
12761277
color: rgba(255, 255, 255, 0.8) !important;
1277-
outline: 2px solid rgba(139, 92, 246, 0.5) !important;
1278+
outline: 2px solid rgb(var(--sl-color-accent-rgb) / 0.5) !important;
12781279
outline-offset: 2px !important;
12791280
border-radius: 4px !important;
12801281
}
@@ -1606,12 +1607,12 @@ nav.sidebar a {
16061607

16071608
nav.sidebar a:hover {
16081609
color: #fff;
1609-
background: rgba(139, 92, 246, 0.1);
1610+
background: rgb(var(--sl-color-accent-rgb) / 0.1);
16101611
}
16111612

16121613
nav.sidebar a[aria-current="page"] {
16131614
color: #fff;
1614-
background: rgba(139, 92, 246, 0.2);
1615+
background: rgb(var(--sl-color-accent-rgb) / 0.2);
16151616
}
16161617

16171618
/* Sidebar group labels - "GETTING STARTED", "COMMANDS", etc. */
@@ -1835,8 +1836,8 @@ summary[id="starlight__on-this-page--mobile"] .caret {
18351836
.overscroll-message span {
18361837
display: inline-block;
18371838
padding: 0.6rem 1.5rem;
1838-
background: rgba(139, 92, 246, 0.12);
1839-
border: 1px solid rgba(139, 92, 246, 0.25);
1839+
background: rgb(var(--sl-color-accent-rgb) / 0.12);
1840+
border: 1px solid rgb(var(--sl-color-accent-rgb) / 0.25);
18401841
border-radius: 24px;
18411842
color: rgba(255, 255, 255, 0.8);
18421843
font-size: 0.9rem;

0 commit comments

Comments
 (0)