Text sizes through cn(), tab underline, sticky table header, release 0.7.1

- cn(): tailwind-merge knows text-ui / text-2xs / text-3xs. Before, text-ui
  was taken for a colour and dropped next to text-<colour>, so section tabs
  and other text-ui labels rendered at 16px instead of 13px (regression
  from 0.7.0).
- ContentTabs: the line underline no longer overflows the strip by 1px (the
  strip stopped being vertically scrollable); new `actions` slot puts
  buttons in the same row with one shared bottom line.
- DataTable: sticky header has a solid background and its divider is a cell
  shadow, so it scrolls with the header and rows don't show through.
- PageFrame: the title is a pill like the SectionTabsBar root tab
  (13px medium, same height and position).
- ScheduleGrid: solid sticky header.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Ilya Mukhortov 2026-10-26 09:14:11 +10:00
parent 770e2c35e6
commit 87d12b72ec
7 changed files with 53 additions and 15 deletions

View File

@ -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.7.0"
npm i "git+https://git.med-logic.ru/medlogic/medkit.git#semver:^0.7.1"
```
`package-lock.json` фиксирует коммит; обновиться до свежего тега — `npm update @medkit/ui`. В medicine-ui kit подключён git-submodule в `packages/medkit` (npm workspace) — правки видны сразу.

View File

@ -1,6 +1,6 @@
{
"name": "@medkit/ui",
"version": "0.7.0",
"version": "0.7.1",
"private": true,
"description": "Medkit — UI kit МИС «Медицина»: React 19 + Tailwind 4 + Radix (shadcn/ui)",
"repository": {

View File

@ -1,3 +1,4 @@
import * as React from "react"
import { type LucideIcon } from "lucide-react"
import { cn } from "../lib/utils"
@ -18,28 +19,37 @@ export interface ContentTabItem<T extends string = string> {
* Контентные вкладки внутри страницы/карточки.
* `line` — подчёркивание (разделы карточки), `pill` — заливка (переключатели в блоках).
* Вкладки-фильтры по статусам: `{ id, label, count, tone }`, первая — «Все» без тона.
* `actions` — кнопки справа в той же строке («Наклейки», «Excel»): у вкладок и кнопок одна
* нижняя линия, подчёркивание лежит прямо на ней. Не собирать такую строку вручную
* из ContentTabs с `border-b-0` — подчёркивание повиснет над линией.
*/
export function ContentTabs<T extends string>({
tabs,
value,
onValueChange,
variant = "line",
actions,
className,
}: {
tabs: readonly ContentTabItem<T>[]
value: T
onValueChange: (value: T) => void
variant?: "line" | "pill"
/** Кнопки справа в строке вкладок. */
actions?: React.ReactNode
className?: string
}) {
return (
const list = (
<div
role="tablist"
className={cn(
"scrollbar-none flex shrink-0 items-center gap-1 overflow-x-auto",
variant === "line" && "border-b px-3",
// overflow-y-hidden: иначе overflow-x-auto делает строку прокручиваемой и по вертикали
"scrollbar-none flex shrink-0 items-center gap-1 overflow-x-auto overflow-y-hidden",
variant === "line" && "px-3",
variant === "line" && !actions && "border-b",
variant === "line" && actions && "min-w-0 flex-1 self-end",
variant === "pill" && "w-fit max-w-full rounded-xl bg-muted/70 p-1",
className,
!actions && className,
)}
>
{tabs.map((tab) => {
@ -76,11 +86,25 @@ export function ContentTabs<T extends string>({
</span>
)}
{variant === "line" && active && (
<span className="absolute inset-x-2 -bottom-px h-0.5 rounded-full bg-primary" />
<span className="absolute inset-x-2 bottom-0 h-0.5 rounded-full bg-primary" />
)}
</button>
)
})}
</div>
)
if (!actions) return list
return (
<div
className={cn(
"flex shrink-0 items-end gap-x-2",
variant === "line" && "border-b",
className,
)}
>
{list}
<div className="flex shrink-0 items-center gap-2 self-center py-1.5 pr-4">{actions}</div>
</div>
)
}

View File

@ -122,7 +122,8 @@ export function DataTable<T>({
return (
<table className={cn("w-full text-sm", className)}>
<thead className="sticky top-0 z-10 border-b bg-card/95 backdrop-blur">
{/* Липкая шапка: фон непрозрачный, линия — тенью ячеек (border у thead при прокрутке остаётся на месте). */}
<thead className="sticky top-0 z-10">
<tr className="text-left text-xs text-muted-foreground">
{columns.map((col) => {
const active = sort?.id === col.id
@ -131,7 +132,10 @@ export function DataTable<T>({
<th
key={col.id}
aria-sort={active ? (sort.direction === "asc" ? "ascending" : "descending") : undefined}
className={cn("h-10 px-3 font-medium first:pl-5 last:pr-5", col.headerClassName)}
className={cn(
"h-10 bg-card px-3 font-medium shadow-[inset_0_-1px_0_var(--border)] first:pl-5 last:pr-5",
col.headerClassName,
)}
>
{col.sort && onSortChange ? (
<button

View File

@ -30,10 +30,14 @@ export function PageFrame({
return (
<div className="flex min-h-0 flex-1 flex-col p-2 lg:p-3">
<div className="flex min-h-0 flex-1 flex-col overflow-clip rounded-xl border bg-card shadow-[0_1px_2px_rgba(15,40,60,0.04)]">
<header className="flex h-12 shrink-0 items-center gap-2 border-b px-4">
{Icon && <Icon className="size-4 text-primary" />}
<h1 className="text-sm font-semibold">{title}</h1>
{actions && <div className="ml-auto flex items-center gap-2">{actions}</div>}
{/* Шапка и заголовок — как у SectionTabsBar с активной корневой вкладкой (PageTabs, CHIP_CLASS):
разделы со вкладками и без выглядят одинаково. */}
<header className="flex h-12 shrink-0 items-center gap-2 border-b px-2">
<h1 className="flex h-8 min-w-0 items-center gap-2 rounded-lg bg-accent px-2.5 text-ui font-medium text-accent-foreground">
{Icon && <Icon className="size-4 shrink-0 text-primary" />}
<span className="truncate">{title}</span>
</h1>
{actions && <div className="ml-auto flex shrink-0 items-center gap-2">{actions}</div>}
</header>
{toolbar && <div className="shrink-0 border-b px-4 py-3">{toolbar}</div>}
{scroll ? (

View File

@ -158,7 +158,7 @@ export function ScheduleGrid({
>
<div className="sticky top-0 left-0 z-30 border-r border-b bg-card" />
{resources.map((r) => (
<div key={r.id} className="sticky top-0 z-20 min-w-0 border-r border-b bg-card/95 px-3 py-2 backdrop-blur last:border-r-0">
<div key={r.id} className="sticky top-0 z-20 min-w-0 border-r border-b bg-card px-3 py-2 last:border-r-0">
<div className="truncate text-sm font-semibold">{r.title}</div>
{r.subtitle && <div className="truncate text-xs text-muted-foreground">{r.subtitle}</div>}
</div>

View File

@ -1,5 +1,11 @@
import { clsx, type ClassValue } from "clsx"
import { twMerge } from "tailwind-merge"
import { extendTailwindMerge } from "tailwind-merge"
// Свои размеры текста из styles.css (--text-ui, --text-2xs, --text-3xs). Без этого
// tailwind-merge считает text-ui цветом и выбрасывает его рядом с text-<цвет>.
const twMerge = extendTailwindMerge({
extend: { theme: { text: ["ui", "2xs", "3xs"] } },
})
export function cn(...inputs: ClassValue[]) {
return twMerge(clsx(inputs))