@flexprice/flexprice-ui 0.1.0
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 +73 -0
- package/dist/flexprice-ui.cjs +223 -0
- package/dist/flexprice-ui.cjs.map +1 -0
- package/dist/flexprice-ui.d.mts +330 -0
- package/dist/flexprice-ui.mjs +14071 -0
- package/dist/flexprice-ui.mjs.map +1 -0
- package/dist/style.css +1 -0
- package/package.json +40 -0
package/README.md
ADDED
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
# @flexprice/flexprice-ui
|
|
2
|
+
|
|
3
|
+
Drop-in **React** components for pricing pages, extracted from the Flexprice dashboard so your
|
|
4
|
+
app renders the exact same pricing UI. **Bring your own data** — the components are purely
|
|
5
|
+
presentational (no fetching, no auth, no routing).
|
|
6
|
+
|
|
7
|
+
## Install
|
|
8
|
+
|
|
9
|
+
```bash
|
|
10
|
+
npm install @flexprice/flexprice-ui
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
`react` and `react-dom` (v18) are peer dependencies.
|
|
14
|
+
|
|
15
|
+
## Usage
|
|
16
|
+
|
|
17
|
+
Import the stylesheet once (ships the theme tokens + only the utilities the widget uses):
|
|
18
|
+
|
|
19
|
+
```tsx
|
|
20
|
+
import '@flexprice/flexprice-ui/style.css';
|
|
21
|
+
import { PricingTable, PricingCard, type Plan } from '@flexprice/flexprice-ui';
|
|
22
|
+
```
|
|
23
|
+
|
|
24
|
+
### `PricingTable` — the full grid
|
|
25
|
+
|
|
26
|
+
```tsx
|
|
27
|
+
const plans: Plan[] = /* fetch + map your Flexprice plans (see adapters below) */;
|
|
28
|
+
|
|
29
|
+
<PricingTable
|
|
30
|
+
plans={plans}
|
|
31
|
+
billingPeriod={period}
|
|
32
|
+
onBillingPeriodChange={setPeriod}
|
|
33
|
+
billingPeriodOptions={[{ label: 'Monthly', value: 'MONTHLY' }]}
|
|
34
|
+
currency={currency}
|
|
35
|
+
onCurrencyChange={setCurrency}
|
|
36
|
+
currencyOptions={[{ label: 'USD', value: 'USD' }]}
|
|
37
|
+
onSelectPlan={(planId) => router.push(`/checkout/${planId}`)}
|
|
38
|
+
/>
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
### `PricingCard` — a single plan, use standalone
|
|
42
|
+
|
|
43
|
+
```tsx
|
|
44
|
+
<PricingCard {...plan} useModernChrome onSelectPlan={handleSelect} />
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
Both are individual components — compose your own layout with `PricingCard`, or use
|
|
48
|
+
`PricingTable` for the standard responsive grid.
|
|
49
|
+
|
|
50
|
+
## Bring your own data
|
|
51
|
+
|
|
52
|
+
The `plans` prop is the presentational `Plan` shape (decoupled from the Flexprice API). If you
|
|
53
|
+
fetch raw Flexprice plans/prices/entitlements, map them with the exported adapters:
|
|
54
|
+
|
|
55
|
+
```ts
|
|
56
|
+
import { adaptPlanToCard, filterAndSortPlans } from '@flexprice/flexprice-ui';
|
|
57
|
+
|
|
58
|
+
const cards = filterAndSortPlans(plansWithData, 'USD', 'MONTHLY').map((p) => adaptPlanToCard(p, grants));
|
|
59
|
+
```
|
|
60
|
+
|
|
61
|
+
Or build the `Plan` objects yourself — see the exported `Plan` / `Feature` types.
|
|
62
|
+
|
|
63
|
+
## Theming
|
|
64
|
+
|
|
65
|
+
Override the CSS variables on a wrapping element. Add `class="dark"` for dark mode.
|
|
66
|
+
|
|
67
|
+
```css
|
|
68
|
+
.my-pricing { --brand: 243 75% 59%; --radius: 12px; }
|
|
69
|
+
```
|
|
70
|
+
|
|
71
|
+
## Dark mode
|
|
72
|
+
|
|
73
|
+
The stylesheet includes a `.dark` variant. Toggle it by adding the `dark` class to any ancestor.
|