|
| 1 | +import React from 'react'; |
| 2 | +import { FaLock, FaUnlock, FaCloud, FaServer, FaFlask, FaStar } from 'react-icons/fa'; |
| 3 | + |
| 4 | +/** |
| 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 |
| 7 | + * |
| 8 | + * Usage in MDX: |
| 9 | + * import DocHeaderChips from '@site/src/components/DocHeaderChips'; |
| 10 | + * <DocHeaderChips chips={['enterprise', 'cloud']} /> |
| 11 | + * |
| 12 | + * Available chip types: 'enterprise', 'oss', 'cloud', 'selfhosted', 'dedicated', 'beta', 'new' |
| 13 | + */ |
| 14 | + |
| 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 | + }, |
| 23 | + oss: { |
| 24 | + label: 'Open Source', |
| 25 | + icon: FaUnlock, |
| 26 | + bg: 'linear-gradient(135deg, #10b981 0%, #059669 100%)', |
| 27 | + color: '#fff', |
| 28 | + borderColor: 'transparent', |
| 29 | + }, |
| 30 | + cloud: { |
| 31 | + 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 | + 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', |
| 64 | + }, |
| 65 | +}; |
| 66 | + |
| 67 | +export default function DocHeaderChips({ chips = [] }) { |
| 68 | + if (!chips || chips.length === 0) return null; |
| 69 | + |
| 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()); |
| 77 | + |
| 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 | + })} |
| 93 | + <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; |
| 100 | + } |
| 101 | + .doc-chip { |
| 102 | + display: inline-flex; |
| 103 | + align-items: center; |
| 104 | + gap: 0.375rem; |
| 105 | + padding: 0.375rem 0.75rem; |
| 106 | + font-size: 0.75rem; |
| 107 | + font-weight: 600; |
| 108 | + text-transform: uppercase; |
| 109 | + letter-spacing: 0.04em; |
| 110 | + border-radius: 6px; |
| 111 | + white-space: nowrap; |
| 112 | + } |
| 113 | + .doc-chip--primary { |
| 114 | + box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1); |
| 115 | + } |
| 116 | + .doc-chip--secondary { |
| 117 | + background: transparent !important; |
| 118 | + } |
| 119 | + html[data-theme="dark"] .doc-chip--secondary { |
| 120 | + border-color: currentColor !important; |
| 121 | + opacity: 0.9; |
| 122 | + } |
| 123 | + `}</style> |
| 124 | + </div> |
| 125 | + ); |
| 126 | +} |
| 127 | + |
0 commit comments