Skip to content

zanelab/zane-ui

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

74 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

@zanejs/ui

zanejs logo

npm version License: MIT Stencil

English | 中文

Introduction

A modern, lightweight native Web Components UI library built with Stencil.js. Framework-agnostic, works in JS/Vue/React/Angular projects, and provides complete TypeScript type support.

Features

  • Built with Stencil.js: Uses standard Web Components standards, compatible with any frontend framework
  • Framework-agnostic: Native Web Components, usable in any framework
  • Lightweight: Load on demand, minimized bundle size
  • Modern Design: Clean and beautiful interface design
  • TypeScript Support: Complete type definitions and intelligent code completion
  • Internationalization: Supports both Chinese and English
  • Responsive Design: Adapts to various screen sizes
  • Customizable Theme: Supports theme customization and configuration

Installation

npm

npm install @zanejs/ui

pnpm

pnpm add @zanejs/ui

yarn

yarn add @zanejs/ui

Quick Start

Basic Usage

Directly include in HTML file:

<!DOCTYPE html>
<html>
  <head>
    <script src="https://unpkg.com/@zanejs/ui@1.0.1/dist/zane-ui/zane-ui.esm.js"></script>
  </head>
  <body>
    <zane-button type="primary">Hello Zane UI</zane-button>
  </body>
</html>

Usage in Frameworks

React Example

import React from 'react';
import ReactDOM from 'react-dom';
import './index.css';
import App from './App';
import registerServiceWorker from './registerServiceWorker';

+ import { defineCustomElements } from '@zanejs/ui/loader';

ReactDOM.render(<App />, document.getElementById('root'));
registerServiceWorker();

+ defineCustomElements();

Vue Example

// src/main.ts

import { createApp } from 'vue'
import App from './App.vue';
+ import { defineCustomElements } from '@zanejs/ui/loader';

+ defineCustomElements();

createApp(App).mount('#app')

Modify vite.config.js for Vue compilation compatibility with custom elements:

import { defineConfig } from 'vite';

export default defineConfig({
  vue: {
    template: {
      compilerOptions: {
+        isCustomElement: tag => tag.startsWith('zane-')
      },
    },
  },
});

Available Components

Basic Components

  • Button - Button component with various styles and states
  • Input - Input component supporting multiple types
  • Tag - Tag component for labeling and selection
  • Avatar - Avatar component
  • Icon - Icon component
  • Link - Link component
  • Text - Text component

Form Components

Layout Components

Feedback Components

Other Components

🛠️ Development

Requirements

  • Node.js >= 18.x
  • pnpm >= 8.x

Install Dependencies

pnpm install

Development Mode

# Start development server (with hot reload)
pnpm run dev

Build Project

# Build production version
pnpm run build

# Generate documentation only
pnpm run build:docs-only

# Generate components
pnpm run generate

Run Tests

# Run all tests
pnpm run test

# Run tests in watch mode
pnpm run test.watch

Project Structure

zane-ui/
├── src/
│   ├── components/          # Component source code
│   │   ├── button/          # Button component
│   │   ├── input/           # Input component
│   │   ├── form/            # Form component
│   │   ├── ...              # Other components
│   ├── global/              # Global configuration
│   │   ├── theme/           # Theme styles
│   │   └── store.ts         # Global state
│   ├── utils/               # Utility functions
│   ├── hooks/               # Custom Hooks
│   ├── types/               # TypeScript type definitions
│   ├── locale/              # Internationalization language packs
│   └── index.ts             # Entry file
├── dist/                    # Build output directory
├── loader/                  # Dynamic loader
├── www/                     # Example pages
└── stencil.config.ts        # Stencil configuration file

Theme Customization

The project supports theme customization. You can customize themes by modifying SCSS files in the src/global/theme/ directory:

// Custom theme variables
:root {
  --zane-primary-color: #1890ff;
  --zane-success-color: #52c41a;
  --zane-warning-color: #faad14;
  --zane-danger-color: #f5222d;
}

Internationalization

The project has built-in Chinese and English support. You can configure globally using the zane-config-provider component:

<zane-config-provider locale="zh-cn">
  <App />
</zane-config-provider>

<zane-config-provider locale="en">
  <App />
</zane-config-provider>

Contribution Guidelines

We welcome all forms of contributions! Whether it's reporting bugs, suggesting features, or contributing code.

  1. Fork this project
  2. Create your feature branch (git checkout -b feature/AmazingFeature)
  3. Commit your changes (git commit -m 'Add some AmazingFeature')
  4. Push to the branch (git push origin feature/AmazingFeature)
  5. Open a Pull Request

License

This project is open-sourced under the MIT license.

Acknowledgments

Thanks to the following open-source projects:

Contact Us


If this project helps you, please give us a ⭐️!

About

A modern, lightweight native Web Components UI library built with Stencil.js. Framework-agnostic – works seamlessly in JS/Vue/React/Angular projects with full TypeScript support.

Topics

Resources

Stars

Watchers

Forks

Releases

Packages

Contributors

Languages