0.18.0 โ€ข Published 5 months ago

@mohammadbekran/fancy-ui v0.18.0

Weekly downloads
-
License
MIT
Repository
github
Last release
5 months ago

Fancy UI

Version License: MIT PRs Welcome

A modern, accessible, and highly customizable React component library built with TypeScript and Tailwind CSS.

Overview

Fancy UI is a production-ready component library designed for building modern web applications. It provides a comprehensive set of accessible, performant, and customizable UI components that follow the latest web standards and best practices.

Key Features

  • ๐ŸŽจ Modern Design System: Clean, consistent, and professional-looking components
  • โ™ฟ Accessibility First: WCAG 2.1 compliant with full keyboard navigation and screen reader support
  • ๐Ÿš€ Performance Optimized: Minimal bundle size and optimized rendering
  • ๐Ÿ› ๏ธ Developer Experience: TypeScript support, comprehensive documentation, and Storybook integration
  • ๐Ÿงช Quality Assurance: Extensive test coverage and strict type checking

Core Components

Button

import { Button } from "@mohammadbekran/fan wecy-ui";

// Primary button with loading state
<Button
  variant="primary"
  isLoading={true}
  onClick={() => console.log('clicked')}
>
  Submit
</Button>

// Secondary button with icon
<Button
  variant="secondary"
  leftIcon={<IconComponent />}
>
  Download
</Button>

// Ghost button with right icon
<Button
  variant="ghost"
  rightIcon={<IconComponent />}
>
  Learn More
</Button>

Calendar

import { Calendar } from "@mohammadbekran/fancy-ui";

// Basic date picker
<Calendar
  value={date}
  onChange={setDate}
/>

// Range selection with custom styling
<Calendar
  mode="range"
  value={dateRange}
  onChange={setDateRange}
  className="custom-calendar"
/>

Modal

import { Modal } from "@mohammadbekran/fancy-ui";

<Modal title="Confirmation" isOpen={isOpen} onClose={() => setIsOpen(false)} size="md">
  <div className="p-4">
    <p>Are you sure you want to proceed?</p>
    <div className="flex justify-end gap-2 mt-4">
      <Button variant="ghost" onClick={() => setIsOpen(false)}>
        Cancel
      </Button>
      <Button variant="primary" onClick={handleConfirm}>
        Confirm
      </Button>
    </div>
  </div>
</Modal>;

Getting Started

Installation

# Using npm
npm install @mohammadbekran/fancy-ui

# Using yarn
yarn add @mohammadbekran/fancy-ui

# Using pnpm
pnpm add @mohammadbekran/fancy-ui

Configuration

Vite Projects

  1. First, install Tailwind CSS if you haven't already:
npm install -D tailwindcss postcss autoprefixer
npx tailwindcss init -p
  1. Add the following imports to your src/index.css:
@import "tailwindcss";

@source "../node_modules/@mohammadbekran/fancy-ui/dist/**/*.{js,ts,jsx,tsx}";
@import "../node_modules/@mohammadbekran/fancy-ui/dist/fancy-ui.css";

Next.js Projects

  1. Install Tailwind CSS if you haven't already:
npm install -D tailwindcss postcss autoprefixer
npx tailwindcss init -p
  1. Add the following imports to your app/globals.css or styles/globals.css:
@import "tailwindcss";

@source "../../node_modules/@mohammadbekran/fancy-ui/**/*.{js,ts,jsx,tsx}";
@import "../../node_modules/@mohammadbekran/fancy-ui/dist/fancy-ui.css";

Usage

Import components directly from the package:

import { Button, Calendar, Modal } from "@mohammadbekran/fancy-ui";

function App() {
  return (
    <div>
      <Button variant="primary">Click me</Button>
      <Calendar />
      <Modal>Content</Modal>
    </div>
  );
}

TypeScript Support

The library is built with TypeScript and includes comprehensive type definitions. All components are fully typed, providing excellent IDE support and type safety.

Browser Support

  • Chrome (latest)
  • Firefox (latest)
  • Safari (latest)
  • Edge (latest)

