Skip to content

Commit ff7abb4

Browse files
scalvertclaude
andcommitted
refactor(McpInstallButton): use Docusaurus/Infima CSS variables
Replace custom hardcoded colors with Docusaurus CSS variables: - --ifm-pre-background / --ifm-pre-color for code blocks - --ifm-color-emphasis-* for grays (adapts to light/dark) - --ifm-color-success for success states This allows users to override styles via their Docusaurus theme and ensures consistent theming across light/dark modes. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
1 parent 983a136 commit ff7abb4

1 file changed

Lines changed: 12 additions & 31 deletions

File tree

src/theme/McpInstallButton.tsx

Lines changed: 12 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -350,27 +350,8 @@ export function McpInstallButton({
350350
</li>
351351
</ul>
352352

353-
{/* Scoped styles using CSS variables for customization */}
353+
{/* Scoped styles using Docusaurus/Infima CSS variables */}
354354
<style>{`
355-
.mcp-install-dropdown {
356-
--mcp-dropdown-width: 520px;
357-
/* Light mode: grey code blocks */
358-
--mcp-code-bg: #f3f4f6;
359-
--mcp-code-color: #374151;
360-
--mcp-copy-bg: #e5e7eb;
361-
--mcp-copy-bg-hover: #d1d5db;
362-
--mcp-copy-color: #6b7280;
363-
}
364-
365-
/* Dark mode: dark code blocks */
366-
[data-theme='dark'] .mcp-install-dropdown {
367-
--mcp-code-bg: #1e1e1e;
368-
--mcp-code-color: #e5e7eb;
369-
--mcp-copy-bg: #374151;
370-
--mcp-copy-bg-hover: #4b5563;
371-
--mcp-copy-color: #9ca3af;
372-
}
373-
374355
.mcp-install-dropdown__button {
375356
display: inline-flex;
376357
align-items: center;
@@ -383,7 +364,7 @@ export function McpInstallButton({
383364
}
384365
385366
.mcp-install-dropdown__menu {
386-
width: var(--mcp-dropdown-width);
367+
width: 520px;
387368
padding: 0;
388369
top: calc(100% + 0.25rem);
389370
}
@@ -392,7 +373,7 @@ export function McpInstallButton({
392373
padding: 0.75rem 1rem;
393374
font-size: var(--ifm-font-size-small);
394375
font-weight: var(--ifm-font-weight-semibold);
395-
color: var(--ifm-color-secondary-darkest);
376+
color: var(--ifm-color-emphasis-700);
396377
background-color: var(--ifm-background-color);
397378
border-bottom: 1px solid var(--ifm-toc-border-color);
398379
}
@@ -417,7 +398,7 @@ export function McpInstallButton({
417398
.mcp-install-dropdown__notes {
418399
margin: 0.5rem 0 0;
419400
font-size: var(--ifm-font-size-small);
420-
color: var(--ifm-color-secondary-darkest);
401+
color: var(--ifm-color-emphasis-700);
421402
line-height: 1.4;
422403
}
423404
@@ -441,24 +422,24 @@ export function McpInstallButton({
441422
text-decoration: none;
442423
}
443424
444-
/* Code block styles */
425+
/* Code block styles - uses Docusaurus pre/code variables */
445426
.mcp-code-block {
446427
display: flex;
447-
border-radius: var(--ifm-code-border-radius, 0.25rem);
428+
border-radius: var(--ifm-code-border-radius);
448429
overflow: hidden;
449430
}
450431
451432
.mcp-code-block__content {
452433
flex: 1;
453-
background-color: var(--mcp-code-bg);
434+
background-color: var(--ifm-pre-background);
454435
padding: 0.75rem 1rem;
455436
overflow-x: auto;
456437
}
457438
458439
.mcp-code-block__content code {
459440
font-family: var(--ifm-font-family-monospace);
460441
font-size: var(--ifm-code-font-size);
461-
color: var(--mcp-code-color);
442+
color: var(--ifm-pre-color);
462443
background: none;
463444
padding: 0;
464445
border: none;
@@ -481,15 +462,15 @@ export function McpInstallButton({
481462
align-items: center;
482463
justify-content: center;
483464
width: 2.75rem;
484-
background-color: var(--mcp-copy-bg);
465+
background-color: var(--ifm-color-emphasis-200);
485466
border: none;
486467
cursor: pointer;
487-
color: var(--mcp-copy-color);
468+
color: var(--ifm-color-emphasis-700);
488469
transition: background-color var(--ifm-transition-fast);
489470
}
490471
491472
.mcp-code-block__copy:hover {
492-
background-color: var(--mcp-copy-bg-hover);
473+
background-color: var(--ifm-color-emphasis-300);
493474
}
494475
495476
.mcp-code-block__icon {
@@ -499,7 +480,7 @@ export function McpInstallButton({
499480
}
500481
501482
.mcp-code-block__icon--success {
502-
color: var(--ifm-color-success, #22c55e);
483+
color: var(--ifm-color-success);
503484
}
504485
`}</style>
505486
</div>

0 commit comments

Comments
 (0)