@gingersnap/toolbox
Version:
A comprehensive Vue 3 component library with Tailwind CSS integration, built with JavaScript
244 lines (187 loc) ⢠6.29 kB
Markdown
# @gingersnap/toolbox
A comprehensive Vue 3 component library designed for modern admin interfaces and enterprise applications. Built with Tailwind CSS and featuring a complete design system.
## šÆ Overview
The Workbench Toolbox provides enterprise-grade UI components, design tokens, and composables specifically designed for admin platforms and internal tools. This library emphasizes developer experience, accessibility, and consistent design patterns.
## š¦ Installation
```bash
npm install @gingersnap/toolbox
# or
yarn add @gingersnap/toolbox
# or
pnpm add @gingersnap/toolbox
```
### Peer Dependencies
```bash
npm install vue@^3.4.0 reka-ui@^2.3.0 lucide-vue-next@^0.525.0
```
## š Quick Start
```vue
<template>
<div>
<!-- Use the enhanced modal component -->
<TbModal v-model:show="showModal" title="Enhanced Modal" size="lg">
<p>This modal has enhanced TypeScript support and better API</p>
<template #actions>
<button @click="showModal = false">Close</button>
</template>
</TbModal>
<!-- Use curated icons -->
<Edit :size="16" class="text-primary" />
<!-- Use toast notifications -->
<button @click="toast.success('Operation completed!')">
Show Toast
</button>
</div>
</template>
<script setup>
import { ref } from 'vue'
import { TbModal, Edit, useToast } from '@gingersnap/toolbox'
import '@gingersnap/toolbox/style.css'
const showModal = ref(false)
const { toast } = useToast()
</script>
```
## š Package Structure
```
packages/toolbox/
āāā src/
ā āāā components/
ā ā āāā foundations/ # Core components (TbModal, TbSelect, etc.)
ā ā āāā patterns/ # Layout components (TbBreadcrumb, etc.)
ā ā āāā feedback/ # User feedback (TbToast, etc.)
ā āāā composables/ # Vue composables (useToast, etc.)
ā āāā icons/ # Curated Lucide icon exports
ā āāā tokens/ # Design tokens and Tailwind preset
ā āāā styles/ # Base styles and CSS
āāā dist/ # Built library files
āāā docs/ # Component documentation
```
## šØ Design System Features
### Semantic Colors
- **Primary**: Sky-based palette for main actions
- **Secondary**: Gray-based palette for secondary actions
- **Success**: Emerald-based palette for positive feedback
- **Danger**: Red-based palette for destructive actions
Each color includes variants: `DEFAULT`, `hover`, `focus`, `light`, `muted`
### Typography
- **Font**: Inter font family with web font loading
- **Scales**: Consistent text sizing and line heights
### Layout
- **Radius**: `rounded-base` for consistent border radius
- **Shadow**: `shadow-base` for consistent drop shadows
- **Spacing**: Tailwind's spacing scale
## š§© Components
### TbModal
Enhanced modal component with TypeScript support and advanced features:
```vue
<TbModal
v-model:show="isOpen"
title="Modal Title"
description="Optional description"
size="lg"
variant="default"
:allow-close="true"
:persistent="false"
animation="scale"
>
<p>Modal content</p>
<template #actions>
<button @click="isOpen = false">Cancel</button>
<button @click="handleSave">Save</button>
</template>
</TbModal>
```
**Props:**
- `show: boolean` - Controls modal visibility
- `size: 'sm' | 'md' | 'lg' | 'xl' | 'full'` - Modal size
- `variant: 'default' | 'destructive'` - Visual variant
- `animation: 'scale' | 'slide' | 'fade'` - Animation type
- `persistent: boolean` - Prevents closing on outside click/escape
## š§ Composables
### useToast()
Toast notification system with TypeScript support:
```javascript
import { useToast } from '@gingersnap/toolbox'
const { success, danger, primary, secondary, show, remove, clear } = useToast()
// Convenience methods
success('Operation completed!')
danger('Something went wrong!')
// Custom toast
show({
type: 'primary',
title: 'Custom Title',
message: 'Custom message',
duration: 5000,
persistent: false
})
```
## š Icons
Curated selection of Lucide icons organized by category:
```javascript
import {
// Navigation
ChevronDown, ChevronUp, ArrowLeft, ArrowRight,
// Actions
Edit, Trash2, Save, RefreshCw,
// Status
Check, CheckCircle, AlertCircle, Info,
// Utility
Search, Filter, Download, Upload
} from '@gingersnap/toolbox'
```
## šØ Tailwind Integration
Include the Tailwind preset in your configuration:
```javascript
// tailwind.config.js
import { tailwindPreset } from '@gingersnap/toolbox'
export default {
presets: [tailwindPreset],
content: [
'./src/**/*.{vue,js,ts}',
'./node_modules/@gingersnap/toolbox/dist/**/*.js'
]
}
```
## šļø Development
```bash
# Install dependencies
npm install
# Start development server
npm run dev
# Build library
npm run build
# Type checking
npm run typecheck
```
## š Build Output
The library builds to multiple formats:
- **ES Modules** (`toolbox.es.js`) - For modern bundlers
- **UMD** (`toolbox.umd.js`) - For legacy support and CDN usage
- **CSS** (`style.css`) - Complete design system styles
- **TypeScript** (`*.d.ts`) - Full type declarations
## š Integration with Main App
The toolbox can be used alongside existing Base components:
```vue
<!-- Existing BaseModal continues to work -->
<BaseModal v-model:show="showOld" size="md">
<p>Legacy modal</p>
</BaseModal>
<!-- Enhanced TbModal with new features -->
<TbModal v-model:show="showNew" variant="destructive" animation="slide">
<p>Enhanced modal with better API</p>
</TbModal>
```
## š Roadmap
- [ ] Complete component migration (TbSelect, TbToast, etc.)
- [ ] Enhanced documentation with live examples
- [ ] Storybook integration for component playground
- [ ] NPM publication for external use
- [ ] Advanced theming system with CSS custom properties
## š¤ Contributing
1. Components should maintain consistency with existing Base components
2. All components must include TypeScript support
3. Follow the established naming convention: `Tb` prefix
4. Include comprehensive prop interfaces and emit types
5. Maintain backward compatibility when possible
## š License
MIT License - See LICENSE file for details