@nozle-js/react 0.5.2 → 0.5.3
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 +88 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -169,6 +169,92 @@ function AfterPayment({ planCode }: { planCode: string }) {
|
|
|
169
169
|
|
|
170
170
|
Pre-built UI components with built-in styling. No CSS imports needed.
|
|
171
171
|
|
|
172
|
+
### `PricingTable`
|
|
173
|
+
|
|
174
|
+
Renders plan cards in a responsive grid with monthly/annual toggle, current plan detection, and CSS variable theming. Auto-fetches plans from the API if none are provided.
|
|
175
|
+
|
|
176
|
+
```tsx
|
|
177
|
+
import { PricingTable } from "@nozle-js/react";
|
|
178
|
+
|
|
179
|
+
// Auto-fetch plans from API
|
|
180
|
+
<PricingTable
|
|
181
|
+
customerId="cust_123"
|
|
182
|
+
highlightPlan="pro"
|
|
183
|
+
onSelect={(plan) => handleUpgrade(plan)}
|
|
184
|
+
/>
|
|
185
|
+
|
|
186
|
+
// Or pass plans explicitly
|
|
187
|
+
<PricingTable
|
|
188
|
+
plans={[
|
|
189
|
+
{ code: "starter", name: "Starter", amount_cents: 2900, amount_currency: "USD", interval: "monthly" },
|
|
190
|
+
{ code: "pro", name: "Pro", amount_cents: 9900, amount_currency: "USD", interval: "monthly" },
|
|
191
|
+
]}
|
|
192
|
+
features={[
|
|
193
|
+
["10K API calls", "Email support"],
|
|
194
|
+
["100K API calls", "Priority support", "Analytics"],
|
|
195
|
+
]}
|
|
196
|
+
currentPlanCode="starter"
|
|
197
|
+
highlightPlan="pro"
|
|
198
|
+
onSelect={(plan) => console.log("Selected:", plan.code)}
|
|
199
|
+
showToggle={true}
|
|
200
|
+
enterpriseEmail="sales@example.com"
|
|
201
|
+
className="my-pricing"
|
|
202
|
+
/>
|
|
203
|
+
```
|
|
204
|
+
|
|
205
|
+
| Prop | Type | Default | Description |
|
|
206
|
+
|------|------|---------|-------------|
|
|
207
|
+
| `customerId` | `string` | -- | Customer ID for auto-detecting current plan |
|
|
208
|
+
| `currentPlanCode` | `string` | -- | Explicitly set current plan (overrides auto-detect) |
|
|
209
|
+
| `plans` | `PricingPlan[]` | -- | Plans to display (auto-fetched from API if omitted) |
|
|
210
|
+
| `features` | `string[][]` | -- | Feature lists per plan (index-matched to plans array) |
|
|
211
|
+
| `onSelect` | `(plan: PricingPlan) => void` | -- | Called when a plan's CTA is clicked |
|
|
212
|
+
| `highlightPlan` | `string` | -- | Plan code to highlight as "Most Popular" |
|
|
213
|
+
| `enterpriseEmail` | `string` | -- | Email for enterprise plan "Contact Sales" button |
|
|
214
|
+
| `showToggle` | `boolean` | `true` | Show monthly/annual toggle (only when annual plans exist) |
|
|
215
|
+
| `className` | `string` | -- | CSS class for the outer wrapper |
|
|
216
|
+
|
|
217
|
+
#### PricingPlan type
|
|
218
|
+
|
|
219
|
+
```ts
|
|
220
|
+
interface PricingPlan {
|
|
221
|
+
code: string;
|
|
222
|
+
name: string;
|
|
223
|
+
amount_cents: number;
|
|
224
|
+
amount_currency: string;
|
|
225
|
+
interval: string;
|
|
226
|
+
description?: string;
|
|
227
|
+
}
|
|
228
|
+
```
|
|
229
|
+
|
|
230
|
+
#### CSS Variable Theming
|
|
231
|
+
|
|
232
|
+
PricingTable uses CSS custom properties for full theming control. Set these on a parent element or `:root`:
|
|
233
|
+
|
|
234
|
+
```css
|
|
235
|
+
:root {
|
|
236
|
+
/* Component-specific overrides */
|
|
237
|
+
--nozle-pricing-bg: #ffffff;
|
|
238
|
+
--nozle-pricing-card-bg: #ffffff;
|
|
239
|
+
--nozle-pricing-highlight: #6366f1;
|
|
240
|
+
--nozle-pricing-border: #e5e7eb;
|
|
241
|
+
--nozle-pricing-radius: 12px;
|
|
242
|
+
|
|
243
|
+
/* Or use global Nozle variables (PricingTable falls back to these) */
|
|
244
|
+
--nozle-background: #ffffff;
|
|
245
|
+
--nozle-card: #ffffff;
|
|
246
|
+
--nozle-primary: #6366f1;
|
|
247
|
+
--nozle-border: #e5e7eb;
|
|
248
|
+
--nozle-radius: 12px;
|
|
249
|
+
--nozle-foreground: #111827;
|
|
250
|
+
--nozle-muted-foreground: #6b7280;
|
|
251
|
+
--nozle-muted: #f3f4f6;
|
|
252
|
+
--nozle-primary-foreground: #ffffff;
|
|
253
|
+
}
|
|
254
|
+
```
|
|
255
|
+
|
|
256
|
+
The component-specific variables (`--nozle-pricing-*`) take precedence over the global ones (`--nozle-*`), which fall back to sensible defaults.
|
|
257
|
+
|
|
172
258
|
### `UsageMeter`
|
|
173
259
|
|
|
174
260
|
Displays usage with bar, ring, or minimal variants.
|
|
@@ -230,6 +316,8 @@ import type {
|
|
|
230
316
|
UsePlanResult,
|
|
231
317
|
UseCheckoutResult,
|
|
232
318
|
Plan,
|
|
319
|
+
PricingPlan,
|
|
320
|
+
PricingTableProps,
|
|
233
321
|
UsageMeterProps,
|
|
234
322
|
PlanBadgeProps,
|
|
235
323
|
UpgradePromptProps,
|