Release 0.16.0: sidebar action buttons beside search.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
parent
08ef767b63
commit
2b0f94bddd
|
|
@ -2,6 +2,11 @@
|
|||
|
||||
Установка версии: `npm i "git+https://git.med-logic.ru/medlogic/medkit.git#semver:^X.Y.Z"`. На 0.x `^0.7.0` не подхватывает 0.8.0 — минорную версию поднимаем в зависимости явно.
|
||||
|
||||
## [0.16.0] — 2026-11-03
|
||||
|
||||
### Новое
|
||||
- `AppSidebar`: проп `actions` — разделы-кнопки в одном ряду с поиском, для разделов, которым не нужна своя строка в меню (например, «Уведомления»). Тип `SidebarAction`: `to`, `label`, `icon`, `badge`, `badgeTone`, `match`. При `badge` больше нуля на кнопке появляется точка, название и число показываются в подсказке и `aria-label`. В свёрнутом меню кнопки встают столбиком под поиском. Без `actions` меню выглядит как раньше.
|
||||
|
||||
## [0.15.0] — 2026-11-02
|
||||
|
||||
### Новое
|
||||
|
|
|
|||
|
|
@ -18,7 +18,7 @@ src/styles.css тема (токены, шрифты, тёмный режим)
|
|||
Пакет ставится прямо из git, версии — теги `vX.Y.Z`:
|
||||
|
||||
```bash
|
||||
npm i "git+https://git.med-logic.ru/medlogic/medkit.git#semver:^0.15.0"
|
||||
npm i "git+https://git.med-logic.ru/medlogic/medkit.git#semver:^0.16.0"
|
||||
```
|
||||
|
||||
`package-lock.json` фиксирует коммит; обновиться до свежего тега — `npm update @medkit/ui`. В medicine-ui kit подключён git-submodule в `packages/medkit` (npm workspace) — правки видны сразу.
|
||||
|
|
@ -64,7 +64,7 @@ function App() {
|
|||
return (
|
||||
<ShellProvider storageKey="lis" basename="/medicine-lis" pathname={location.pathname} search={location.search} navigate={navigate}>
|
||||
<Routes>
|
||||
<Route element={<AppShell sidebar={{ logo, groups, search, user, userMenu }}><Outlet /></AppShell>}>…</Route>
|
||||
<Route element={<AppShell sidebar={{ logo, groups, search, actions, user, userMenu }}><Outlet /></AppShell>}>…</Route>
|
||||
</Routes>
|
||||
</ShellProvider>
|
||||
)
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
{
|
||||
"name": "@medkit/ui",
|
||||
"version": "0.15.0",
|
||||
"version": "0.16.0",
|
||||
"private": true,
|
||||
"description": "Medkit — UI kit МИС «Медицина»: React 19 + Tailwind 4 + Radix (shadcn/ui)",
|
||||
"repository": {
|
||||
|
|
|
|||
|
|
@ -48,6 +48,9 @@ export interface SidebarSearch {
|
|||
readonly onClick: () => void
|
||||
}
|
||||
|
||||
/** Кнопка-иконка рядом с поиском: раздел, которому не нужна своя строка в меню. При `badge` > 0 — точка; название и число — в подсказке. */
|
||||
export type SidebarAction = Pick<SidebarNavItem, "to" | "label" | "icon" | "badge" | "badgeTone" | "match">
|
||||
|
||||
export interface SidebarUser {
|
||||
readonly name: string
|
||||
readonly subtitle?: string
|
||||
|
|
@ -62,6 +65,8 @@ export interface AppSidebarProps {
|
|||
/** Справа от логотипа в развёрнутом меню (часы, окружение). */
|
||||
headerExtra?: React.ReactNode
|
||||
search?: SidebarSearch
|
||||
/** Разделы-кнопки в одном ряду с поиском («Уведомления»); в свёрнутом меню — столбиком под ним. */
|
||||
actions?: readonly SidebarAction[]
|
||||
groups: readonly SidebarNavGroup[]
|
||||
user?: SidebarUser
|
||||
/** Пункты меню пользователя (DropdownMenuLabel, DropdownMenuItem…). */
|
||||
|
|
@ -73,7 +78,7 @@ const toneDot = (tone: SectionTab["tone"], fallback: string) =>
|
|||
tone === "female" ? "bg-female" : tone === "male" ? "bg-male" : fallback
|
||||
|
||||
/**
|
||||
* Тёмное боковое меню: логотип, кнопка поиска, разделы группами со счётчиками,
|
||||
* Тёмное боковое меню: логотип, кнопка поиска, разделы-кнопки, разделы группами со счётчиками,
|
||||
* открытые карточки разделов со вкладками, пользователь и сворачивание. Обычно — внутри AppShell.
|
||||
*/
|
||||
export function AppSidebar({
|
||||
|
|
@ -82,6 +87,7 @@ export function AppSidebar({
|
|||
logo,
|
||||
headerExtra,
|
||||
search,
|
||||
actions,
|
||||
groups,
|
||||
user,
|
||||
userMenu,
|
||||
|
|
@ -102,16 +108,17 @@ export function AppSidebar({
|
|||
{!collapsed && headerExtra}
|
||||
</div>
|
||||
|
||||
{(search || (actions && actions.length > 0)) && (
|
||||
<div className={cn("flex shrink-0 gap-1 px-3 pb-2", collapsed && "flex-col")}>
|
||||
{search && (
|
||||
<div className="shrink-0 px-3 pb-2">
|
||||
<SidebarTooltip label={search.tooltip} enabled={collapsed}>
|
||||
<button
|
||||
type="button"
|
||||
onClick={search.onClick}
|
||||
aria-label={collapsed ? search.tooltip : undefined}
|
||||
className={cn(
|
||||
"flex h-9 w-full items-center gap-2 rounded-lg border border-white/[0.08] bg-white/[0.04] text-sm text-sidebar-muted shadow-[inset_0_1px_0_rgba(255,255,255,0.03)] transition-colors hover:border-white/[0.12] hover:bg-white/[0.07] hover:text-sidebar-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-sidebar-primary/60",
|
||||
collapsed ? "justify-center" : "px-3",
|
||||
"flex h-9 items-center gap-2 rounded-lg border border-white/[0.08] bg-white/[0.04] text-sm text-sidebar-muted shadow-[inset_0_1px_0_rgba(255,255,255,0.03)] transition-colors hover:border-white/[0.12] hover:bg-white/[0.07] hover:text-sidebar-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-sidebar-primary/60",
|
||||
collapsed ? "w-full justify-center" : "min-w-0 flex-1 px-3",
|
||||
)}
|
||||
>
|
||||
<SearchItemIcon className="size-4 shrink-0" />
|
||||
|
|
@ -127,6 +134,10 @@ export function AppSidebar({
|
|||
)}
|
||||
</button>
|
||||
</SidebarTooltip>
|
||||
)}
|
||||
{actions?.map((action) => (
|
||||
<SidebarActionLink key={action.to} action={action} collapsed={collapsed} />
|
||||
))}
|
||||
</div>
|
||||
)}
|
||||
|
||||
|
|
@ -344,6 +355,49 @@ function SidebarLink({ item, collapsed }: { item: SidebarNavItem; collapsed: boo
|
|||
)
|
||||
}
|
||||
|
||||
function SidebarActionLink({ action, collapsed }: { action: SidebarAction; collapsed: boolean }) {
|
||||
const Icon = action.icon
|
||||
const { pathname } = useShell()
|
||||
const active = action.match ? action.match(pathname) : isUnder(pathname, action.to)
|
||||
const count = action.badge ?? 0
|
||||
const label = count > 0 ? `${action.label}: ${count}` : action.label
|
||||
|
||||
return (
|
||||
<Tooltip>
|
||||
<TooltipTrigger asChild>
|
||||
<ShellLink
|
||||
href={action.to}
|
||||
aria-label={label}
|
||||
aria-current={active ? "page" : undefined}
|
||||
className={cn(
|
||||
"group/link relative grid h-9 shrink-0 place-items-center rounded-lg border transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-sidebar-primary/60",
|
||||
collapsed ? "w-full" : "w-9",
|
||||
active
|
||||
? "border-transparent bg-sidebar-accent text-white ring-1 ring-inset ring-white/[0.05]"
|
||||
: "border-white/[0.08] bg-white/[0.04] text-sidebar-foreground/80 shadow-[inset_0_1px_0_rgba(255,255,255,0.03)] hover:border-white/[0.12] hover:bg-white/[0.07] hover:text-white",
|
||||
)}
|
||||
>
|
||||
<Icon
|
||||
className={cn(
|
||||
"size-4 shrink-0 transition-colors group-hover/link:text-sidebar-primary motion-safe:group-hover/link:animate-nav-icon",
|
||||
active && "text-sidebar-primary",
|
||||
)}
|
||||
/>
|
||||
{count > 0 && (
|
||||
<span
|
||||
className={cn(
|
||||
"absolute top-1 right-1 size-1.5 rounded-full ring-2 ring-sidebar",
|
||||
action.badgeTone === "warning" ? "bg-warning" : "bg-coral",
|
||||
)}
|
||||
/>
|
||||
)}
|
||||
</ShellLink>
|
||||
</TooltipTrigger>
|
||||
<TooltipContent side={collapsed ? "right" : "bottom"}>{label}</TooltipContent>
|
||||
</Tooltip>
|
||||
)
|
||||
}
|
||||
|
||||
function UserMenu({ user, collapsed, menu }: { user: SidebarUser; collapsed: boolean; menu?: React.ReactNode }) {
|
||||
const trigger = (
|
||||
<button
|
||||
|
|
|
|||
Loading…
Reference in New Issue