@l3mpire/ui 2.5.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +211 -0
- package/USAGE.md +1025 -0
- package/dist/index.d.mts +584 -0
- package/dist/index.d.ts +584 -0
- package/dist/index.js +4339 -0
- package/dist/index.js.map +1 -0
- package/dist/index.mjs +4256 -0
- package/dist/index.mjs.map +1 -0
- package/package.json +80 -0
- package/src/styles/globals.css +524 -0
package/README.md
ADDED
|
@@ -0,0 +1,211 @@
|
|
|
1
|
+
# @l3mpire/ui
|
|
2
|
+
|
|
3
|
+
React component library for the lemDS design system. Built with **CVA** (Class Variance Authority), **Tailwind CSS v4**, and **Radix UI** primitives.
|
|
4
|
+
|
|
5
|
+
## Installation
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
pnpm add @l3mpire/ui @l3mpire/tokens @l3mpire/icons
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
Peer dependencies:
|
|
12
|
+
|
|
13
|
+
```bash
|
|
14
|
+
pnpm add react react-dom @l3mpire/icons
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
## Setup
|
|
18
|
+
|
|
19
|
+
### 1. Import the global stylesheet
|
|
20
|
+
|
|
21
|
+
In your app's root CSS file:
|
|
22
|
+
|
|
23
|
+
```css
|
|
24
|
+
@import "@l3mpire/ui/globals.css";
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
This file:
|
|
28
|
+
- Imports all design tokens as CSS custom properties
|
|
29
|
+
- Registers tokens with Tailwind CSS v4's `@theme`
|
|
30
|
+
- Sets up dark mode via `data-theme="dark"` custom variant
|
|
31
|
+
- Defines component animations
|
|
32
|
+
|
|
33
|
+
### 2. Configure Tailwind (if using Tailwind in your project)
|
|
34
|
+
|
|
35
|
+
Add the UI package to your content sources so Tailwind can scan component classes:
|
|
36
|
+
|
|
37
|
+
```css
|
|
38
|
+
@source "../node_modules/@l3mpire/ui/dist";
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
## Usage
|
|
42
|
+
|
|
43
|
+
```tsx
|
|
44
|
+
import { Button, Badge, TextInput, Toast } from "@l3mpire/ui";
|
|
45
|
+
import { Icon, faCheck } from "@l3mpire/icons";
|
|
46
|
+
|
|
47
|
+
function Example() {
|
|
48
|
+
return (
|
|
49
|
+
<>
|
|
50
|
+
<Button appearance="solid" intent="brand" size="md" leftIcon={faCheck}>
|
|
51
|
+
Confirm
|
|
52
|
+
</Button>
|
|
53
|
+
|
|
54
|
+
<Badge appearance="solid" intent="primary" size="md">
|
|
55
|
+
New
|
|
56
|
+
</Badge>
|
|
57
|
+
|
|
58
|
+
<TextInput
|
|
59
|
+
placeholder="Enter your email"
|
|
60
|
+
size="md"
|
|
61
|
+
/>
|
|
62
|
+
|
|
63
|
+
<Toast type="success" title="Saved!" description="Your changes have been saved." />
|
|
64
|
+
</>
|
|
65
|
+
);
|
|
66
|
+
}
|
|
67
|
+
```
|
|
68
|
+
|
|
69
|
+
## Components
|
|
70
|
+
|
|
71
|
+
### Actions
|
|
72
|
+
|
|
73
|
+
| Component | Variants | Description |
|
|
74
|
+
|-----------|----------|-------------|
|
|
75
|
+
| **Button** | `appearance`: solid, outlined, ghost | Primary action element |
|
|
76
|
+
| | `intent`: brand, alert | |
|
|
77
|
+
| | `size`: sm, md, lg | |
|
|
78
|
+
| **Link** | `variant`: brand, neutral | Text link with hover/pressed states |
|
|
79
|
+
|
|
80
|
+
### Data Display
|
|
81
|
+
|
|
82
|
+
| Component | Variants | Description |
|
|
83
|
+
|-----------|----------|-------------|
|
|
84
|
+
| **Avatar** | `size`: sm, md, lg, xl | User profile image with initials fallback |
|
|
85
|
+
| | `shape`: rounded, squared | |
|
|
86
|
+
| **Badge** | `appearance`: solid, light, outlined | Inline label / status indicator |
|
|
87
|
+
| | `intent`: primary, success, critical, warning, neutral | |
|
|
88
|
+
| **Tag** | `variant`: brand, neutral | Removable inline tag |
|
|
89
|
+
| **Tooltip** | `variant`: default, invert | Contextual hover tooltip |
|
|
90
|
+
|
|
91
|
+
### Feedback
|
|
92
|
+
|
|
93
|
+
| Component | Variants | Description |
|
|
94
|
+
|-----------|----------|-------------|
|
|
95
|
+
| **InfoMessage** | `type`: info, success, alert, warning, empty | Alert / notification banner |
|
|
96
|
+
| **Toast** | `type`: info, success, alert, warning | Notification toast |
|
|
97
|
+
|
|
98
|
+
### Forms
|
|
99
|
+
|
|
100
|
+
| Component | Description |
|
|
101
|
+
|-----------|-------------|
|
|
102
|
+
| **Checkbox** | Checkbox with label (Radix UI) |
|
|
103
|
+
| **InputLabel** | Form label with optional/mandatory indicator |
|
|
104
|
+
| **SearchBar** | Search input with magnifying glass icon |
|
|
105
|
+
| **Select** | Custom dropdown select with chevron |
|
|
106
|
+
| **Switch** | Toggle switch with label (Radix UI) |
|
|
107
|
+
| **TextArea** | Multi-line input with character counter |
|
|
108
|
+
| **TextInput** | Single-line input with icon and validation |
|
|
109
|
+
|
|
110
|
+
### Data
|
|
111
|
+
|
|
112
|
+
| Component | Description |
|
|
113
|
+
|-----------|-------------|
|
|
114
|
+
| **Table** | Low-level table primitives (Header, Body, Row, Cell, Caption) |
|
|
115
|
+
| **DataTable** | Data-driven table powered by TanStack Table |
|
|
116
|
+
| | Features: sorting, filtering, pagination, row selection, column resizing, column drag reorder |
|
|
117
|
+
| **DataTablePagination** | Pagination controls with page size selector |
|
|
118
|
+
| **EmptyState** | Placeholder with icon, title, description, and optional action |
|
|
119
|
+
| **Cell Renderers** | `AvatarCell`, `StatusCell`, `NumberCell`, `DateCell`, `EmailCell`, `LinkCell`, `ButtonCell`, `EditableCell` |
|
|
120
|
+
| **RowActions** | Hover-reveal action buttons for table rows |
|
|
121
|
+
|
|
122
|
+
### Navigation
|
|
123
|
+
|
|
124
|
+
| Component | Description |
|
|
125
|
+
|-----------|-------------|
|
|
126
|
+
| **DropdownMenu** | Menu with items, headings, sections, and clear action |
|
|
127
|
+
| **ProductLogo** | Product logo with optional text |
|
|
128
|
+
| **Sidebar** | Collapsible app sidebar with header, sections, footer |
|
|
129
|
+
| **SidebarItem** | Navigation item with icon, badge, avatar support |
|
|
130
|
+
| **SidebarHeadingItem** | Section heading label for sidebar |
|
|
131
|
+
| **Typography** | Text component with variant presets |
|
|
132
|
+
| **UserMenu** | User profile dropdown with info rows and sections |
|
|
133
|
+
|
|
134
|
+
## Component Patterns
|
|
135
|
+
|
|
136
|
+
### CVA Variants
|
|
137
|
+
|
|
138
|
+
All components use CVA for variant management:
|
|
139
|
+
|
|
140
|
+
```tsx
|
|
141
|
+
<Button appearance="solid" intent="brand" size="md">Click me</Button>
|
|
142
|
+
<Button appearance="ghost" intent="brand" size="sm">Cancel</Button>
|
|
143
|
+
```
|
|
144
|
+
|
|
145
|
+
### Polymorphic Rendering (`asChild`)
|
|
146
|
+
|
|
147
|
+
Components support the `asChild` prop via Radix UI's Slot, allowing you to render as any element:
|
|
148
|
+
|
|
149
|
+
```tsx
|
|
150
|
+
<Button asChild>
|
|
151
|
+
<a href="/dashboard">Go to Dashboard</a>
|
|
152
|
+
</Button>
|
|
153
|
+
```
|
|
154
|
+
|
|
155
|
+
### Icons in Components
|
|
156
|
+
|
|
157
|
+
Pass FontAwesome icon definitions directly:
|
|
158
|
+
|
|
159
|
+
```tsx
|
|
160
|
+
import { faPen, faTrash } from "@l3mpire/icons";
|
|
161
|
+
|
|
162
|
+
<Button leftIcon={faPen} size="md">Edit</Button>
|
|
163
|
+
<Button rightIcon={faTrash} intent="alert" size="md">Delete</Button>
|
|
164
|
+
<Button leftIcon={faPlus} iconOnly size="sm" />
|
|
165
|
+
```
|
|
166
|
+
|
|
167
|
+
### Dark Mode
|
|
168
|
+
|
|
169
|
+
Toggle dark mode by setting the `data-theme` attribute:
|
|
170
|
+
|
|
171
|
+
```html
|
|
172
|
+
<html data-theme="dark">
|
|
173
|
+
```
|
|
174
|
+
|
|
175
|
+
All component tokens automatically switch to their dark mode values.
|
|
176
|
+
|
|
177
|
+
## Utility: `cn()`
|
|
178
|
+
|
|
179
|
+
A `clsx` + `tailwind-merge` utility is exported for combining classes:
|
|
180
|
+
|
|
181
|
+
```tsx
|
|
182
|
+
import { cn } from "@l3mpire/ui";
|
|
183
|
+
|
|
184
|
+
<div className={cn("p-md rounded-base", isActive && "bg-blue-500")} />
|
|
185
|
+
```
|
|
186
|
+
|
|
187
|
+
## Exports
|
|
188
|
+
|
|
189
|
+
Every component exports its React component, CVA variants function (when applicable), and TypeScript props type:
|
|
190
|
+
|
|
191
|
+
```tsx
|
|
192
|
+
import {
|
|
193
|
+
Button,
|
|
194
|
+
buttonVariants, // CVA variants function
|
|
195
|
+
type ButtonProps, // TypeScript type
|
|
196
|
+
} from "@l3mpire/ui";
|
|
197
|
+
|
|
198
|
+
// Use buttonVariants() to get classes without rendering:
|
|
199
|
+
const classes = buttonVariants({ appearance: "solid", intent: "brand", size: "md" });
|
|
200
|
+
```
|
|
201
|
+
|
|
202
|
+
## Storybook
|
|
203
|
+
|
|
204
|
+
Browse the full component documentation with interactive examples:
|
|
205
|
+
|
|
206
|
+
```bash
|
|
207
|
+
# From the monorepo root
|
|
208
|
+
pnpm --filter @l3mpire/storybook dev
|
|
209
|
+
```
|
|
210
|
+
|
|
211
|
+
Opens at `http://localhost:6006`.
|