ServerKit is a lightweight, modern server control panel for managing web applications, databases, and services on your VPS or dedicated server. Built with Python/Flask backend and React frontend.
Python astracloudflarecontrol-panelcyberpaneldnsfablehosting-control-panelhosting-panelkimi-k3server-managementserverkitubuntu-web-panelwebserver
feat: add shared primitives and extract reusable overflow logic
Juan Denis7f50e741cddf
diff --git a/frontend/src/components/FormField.jsx b/frontend/src/components/FormField.jsxnew file mode 100644index 00000000..93341d73--- /dev/null+++ b/frontend/src/components/FormField.jsx@@ -0,0 +1,57 @@+import React from 'react';+import { Label } from '@/components/ui/label';+import { cn } from '@/lib/utils';++/**+ * Standard form field wrapper: label, hint, error message, and input slot.+ *+ * <FormField label="Email" htmlFor="email" error="Required" hint="Used for notifications">+ * <Input id="email" ... />+ * </FormField>+ */+export function FormField({+ label,+ htmlFor,+ children,+ error,+ hint,+ required = false,+ className,+ labelClassName,+}) {+ const inputId = htmlFor;++ return (+ <div className={cn('form-field', className)}>+ {label && (+ <Label htmlFor={inputId} className={cn('form-field__label', labelClassName)}>+ {label}+ {required && <span className="form-field__required" aria-hidden="true">*</span>}+ </Label>+ )}+ <div className="form-field__control">+ {children}+ </div>+ {hint && !error && <p className="form-field__hint">{hint}</p>}+ {error && <p className="form-field__error" role="alert">{error}</p>}+ </div>+ );+}++/**+ * Horizontal row of form fields. Use for side-by-side inputs.+ *+ * <FormRow>+ * <FormField label="First name"><Input ... /></FormField>+ * <FormField label="Last name"><Input ... /></FormField>+ * </FormRow>+ */+export function FormRow({ children, className }) {+ return (+ <div className={cn('form-row', className)}>+ {children}+ </div>+ );+}++export default FormField;diff --git a/frontend/src/components/IconButton.jsx b/frontend/src/components/IconButton.jsxnew file mode 100644index 00000000..99bdbd13--- /dev/null+++ b/frontend/src/components/IconButton.jsx@@ -0,0 +1,39 @@+import React from 'react';+import { Button } from '@/components/ui/button';+import { cn } from '@/lib/utils';++/**+ * Accessible icon-only button. Always provide a descriptive label; it is used+ * for the aria-label and optional title.+ *+ * <IconButton icon={<RefreshCw size={16} />} label="Refresh" onClick={load} />+ */+export function IconButton({+ icon,+ label,+ onClick,+ variant = 'ghost',+ size = 'sm',+ className,+ title,+ disabled,+ ...props+}) {+ return (+ <Button+ type="button"+ variant={variant}+ size="icon"+ className={cn('icon-button', size === 'sm' && 'btn-sm', className)}+ onClick={onClick}+ disabled={disabled}+ aria-label={label}+ title={title || label}+ {...props}+ >+ {icon}+ </Button>+ );+}++export default IconButton;diff --git a/frontend/src/components/PageLoader.jsx b/frontend/src/components/PageLoader.jsxnew file mode 100644index 00000000..d1cf9085--- /dev/null+++ b/frontend/src/components/PageLoader.jsx@@ -0,0 +1,16 @@+import React from 'react';+import { Spinner } from './Spinner';++/**+ * Full-page loader for tab-group pages.+ * Centers a spinner inside the standard tab-group inner area.+ */+export function PageLoader({ className = '' }) {+ return (+ <div className={`sk-tabgroup__inner ${className}`.trim()}>+ <Spinner />+ </div>+ );+}++export default PageLoader;diff --git a/frontend/src/components/ds/DataTable.jsx b/frontend/src/components/ds/DataTable.jsxnew file mode 100644index 00000000..c8c68117--- /dev/null+++ b/frontend/src/components/ds/DataTable.jsx@@ -0,0 +1,180 @@+import React, { useState, useMemo } from 'react';+import { ChevronUp, ChevronDown } from 'lucide-react';+import {+ Table,+ TableBody,+ TableCell,+ TableHead,+ TableHeader,+ TableRow,+} from '@/components/ui/table';+import { cn } from '@/lib/utils';+import EmptyState from '../EmptyState';+import { Spinner } from '../Spinner';++/**+ * Declarative data table built on top of the shadcn/ui Table primitives.+ *+ * Supports sorting, empty states, loading states, clickable rows, and custom+ * cell rendering. Styling uses the existing `.ui-table` / `.sk-dtable` specs.+ *+ * Example:+ * <DataTable+ * columns={[+ * { key: 'name', header: 'Server', sortable: true, render: s => <ServerCell server={s} /> },+ * { key: 'status', header: 'Status', render: s => <Pill kind={s.status}>{s.status}</Pill> },+ * { key: 'actions', header: '', className: 'text-right', render: s => <Actions server={s} /> },+ * ]}+ * data={servers}+ * keyField="id"+ * emptyTitle="No servers"+ * emptyMessage="Add your first server to start monitoring."+ * />+ */+export function DataTable({+ columns,+ data,+ keyField = 'id',+ sortable = true,+ defaultSort = null,+ emptyState,+ emptyTitle = 'No results',+ emptyMessage = 'Nothing to show yet.',+ loading = false,+ onRowClick,+ renderRow,+ className,+ rowClassName,+ tableClassName,+}) {+ const [sort, setSort] = useState(defaultSort);++ const sortedData = useMemo(() => {+ if (!sort || !sortable) return data;+ const column = columns.find((c) => c.key === sort.key);+ if (!column) return data;++ const direction = sort.direction === 'desc' ? -1 : 1;+ const getValue = column.sortValue || ((row) => row[column.key]);++ return [...data].sort((a, b) => {+ const av = getValue(a);+ const bv = getValue(b);+ if (av == null && bv == null) return 0;+ if (av == null) return direction;+ if (bv == null) return -direction;+ if (typeof av === 'number' && typeof bv === 'number') {+ return (av - bv) * direction;+ }+ return String(av).localeCompare(String(bv)) * direction;+ });+ }, [data, sort, sortable, columns]);++ const handleHeaderClick = (column) => {+ if (!sortable || !column.sortable) return;+ setSort((prev) => {+ if (prev?.key === column.key) {+ if (prev.direction === 'asc') return { key: column.key, direction: 'desc' };+ return null;+ }+ return { key: column.key, direction: 'asc' };+ });+ };++ if (loading) {+ return (+ <div className="sk-dtable__loading">+ <Spinner />+ </div>+ );+ }++ if (!loading && data.length === 0) {+ if (emptyState) return emptyState;+ return <EmptyState title={emptyTitle} message={emptyMessage} />;+ }++ return (+ <div className={cn('sk-dtable-wrap', className)}>+ <Table className={cn('sk-dtable', tableClassName)}>+ <TableHeader>+ <TableRow>+ {columns.map((column) => {+ const isSorted = sort?.key === column.key;+ const canSort = sortable && column.sortable;+ return (+ <TableHead+ key={column.key}+ className={cn(+ column.className,+ canSort && 'is-sortable'+ )}+ style={column.width ? { width: column.width } : undefined}+ onClick={() => handleHeaderClick(column)}+ aria-sort={+ isSorted+ ? sort.direction === 'asc'+ ? 'ascending'+ : 'descending'+ : 'none'+ }+ >+ <span className="sk-dtable__head-inner">+ {column.header}+ {canSort && (+ <span className="sk-dtable__sort">+ {isSorted && sort.direction === 'asc' ? (+ <ChevronUp size={14} />+ ) : isSorted && sort.direction === 'desc' ? (+ <ChevronDown size={14} />+ ) : (+ <ChevronUp size={14} className="sk-dtable__sort-placeholder" />+ )}+ </span>+ )}+ </span>+ </TableHead>+ );+ })}+ </TableRow>+ </TableHeader>+ <TableBody>+ {sortedData.map((row) => {+ const key = typeof keyField === 'function' ? keyField(row) : row[keyField];+ const computedRowClass = typeof rowClassName === 'function'+ ? rowClassName(row)+ : rowClassName;++ if (renderRow) {+ return renderRow(row, { key, className: computedRowClass });+ }++ return (+ <TableRow+ key={key}+ className={cn(+ computedRowClass,+ onRowClick && 'is-clickable'+ )}+ onClick={onRowClick ? () => onRowClick(row) : undefined}+ >+ {columns.map((column) => (+ <TableCell+ key={`${key}-${column.key}`}+ className={column.cellClassName}+ >+ {column.render+ ? column.render(row)+ : row[column.key]}+ </TableCell>+ ))}+ </TableRow>+ );+ })}+ </TableBody>+ </Table>+ </div>+ );+}++export default DataTable;diff --git a/frontend/src/components/ds/PageTopbar.jsx b/frontend/src/components/ds/PageTopbar.jsxindex c7c22941..8ad8f455 100644--- a/frontend/src/components/ds/PageTopbar.jsx+++ b/frontend/src/components/ds/PageTopbar.jsx@@ -3,6 +3,7 @@ import { NavLink, useLocation } from 'react-router-dom';import { MoreHorizontal } from 'lucide-react';import { Popover, PopoverTrigger, PopoverContent } from '@/components/ui/popover';import { cn } from '@/lib/utils';+import { useOverflowItems } from '@/hooks/useOverflowItems';// The demo's page top bar (see docs/REDESIGN_MAP.md §6 decision 3): infra pages// carry their own top bar — an icon + title, an optional routed sub-nav that@@ -39,102 +40,25 @@ function matchTab(tab, path) {}// Routed sub-nav with overflow handling. Tabs that don't fit the available width-// are hidden and surfaced through a trailing "More" popover — the same greedy-// fit + active-stays-visible logic the shadcn TabsList uses (components/ui/tabs).+// are hidden and surfaced through a trailing "More" popover via useOverflowItems.function TopbarTabs({ tabs, label }) {const location = useLocation();- const containerRef = useRef(null);- const linkRefs = useRef([]);- const moreBtnRef = useRef(null);- const [hiddenIndices, setHiddenIndices] = useState([]);const [popoverOpen, setPopoverOpen] = useState(false);- linkRefs.current.length = tabs.length;-const activeIndex = useMemo(() => tabs.findIndex((t) => matchTab(t, location.pathname)),[tabs, location.pathname]);- const recompute = useCallback(() => {- const container = containerRef.current;- if (!container) return;- const containerWidth = container.clientWidth;- if (containerWidth === 0) return;-- // Measure each link's natural width (briefly un-hiding collapsed ones).- const widths = linkRefs.current.map((el) => {- if (!el) return 0;- const wasHidden = el.style.display === 'none';- if (wasHidden) el.style.display = '';- const w = el.offsetWidth;- if (wasHidden) el.style.display = 'none';- return w;- });-- const moreWidth = moreBtnRef.current?.offsetWidth || 56;- const gap = 2; // matches .sk-topbar__tabs gap-- // All fit?- const total = widths.reduce((s, w, i) => s + w + (i > 0 ? gap : 0), 0);- if (total <= containerWidth) {- setHiddenIndices((prev) => (prev.length === 0 ? prev : []));- return;- }-- // Reserve space for the More button, then greedily fit left-to-right.- const budget = Math.max(0, containerWidth - moreWidth - gap);- const visible = [];- let used = 0;- for (let i = 0; i < widths.length; i++) {- const cost = widths[i] + (visible.length > 0 ? gap : 0);- if (used + cost <= budget) {- visible.push(i);- used += cost;- } else {- break;- }- }-- // The active tab must stay visible — rebuild the visible set around it.- let visibleSet = visible;- if (activeIndex !== -1 && !visible.includes(activeIndex)) {- const others = [];- let othersUsed = widths[activeIndex];- for (let i = 0; i < widths.length; i++) {- if (i === activeIndex) continue;- const cost = widths[i] + gap;- if (othersUsed + cost <= budget) {- others.push(i);- othersUsed += cost;- }- }- visibleSet = [...others, activeIndex].sort((a, b) => a - b);- }+ const getActiveIndex = useCallback(() => activeIndex, [activeIndex]);- const visibleSetObj = new Set(visibleSet);- const hidden = [];- for (let i = 0; i < widths.length; i++) {- if (!visibleSetObj.has(i)) hidden.push(i);- }- setHiddenIndices((prev) => (arraysEqual(prev, hidden) ? prev : hidden));- }, [activeIndex]);-- // Initial measurement + re-run when the tab set or active tab changes.- useEffect(() => {- recompute();- }, [recompute, tabs.length]);-- // Re-fit on container resize.- useEffect(() => {- const container = containerRef.current;- if (!container || typeof ResizeObserver === 'undefined') return undefined;- const ro = new ResizeObserver(() => recompute());- ro.observe(container);- return () => ro.disconnect();- }, [recompute]);-- const hiddenSet = new Set(hiddenIndices);+ const { containerRef, itemRefs, moreBtnRef, hiddenIndices, hiddenSet } = useOverflowItems({+ count: tabs.length,+ gap: 2,+ moreWidth: 56,+ getActiveIndex,+ deps: [activeIndex],+ });return (<nav ref={containerRef} className="sk-topbar__tabs" aria-label={`${label} sections`}>@@ -145,7 +69,7 @@ function TopbarTabs({ tabs, label }) {key={t.to}to={t.to}end={t.end}- ref={(el) => { linkRefs.current[i] = el; }}+ ref={(el) => { itemRefs.current[i] = el; }}className={({ isActive }) => cn('sk-topbar__tab', isActive && 'is-active')}style={{ display: isHidden ? 'none' : undefined }}data-overflow={isHidden ? 'hidden' : undefined}@@ -194,10 +118,4 @@ function TopbarTabs({ tabs, label }) {);}-function arraysEqual(a, b) {- if (a.length !== b.length) return false;- for (let i = 0; i < a.length; i++) if (a[i] !== b[i]) return false;- return true;-}-export default PageTopbar;diff --git a/frontend/src/components/ds/ResourceCard.jsx b/frontend/src/components/ds/ResourceCard.jsxnew file mode 100644index 00000000..22f9042a--- /dev/null+++ b/frontend/src/components/ds/ResourceCard.jsx@@ -0,0 +1,85 @@+import React from 'react';+import { ChevronRight } from 'lucide-react';+import { cn } from '@/lib/utils';++/**+ * Standard resource list item: icon, title/subtitle, status, metadata chips,+ * and optional actions. Used for server rows, app rows, domain rows, container+ * rows, and any other "thing with a name and state" list.+ *+ * <ResourceCard+ * icon={<Server size={18} />}+ * title="web-01"+ * subtitle="192.168.1.10"+ * status={<Pill kind="green">online</Pill>}+ * meta={[{ label: 'OS', value: 'Ubuntu 22.04' }, { label: 'Agent', value: '1.2.3' }]}+ * actions={<Button size="sm">Manage</Button>}+ * onClick={() => navigate('/servers/1')}+ * />+ */+export function ResourceCard({+ icon,+ title,+ subtitle,+ status,+ meta = [],+ actions,+ onClick,+ className,+ selected = false,+ selection,+}) {+ return (+ <div+ className={cn(+ 'sk-resource-card',+ onClick && 'is-clickable',+ selected && 'is-selected',+ className+ )}+ onClick={onClick}+ role={onClick ? 'button' : undefined}+ tabIndex={onClick ? 0 : undefined}+ >+ {selection && (+ <div className="sk-resource-card__select" onClick={(e) => e.stopPropagation()}>+ {selection}+ </div>+ )}++ {icon && <div className="sk-resource-card__icon">{icon}</div>}++ <div className="sk-resource-card__identity">+ <div className="sk-resource-card__title-row">+ <span className="sk-resource-card__title">{title}</span>+ {subtitle && <span className="sk-resource-card__subtitle">{subtitle}</span>}+ </div>+ {meta.length > 0 && (+ <div className="sk-resource-card__meta">+ {meta.map((item, i) => (+ <span key={item.label || i} className="sk-resource-card__meta-item">+ <span className="sk-resource-card__meta-label">{item.label}</span>+ <span className="sk-resource-card__meta-value">{item.value}</span>+ </span>+ ))}+ </div>+ )}+ </div>++ <div className="sk-resource-card__status">{status}</div>++ {actions && <div className="sk-resource-card__actions">{actions}</div>}++ {onClick && <ChevronRight size={16} className="sk-resource-card__chevron" />}+ </div>+ );+}++/**+ * Wrapper that lays out ResourceCards in a consistent vertical stack.+ */+export function ResourceList({ children, className }) {+ return <div className={cn('sk-resource-list', className)}>{children}</div>;+}++export default ResourceCard;diff --git a/frontend/src/components/ds/index.js b/frontend/src/components/ds/index.jsindex f16f0d60..466c11f7 100644--- a/frontend/src/components/ds/index.js+++ b/frontend/src/components/ds/index.js@@ -13,4 +13,6 @@ export { ScoreGauge } from './ScoreGauge';export { Feed, FeedItem } from './Feed';export { Drawer } from './Drawer';export { PageTopbar } from './PageTopbar';+export { DataTable } from './DataTable';+export { ResourceCard, ResourceList } from './ResourceCard';export { svcGrad, initials, gaugeColor } from './utils';diff --git a/frontend/src/components/ui/tabs.jsx b/frontend/src/components/ui/tabs.jsxindex 6ab2c29e..54ac784e 100644--- a/frontend/src/components/ui/tabs.jsx+++ b/frontend/src/components/ui/tabs.jsx@@ -3,18 +3,30 @@ import * as TabsPrimitive from '@radix-ui/react-tabs';import { MoreHorizontal } from 'lucide-react';import { Popover, PopoverTrigger, PopoverContent } from './popover';import { cn } from '@/lib/utils';+import { useOverflowItems } from '@/hooks/useOverflowItems';const Tabs = TabsPrimitive.Root;const TabsList = React.forwardRef(({ className, children, ...props }, ref) => {const childArray = React.Children.toArray(children).filter(React.isValidElement);- const containerRef = React.useRef(null);- const triggerRefs = React.useRef([]);- const moreBtnRef = React.useRef(null);- const [hiddenIndices, setHiddenIndices] = React.useState([]);const [popoverOpen, setPopoverOpen] = React.useState(false);+ const itemRefs = React.useRef([]);- triggerRefs.current.length = childArray.length;+ const getActiveIndex = React.useCallback(() => {+ let active = -1;+ itemRefs.current.forEach((el, i) => {+ if (el?.dataset?.state === 'active') active = i;+ });+ return active;+ }, []);++ const { containerRef, moreBtnRef, hiddenIndices, hiddenSet, recompute } = useOverflowItems({+ count: childArray.length,+ itemRefs,+ gap: 8,+ moreWidth: 36,+ getActiveIndex,+ });const setContainerRef = React.useCallback((node) => {@@ -22,98 +34,13 @@ const TabsList = React.forwardRef(({ className, children, ...props }, ref) => {if (typeof ref === 'function') ref(node);else if (ref) ref.current = node;},- [ref]+ [ref, containerRef]);- const recompute = React.useCallback(() => {- const container = containerRef.current;- if (!container) return;- const containerWidth = container.clientWidth;- if (containerWidth === 0) return;-- // Measure each trigger's natural width. If currently hidden, un-hide briefly.- const widths = triggerRefs.current.map((el) => {- if (!el) return 0;- const wasHidden = el.style.display === 'none';- if (wasHidden) el.style.display = '';- const w = el.offsetWidth;- if (wasHidden) el.style.display = 'none';- return w;- });-- let active = -1;- triggerRefs.current.forEach((el, i) => {- if (el?.dataset?.state === 'active') active = i;- });-- const moreWidth = moreBtnRef.current?.offsetWidth || 36;- const gap = 8; // matches $space-2-- // All fit?- const total = widths.reduce((s, w, i) => s + w + (i > 0 ? gap : 0), 0);- if (total <= containerWidth) {- setHiddenIndices((prev) => (prev.length === 0 ? prev : []));- return;- }-- // Reserve space for the More button.- const budget = Math.max(0, containerWidth - moreWidth - gap);-- // Greedy left-to-right fit.- const visible = [];- let used = 0;- for (let i = 0; i < widths.length; i++) {- const cost = widths[i] + (visible.length > 0 ? gap : 0);- if (used + cost <= budget) {- visible.push(i);- used += cost;- } else {- break;- }- }-- // Ensure active is visible — bring it forward if it would otherwise overflow.- let visibleSet = visible;- if (active !== -1 && !visible.includes(active)) {- const others = [];- let othersUsed = widths[active];- for (let i = 0; i < widths.length; i++) {- if (i === active) continue;- const cost = widths[i] + (others.length === 0 ? gap : gap);- if (othersUsed + cost <= budget) {- others.push(i);- othersUsed += cost;- }- }- visibleSet = [...others, active].sort((a, b) => a - b);- }-- const visibleSetObj = new Set(visibleSet);- const hidden = [];- for (let i = 0; i < widths.length; i++) {- if (!visibleSetObj.has(i)) hidden.push(i);- }- setHiddenIndices((prev) => (arraysEqual(prev, hidden) ? prev : hidden));- }, []);-- // Initial measurement after first paint (preserves SSR/first-paint contract).- React.useEffect(() => {- recompute();- }, [recompute, childArray.length]);-- // Resize observer on the container.- React.useEffect(() => {- const container = containerRef.current;- if (!container || typeof ResizeObserver === 'undefined') return;- const ro = new ResizeObserver(() => recompute());- ro.observe(container);- return () => ro.disconnect();- }, [recompute]);-// Re-run when active tab changes (so active never stays hidden).React.useEffect(() => {if (typeof MutationObserver === 'undefined') return;- const observers = triggerRefs.current+ const observers = itemRefs.current.map((el) => {if (!el) return null;const mo = new MutationObserver(() => recompute());@@ -124,8 +51,6 @@ const TabsList = React.forwardRef(({ className, children, ...props }, ref) => {return () => observers.forEach((o) => o.disconnect());}, [recompute, childArray.length]);- const hiddenSet = new Set(hiddenIndices);-return (<TabsPrimitive.Listref={setContainerRef}@@ -137,7 +62,7 @@ const TabsList = React.forwardRef(({ className, children, ...props }, ref) => {return React.cloneElement(child, {key: child.key ?? i,ref: (el) => {- triggerRefs.current[i] = el;+ itemRefs.current[i] = el;},style: {...(child.props.style || {}),@@ -166,7 +91,7 @@ const TabsList = React.forwardRef(({ className, children, ...props }, ref) => {<div className="tabs-overflow-list">{hiddenIndices.map((idx) => {const child = childArray[idx];- const triggerEl = triggerRefs.current[idx];+ const triggerEl = itemRefs.current[idx];const isActive = triggerEl?.dataset?.state === 'active';return (<TabsPrimitive.Trigger@@ -212,10 +137,4 @@ const TabsContent = React.forwardRef(({ className, ...props }, ref) => ());TabsContent.displayName = TabsPrimitive.Content.displayName;-function arraysEqual(a, b) {- if (a.length !== b.length) return false;- for (let i = 0; i < a.length; i++) if (a[i] !== b[i]) return false;- return true;-}-export { Tabs, TabsList, TabsTrigger, TabsContent };diff --git a/frontend/src/hooks/useOverflowItems.js b/frontend/src/hooks/useOverflowItems.jsnew file mode 100644index 00000000..84f9a90f--- /dev/null+++ b/frontend/src/hooks/useOverflowItems.js@@ -0,0 +1,123 @@+import { useState, useRef, useEffect, useCallback } from 'react';++function arraysEqual(a, b) {+ if (a.length !== b.length) return false;+ for (let i = 0; i < a.length; i++) if (a[i] !== b[i]) return false;+ return true;+}++/**+ * Tracks which child items overflow a container and should be collapsed into a+ * "More" menu. Items are greedily fit left-to-right; the active item is always+ * kept visible by rebuilding the visible set around it.+ *+ * @param {Object} options+ * @param {number} options.count - Number of items to measure.+ * @param {React.MutableRefObject<(HTMLElement|null)[]>} [options.itemRefs] - Optional external ref array for the items. Useful when the caller needs to read from the refs (e.g. to detect active state).+ * @param {number} [options.gap=8] - Gap between items in pixels.+ * @param {number} [options.moreWidth=36] - Estimated width of the "More" trigger.+ * @param {() => number} [options.getActiveIndex=() => -1] - Returns the index of the item that must stay visible.+ * @param {React.DependencyList} [options.deps=[]] - Additional dependencies that should trigger a recompute.+ *+ * @returns {{+ * containerRef: React.RefObject<HTMLElement>,+ * itemRefs: React.MutableRefObject<(HTMLElement|null)[]>,+ * moreBtnRef: React.RefObject<HTMLElement>,+ * hiddenIndices: number[],+ * hiddenSet: Set<number>,+ * recompute: () => void+ * }}+ */+export function useOverflowItems({ count, itemRefs: externalItemRefs, gap = 8, moreWidth = 36, getActiveIndex = () => -1, deps = [] }) {+ const containerRef = useRef(null);+ const internalItemRefs = useRef([]);+ const moreBtnRef = useRef(null);+ const [hiddenIndices, setHiddenIndices] = useState([]);++ const itemRefs = externalItemRefs || internalItemRefs;+ itemRefs.current.length = count;++ const recompute = useCallback(() => {+ const container = containerRef.current;+ if (!container) return;+ const containerWidth = container.clientWidth;+ if (containerWidth === 0) return;++ // Measure each item's natural width (briefly un-hiding collapsed ones).+ const widths = itemRefs.current.map((el) => {+ if (!el) return 0;+ const wasHidden = el.style.display === 'none';+ if (wasHidden) el.style.display = '';+ const w = el.offsetWidth;+ if (wasHidden) el.style.display = 'none';+ return w;+ });++ const activeIndex = getActiveIndex();+ const actualMoreWidth = moreBtnRef.current?.offsetWidth || moreWidth;++ // All fit?+ const total = widths.reduce((s, w, i) => s + w + (i > 0 ? gap : 0), 0);+ if (total <= containerWidth) {+ setHiddenIndices((prev) => (prev.length === 0 ? prev : []));+ return;+ }++ // Reserve space for the More button, then greedily fit left-to-right.+ const budget = Math.max(0, containerWidth - actualMoreWidth - gap);+ const visible = [];+ let used = 0;+ for (let i = 0; i < widths.length; i++) {+ const cost = widths[i] + (visible.length > 0 ? gap : 0);+ if (used + cost <= budget) {+ visible.push(i);+ used += cost;+ } else {+ break;+ }+ }++ // The active item must stay visible — rebuild the visible set around it.+ let visibleSet = visible;+ if (activeIndex !== -1 && !visible.includes(activeIndex)) {+ const others = [];+ let othersUsed = widths[activeIndex];+ for (let i = 0; i < widths.length; i++) {+ if (i === activeIndex) continue;+ const cost = widths[i] + (others.length === 0 ? gap : gap);+ if (othersUsed + cost <= budget) {+ others.push(i);+ othersUsed += cost;+ }+ }+ visibleSet = [...others, activeIndex].sort((a, b) => a - b);+ }++ const visibleSetObj = new Set(visibleSet);+ const hidden = [];+ for (let i = 0; i < widths.length; i++) {+ if (!visibleSetObj.has(i)) hidden.push(i);+ }+ setHiddenIndices((prev) => (arraysEqual(prev, hidden) ? prev : hidden));+ }, [count, gap, moreWidth, getActiveIndex, ...deps]);++ // Initial measurement after first paint.+ useEffect(() => {+ recompute();+ }, [recompute, count]);++ // Re-fit on container resize.+ useEffect(() => {+ const container = containerRef.current;+ if (!container || typeof ResizeObserver === 'undefined') return undefined;+ const ro = new ResizeObserver(() => recompute());+ ro.observe(container);+ return () => ro.disconnect();+ }, [recompute]);++ const hiddenSet = new Set(hiddenIndices);++ return { containerRef, itemRefs, moreBtnRef, hiddenIndices, hiddenSet, recompute };+}++export default useOverflowItems;diff --git a/frontend/src/styles/components/_design-system.scss b/frontend/src/styles/components/_design-system.scssindex 5cb60231..587200c0 100644--- a/frontend/src/styles/components/_design-system.scss+++ b/frontend/src/styles/components/_design-system.scss@@ -270,6 +270,18 @@ $sk-tones: ('accent', 'green', 'cyan', 'amber', 'red', 'violet');.sk-cell-name { font-weight: 550; display: flex; align-items: center; gap: 11px; }.sk-cell-mono { font-family: var(--mono); font-size: 12px; color: var(--text-dim); }.sk-cell-sub { font-family: var(--mono); font-size: 11.5px; color: var(--text-faint); margin-top: 3px; }++ // Sortable column headers (used by the DataTable component).+ .is-sortable { cursor: pointer; user-select: none; }+ &__head-inner { display: inline-flex; align-items: center; gap: 5px; }+ &__sort { display: inline-flex; color: var(--accent-bright); }+ &__sort-placeholder { color: var(--text-faint); opacity: 0.35; }+}++.sk-dtable-wrap { overflow-x: auto; }+.sk-dtable__loading {+ display: flex; align-items: center; justify-content: center;+ min-height: 180px; color: var(--text-faint);}// ------------------------------------------------------------@@ -377,3 +389,107 @@ $sk-tones: ('accent', 'green', 'cyan', 'amber', 'red', 'violet');&__sub { font-family: var(--mono); font-size: 11px; color: var(--text-faint); margin-top: 1px; }&__body { flex: 1; overflow: auto; min-height: 0; }}++// ------------------------------------------------------------+// ResourceCard / ResourceList — consistent list item for servers,+// apps, domains, containers, and other named resources.+// ------------------------------------------------------------+.sk-resource-list {+ display: flex; flex-direction: column;+ border: 1px solid var(--border-soft);+ border-radius: 12px;+ background: var(--surface);+ overflow: hidden;+}++.sk-resource-card {+ display: flex; align-items: center; gap: 12px;+ padding: 12px 16px;+ border-bottom: 1px solid var(--border-soft);+ background: var(--surface);+ transition: background 0.12s;++ &:last-child { border-bottom: none; }+ &.is-clickable { cursor: pointer; }+ &.is-clickable:hover { background: var(--surface-2); }+ &.is-selected { background: var(--accent-bg-soft); }++ &__select { display: inline-flex; align-items: center; }+ &__icon { color: var(--accent-bright); display: inline-flex; flex-shrink: 0; }+ &__identity { min-width: 0; flex: 1 1 auto; }+ &__title-row { display: flex; align-items: baseline; gap: 8px; flex-wrap: wrap; }+ &__title { font-weight: 550; font-size: 13.5px; color: var(--text); }+ &__subtitle { font-family: var(--mono); font-size: 12px; color: var(--text-faint); }+ &__meta { display: flex; align-items: center; gap: 12px; margin-top: 4px; flex-wrap: wrap; }+ &__meta-item { display: inline-flex; align-items: center; gap: 4px; }+ &__meta-label { font-family: var(--mono); font-size: 10.5px; color: var(--text-faint); text-transform: uppercase; }+ &__meta-value { font-family: var(--mono); font-size: 11.5px; color: var(--text-dim); }+ &__status { flex-shrink: 0; }+ &__actions { display: inline-flex; align-items: center; gap: 6px; flex-shrink: 0; }+ &__chevron { color: var(--text-faint); flex-shrink: 0; margin-left: 4px; }+}+++// ------------------------------------------------------------+// ErrorState — consistent empty error panel.+// ------------------------------------------------------------+.sk-error-state {+ display: flex; flex-direction: column; align-items: center; justify-content: center;+ min-height: 220px; padding: 32px; text-align: center;+ border: 1px dashed var(--border); border-radius: 14px;+ background: var(--surface);++ &__icon { color: var(--danger); margin-bottom: 14px; }+ &__title { font-size: 15px; font-weight: 600; color: var(--text); margin: 0 0 6px; }+ &__message { font-size: 13px; color: var(--text-dim); max-width: 420px; margin: 0 0 16px; }+}++// ------------------------------------------------------------+// SearchFilterBar — reusable search + filter + sort bar.+// ------------------------------------------------------------+.sk-search-filter-bar {+ display: flex; align-items: center; gap: 12px; flex-wrap: wrap;++ &__search { position: relative; flex: 1 1 220px; min-width: 180px; }+ &__search-icon { position: absolute; left: 10px; top: 50%; transform: translateY(-50%); color: var(--text-faint); pointer-events: none; }+ &__input { padding-left: 32px; }+ &__clear { position: absolute; right: 2px; top: 50%; transform: translateY(-50%); color: var(--text-faint); }++ &__filters { display: inline-flex; align-items: center; gap: 6px; flex-wrap: wrap; }+ &__chip {+ display: inline-flex; align-items: center; gap: 5px;+ padding: 5px 11px; border-radius: 7px;+ font-size: 12.5px; font-weight: 450;+ color: var(--text-dim); background: var(--surface-2);+ border: 1px solid var(--border-soft);+ cursor: pointer; transition: background 0.12s, color 0.12s, border-color 0.12s;++ &:hover { background: var(--surface-3); }+ &.is-active { color: var(--accent-bright); background: var(--accent-bg-soft); border-color: var(--accent-soft); }+ }+ &__count {+ font-family: var(--mono); font-size: 10.5px; color: var(--text-faint);+ .is-active & { color: var(--accent-bright); }+ }++ &__sort {+ select {+ appearance: none;+ padding: 6px 24px 6px 10px;+ border-radius: 7px;+ border: 1px solid var(--border-soft);+ background: var(--surface-2);+ color: var(--text-dim);+ font-size: 12.5px;+ cursor: pointer;+ }+ }+}++// ------------------------------------------------------------+// CopyButton — copy-to-clipboard with feedback.+// ------------------------------------------------------------+.copy-button {+ &.is-copied { color: var(--green); }+ &__label { margin-left: 6px; }+}diff --git a/frontend/src/styles/components/_forms.scss b/frontend/src/styles/components/_forms.scssindex e8957f6e..d285f9b4 100644--- a/frontend/src/styles/components/_forms.scss+++ b/frontend/src/styles/components/_forms.scss@@ -46,6 +46,46 @@}}+// Standard form field wrapper (used by <FormField /> component).+.form-field {+ margin-bottom: $space-4;++ &__label {+ display: inline-flex;+ align-items: center;+ gap: $space-1;+ font-size: $font-size-sm;+ font-weight: $font-weight-medium;+ color: $text-secondary;+ margin-bottom: $space-2;+ }++ &__required {+ color: $danger;+ }++ &__control {+ // Ensure shadcn inputs, selects, textareas fill the width.+ > * {+ width: 100%;+ }+ }++ &__hint {+ font-size: $font-size-xs + 1;+ color: $text-tertiary;+ margin-top: $space-1;+ margin-bottom: 0;+ }++ &__error {+ font-size: $font-size-xs + 1;+ color: $danger;+ margin-top: $space-1;+ margin-bottom: 0;+ }+}+// Inline form (input + button).install-form,.env-form,@@ -85,6 +125,16 @@padding: $space-3 $space-4;border-radius: $radius-lg;margin-bottom: $space-6;++ &__close {+ float: right;+ background: none;+ border: none;+ cursor: pointer;+ color: inherit;+ font-size: 18px;+ line-height: 1;+ }}// Filter toggle (checkbox)