|
1 | 1 | import React from 'react'; |
2 | | -import { FaLock, FaUnlock, FaCloud, FaServer, FaFlask, FaStar } from 'react-icons/fa'; |
3 | 2 |
|
4 | 3 | /** |
5 | | - * DocHeaderChips - Display tier/offering badges at the top of doc pages |
6 | | - * Replaces the old gray "Tier/Offering" box with a modern badge row |
| 4 | + * DocHeaderChips - Minimal metadata strip for doc pages |
| 5 | + * Shows tier/availability as subtle inline badges, not a competing card |
7 | 6 | * |
8 | 7 | * Usage in MDX: |
9 | 8 | * import DocHeaderChips from '@site/src/components/DocHeaderChips'; |
10 | | - * <DocHeaderChips chips={['enterprise', 'cloud']} /> |
| 9 | + * <DocHeaderChips tier="oss" version="4.0.0" /> |
| 10 | + * <DocHeaderChips tier="enterprise" /> |
11 | 11 | * |
12 | | - * Available chip types: 'enterprise', 'oss', 'cloud', 'selfhosted', 'dedicated', 'beta', 'new' |
| 12 | + * Props: |
| 13 | + * - tier: 'oss' | 'enterprise' | 'cloud' (optional) |
| 14 | + * - version: string (optional, e.g., "4.0.0") |
| 15 | + * - availability: array of strings (optional, e.g., ['cli', 'cloud']) |
13 | 16 | */ |
14 | 17 |
|
15 | | -const chipConfig = { |
16 | | - enterprise: { |
17 | | - label: 'Enterprise', |
18 | | - icon: FaLock, |
19 | | - bg: 'linear-gradient(135deg, #7c3aed 0%, #6d28d9 100%)', |
20 | | - color: '#fff', |
21 | | - borderColor: 'transparent', |
22 | | - }, |
| 18 | +const tierStyles = { |
23 | 19 | oss: { |
24 | 20 | label: 'Open Source', |
25 | | - icon: FaUnlock, |
26 | | - bg: 'linear-gradient(135deg, #10b981 0%, #059669 100%)', |
27 | | - color: '#fff', |
28 | | - borderColor: 'transparent', |
| 21 | + color: '#059669', |
| 22 | + bg: 'rgba(16, 185, 129, 0.08)', |
| 23 | + dotColor: '#10b981', |
| 24 | + }, |
| 25 | + enterprise: { |
| 26 | + label: 'Enterprise', |
| 27 | + color: '#7c3aed', |
| 28 | + bg: 'rgba(139, 92, 246, 0.08)', |
| 29 | + dotColor: '#8b5cf6', |
29 | 30 | }, |
30 | 31 | cloud: { |
31 | 32 | label: 'Cloud', |
32 | | - icon: FaCloud, |
33 | | - bg: 'linear-gradient(135deg, #3b82f6 0%, #2563eb 100%)', |
34 | | - color: '#fff', |
35 | | - borderColor: 'transparent', |
36 | | - }, |
37 | | - selfhosted: { |
38 | | - label: 'Self-hosted', |
39 | | - icon: FaServer, |
40 | | - bg: 'rgba(16, 185, 129, 0.1)', |
41 | | - color: '#059669', |
42 | | - borderColor: '#10b981', |
43 | | - }, |
44 | | - dedicated: { |
45 | | - label: 'Dedicated', |
46 | | - icon: FaServer, |
47 | | - bg: 'rgba(59, 130, 246, 0.1)', |
48 | 33 | color: '#2563eb', |
49 | | - borderColor: '#3b82f6', |
50 | | - }, |
51 | | - beta: { |
52 | | - label: 'Beta', |
53 | | - icon: FaFlask, |
54 | | - bg: 'rgba(245, 158, 11, 0.1)', |
55 | | - color: '#d97706', |
56 | | - borderColor: '#f59e0b', |
57 | | - }, |
58 | | - new: { |
59 | | - label: 'New', |
60 | | - icon: FaStar, |
61 | | - bg: 'rgba(236, 72, 153, 0.1)', |
62 | | - color: '#db2777', |
63 | | - borderColor: '#ec4899', |
| 34 | + bg: 'rgba(59, 130, 246, 0.08)', |
| 35 | + dotColor: '#3b82f6', |
64 | 36 | }, |
65 | 37 | }; |
66 | 38 |
|
67 | | -export default function DocHeaderChips({ chips = [] }) { |
68 | | - if (!chips || chips.length === 0) return null; |
| 39 | +export default function DocHeaderChips({ tier, version, availability = [] }) { |
| 40 | + const hasTier = tier && tierStyles[tier.toLowerCase()]; |
| 41 | + const hasVersion = version && version.trim(); |
| 42 | + const hasAvailability = availability && availability.length > 0; |
69 | 43 |
|
70 | | - return ( |
71 | | - <div className="doc-chips-container"> |
72 | | - {chips.map((chip) => { |
73 | | - const config = chipConfig[chip.toLowerCase()]; |
74 | | - if (!config) return null; |
75 | | - const Icon = config.icon; |
76 | | - const isPrimary = ['enterprise', 'oss', 'cloud'].includes(chip.toLowerCase()); |
| 44 | + // Don't render if nothing to show |
| 45 | + if (!hasTier && !hasVersion && !hasAvailability) return null; |
| 46 | + |
| 47 | + const tierConfig = hasTier ? tierStyles[tier.toLowerCase()] : null; |
77 | 48 |
|
78 | | - return ( |
79 | | - <span |
80 | | - key={chip} |
81 | | - className={`doc-chip ${isPrimary ? 'doc-chip--primary' : 'doc-chip--secondary'}`} |
82 | | - style={{ |
83 | | - background: config.bg, |
84 | | - color: config.color, |
85 | | - border: isPrimary ? 'none' : `1px solid ${config.borderColor}`, |
86 | | - }} |
87 | | - > |
88 | | - <Icon size={12} /> |
89 | | - {config.label} |
90 | | - </span> |
91 | | - ); |
92 | | - })} |
| 49 | + return ( |
| 50 | + <div className="doc-meta"> |
| 51 | + {tierConfig && ( |
| 52 | + <span className="doc-meta__tier" style={{ color: tierConfig.color }}> |
| 53 | + <span className="doc-meta__dot" style={{ background: tierConfig.dotColor }} /> |
| 54 | + {tierConfig.label} |
| 55 | + </span> |
| 56 | + )} |
| 57 | + {hasVersion && ( |
| 58 | + <span className="doc-meta__version"> |
| 59 | + v{version.replace(/^v/i, '')} |
| 60 | + </span> |
| 61 | + )} |
| 62 | + {hasAvailability && ( |
| 63 | + <span className="doc-meta__availability"> |
| 64 | + {availability.join(' · ')} |
| 65 | + </span> |
| 66 | + )} |
93 | 67 | <style>{` |
94 | | - .doc-chips-container { |
95 | | - display: flex; |
96 | | - flex-wrap: wrap; |
97 | | - gap: 0.5rem; |
98 | | - margin-bottom: 1.5rem; |
99 | | - margin-top: -0.5rem; |
| 68 | + .doc-meta { |
| 69 | + display: inline-flex; |
| 70 | + align-items: center; |
| 71 | + gap: 0.75rem; |
| 72 | + font-size: 0.75rem; |
| 73 | + color: #6b7280; |
| 74 | + margin-bottom: 0.5rem; |
100 | 75 | } |
101 | | - .doc-chip { |
| 76 | + .doc-meta__tier { |
102 | 77 | display: inline-flex; |
103 | 78 | align-items: center; |
104 | 79 | gap: 0.375rem; |
105 | | - padding: 0.375rem 0.75rem; |
106 | | - font-size: 0.75rem; |
107 | 80 | font-weight: 600; |
108 | | - text-transform: uppercase; |
109 | | - letter-spacing: 0.04em; |
110 | | - border-radius: 6px; |
111 | | - white-space: nowrap; |
| 81 | + letter-spacing: 0.01em; |
| 82 | + } |
| 83 | + .doc-meta__dot { |
| 84 | + width: 6px; |
| 85 | + height: 6px; |
| 86 | + border-radius: 50%; |
| 87 | + flex-shrink: 0; |
| 88 | + } |
| 89 | + .doc-meta__version { |
| 90 | + font-family: ui-monospace, SFMono-Regular, 'SF Mono', Menlo, monospace; |
| 91 | + font-size: 0.6875rem; |
| 92 | + font-weight: 500; |
| 93 | + color: #9ca3af; |
| 94 | + background: rgba(0, 0, 0, 0.04); |
| 95 | + padding: 0.125rem 0.375rem; |
| 96 | + border-radius: 4px; |
112 | 97 | } |
113 | | - .doc-chip--primary { |
114 | | - box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1); |
| 98 | + .doc-meta__availability { |
| 99 | + color: #9ca3af; |
| 100 | + font-weight: 500; |
| 101 | + } |
| 102 | +
|
| 103 | + /* Dark mode */ |
| 104 | + html[data-theme="dark"] .doc-meta { |
| 105 | + color: #9ca3af; |
115 | 106 | } |
116 | | - .doc-chip--secondary { |
117 | | - background: transparent !important; |
| 107 | + html[data-theme="dark"] .doc-meta__version { |
| 108 | + color: #6b7280; |
| 109 | + background: rgba(255, 255, 255, 0.06); |
118 | 110 | } |
119 | | - html[data-theme="dark"] .doc-chip--secondary { |
120 | | - border-color: currentColor !important; |
121 | | - opacity: 0.9; |
| 111 | + html[data-theme="dark"] .doc-meta__availability { |
| 112 | + color: #6b7280; |
122 | 113 | } |
123 | 114 | `}</style> |
124 | 115 | </div> |
|
0 commit comments