Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
66 commits
Select commit Hold shift + click to select a range
8937d5a
add vue package
Applelo Feb 28, 2024
87bd3b2
update dependencies
Applelo Feb 28, 2024
813e8b8
update documentation
Applelo Feb 28, 2024
2b1ce9b
update doc for composable
Applelo Mar 1, 2024
0b02397
update dependencies
Applelo Mar 2, 2024
2ba5305
add demo folder on vue
Applelo Mar 3, 2024
6c6bb03
add events on with ts rework
Applelo Mar 5, 2024
35f5338
fix build
Applelo Mar 6, 2024
19da689
fix CI
Applelo Mar 6, 2024
38ad7fd
fix test snapshot
Applelo Mar 6, 2024
9f1d232
update dependencies, work on composables
Applelo Mar 27, 2024
f153d66
update package
Applelo Apr 4, 2024
830c1e1
working on vue component
Applelo Jun 6, 2024
e21ab28
init on method and not on constructor
Applelo Jun 6, 2024
a501cff
Update pnpm and dependencies
Applelo Aug 26, 2024
fec1e82
update dependencies
Applelo Aug 30, 2024
6d36a8c
rewrite components structure
Applelo Sep 28, 2024
bf65903
fix lint issue, update typings
Applelo Sep 29, 2024
360325b
update dependencies, fix typescript issue
Applelo Feb 7, 2026
0313c77
fix lint issues
Applelo Feb 7, 2026
4489f4d
respect options override
Applelo Feb 7, 2026
ecf3fd2
replace vite by rolldown
Applelo Feb 7, 2026
36284fb
replace vite by rolldown
Applelo Feb 7, 2026
cd98cbc
disable vue plugin since there is only composable
Applelo Feb 7, 2026
f736b45
rewrite collapse test with vitest browser test suite
Applelo Feb 8, 2026
e411f25
add marquee test, fix accessibility tabindex on marquee
Applelo Feb 8, 2026
da34f4f
add parent test
Applelo Feb 8, 2026
d81766a
add drag test
Applelo Feb 8, 2026
7488c7c
allow not element in constructor (for reinit), add dropdown test
Applelo Feb 8, 2026
8922b3e
add drilldown component
Applelo Feb 8, 2026
b366d56
add drilldown test
Applelo Feb 8, 2026
dbf5a25
install deps with playwright
Applelo Feb 8, 2026
989678a
fix ci issue
Applelo Feb 8, 2026
28cf898
add reactiv vue composable
Applelo Feb 8, 2026
b055fe1
add vue composables test
Applelo Feb 8, 2026
7c62513
fix lint issue on tsconfig
Applelo Feb 8, 2026
b19e500
add vue components
Applelo Feb 8, 2026
9987e19
fix drilldown items, fix lint issue
Applelo Feb 8, 2026
a7b7db2
update agents.md, remove css import from vue component
Applelo Feb 9, 2026
9c6d199
fix documentation
Applelo Feb 9, 2026
d6b2e95
update components method and available options
Applelo Feb 9, 2026
dcb3221
add vue events into components
Applelo Feb 9, 2026
3a0908d
improve vue implementation
Applelo Feb 13, 2026
4513d1c
debounce all observer to prevent page freezing
Applelo Feb 13, 2026
7fbdf35
remove claude stuff
Applelo Feb 13, 2026
ff3d794
add doc-sync, update CCollapse and CCollapseTrigger
Applelo Feb 13, 2026
700ca6d
use node 24 and add coverage
Applelo Feb 13, 2026
4dda869
fix test
Applelo Feb 13, 2026
51636e5
fix coverage CI and collapse problem
Applelo Feb 13, 2026
f031cef
fix lint issue
Applelo Feb 13, 2026
40315e1
add lcov reporter
Applelo Feb 13, 2026
56493d1
improve vitest config
Applelo Feb 13, 2026
c79d2e8
use pnpm instead of vitest projects
Applelo Feb 14, 2026
18ef640
fix marquee options, collapse destroy and use same destroy verificat…
Applelo Feb 14, 2026
758ea11
improve CI setup
Applelo Feb 14, 2026
0203b3d
fix CI setup
Applelo Feb 14, 2026
a0d7a2d
fix issues accross the components
Applelo Feb 14, 2026
1b6e3f0
fix dropdown flacky test
Applelo Feb 14, 2026
5d7c46b
update documentation
Applelo Feb 14, 2026
6632e21
update demo by using vue components
Applelo Feb 15, 2026
0a52723
update documentation
Applelo Feb 15, 2026
44fdfa2
fix events pollution on vue components
Applelo Feb 15, 2026
67c36ba
improve test coverage
Applelo Feb 16, 2026
811859c
fix lint issues
Applelo Feb 16, 2026
1bbb893
fix debounce and marquee css init
Applelo Feb 16, 2026
347a40d
update features section
Applelo Feb 16, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion .eslintignore

