Skip to content

Commit 983a136

Browse files
scalvertclaude
andcommitted
feat(McpInstallButton): add icon-only mode, configurable header, theme-aware code blocks
- Make `label` prop optional - when omitted, shows only the MCP icon - Add `headerText` prop to customize dropdown header (default: "Choose your AI tool:") - Use grey code blocks in light mode, dark in dark mode (via CSS variables) - Add aria-label for accessibility when in icon-only mode Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
1 parent 758f7c1 commit 983a136

2 files changed

Lines changed: 32 additions & 10 deletions

File tree

README.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -178,7 +178,8 @@ The button shows a dropdown with copy-to-clipboard configurations for all suppor
178178
|------|------|---------|-------------|
179179
| `serverUrl` | `string` | required | Your MCP server endpoint URL |
180180
| `serverName` | `string` | required | Name for the MCP server |
181-
| `label` | `string` | `"Install MCP"` | Button label |
181+
| `label` | `string` | (none) | Button label. If omitted, shows only the MCP icon |
182+
| `headerText` | `string` | `"Choose your AI tool:"` | Text shown at the top of the dropdown |
182183
| `className` | `string` | `""` | Optional CSS class |
183184
| `clients` | `ClientId[]` | All HTTP-capable | Which clients to show |
184185

src/theme/McpInstallButton.tsx

Lines changed: 30 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -133,12 +133,14 @@ export interface McpInstallButtonProps {
133133
serverUrl?: string;
134134
/** Server name. If not provided, uses plugin configuration. */
135135
serverName?: string;
136-
/** Button label (default: "Install docs MCP") */
136+
/** Button label. If not provided, shows only the MCP icon. */
137137
label?: string;
138138
/** Optional className for styling */
139139
className?: string;
140140
/** Clients to show. Defaults to all HTTP-capable clients from registry. */
141141
clients?: ClientId[];
142+
/** Header text shown at top of dropdown (default: "Choose your AI tool:") */
143+
headerText?: string;
142144
}
143145

144146
/**
@@ -156,9 +158,10 @@ export interface McpInstallButtonProps {
156158
export function McpInstallButton({
157159
serverUrl: serverUrlProp,
158160
serverName: serverNameProp,
159-
label = 'Install docs MCP',
161+
label,
160162
className = '',
161163
clients: clientsProp,
164+
headerText = 'Choose your AI tool:',
162165
}: McpInstallButtonProps) {
163166
const [isOpen, setIsOpen] = useState(false);
164167
const [copiedClient, setCopiedClient] = useState<string | null>(null);
@@ -281,19 +284,20 @@ export function McpInstallButton({
281284
<div ref={dropdownRef} className={dropdownClasses}>
282285
{/* Infima button classes */}
283286
<button
284-
className="button button--primary mcp-install-dropdown__button"
287+
className={`button button--primary mcp-install-dropdown__button${label ? '' : ' mcp-install-dropdown__button--icon-only'}`}
285288
onClick={() => setIsOpen(!isOpen)}
286289
aria-expanded={isOpen}
287290
aria-haspopup="true"
291+
aria-label={label || 'Install MCP'}
288292
>
289293
<IconMcp size={16} />
290-
<span>{label}</span>
294+
{label && <span>{label}</span>}
291295
<IconChevron isOpen={isOpen} />
292296
</button>
293297

294298
{/* Dropdown menu using Infima classes */}
295299
<ul className="dropdown__menu mcp-install-dropdown__menu">
296-
<li className="mcp-install-dropdown__header">Choose your AI tool:</li>
300+
<li className="mcp-install-dropdown__header">{headerText}</li>
297301

298302
{clientConfigs.map((client) => {
299303
const command = getCommandForClient(client.id);
@@ -350,9 +354,21 @@ export function McpInstallButton({
350354
<style>{`
351355
.mcp-install-dropdown {
352356
--mcp-dropdown-width: 520px;
353-
/* Always use dark code blocks for consistency across themes */
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 {
354367
--mcp-code-bg: #1e1e1e;
355368
--mcp-code-color: #e5e7eb;
369+
--mcp-copy-bg: #374151;
370+
--mcp-copy-bg-hover: #4b5563;
371+
--mcp-copy-color: #9ca3af;
356372
}
357373
358374
.mcp-install-dropdown__button {
@@ -361,6 +377,11 @@ export function McpInstallButton({
361377
gap: 0.5rem;
362378
}
363379
380+
.mcp-install-dropdown__button--icon-only {
381+
padding: 0.5rem 0.75rem;
382+
gap: 0.25rem;
383+
}
384+
364385
.mcp-install-dropdown__menu {
365386
width: var(--mcp-dropdown-width);
366387
padding: 0;
@@ -460,15 +481,15 @@ export function McpInstallButton({
460481
align-items: center;
461482
justify-content: center;
462483
width: 2.75rem;
463-
background-color: var(--ifm-color-gray-800, #374151);
484+
background-color: var(--mcp-copy-bg);
464485
border: none;
465486
cursor: pointer;
466-
color: var(--ifm-color-gray-400, #9ca3af);
487+
color: var(--mcp-copy-color);
467488
transition: background-color var(--ifm-transition-fast);
468489
}
469490
470491
.mcp-code-block__copy:hover {
471-
background-color: var(--ifm-color-gray-700, #4b5563);
492+
background-color: var(--mcp-copy-bg-hover);
472493
}
473494
474495
.mcp-code-block__icon {

0 commit comments

Comments
 (0)