feat(ui): register favorite star and glyph-only actions
This commit is contained in:
@@ -235,7 +235,7 @@ const iconGroups: Array<{ title: string; note: string; icons: IconName[] }> = [
|
|||||||
{
|
{
|
||||||
title: "Состояние и доступ",
|
title: "Состояние и доступ",
|
||||||
note: "Вся платформа",
|
note: "Вся платформа",
|
||||||
icons: ["check", "alert", "info", "info-plain", "activity", "lock", "unlock", "key", "shield", "circle", "eye", "eye-off"],
|
icons: ["check", "alert", "info", "info-plain", "activity", "lock", "unlock", "key", "shield", "circle", "eye", "eye-off", "star"],
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
title: "Сущности",
|
title: "Сущности",
|
||||||
@@ -250,6 +250,7 @@ const iconGroups: Array<{ title: string; note: string; icons: IconName[] }> = [
|
|||||||
];
|
];
|
||||||
|
|
||||||
const iconLabels: Record<IconName, string> = {
|
const iconLabels: Record<IconName, string> = {
|
||||||
|
star: "Избранное",
|
||||||
pipette: "Пипетка",
|
pipette: "Пипетка",
|
||||||
ruler: "Линейка", section: "Секущая плоскость", isolate: "Изолировать элемент",
|
ruler: "Линейка", section: "Секущая плоскость", isolate: "Изолировать элемент",
|
||||||
power: "Питание",
|
power: "Питание",
|
||||||
@@ -1859,6 +1860,8 @@ export function CatalogApp() {
|
|||||||
<div className="catalog-icon-catalog">
|
<div className="catalog-icon-catalog">
|
||||||
<Preview title="Размеры и поверхности" note="glyph 16 px" className="catalog-preview--wide">
|
<Preview title="Размеры и поверхности" note="glyph 16 px" className="catalog-preview--wide">
|
||||||
<div className="catalog-window-actions-demo">
|
<div className="catalog-window-actions-demo">
|
||||||
|
<IconButton surface="none" label="В избранное" aria-pressed="false"><Icon name="star" /></IconButton>
|
||||||
|
<IconButton surface="none" label="Убрать из избранного" aria-pressed="true"><Icon name="star" fill="currentColor" /></IconButton>
|
||||||
<IconButton label="Камера включена" aria-pressed="true"><Icon name="camera" /></IconButton>
|
<IconButton label="Камера включена" aria-pressed="true"><Icon name="camera" /></IconButton>
|
||||||
<IconButton label="План"><Icon name="plan" /></IconButton>
|
<IconButton label="План"><Icon name="plan" /></IconButton>
|
||||||
<IconButton label="Добавить"><Icon name="plus" /></IconButton>
|
<IconButton label="Добавить"><Icon name="plus" /></IconButton>
|
||||||
|
|||||||
@@ -0,0 +1,5 @@
|
|||||||
|
# Favorites
|
||||||
|
|
||||||
|
Use the registered `star` icon in an IconButton with `aria-pressed`. The unset state is outline-only; the selected glyph uses `fill="currentColor"`. Keep the same hit target in both states. Place a card favorite action in its upper trailing corner, independent of opening the card. Persist the domain value at its owner; filtering favorites must not change it.
|
||||||
|
|
||||||
|
For a star without a surrounding disc, use `IconButton surface="none"`. The shared component owns the transparent surface and foreground; applications only position it. Keyboard focus and the hit target remain unchanged.
|
||||||
Generated
+1
-1
@@ -2530,7 +2530,7 @@
|
|||||||
},
|
},
|
||||||
"packages/ui-react": {
|
"packages/ui-react": {
|
||||||
"name": "@nodedc/ui-react",
|
"name": "@nodedc/ui-react",
|
||||||
"version": "0.7.5",
|
"version": "0.7.6",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@dnd-kit/core": "^6.3.1",
|
"@dnd-kit/core": "^6.3.1",
|
||||||
"@dnd-kit/sortable": "^10.0.0",
|
"@dnd-kit/sortable": "^10.0.0",
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@nodedc/ui-react",
|
"name": "@nodedc/ui-react",
|
||||||
"version": "0.7.5",
|
"version": "0.7.6",
|
||||||
"type": "module",
|
"type": "module",
|
||||||
"files": [
|
"files": [
|
||||||
"dist"
|
"dist"
|
||||||
|
|||||||
@@ -65,12 +65,16 @@ export const Button = forwardRef<HTMLButtonElement, ButtonProps>(function Button
|
|||||||
export interface IconButtonProps extends ButtonHTMLAttributes<HTMLButtonElement> {
|
export interface IconButtonProps extends ButtonHTMLAttributes<HTMLButtonElement> {
|
||||||
label: string;
|
label: string;
|
||||||
shape?: "circle" | "rounded";
|
shape?: "circle" | "rounded";
|
||||||
|
/** Glyph-only action; keeps the normal hit target and keyboard focus. */
|
||||||
|
surface?: "default" | "none";
|
||||||
loading?: boolean;
|
loading?: boolean;
|
||||||
}
|
}
|
||||||
|
|
||||||
export const IconButton = forwardRef<HTMLButtonElement, IconButtonProps>(function IconButton({
|
export const IconButton = forwardRef<HTMLButtonElement, IconButtonProps>(function IconButton({
|
||||||
label,
|
label,
|
||||||
shape = "circle",
|
shape = "circle",
|
||||||
|
surface = "default",
|
||||||
|
style,
|
||||||
className,
|
className,
|
||||||
children,
|
children,
|
||||||
type = "button",
|
type = "button",
|
||||||
@@ -84,6 +88,7 @@ export const IconButton = forwardRef<HTMLButtonElement, IconButtonProps>(functio
|
|||||||
type={type}
|
type={type}
|
||||||
className={cn("nodedc-icon-button", className)}
|
className={cn("nodedc-icon-button", className)}
|
||||||
data-shape={shape === "circle" ? undefined : shape}
|
data-shape={shape === "circle" ? undefined : shape}
|
||||||
|
style={surface === "none" ? { ...style, background: "transparent", boxShadow: "none", color: "var(--nodedc-text-primary)" } : style}
|
||||||
aria-label={label}
|
aria-label={label}
|
||||||
title={label}
|
title={label}
|
||||||
{...props}
|
{...props}
|
||||||
|
|||||||
@@ -64,6 +64,7 @@ import {
|
|||||||
ShieldCheck,
|
ShieldCheck,
|
||||||
SlidersHorizontal,
|
SlidersHorizontal,
|
||||||
Square,
|
Square,
|
||||||
|
Star,
|
||||||
Terminal,
|
Terminal,
|
||||||
Trash2,
|
Trash2,
|
||||||
UploadCloud,
|
UploadCloud,
|
||||||
@@ -156,6 +157,7 @@ const icons = {
|
|||||||
shield: ShieldCheck,
|
shield: ShieldCheck,
|
||||||
sliders: SlidersHorizontal,
|
sliders: SlidersHorizontal,
|
||||||
stop: Square,
|
stop: Square,
|
||||||
|
star: Star,
|
||||||
terminal: Terminal,
|
terminal: Terminal,
|
||||||
trash: Trash2,
|
trash: Trash2,
|
||||||
upload: UploadCloud,
|
upload: UploadCloud,
|
||||||
|
|||||||
@@ -176,6 +176,7 @@
|
|||||||
],
|
],
|
||||||
"rules": [
|
"rules": [
|
||||||
"Icon-only actions are circular by default.",
|
"Icon-only actions are circular by default.",
|
||||||
|
"IconButton surface=none keeps the normal hit target and focus while removing the disc. Favorite stars use outline/filled glyph states; see docs/FAVORITES.md.",
|
||||||
"Groups over rendered imagery use nodedc-scene-controls: Button, IconButton, Select and SegmentedControl share the opaque field surface and interaction states; all viewport controls use the same 70-percent geometry, and rails must not inherit the translucent header background.",
|
"Groups over rendered imagery use nodedc-scene-controls: Button, IconButton, Select and SegmentedControl share the opaque field surface and interaction states; all viewport controls use the same 70-percent geometry, and rails must not inherit the translucent header background.",
|
||||||
"Controlled toggle actions expose aria-pressed and use the canonical active surface without changing geometry.",
|
"Controlled toggle actions expose aria-pressed and use the canonical active surface without changing geometry.",
|
||||||
"Filled accent actions derive foreground contrast from the actual accent.",
|
"Filled accent actions derive foreground contrast from the actual accent.",
|
||||||
|
|||||||
+2
-1
@@ -107,7 +107,8 @@
|
|||||||
"shield",
|
"shield",
|
||||||
"circle",
|
"circle",
|
||||||
"eye",
|
"eye",
|
||||||
"eye-off"
|
"eye-off",
|
||||||
|
"star"
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user