Performance Considerations

  • Components are tree-shakeable, ensuring minimal bundle size
  • CSS is optimized and purged in production builds
  • Components use React.memo where appropriate for optimal rendering performance

Development

Prerequisites

  • Node.js 18+
  • pnpm 8+
  • Git

Setup

# Clone the repository
git clone https://github.com/MohammadBekran/fancy-ui.git

# Install dependencies
pnpm install

# Start development server
pnpm dev

# Run Storybook
pnpm storybook

Available Scripts

ScriptDescription
pnpm devStart development server
pnpm buildBuild the library
pnpm testRun tests
pnpm test-coverageGenerate test coverage report
pnpm storybookStart Storybook
pnpm lintRun ESLint
pnpm formatFormat code with Prettier

Project Structure

fancy-ui/
โ”œโ”€โ”€ src/
โ”‚   โ”œโ”€โ”€ app/              # Application entry point
โ”‚   โ”œโ”€โ”€ assets/           # Static assets (images)
โ”‚   โ”œโ”€โ”€ components/       # Shared UI components
โ”‚   โ”‚   โ””โ”€โ”€ spinner.tsx   # Loading spinner component
โ”‚   โ”œโ”€โ”€ core/            # Core utilities and configurations
โ”‚   โ”œโ”€โ”€ features/        # Feature-specific components
โ”‚   โ”‚   โ”œโ”€โ”€ button/      # Button component and its variants
โ”‚   โ”‚   โ”œโ”€โ”€ calendar/    # Calendar component
โ”‚   โ”‚   โ”œโ”€โ”€ input/       # Input component
โ”‚   โ”‚   โ””โ”€โ”€ modal/       # Modal component
โ”‚   โ”œโ”€โ”€ test/           # Test utilities and setup
โ”‚   โ”œโ”€โ”€ index.css       # Global styles
โ”‚   โ””โ”€โ”€ main.tsx        # Application entry point
โ”œโ”€โ”€ .storybook/         # Storybook configuration
โ”œโ”€โ”€ public/            # Public static assets
โ”œโ”€โ”€ .husky/           # Git hooks configuration
โ”œโ”€โ”€ vitest.config.ts  # Vitest configuration
โ”œโ”€โ”€ vite.config.ts    # Vite configuration
โ”œโ”€โ”€ tsconfig.json     # TypeScript configuration
โ””โ”€โ”€ package.json      # Project dependencies and scripts

Testing

The library uses Vitest and React Testing Library for comprehensive testing:

# Run all tests
pnpm test

# Run tests with coverage
pnpm test-coverage

# Run tests with UI
pnpm test:ui

Contributing

We welcome contributions! Please follow these steps:

  1. Fork the repository
  2. Create your feature branch (git checkout -b feature/amazing-feature)
  3. Commit your changes (git commit -m 'feat: add amazing feature')
  4. Push to the branch (git push origin feature/amazing-feature)
  5. Open a Pull Request

Commit Convention

We follow the Conventional Commits specification:

  • feat: - New feature
  • fix: - Bug fix
  • docs: - Documentation changes
  • style: - Code style changes
  • refactor: - Code refactoring
  • test: - Adding or modifying tests
  • chore: - Maintenance tasks

Performance

Fancy UI is optimized for performance:

  • Tree-shakeable components
  • Minimal runtime overhead
  • Optimized bundle size
  • Efficient re-rendering
  • Lazy loading support

Browser Support

  • Chrome (latest)
  • Firefox (latest)
  • Safari (latest)
  • Edge (latest)

License

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

Acknowledgments

Support

For support, please:

  • Open an issue on GitHub
  • Check the documentation

Built with โค๏ธ by Mohammad Bekran

0.18.0

5 months ago

0.17.0

5 months ago

0.16.0

5 months ago

0.15.0

5 months ago

0.14.0

5 months ago

0.12.0

5 months ago

0.11.0

5 months ago

0.10.0

5 months ago

0.9.0

5 months ago

0.8.0

5 months ago

0.7.0

5 months ago

0.5.0

5 months ago

0.4.0

5 months ago

0.3.0

5 months ago

0.2.0

5 months ago

0.1.0

5 months ago