@syscore/ui-library 2.0.0-beta-publish-workflow-beta.25 → 2.0.0-beta-publish-workflow-beta.26
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/client/components/icons/SystemIcon.tsx +37 -0
- package/client/components/ui/nav-rail.tsx +54 -0
- package/dist/client/components/icons/SystemIcon.js +18 -0
- package/dist/client/components/ui/nav-rail.js +29 -0
- package/dist/client/lib/system-icons.js +1578 -0
- package/dist/index.cjs +1 -1
- package/dist/index.d.ts +21 -0
- package/dist/ui/index.js +6 -0
- package/package.json +1 -1
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import * as LucideIcons from "lucide-react";
|
|
2
|
+
import type { LucideIcon, LucideProps } from "lucide-react";
|
|
3
|
+
|
|
4
|
+
import {
|
|
5
|
+
SYSTEM_ICON_COLOR,
|
|
6
|
+
SYSTEM_ICON_NAMES,
|
|
7
|
+
SYSTEM_ICON_SIZE,
|
|
8
|
+
SYSTEM_ICON_STROKE_WIDTH,
|
|
9
|
+
toLucideName,
|
|
10
|
+
} from "../../lib/system-icons";
|
|
11
|
+
|
|
12
|
+
export type SystemIconName = (typeof SYSTEM_ICON_NAMES)[number];
|
|
13
|
+
|
|
14
|
+
export interface SystemIconProps extends Omit<LucideProps, "ref"> {
|
|
15
|
+
name: SystemIconName;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
const icons = LucideIcons as unknown as Record<string, LucideIcon | undefined>;
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* Any Figma system icon (`system-icons.ts`'s own Lucide-backed set) by name, without the
|
|
22
|
+
* consumer importing `lucide-react` directly — previously only assembled ad hoc in
|
|
23
|
+
* `Icons.stories.tsx` for the Storybook gallery; this is the same lookup as a real component.
|
|
24
|
+
*/
|
|
25
|
+
export function SystemIcon({
|
|
26
|
+
name,
|
|
27
|
+
size = SYSTEM_ICON_SIZE,
|
|
28
|
+
strokeWidth = SYSTEM_ICON_STROKE_WIDTH,
|
|
29
|
+
color = SYSTEM_ICON_COLOR,
|
|
30
|
+
...props
|
|
31
|
+
}: SystemIconProps) {
|
|
32
|
+
const Icon = icons[toLucideName(name)];
|
|
33
|
+
|
|
34
|
+
if (!Icon) return null;
|
|
35
|
+
|
|
36
|
+
return <Icon size={size} strokeWidth={strokeWidth} color={color} {...props} />;
|
|
37
|
+
}
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
|
|
3
|
+
import { cn } from "@/lib/utils";
|
|
4
|
+
import { SystemIcon, type SystemIconName } from "@/components/icons/SystemIcon";
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* A flat icon + label nav list for a page-local tab rail (e.g. a dashboard sidebar) —
|
|
8
|
+
* reuses the `.sidebar-menu*` classes `Sidebar`/`SidebarMenuButton` already ship, but
|
|
9
|
+
* without `SidebarProvider`: that wrapper's `.sidebar-wrapper` forces `min-height: 100svh`,
|
|
10
|
+
* meant for an app-shell-level sidebar, which would stretch an inline content column to
|
|
11
|
+
* the full viewport height. `NavRail` has no such wrapper, so it drops into page content
|
|
12
|
+
* directly (e.g. inside a `Columns preset="sidebar"` cell).
|
|
13
|
+
*/
|
|
14
|
+
export interface NavRailItem {
|
|
15
|
+
key: string;
|
|
16
|
+
label: string;
|
|
17
|
+
icon?: SystemIconName;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
export interface NavRailProps extends React.ComponentProps<"nav"> {
|
|
21
|
+
items: NavRailItem[];
|
|
22
|
+
activeKey: string;
|
|
23
|
+
onSelect: (key: string) => void;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
export const NavRail = React.forwardRef<HTMLElement, NavRailProps>(
|
|
27
|
+
({ items, activeKey, onSelect, className, ...props }, ref) => {
|
|
28
|
+
return (
|
|
29
|
+
<nav ref={ref} className={cn("sidebar", "nav-rail", className)} {...props}>
|
|
30
|
+
<ul className="sidebar-menu">
|
|
31
|
+
{items.map((item) => {
|
|
32
|
+
const isActive = activeKey === item.key;
|
|
33
|
+
|
|
34
|
+
return (
|
|
35
|
+
<li key={item.key} className="sidebar-menu-item">
|
|
36
|
+
<button
|
|
37
|
+
type="button"
|
|
38
|
+
className="sidebar-menu-button"
|
|
39
|
+
data-active={isActive}
|
|
40
|
+
aria-current={isActive ? "page" : undefined}
|
|
41
|
+
onClick={() => onSelect(item.key)}
|
|
42
|
+
>
|
|
43
|
+
{item.icon ? <SystemIcon name={item.icon} size={16} /> : null}
|
|
44
|
+
<span>{item.label}</span>
|
|
45
|
+
</button>
|
|
46
|
+
</li>
|
|
47
|
+
);
|
|
48
|
+
})}
|
|
49
|
+
</ul>
|
|
50
|
+
</nav>
|
|
51
|
+
);
|
|
52
|
+
},
|
|
53
|
+
);
|
|
54
|
+
NavRail.displayName = "NavRail";
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { jsx } from "react/jsx-runtime";
|
|
2
|
+
import * as LucideIcons from "lucide-react";
|
|
3
|
+
import { toLucideName, SYSTEM_ICON_COLOR, SYSTEM_ICON_STROKE_WIDTH, SYSTEM_ICON_SIZE } from "../../lib/system-icons.js";
|
|
4
|
+
const icons = LucideIcons;
|
|
5
|
+
function SystemIcon({
|
|
6
|
+
name,
|
|
7
|
+
size = SYSTEM_ICON_SIZE,
|
|
8
|
+
strokeWidth = SYSTEM_ICON_STROKE_WIDTH,
|
|
9
|
+
color = SYSTEM_ICON_COLOR,
|
|
10
|
+
...props
|
|
11
|
+
}) {
|
|
12
|
+
const Icon = icons[toLucideName(name)];
|
|
13
|
+
if (!Icon) return null;
|
|
14
|
+
return /* @__PURE__ */ jsx(Icon, { size, strokeWidth, color, ...props });
|
|
15
|
+
}
|
|
16
|
+
export {
|
|
17
|
+
SystemIcon
|
|
18
|
+
};
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
2
|
+
import * as React from "react";
|
|
3
|
+
import { cn } from "../../lib/utils.js";
|
|
4
|
+
import { SystemIcon } from "../icons/SystemIcon.js";
|
|
5
|
+
const NavRail = React.forwardRef(
|
|
6
|
+
({ items, activeKey, onSelect, className, ...props }, ref) => {
|
|
7
|
+
return /* @__PURE__ */ jsx("nav", { ref, className: cn("sidebar", "nav-rail", className), ...props, children: /* @__PURE__ */ jsx("ul", { className: "sidebar-menu", children: items.map((item) => {
|
|
8
|
+
const isActive = activeKey === item.key;
|
|
9
|
+
return /* @__PURE__ */ jsx("li", { className: "sidebar-menu-item", children: /* @__PURE__ */ jsxs(
|
|
10
|
+
"button",
|
|
11
|
+
{
|
|
12
|
+
type: "button",
|
|
13
|
+
className: "sidebar-menu-button",
|
|
14
|
+
"data-active": isActive,
|
|
15
|
+
"aria-current": isActive ? "page" : void 0,
|
|
16
|
+
onClick: () => onSelect(item.key),
|
|
17
|
+
children: [
|
|
18
|
+
item.icon ? /* @__PURE__ */ jsx(SystemIcon, { name: item.icon, size: 16 }) : null,
|
|
19
|
+
/* @__PURE__ */ jsx("span", { children: item.label })
|
|
20
|
+
]
|
|
21
|
+
}
|
|
22
|
+
) }, item.key);
|
|
23
|
+
}) }) });
|
|
24
|
+
}
|
|
25
|
+
);
|
|
26
|
+
NavRail.displayName = "NavRail";
|
|
27
|
+
export {
|
|
28
|
+
NavRail
|
|
29
|
+
};
|