mirror of
https://github.com/lukaszraczylo/gohoarder.git
synced 2026-11-26 06:37:07 +00:00
feat(frontend): add the perfect-design theme, shell and helpers
Install @perfect-design/ui 0.3.10 with the workbench style pack, IBM Plex faces and the inline theme boot script. The app shell uses AppHeader, AppShell and SidebarNav. Shared formatters, severity tones and icon data replace the per-view copies. A test checks that main.css scans only the library directories the app imports.
This commit is contained in:
@@ -0,0 +1,22 @@
|
||||
const BYTE_UNITS = ['B', 'KB', 'MB', 'GB', 'TB']
|
||||
const BYTES_PER_UNIT = 1024
|
||||
|
||||
export function formatNumber(num: number): string {
|
||||
return new Intl.NumberFormat().format(num)
|
||||
}
|
||||
|
||||
export function formatBytes(bytes: number): string {
|
||||
if (bytes === 0) return '0 B'
|
||||
const i = Math.floor(Math.log(bytes) / Math.log(BYTES_PER_UNIT))
|
||||
return Math.round((bytes / Math.pow(BYTES_PER_UNIT, i)) * 100) / 100 + ' ' + BYTE_UNITS[i]
|
||||
}
|
||||
|
||||
export function formatDate(date: string): string {
|
||||
if (!date) return 'N/A'
|
||||
const parsed = new Date(date)
|
||||
return Number.isNaN(parsed.getTime()) ? date : parsed.toLocaleString()
|
||||
}
|
||||
|
||||
export function withVersionPrefix(version: string): string {
|
||||
return version.startsWith('v') ? version : 'v' + version
|
||||
}
|
||||
@@ -0,0 +1,24 @@
|
||||
export {
|
||||
faArrowLeft,
|
||||
faBan,
|
||||
faBox,
|
||||
faBoxOpen,
|
||||
faBoxesStacked,
|
||||
faChartColumn,
|
||||
faChartLine,
|
||||
faChartPie,
|
||||
faDownload,
|
||||
faHardDrive,
|
||||
faPen,
|
||||
faShieldHalved,
|
||||
faTrash,
|
||||
faTriangleExclamation,
|
||||
} from '@fortawesome/free-solid-svg-icons'
|
||||
export {
|
||||
faCircleCheck,
|
||||
faMagnifyingGlass,
|
||||
faPlus,
|
||||
faRotateRight,
|
||||
faChevronDown,
|
||||
faChevronUp,
|
||||
} from '@perfect-design/ui/lib/icons'
|
||||
@@ -0,0 +1,33 @@
|
||||
import type { VulnerabilityCounts } from '@/stores/packages'
|
||||
|
||||
export type SeverityTone = 'danger' | 'warning' | 'info' | 'neutral'
|
||||
|
||||
export const SEVERITY_TONES: Record<string, SeverityTone> = {
|
||||
critical: 'danger',
|
||||
high: 'warning',
|
||||
moderate: 'info',
|
||||
medium: 'info',
|
||||
low: 'neutral',
|
||||
}
|
||||
|
||||
export const SEVERITY_RANK: Record<string, number> = {
|
||||
critical: 4,
|
||||
high: 3,
|
||||
moderate: 2,
|
||||
medium: 2,
|
||||
low: 1,
|
||||
}
|
||||
|
||||
export const SEVERITY_LEVELS = ['critical', 'high', 'moderate', 'low'] as const
|
||||
export type SeverityLevel = (typeof SEVERITY_LEVELS)[number]
|
||||
|
||||
export const NO_VULNERABILITIES: VulnerabilityCounts = { critical: 0, high: 0, moderate: 0, low: 0 }
|
||||
|
||||
export function severityRank(severity: string): number {
|
||||
return SEVERITY_RANK[severity.toLowerCase()] ?? 0
|
||||
}
|
||||
|
||||
export function formatSeverityName(severity: string): string {
|
||||
const lower = severity.toLowerCase()
|
||||
return lower.charAt(0).toUpperCase() + lower.slice(1)
|
||||
}
|
||||
Reference in New Issue
Block a user