mirror of
https://github.com/chillpadclub/bedolaga-cabinet.git
synced 2026-07-28 09:33:46 +00:00
Split 1123-line monolithic AdminSettings.tsx into 11 modules: Components: - icons.tsx (85 lines) - All SVG icons - Toggle.tsx (21 lines) - Reusable toggle component - SettingInput.tsx (89 lines) - Text/select input for settings - SettingRow.tsx (104 lines) - Single setting card - BrandingTab.tsx (212 lines) - Logo, name, animation settings - ThemeTab.tsx (277 lines) - Theme presets and custom colors - FavoritesTab.tsx (59 lines) - Starred settings display - SettingsTab.tsx (144 lines) - Accordion categories view Utilities: - constants.ts (55 lines) - MENU_SECTIONS, THEME_PRESETS - utils.ts (35 lines) - formatSettingKey, stripHtml - index.ts (13 lines) - Barrel exports Result: AdminSettings.tsx reduced from 1123 to 251 lines
36 lines
996 B
TypeScript
36 lines
996 B
TypeScript
// Format setting key from Snake_Case / CamelCase to readable text
|
|
export function formatSettingKey(name: string): string {
|
|
if (!name) return ''
|
|
|
|
return name
|
|
// CamelCase -> spaces
|
|
.replace(/([a-z])([A-Z])/g, '$1 $2')
|
|
// snake_case -> spaces
|
|
.replace(/_/g, ' ')
|
|
// Remove extra spaces
|
|
.replace(/\s+/g, ' ')
|
|
.trim()
|
|
// Capitalize first letter
|
|
.replace(/^./, c => c.toUpperCase())
|
|
}
|
|
|
|
// Strip HTML tags and template descriptions from setting descriptions
|
|
export function stripHtml(html: string): string {
|
|
if (!html) return ''
|
|
let cleaned = html
|
|
.replace(/<[^>]*>/g, '')
|
|
.replace(/ /g, ' ')
|
|
.replace(/&/g, '&')
|
|
.replace(/</g, '<')
|
|
.replace(/>/g, '>')
|
|
.replace(/"/g, '"')
|
|
.trim()
|
|
|
|
// Remove template descriptions like "Параметр X управляет категорией Y"
|
|
if (cleaned.match(/^Параметр .+ управляет категорией/)) {
|
|
return ''
|
|
}
|
|
|
|
return cleaned
|
|
}
|