Skip to content

MilosTanaskovic/ComponentKit

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

3 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

ComponentKit

Framework-agnostic Web Components library built with TypeScript. Copy and paste components into your project - no npm install required.

License: MIT TypeScript

✨ Features

  • 🎯 Framework Agnostic - Works with React, Vue, Angular, Svelte, or vanilla JavaScript
  • πŸ“‹ Copy & Paste - No npm packages, full code ownership
  • πŸ’ͺ TypeScript First - Complete type safety
  • 🎨 Fully Customizable - Own and modify the code
  • πŸš€ Zero Dependencies - Pure Web Components
  • β™Ώ Accessible - Built with ARIA attributes and keyboard navigation

πŸš€ Quick Start

Prerequisites

  • Node.js 16+ and npm
  • TypeScript knowledge (optional but recommended)

Installation

# Clone the repository
git clone https://github.com/yourusername/componentkit.git
cd componentkit

# Install dependencies
npm install

# Build TypeScript files
npm run build

# Start development server
npm run serve

Open http://localhost:3000/public/index.html in your browser.

πŸ“ Project Structure

componentkit/
β”œβ”€β”€ src/
β”‚   β”œβ”€β”€ components/          # Web Component source files
β”‚   β”‚   β”œβ”€β”€ button/
β”‚   β”‚   β”‚   β”œβ”€β”€ ck-button.ts
β”‚   β”‚   β”‚   β”œβ”€β”€ ck-button.styles.ts
β”‚   β”‚   β”‚   └── index.ts
β”‚   β”‚   β”œβ”€β”€ card/
β”‚   β”‚   β”œβ”€β”€ modal/
β”‚   β”‚   └── index.ts        # Main component registry
β”‚   β”œβ”€β”€ styles/              # Global CSS files
β”‚   β”‚   β”œβ”€β”€ variables.css   # CSS custom properties
β”‚   β”‚   β”œβ”€β”€ global.css      # Global styles
β”‚   β”‚   └── components.css  # Component page styles
β”‚   β”œβ”€β”€ types/               # TypeScript type definitions
β”‚   β”‚   └── component-types.ts
β”‚   └── utils/               # Utility functions
β”‚       └── register-components.ts
β”œβ”€β”€ public/                  # Static HTML pages
β”‚   β”œβ”€β”€ index.html          # Landing page
β”‚   β”œβ”€β”€ components.html     # Component documentation
β”‚   └── assets/             # Images, icons, etc.
β”œβ”€β”€ dist/                    # Compiled JavaScript (generated)
β”œβ”€β”€ docs/                    # Component documentation
β”œβ”€β”€ package.json
β”œβ”€β”€ tsconfig.json
└── README.md

🎯 Usage

Using a Component

  1. Browse Components: Visit /public/components.html to see all available components
  2. Copy the Code: Click the "Copy" button to get the TypeScript source
  3. Paste into Your Project: Add the component files to your project
  4. Customize: Modify styles and behavior as needed

Example: Adding a Button

// Import and use the button component
import './components/button';

// In your HTML
Click Me

// With JavaScript
const button = document.querySelector('ck-button');
button.addEventListener('ck-click', () => {
  console.log('Button clicked!');
});

πŸ“š Available Components

Button

Customizable button with multiple variants (primary, secondary, outline)

Primary Button
Secondary Button
Outline Button

Card

Flexible card layout with header, content, and footer slots

  Card Title
  Card content goes here
  
    Action
  

Modal

Dialog component with backdrop overlay

  Modal Title
  Modal content
  
    Close
  



  const modal = document.querySelector('#myModal');
  modal.open();  // Opens the modal
  modal.close(); // Closes the modal

πŸ› οΈ Development

Watch Mode

Automatically rebuild on file changes:

npm run dev

Build for Production

Compile TypeScript to JavaScript:

npm run build

Local Development Server

Serve the project locally:

npm run serve

🎨 Customization

Styling Components

Each component has its styles defined in a separate .styles.ts file. Modify these to customize appearance:

// src/components/button/ck-button.styles.ts
export const buttonStyles = `
  button {
    /* Your custom styles */
  }
`;

CSS Variables

Customize the color scheme by modifying src/styles/variables.css:

:root {
  --ck-primary: #6366f1;
  --ck-primary-hover: #4f46e5;
  /* ... more variables */
}

🀝 Contributing

Contributions are welcome! Follow these steps:

  1. Fork the repository
  2. Create a feature branch (git checkout -b feature/amazing-component)
  3. Follow the existing component structure
  4. Add documentation for your component
  5. Commit your changes (git commit -m 'Add amazing component')
  6. Push to the branch (git push origin feature/amazing-component)
  7. Open a Pull Request

Adding a New Component

  1. Create a new folder: src/components/your-component/
  2. Add three files:
    • your-component.ts - Component logic
    • your-component.styles.ts - Component styles
    • index.ts - Export and registration
  3. Register in src/components/index.ts
  4. Add documentation to public/components.html

πŸ“– Documentation

Full documentation is available at /public/components.html when running the development server.

πŸ§ͺ Browser Support

ComponentKit uses native Web Components and requires:

  • Chrome/Edge 67+
  • Firefox 63+
  • Safari 10.1+
  • Opera 54+

For older browsers, consider using webcomponents.js polyfills.

πŸ“„ License

This project is licensed under the MIT License - see the LICENSE file for details.

πŸ™ Acknowledgments

Inspired by shadcn/ui - the copy-paste component library approach for React.

πŸ“ž Support

  • πŸ“« Create an issue for bug reports or feature requests
  • πŸ’¬ Start a discussion for questions or ideas
  • ⭐ Star this repo if you find it helpful!

Built with ❀️ using Web Components and TypeScript

About

Framework agnostic Web Components you can copy and paste into your apps. Built with TypeScript and native Web Standards.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors