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

@@ -0,0 +1,65 @@
import { render, screen } from '@testing-library/react'
import { describe, expect, it } from 'vitest'
import { expectNoA11yViolations } from '../test/a11y'
import { Avatar, AvatarGroup } from './Avatar'
import { colorFromName, initialsFromName } from './avatar.tokens'
describe('Avatar', () => {
it('falls back to initials with the name as accessible text', () => {
render(<Avatar name="Jane Doe" />)
expect(screen.getByText('JD')).toHaveAttribute('aria-hidden', 'true')
expect(screen.getByText('Jane Doe')).toHaveClass('sr-only')
})
it('falls back to initials while the image has not loaded', () => {
render(<Avatar name="John Smith" src="data:image/png;base64,x" />)
expect(screen.getByText('JS')).toBeInTheDocument()
})
it('labels the status dot', () => {
render(<Avatar name="Jane Doe" status="online" />)
expect(screen.getByRole('img', { name: 'Online' })).toBeInTheDocument()
})
it('accepts a custom status label', () => {
render(<Avatar name="Jane Doe" status="busy" statusLabel="In a meeting" />)
expect(screen.getByRole('img', { name: 'In a meeting' })).toBeInTheDocument()
})
it('derives initials and a stable colour from the name', () => {
expect(initialsFromName('Jane Mary Doe')).toBe('JD')
expect(initialsFromName('Acme')).toBe('AC')
expect(colorFromName('Jane Doe')).toBe(colorFromName('Jane Doe'))
})
})
describe('AvatarGroup', () => {
it('shows max avatars and an overflow count', () => {
render(
<AvatarGroup max={2} aria-label="Team">
<Avatar name="Jane Doe" />
<Avatar name="John Smith" />
<Avatar name="Maya Chen" />
<Avatar name="Carlos Mendez" />
</AvatarGroup>,
)
expect(screen.getByRole('group', { name: 'Team' })).toBeInTheDocument()
expect(screen.queryByText('PR')).not.toBeInTheDocument()
expect(screen.getByText('+2')).toBeInTheDocument()
expect(screen.getByText('and 2 more')).toBeInTheDocument()
})
it('has no axe violations', async () => {
const { container } = render(
<div>
<Avatar name="Jane Doe" status="away" />
<Avatar alt="Unknown user" />
<AvatarGroup max={1} aria-label="Reviewers">
<Avatar name="Jane Doe" />
<Avatar name="John Smith" />
</AvatarGroup>
</div>,
)
await expectNoA11yViolations(container)
})
})