@kerne/react 1.1.0 → 1.3.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 +62 -0
- package/dist/chunk-3R66S7BY.cjs +3312 -0
- package/dist/chunk-ZVL47U4B.js +3312 -0
- package/dist/{i18n-QilNgwqe.d.cts → fr-E5mmylSH.d.cts} +135 -3
- package/dist/{i18n-QilNgwqe.d.ts → fr-E5mmylSH.d.ts} +135 -3
- package/dist/index.cjs +51 -27
- package/dist/index.d.cts +61 -41
- package/dist/index.d.ts +61 -41
- package/dist/index.js +44 -20
- package/dist/ui/index.cjs +984 -1906
- package/dist/ui/index.d.cts +42 -96
- package/dist/ui/index.d.ts +42 -96
- package/dist/ui/index.js +1091 -2013
- package/package.json +11 -5
- package/dist/chunk-IZMRK3WK.js +0 -1285
- package/dist/chunk-TYNZ2WU7.cjs +0 -1285
package/README.md
CHANGED
|
@@ -81,6 +81,68 @@ const { openCheckout } = useCheckout();
|
|
|
81
81
|
const { openPortal } = usePortal();
|
|
82
82
|
```
|
|
83
83
|
|
|
84
|
+
## Prebuilt UI
|
|
85
|
+
|
|
86
|
+
`@kerne/react/ui` ships full screens - sign-in/up, account management, pricing table, usage meters, checkout result - accessible and themeable out of the box, for when you don't want to build auth/billing UI by hand.
|
|
87
|
+
|
|
88
|
+
```tsx
|
|
89
|
+
import { LoginForm, UserButton, PricingTable } from '@kerne/react/ui';
|
|
90
|
+
|
|
91
|
+
<LoginForm appearance={{ surface: 'card' }} />
|
|
92
|
+
<UserButton items={[{ label: 'Settings', href: '/settings' }]} />
|
|
93
|
+
<PricingTable product="pro">
|
|
94
|
+
<PricingTable.Header headline="Pricing that grows with you" />
|
|
95
|
+
<PricingTable.LabelSwitch />
|
|
96
|
+
<PricingTable.Plans featuredSlug="scale" featuredBadge="Recommended" />
|
|
97
|
+
</PricingTable>
|
|
98
|
+
```
|
|
99
|
+
|
|
100
|
+
Every component takes an `appearance` prop - `primaryColor` alone derives a matched hover state, label color, and focus ring (WCAG-checked), or set `fontFamily`/`radius`/`controlHeight`/`theme` individually:
|
|
101
|
+
|
|
102
|
+
```tsx
|
|
103
|
+
<LoginForm
|
|
104
|
+
appearance={{
|
|
105
|
+
primaryColor: '#6d5ef5',
|
|
106
|
+
fontFamily: '"Plus Jakarta Sans", -apple-system, sans-serif',
|
|
107
|
+
radius: '12px',
|
|
108
|
+
}}
|
|
109
|
+
/>
|
|
110
|
+
```
|
|
111
|
+
|
|
112
|
+
The unstyled default (system font, neutral gray) is deliberate - these components land inside someone else's product, so a saturated default would clash with every host they meet. The theming above is the mechanism to get a distinctive look for a single tenant, or your own hosted portal.
|
|
113
|
+
|
|
114
|
+
There is no `styles.css` to import or override - theming is exclusively `appearance` (per component) or the global `--kerne-*` CSS custom properties above; the stylesheet itself is injected at runtime rather than shipped as a file, which is what keeps drop-in install possible. Known limitation: under a strict CSP `style-src` (no `'unsafe-inline'`), that runtime injection is blocked and the components render unstyled - there's no fix for this today, only the `--kerne-*` variables to compensate.
|
|
115
|
+
|
|
116
|
+
If your own app needs the default palette's raw values (to match it in your own stylesheet, say) rather than reading them off the rendered page, import `defaultTokens` instead of hand-copying hex codes - it's the same values the injected stylesheet uses, so it can't drift from what actually renders:
|
|
117
|
+
|
|
118
|
+
```tsx
|
|
119
|
+
import { defaultTokens } from '@kerne/react/ui';
|
|
120
|
+
|
|
121
|
+
defaultTokens.light['primary']; // '#16171a'
|
|
122
|
+
defaultTokens.dark['primary']; // '#f0f1f3'
|
|
123
|
+
```
|
|
124
|
+
|
|
125
|
+
Every string these components render - labels, placeholders, error messages - comes from `localization`. A French pack ships as `fr`:
|
|
126
|
+
|
|
127
|
+
```tsx
|
|
128
|
+
import { fr } from '@kerne/react/ui';
|
|
129
|
+
|
|
130
|
+
<KerneProvider appId="..." localization={fr}>
|
|
131
|
+
<AuthFlow />
|
|
132
|
+
</KerneProvider>;
|
|
133
|
+
```
|
|
134
|
+
|
|
135
|
+
Override just a few strings on top of a pack with `mergeLocalization`:
|
|
136
|
+
|
|
137
|
+
```tsx
|
|
138
|
+
import { fr, mergeLocalization } from '@kerne/react/ui';
|
|
139
|
+
|
|
140
|
+
<KerneProvider
|
|
141
|
+
appId="..."
|
|
142
|
+
localization={mergeLocalization({ common: { email: 'Adresse professionnelle' } }, fr)}
|
|
143
|
+
/>;
|
|
144
|
+
```
|
|
145
|
+
|
|
84
146
|
## Core Hooks
|
|
85
147
|
|
|
86
148
|
- `useAuth`: login, signup, logout, password reset, email verification, cross-origin session handoff (`redirectWithSession` - for an app hosting login on a different origin, e.g. a portal).
|