Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
19 commits
Select commit Hold shift + click to select a range
cf752fb
feat: migrate to pnpm workspace
Leioy Apr 11, 2025
e0efb26
feat:unit test tool migrate to vitest,testing-library and add new docs
Leioy Apr 14, 2025
15b48a3
fix: standardize peer dependencies and resolve TypeScript issues
Leioy Nov 21, 2025
6e28ee4
fix: eslint errors
Leioy Nov 21, 2025
bcc2c12
chore: upgrade outdated dependencies to latest versions
Leioy Nov 21, 2025
56362e2
feat: Refactor TypeScript configurations to separate type checking fr…
Leioy Nov 28, 2025
249f898
feat: Add comprehensive test coverage for numerous components, update…
Leioy Dec 3, 2025
029e741
docs: Update component and hook documentation, refactor icon usage, a…
Leioy Dec 11, 2025
c2f9119
chore: update ESLint configuration to ignore the docusaurus directory…
Leioy Dec 11, 2025
a8dbbc7
feat: Remove blog functionality, update site branding with new logos …
Leioy Dec 11, 2025
6a4ff93
chore: update pnpm dependencies
Leioy Dec 11, 2025
19673f7
chore: rename package name to docusaurus
Leioy Dec 11, 2025
2fde3d3
chore: Change Docusaurus baseUrl from `/kube-design/` to `/`
Leioy Dec 11, 2025
be4ed71
fix: adjust dropdown menu CSS to resolve hover issues
Leioy Dec 12, 2025
08ace4b
feat: add docsearch
Leioy Dec 12, 2025
055d252
feat: Add ESM output for icons and migrate Storybook to Vite builder …
Leioy Dec 29, 2025
b74ea2e
feat: Update docs build/start scripts to reference docusaurus directo…
Leioy Dec 29, 2025
9ec36a9
Merge branch 'master' of upstream into migrate-tools
Leioy Dec 30, 2025
7afc7ee
chore: Update pnpm lockfile to reflect dependency changes
Leioy Dec 30, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
1 change: 1 addition & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,4 @@ public
.cache
.eslintrc.js
*.d.ts
docusaurus/
46 changes: 45 additions & 1 deletion .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@ module.exports = {
extends: ['airbnb-typescript', 'plugin:jest/recommended', 'plugin:prettier/recommended'],
plugins: ['prettier', '@typescript-eslint', 'jest'],
parserOptions: {
project: './tsconfig.json',
project: ['./packages/*/tsconfig.json'],
tsconfigRootDir: __dirname,
},

env: {
Expand All @@ -12,7 +13,45 @@ module.exports = {
'jest/globals': true,
},

settings: {
jest: {
version: 27,
},
},

overrides: [
{
files: ['*.story.tsx', '*.story.ts'],
parserOptions: {
project: null,
},
rules: {
'@typescript-eslint/dot-notation': 'off',
'@typescript-eslint/no-implied-eval': 'off',
'@typescript-eslint/no-throw-literal': 'off',
'@typescript-eslint/return-await': 'off',
},
},
{
files: ['scripts/**/*.ts', 'configs/**/*.ts'],
parserOptions: {
project: null,
},
rules: {
'@typescript-eslint/dot-notation': 'off',
'@typescript-eslint/no-implied-eval': 'off',
'@typescript-eslint/no-throw-literal': 'off',
'@typescript-eslint/return-await': 'off',
},
},
],
Comment on lines +22 to +47

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

The parserOptions and rules in these two overrides blocks are identical. To improve maintainability and reduce duplication, you can merge them into a single block by combining the files arrays.

  overrides: [
    {
      files: ['*.story.tsx', '*.story.ts', 'scripts/**/*.ts', 'configs/**/*.ts'],
      parserOptions: {
        project: null,
      },
      rules: {
        '@typescript-eslint/dot-notation': 'off',
        '@typescript-eslint/no-implied-eval': 'off',
        '@typescript-eslint/no-throw-literal': 'off',
        '@typescript-eslint/return-await': 'off',
      },
    },
  ],


rules: {
// Disable deprecated rules
'react/jsx-filename-extension': 'off',
'import/extensions': 'off',
'jsx-a11y/click-events-have-key-events': 'off',

'max-len': [
'error',
100,
Expand Down Expand Up @@ -53,6 +92,11 @@ module.exports = {
// disabled for condition && someFunc()
'no-unused-expressions': 'off',

// Disable deprecated/removed rules in newer ESLint versions
'react/prop-types': 'off',
'react/no-unused-prop-types': 'off',
'react/button-has-type': 'off',

// backend developers like _, no need to transform data all the time
camelcase: 'off',

Expand Down
51 changes: 51 additions & 0 deletions .github/workflows/docsearch.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
name: Update Algolia DocSearch Index

on:
# 1. Automatically triggered on push to main branch (most common)
push:
branches:
- main
- master # Add master branch if you use it

# 2. Manual trigger (important!)
workflow_dispatch:
# Optional: Add an input field for manually entering the site URL (remove these lines if not needed)
inputs:
site_url:
description: 'Site URL (defaults to start_urls from config)'
required: false
default: ''

jobs:
algolia:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Read docsearch.json configuration
id: algolia_config
run: |
CONFIG=$(cat docusaurus/algolia-crawler-config.json | jq -c .)
echo "config=$CONFIG" >> $GITHUB_OUTPUT

- name: Override start_urls in config if URL is manually entered (optional feature)
if: github.event.inputs.site_url != ''
run: |
NEW_CONFIG=$(jq --arg url "${{ github.event.inputs.site_url }}" \
'.start_urls[0].url = $url' docsearch.json)
echo "$NEW_CONFIG" > docsearch.json.tmp
mv docsearch.json.tmp docsearch.json
echo "Replaced with manually entered URL: ${{ github.event.inputs.site_url }}"

- name: Run Algolia official crawler
env:
APPLICATION_ID: ${{ secrets.APPLICATION_ID }} # Your Application ID
API_KEY: ${{ secrets.API_KEY }} # Your Admin API Key (write permission)
CONFIG: ${{ steps.algolia_config.outputs.config }}
run: |
docker run --rm \
--env APPLICATION_ID=${APPLICATION_ID} \
--env API_KEY=${API_KEY} \
--env "CONFIG=${CONFIG}" \
algolia/docsearch-scraper
5 changes: 4 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -37,4 +37,7 @@ docs/.next
!docs/lib

# history
.history/
.history/

**/__snapshots__/
coverage/
4 changes: 4 additions & 0 deletions .npmrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
shamefully-hoist=true
strict-peer-dependencies=false
auto-install-peers=true
node-linker=hoisted
179 changes: 179 additions & 0 deletions CLAUDE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,179 @@
# CLAUDE.md

This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.

## Project Overview

Kube Design is a comprehensive React component library originally built for KubeSphere Console, featuring components, hooks, and icons. The project uses a monorepo structure with multiple packages and documentation platforms.

## Architecture

### Monorepo Structure
- **Packages**: Located in `/packages/` with individual build configurations
- **Documentation**: Multiple platforms (Next.js docs, Nextra, Astro)
- **Build System**: Custom TypeScript/Rollup-based build with ESM/CJS output
- **Testing**: Vitest with React Testing Library and jest-axe for accessibility

### Key Packages
- `@kubed/components` - Main React component library (50+ components)
- `@kubed/icons` - Icon system with generation pipeline
- `@kubed/hooks` - React utility hooks
- `@kubed/charts` - Chart components
- `@kubed/code-editor` - Code editor component
- `@kubed/diff-viewer` - Diff viewer component
- `@kubed/log-viewer` - Log viewer component

## Development Commands

### Core Commands
```bash
# Install dependencies
pnpm install

# Build all packages
pnpm build:all

# Build specific package
pnpm build components

# Development with live reload
pnpm storybook # Storybook on port 7001
pnpm start:docs # Next.js docs development

# Linting and Type Checking
pnpm lint # ESLint for all packages
pnpm typecheck # TypeScript checking
pnpm test # Run all tests + syncpack

# Testing
pnpm test:watch # Watch mode testing
pnpm test:coverage # Coverage reports
pnpm test:ui # Vitest UI interface
```

### Package-Specific Commands
```bash
# Build individual packages
pnpm build components # Build components package
pnpm build icons # Build icons package
pnpm build:docs # Build documentation

# Generate documentation
pnpm docs:docgen # Auto-generate component docs
```

## Build System

### Build Configuration
- **Output Formats**: ESM (`esm/`), CJS (`cjs/`), TypeScript definitions (`lib/`)
- **Builder**: Custom TypeScript/Rollup configuration in `/scripts/`
- **Source**: Each package has `src/` → builds to `esm/` + `cjs/` + `lib/`

### Build Options
```bash
# Available build flags
--analyze # Generate bundle analysis
--sourcemap # Include source maps (default: true)
--minify # Minify UMD files (default: false)
--formats # Output formats: es, cjs (default: both)
```

## Testing

### Test Setup
- **Framework**: Vitest with React Testing Library
- **Environment**: jsdom with styled-components support
- **Accessibility**: jest-axe for a11y testing
- **Coverage**: Reports in HTML, JSON, and text formats

### Test Patterns
- Component tests: `*.test.tsx` alongside components
- Story files: `*.story.tsx` for Storybook
- Test utilities: `@kubed/tests` package with shared helpers

### Running Tests
```bash
# Single test file
vitest run Button.test.tsx

# Test with coverage for specific package
vitest run --coverage.include="packages/components/src/Button/**/*"

# Test specific pattern
vitest run Alert
```

## Documentation Platforms

### 1. Next.js Documentation (`/docs/`)
- **Tech**: Next.js 14 with MDX, i18n support
- **Run**: `pnpm start:docs` (port 3000)
- **Build**: `pnpm build:docs`

### 2. Nextra Documentation (`/nextra/`)
- **Tech**: Next.js 15 with Nextra 4
- **Run**: `pnpm dev` from /nextra directory
- **Features**: Pagefind search, Tailwind CSS

### 3. Astro Documentation (`/astro/`)
- **Tech**: Astro with React components
- **Run**: `pnpm dev` from /astro directory

## Package Development

### Creating New Components
1. Create component in `packages/components/src/[ComponentName]/`
2. Add `.story.tsx` for Storybook
3. Add `.test.tsx` for tests
4. Export from `packages/components/src/index.ts`
5. Run `pnpm build components` to build

### Component Structure
```
ComponentName/
├── ComponentName.tsx # Main component
├── ComponentName.styles.ts # Styled components
├── ComponentName.story.tsx # Storybook story
├── ComponentName.test.tsx # Component tests
└── index.ts # Re-export
```

### Icon System
- **Source**: SVG files in `packages/icons/source/`
- **Generation**: `pnpm build icons` generates React components
- **Output**: Multiple icon sets (fill, duotone variants)

## Tooling

### Dependencies
- **Package Manager**: pnpm with workspace support
- **Styling**: styled-components with theme system
- **TypeScript**: Strict mode with ES2015 target
- **Linting**: ESLint with Airbnb config + TypeScript
- **Formatting**: Prettier

### Configuration Files
- **TypeScript**: `tsconfig.base.json` (base), individual package configs
- **Build**: `scripts/utils/build-package.ts` (shared build logic)
- **Testing**: `vitest.config.ts` (test configuration)
- **Linting**: ESLint config at root level

## Environment Setup

### Node.js Requirements
- Node.js 16+ (recommended: latest LTS)
- pnpm 8+ (package manager)

### IDE Integration
- TypeScript path mapping configured for `@kubed/*` packages
- Storybook for component development
- Vitest for test running

## Common Development Flow

1. **Start development**: `pnpm storybook` for component work
2. **Create component**: Add to `packages/components/src/`
3. **Test**: `pnpm test:watch` for TDD
4. **Build**: `pnpm build [package]` to verify builds
5. **Document**: Update MDX files in `/docs/` or `/nextra/`
6. **Check**: `pnpm lint && pnpm typecheck` before commit
26 changes: 9 additions & 17 deletions configs/.storybook/main.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import { dirname, join } from 'path';
/* eslint-disable no-param-reassign */
const path = require('path');
const TsconfigPathsPlugin = require('tsconfig-paths-webpack-plugin').default;

module.exports = {
stories: [
Expand All @@ -10,34 +9,27 @@ module.exports = {
],

addons: [
getAbsolutePath('storybook-addon-turbo-build'),
getAbsolutePath('@storybook/addon-docs'),
],

typescript: {
reactDocgen: true,
},

webpackFinal: async (config) => {
config.resolve = {
...config.resolve,
plugins: [
...(config.resolve.plugins || []),
new TsconfigPathsPlugin({
extensions: ['.ts', '.tsx', '.js'],
configFile: path.join(__dirname, '../../tsconfig.json'),
}),
],
async viteFinal(config) {
// Ensure ESM resolution for monorepo packages
config.resolve = config.resolve || {};
config.resolve.alias = {
...config.resolve.alias,
'@kubed/icons': path.resolve(__dirname, '../../packages/icons/dist/index.mjs'),
'@kubed/components': path.resolve(__dirname, '../../packages/components/src'),
'@kubed/hooks': path.resolve(__dirname, '../../packages/hooks/src'),
};

// Turn off docgen plugin as it breaks bundle with displayName
// config.plugins.pop();

return config;
},

framework: {
name: getAbsolutePath('@storybook/nextjs'),
name: getAbsolutePath('@storybook/react-vite'),
options: {},
},

Expand Down
8 changes: 0 additions & 8 deletions configs/jest/enzyme.setup.js

This file was deleted.

13 changes: 0 additions & 13 deletions configs/jest/jsdom.mocks.js

This file was deleted.

Loading
Loading