This file was deleted.

17 changes: 17 additions & 0 deletions .github/actions/setup/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
name: Setup
description: Install pnpm, Node.js and dependencies

runs:
using: composite
steps:
- uses: pnpm/action-setup@v4

- name: Use Node.js 24
uses: actions/setup-node@v6
with:
node-version: 24
cache: pnpm

- name: Install
shell: bash
run: pnpm install
90 changes: 30 additions & 60 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,89 +12,59 @@ on:
jobs:
test:
runs-on: ubuntu-latest
name: Test & Coverage

steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v6

- uses: pnpm/action-setup@v2
with:
version: 8

- name: Use Node.js 20
uses: actions/setup-node@v3
with:
node-version: 20
cache: pnpm

- name: Install
run: pnpm install
- uses: ./.github/actions/setup

- name: Playwright Install
run: npx playwright install
run: npx playwright install --with-deps

- name: Build
run: pnpm build

- name: Test
run: pnpm test
run: pnpm test:coverage

# coverage:
# runs-on: ubuntu-latest
# name: 'Coverage'
- name: Coveralls
uses: coverallsapp/github-action@v2
with:
github-token: ${{ secrets.GITHUB_TOKEN }}

# steps:
# - uses: actions/checkout@v3
# with:
# fetch-depth: 0
lint:
runs-on: ubuntu-latest
name: Lint

steps:
- uses: actions/checkout@v6

# - uses: pnpm/action-setup@v2.2.4
# with:
# version: 7
- uses: ./.github/actions/setup

# - name: Set node version to 16
# uses: actions/setup-node@v3
# with:
# node-version: 16
# cache: pnpm
- name: Lint
run: pnpm lint

# - name: Install
# run: pnpm install
docs-sync:
runs-on: ubuntu-latest
name: Docs Sync

# - name: Build
# run: pnpm build
steps:
- uses: actions/checkout@v6

# - name: Test
# run: pnpm coverage
- uses: ./.github/actions/setup

# - name: Coveralls
# uses: coverallsapp/github-action@master
# with:
# github-token: ${{ secrets.GITHUB_TOKEN }}
- name: Check docs are in sync
run: pnpm docs:sync

lint:
build:
runs-on: ubuntu-latest
name: 'Lint: node-18, ubuntu-latest'
name: Build

steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0
- uses: actions/checkout@v6

- uses: pnpm/action-setup@v2
with:
version: 8

- name: Set node version to 20
uses: actions/setup-node@v3
with:
node-version: 20
cache: pnpm

- name: Install
run: pnpm install
- uses: ./.github/actions/setup

- name: Build
run: pnpm build

- name: Lint
run: pnpm lint
7 changes: 6 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ reports
coverage
*.lcov
.nyc_output
__screenshots__

# VSCode
.vscode
Expand All @@ -50,4 +51,8 @@ Network Trash Folder
Temporary Items
.apdisk

docs/.vitepress/cache
docs/.vitepress/cache

# CLAUDE
.claude
CLAUDE.md
164 changes: 164 additions & 0 deletions AGENTS.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,164 @@
# CLAUDE.md / AGENTS.md

This file provides guidance when working with code in this repository.

## Project Overview

Compotes is a component library focused on customization and accessibility. It provides framework-agnostic UI components (collapse, drag, drilldown, dropdown, marquee) with minimal CSS to allow maximum customization.

## Monorepo Structure

This is a pnpm workspace monorepo with catalog mode enabled (`catalogMode: strict`):

