chore: consolidate platform split checks
This commit is contained in:
@@ -1,3 +1,5 @@
|
||||
import { usePlatformLanguage } from "../i18n/LanguageContext";
|
||||
|
||||
export type ModuleSubnavItem<T extends string> = {
|
||||
id: T;
|
||||
label: string;
|
||||
@@ -29,34 +31,35 @@ export default function ModuleSubnav<T extends string>({
|
||||
groups,
|
||||
onSelect,
|
||||
className = ""
|
||||
}: {
|
||||
active: T;
|
||||
groups: ModuleSubnavGroup<T>[];
|
||||
onSelect: (section: T) => void;
|
||||
className?: string;
|
||||
}) {
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}: {active: T;groups: ModuleSubnavGroup<T>[];onSelect: (section: T) => void;className?: string;}) {
|
||||
const { translateText } = usePlatformLanguage();
|
||||
return (
|
||||
<aside className={`section-sidebar ${className}`.trim()}>
|
||||
{groups.map((group, groupIndex) => (
|
||||
<div className="section-group" key={`${group.title ?? "group"}-${groupIndex}`}>
|
||||
{group.title && <div className={`section-title ${groupIndex > 0 ? "section-title-lower" : ""}`.trim()}>{group.title}</div>}
|
||||
{groups.map((group, groupIndex) =>
|
||||
<div className="section-group" key={`${group.title ?? "group"}-${groupIndex}`}>
|
||||
{group.title && <div className={`section-title ${groupIndex > 0 ? "section-title-lower" : ""}`.trim()}>{translateText(group.title)}</div>}
|
||||
{group.items.map((entry) => {
|
||||
const key = isAction(entry) ? entry.actionId : entry.id;
|
||||
const activeClass = !isAction(entry) && active === entry.id ? " active" : "";
|
||||
const primaryClass = entry.primary ? " section-link-primary" : "";
|
||||
const subtleClass = entry.subtle ? " subtle" : "";
|
||||
return (
|
||||
<button
|
||||
key={key}
|
||||
className={`section-link${primaryClass}${subtleClass}${activeClass}`}
|
||||
onClick={() => (isAction(entry) ? entry.onClick() : onSelect(entry.id))}
|
||||
>
|
||||
{entry.label}
|
||||
</button>
|
||||
);
|
||||
})}
|
||||
const key = isAction(entry) ? entry.actionId : entry.id;
|
||||
const activeClass = !isAction(entry) && active === entry.id ? " active" : "";
|
||||
const primaryClass = entry.primary ? " section-link-primary" : "";
|
||||
const subtleClass = entry.subtle ? " subtle" : "";
|
||||
return (
|
||||
<button
|
||||
key={key}
|
||||
className={`section-link${primaryClass}${subtleClass}${activeClass}`}
|
||||
onClick={() => isAction(entry) ? entry.onClick() : onSelect(entry.id)}>
|
||||
|
||||
{translateText(entry.label)}
|
||||
</button>);
|
||||
|
||||
})}
|
||||
</div>
|
||||
))}
|
||||
</aside>
|
||||
);
|
||||
)}
|
||||
</aside>);
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user