Package Tansy UI as @openkhalix/tansy-ui in a monorepo (v0.4.0)
CI / check (push) Successful in 3m9s
Release / publish (push) Failing after 1m22s

Restructure the repo into npm workspaces so the component kit publishes as
its own package, like MUI and shadcn/ui:

- packages/ui: @openkhalix/tansy-ui (published), with components, stories,
  tests, tokens and the library build
- packages/brand: private logo and catalogue data shared by both apps
- apps/site: the landing page
- apps/docs: Storybook

The package:
- MIT licence (copyright OpenKhalix)
- per-component ES modules and type declarations
- "use client" on component modules so they import into Next.js Server
  Components; helpers stay server-safe
- tokens.css for Tailwind v4 apps, and a prebuilt styles.css for apps
  without Tailwind
- lucide-react 1.x, whose types compile against current React 19 types

The apps resolve the package through a "source" export condition, so they
hot-reload component edits, while outside users get dist/.

scripts/test-package.mjs packs the package and installs the tarball into
Vite + Tailwind (strict types), plain React and Next.js apps; each must
build and render correctly. Gitea workflows run CI on push and publish to
npm when a vX.Y.Z tag matching the package version is pushed.
This commit is contained in:
thekhalidsha committed 2026-09-29 09:24:03 +05:30
1 parent 23e67006d3
commit 9255b255a6
214 files changed
+1521 -389

No files matched your search

+91
View File
@@ -0,0 +1,91 @@
import { createElement, type ComponentProps, type ReactNode } from 'react'
import { Accordion as BaseAccordion } from '@base-ui/react/accordion'
import { ChevronDown } from 'lucide-react'
import { cn } from '../lib/cn'
import {
ACCORDION_ITEM_STYLES,
ACCORDION_PANEL_INNER,
ACCORDION_ROOT_STYLES,
ACCORDION_TRIGGER_STYLES,
accordionChevron,
accordionPanel,
accordionTrigger,
type AccordionHeadingLevel,
type AccordionVariant,
} from './accordion.tokens'
export type AccordionItem = {
/** Unique id for the item; used in `value`. */
value: string
title: ReactNode
content: ReactNode
disabled?: boolean
}
export type AccordionProps = Omit<ComponentProps<'div'>, 'defaultValue' | 'onChange'> & {
items: AccordionItem[]
/** Allows several items to be open at once. */
multiple?: boolean
/** Open items (controlled). */
value?: string[]
/** Initially open items (uncontrolled). */
defaultValue?: string[]
/** Called with the open items whenever one opens or closes. */
onValueChange?: (value: string[]) => void
/** `bordered` groups items in one box, `separated` gives each its own card, `ghost` only divides them. */
variant?: AccordionVariant
/** Heading level of each trigger, to fit the page outline. */
headingLevel?: AccordionHeadingLevel
/** Disables every item. */
disabled?: boolean
}
/**
* A stack of collapsible sections. Closed panels stay in the DOM as
* `hidden="until-found"`, so the browser's find-in-page can open them.
*/
export function Accordion({
items,
multiple = false,
value,
defaultValue,
onValueChange,
variant = 'bordered',
headingLevel = 3,
disabled,
className,
...props
}: AccordionProps) {
const heading = `h${headingLevel}`
return (
<BaseAccordion.Root
multiple={multiple}
value={value}
defaultValue={defaultValue}
onValueChange={onValueChange ? (next) => onValueChange(next as string[]) : undefined}
disabled={disabled}
hiddenUntilFound
className={cn(ACCORDION_ROOT_STYLES[variant], className)}
{...props}
>
{items.map((item) => (
<BaseAccordion.Item
key={item.value}
value={item.value}
disabled={item.disabled}
className={ACCORDION_ITEM_STYLES[variant]}
>
<BaseAccordion.Header render={(headerProps) => createElement(heading, headerProps)} className="m-0">
<BaseAccordion.Trigger className={cn(accordionTrigger, ACCORDION_TRIGGER_STYLES[variant])}>
<span className="min-w-0">{item.title}</span>
<ChevronDown aria-hidden="true" className={accordionChevron} />
</BaseAccordion.Trigger>
</BaseAccordion.Header>
<BaseAccordion.Panel className={accordionPanel}>
<div className={ACCORDION_PANEL_INNER[variant]}>{item.content}</div>
</BaseAccordion.Panel>
</BaseAccordion.Item>
))}
</BaseAccordion.Root>
)
}