- **packages/core** (`compotes`): Vanilla JavaScript/TypeScript components (class-based)
- **packages/vue** (`@compotes/vue`): Vue 3 wrapper components
- **docs/**: VitePress documentation site

Dependencies are managed via pnpm catalog in `pnpm-workspace.yaml`. Use `catalog:` in package.json to reference catalog versions.

## Common Commands

### Building
```bash
pnpm build # Build all packages
pnpm -F compotes build # Build core package only
pnpm -F @compotes/vue build # Build Vue package only
```

### Testing
```bash
pnpm test # Run all tests (types + vitest)
pnpm test:vitest # Run vitest tests across all packages
pnpm test:types # Run type checks only
pnpm -F compotes test:vitest # Run tests for core package only
```

Tests use Vitest with browser testing via Playwright. Browser tests run against Chromium, Firefox, and WebKit.

### Linting
```bash
pnpm lint # Lint all files
pnpm lint:fix # Lint and auto-fix
```

Uses `@antfu/eslint-config`.

### Documentation
```bash
pnpm docs # Start VitePress dev server
pnpm docs:build # Build documentation
pnpm docs:serve # Preview built docs
```

## Architecture

### Core Package (packages/core)

Components follow a class-based architecture:

1. **Parent Base Class** (`src/components/_parent.ts`):
- All components extend `Parent<E, O>` abstract class
- Provides lifecycle methods: `init()`, `destroy()`
- Event system using custom events with naming pattern: `c.{componentName}.{eventName}`
- Event cleanup via AbortController
- `registerEvent()` for automatic cleanup on destroy
- Error handling via custom ErrorCompotes class
- Options interface with `init` and `on` event listeners

2. **Component Pattern**:
- Constructor accepts element (selector or HTMLElement) and options
- `initElements()`: Query and store DOM element references
- `initEvents()`: Register event listeners using `registerEvent()`
- `initAccessibilityAttrs()`: Set ARIA attributes for accessibility
- Public methods for component actions (show, hide, toggle, etc.)
- Protected `emitEvent()` for custom events

3. **CSS Architecture**:
- Components use BEM-like naming: `c-{component}`, `c-{component}--{modifier}`
- Trigger/action elements: `c-{component}-{action}` (e.g., `c-collapse-trigger`)
- Individual CSS files per component in `src/css/`
- CSS can be imported separately: `compotes/css/{component}.css`

4. **Build Configuration**:
- Uses tsdown with custom plugin to emit individual CSS files
- Outputs ESM and UMD formats
- LightningCSS for CSS minification
- Global name: `compotes` (for UMD)

### Vue Package (packages/vue)

Vue components wrap core components using a composable pattern:

1. **Component Structure**:
- Each Vue component (e.g., `CCollapse.vue`) is a thin wrapper
- Uses corresponding composable (e.g., `useCollapse()`)
- Provides Vue-friendly API: props, emits, expose
- Supports `as` prop for custom element rendering
- Auto-generates stable IDs for accessibility

2. **Composables** (`src/composables/`):
- All composables extend `useParent()` base composable
- Create and manage core component instances
- Return reactive state + action methods
- Sync Vue reactive state with core component state via event listeners
- Use `markRaw()` for component instances to avoid reactivity overhead
- Use `shallowReactive()` for state to minimize reactivity

3. **Context System**:
- Uses Vue's provide/inject for component communication
- Context keys defined in `src/components/context.ts`
- Example: Collapse trigger components inject collapse ID from parent

## Development Guidelines

### Adding a New Component

1. **Core package**:
- Create component class extending `Parent` in `src/components/{name}.ts`
- Define Events enum and ComponentOptions interface
- Add CSS file in `src/css/{name}.css`
- Export from `src/index.ts`
- Add CSS export to `package.json` exports field
- Document in `docs/guide/{name}.md` (options, methods, events, data)

2. **Vue package**:
- Create composable in `src/composables/{name}.ts` extending `useParent()`
- Create component(s) in `src/components/C{Name}.vue`
- Add context key if needed in `src/components/context.ts`
- Export from `src/index.ts`
- Document component in `docs/guide/vue/components.md` (props, events, exposed)
- Document composable in `docs/guide/vue/composables.md` (list table, state section)

### Event Naming Convention

Custom events follow the pattern: `c.{componentName}.{eventName}`

Example: `c.collapse.show`, `c.collapse.hidden`, `c.drilldown.next`

Declare global event types:
```typescript
declare global {
interface HTMLElementEventMap extends Record<`c.component.${Events}`, CustomEvent<Component>> {}
}
```

### Accessibility Patterns

- Use `initAccessibilityAttrs()` to set ARIA attributes
- Common attributes: `aria-controls`, `aria-expanded`, `role="button"`
- Use `tabbable` package for focus management
- Utility functions in `src/utils/accessibility.ts` (focusFirst, focusLast, focusSibling, etc.)

### Animation Handling

- Use `getTransitionDuration()` from `src/utils/animation.ts` to respect CSS transitions
- Set collapsing/transitioning states during animations
- Clean up with `clearTimeout()` before new animations

## Important Notes

- Node.js 24 required
- pnpm is the package manager (use pnpm, not npm or yarn)
- Vue package has peer dependency on Vue >= 3.0.0
- Core components work in any JavaScript environment (no framework required)
- CSS is intentionally minimal for customization
Loading