@kbach/react 0.5.6 → 0.5.7

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 CHANGED
@@ -329,7 +329,7 @@ Available families: slate, gray, zinc, neutral, stone, red, orange, amber, yello
329
329
  | Category | Examples |
330
330
  |---|---|
331
331
  | Background | `bg-white`, `bg-gray-10`, `bg-blue-6`, `bg-[#fff]` |
332
- | Text | `text-sm`, `text-2xl`, `text-gray-10`, `font-bold` |
332
+ | Text | `text-sm`, `text-2xl`, `text-gray-10`, `font-bold`, `font-sans` |
333
333
  | Text wrap | `text-balance`, `text-pretty`, `text-nowrap`, `text-wrap` |
334
334
  | Line clamp | `line-clamp-3`, `line-clamp-none` |
335
335
  | Padding | `p-4`, `px-6`, `py-3` |
@@ -389,3 +389,44 @@ import { updateConfig } from '@kbach/react';
389
389
 
390
390
  updateConfig({ extend: { theme: { colors: { brand: { 6: '#6366f1' } } } } });
391
391
  ```
392
+
393
+ ### Font Family
394
+
395
+ Define custom font families and use them with `font-<name>`:
396
+
397
+ ```js
398
+ // kbach.config.js
399
+ module.exports = {
400
+ extend: {
401
+ fontFamily: {
402
+ // shorthand: extend.fontFamily is equivalent to extend.theme.fontFamily
403
+ sans: 'CormorantGaramond_400Regular',
404
+ 'sans-md': 'CormorantGaramond_500Medium',
405
+ 'sans-semi': 'CormorantGaramond_600SemiBold',
406
+ 'sans-bold': 'CormorantGaramond_700Bold',
407
+ },
408
+ },
409
+ };
410
+ ```
411
+
412
+ Use them as utilities:
413
+
414
+ ```jsx
415
+ <Text className="font-sans">Regular</Text>
416
+ <Text className="font-sans-md">Medium</Text>
417
+ <Text className="font-sans-bold">Bold</Text>
418
+ ```
419
+
420
+ **Global default font (web only):** When you set `fontFamily.sans` to anything other than `'System'`, Kbach automatically injects `body { font-family: <your-font> }` into the page — all text inherits it without needing `font-sans` on every element.
421
+
422
+ **React Native:** CSS inheritance does not exist in RN. Apply `font-sans` (or your base font utility) to each `Text` component, or use `styled()` to create a pre-styled text component:
423
+
424
+ ```jsx
425
+ // Define once
426
+ const Body = styled(Text, 'font-sans');
427
+ const Heading = styled(Text, 'font-sans-bold text-2xl');
428
+
429
+ // Use everywhere
430
+ <Body>Regular text</Body>
431
+ <Heading>Title</Heading>
432
+ ```
@@ -8,7 +8,7 @@ import {
8
8
  resolve,
9
9
  useConditionalWidth,
10
10
  useGlobalDarkMode
11
- } from "./chunk-MNDU7U43.mjs";
11
+ } from "./chunk-YLT5TFLD.mjs";
12
12
 
13
13
  // src/jsx-runtime.tsx
14
14
  import { jsx as _jsx, jsxs as _jsxs, Fragment } from "react/jsx-runtime";
@@ -3005,6 +3005,24 @@ function injectRule(rule) {
3005
3005
  } catch {
3006
3006
  }
3007
3007
  }
3008
+ var _globalStyleEl = null;
3009
+ function getGlobalStyleEl() {
3010
+ if (_globalStyleEl) return _globalStyleEl;
3011
+ _globalStyleEl = document.createElement("style");
3012
+ _globalStyleEl.setAttribute("data-kbach-global", "");
3013
+ document.head.insertBefore(_globalStyleEl, getStyleEl());
3014
+ return _globalStyleEl;
3015
+ }
3016
+ function injectGlobalStyles(theme) {
3017
+ if (typeof document === "undefined") return;
3018
+ const rules = [];
3019
+ const ff = theme.fontFamily;
3020
+ if (ff.sans && ff.sans !== "System") {
3021
+ const family = Array.isArray(ff.sans) ? ff.sans.join(", ") : ff.sans;
3022
+ rules.push(`body { font-family: ${family}; }`);
3023
+ }
3024
+ getGlobalStyleEl().textContent = rules.join("\n");
3025
+ }
3008
3026
  var MODIFIER_TO_PSEUDO = {
3009
3027
  hover: ":hover",
3010
3028
  focus: ":focus",
@@ -3414,6 +3432,7 @@ function buildConfig(userConfig) {
3414
3432
  for (const plugin of resolved.plugins) {
3415
3433
  plugin(pluginAPI);
3416
3434
  }
3435
+ injectGlobalStyles(resolved.theme);
3417
3436
  return resolved;
3418
3437
  }
3419
3438
  function makePluginAPI(theme) {
package/dist/index.js CHANGED
@@ -3135,6 +3135,24 @@ function injectRule(rule) {
3135
3135
  } catch {
3136
3136
  }
3137
3137
  }
3138
+ var _globalStyleEl = null;
3139
+ function getGlobalStyleEl() {
3140
+ if (_globalStyleEl) return _globalStyleEl;
3141
+ _globalStyleEl = document.createElement("style");
3142
+ _globalStyleEl.setAttribute("data-kbach-global", "");
3143
+ document.head.insertBefore(_globalStyleEl, getStyleEl());
3144
+ return _globalStyleEl;
3145
+ }
3146
+ function injectGlobalStyles(theme) {
3147
+ if (typeof document === "undefined") return;
3148
+ const rules = [];
3149
+ const ff = theme.fontFamily;
3150
+ if (ff.sans && ff.sans !== "System") {
3151
+ const family = Array.isArray(ff.sans) ? ff.sans.join(", ") : ff.sans;
3152
+ rules.push(`body { font-family: ${family}; }`);
3153
+ }
3154
+ getGlobalStyleEl().textContent = rules.join("\n");
3155
+ }
3138
3156
  var MODIFIER_TO_PSEUDO = {
3139
3157
  hover: ":hover",
3140
3158
  focus: ":focus",
@@ -3544,6 +3562,7 @@ function buildConfig(userConfig) {
3544
3562
  for (const plugin of resolved.plugins) {
3545
3563
  plugin(pluginAPI);
3546
3564
  }
3565
+ injectGlobalStyles(resolved.theme);
3547
3566
  return resolved;
3548
3567
  }
3549
3568
  function makePluginAPI(theme) {
package/dist/index.mjs CHANGED
@@ -23,7 +23,7 @@ import {
23
23
  useConditionalWidth,
24
24
  useGlobalDarkMode,
25
25
  useGlobalWidth
26
- } from "./chunk-MNDU7U43.mjs";
26
+ } from "./chunk-YLT5TFLD.mjs";
27
27
 
28
28
  // src/context.tsx
29
29
  import { createContext, useContext } from "react";
@@ -3026,6 +3026,24 @@ function injectRule(rule) {
3026
3026
  } catch {
3027
3027
  }
3028
3028
  }
3029
+ var _globalStyleEl = null;
3030
+ function getGlobalStyleEl() {
3031
+ if (_globalStyleEl) return _globalStyleEl;
3032
+ _globalStyleEl = document.createElement("style");
3033
+ _globalStyleEl.setAttribute("data-kbach-global", "");
3034
+ document.head.insertBefore(_globalStyleEl, getStyleEl());
3035
+ return _globalStyleEl;
3036
+ }
3037
+ function injectGlobalStyles(theme) {
3038
+ if (typeof document === "undefined") return;
3039
+ const rules = [];
3040
+ const ff = theme.fontFamily;
3041
+ if (ff.sans && ff.sans !== "System") {
3042
+ const family = Array.isArray(ff.sans) ? ff.sans.join(", ") : ff.sans;
3043
+ rules.push(`body { font-family: ${family}; }`);
3044
+ }
3045
+ getGlobalStyleEl().textContent = rules.join("\n");
3046
+ }
3029
3047
  var MODIFIER_TO_PSEUDO = {
3030
3048
  hover: ":hover",
3031
3049
  focus: ":focus",
@@ -3427,6 +3445,7 @@ function buildConfig(userConfig) {
3427
3445
  for (const plugin of resolved.plugins) {
3428
3446
  plugin(pluginAPI);
3429
3447
  }
3448
+ injectGlobalStyles(resolved.theme);
3430
3449
  return resolved;
3431
3450
  }
3432
3451
  function makePluginAPI(theme) {
@@ -2,8 +2,8 @@ import {
2
2
  Fragment,
3
3
  jsx,
4
4
  jsxs
5
- } from "./chunk-BQJS4P2Z.mjs";
6
- import "./chunk-MNDU7U43.mjs";
5
+ } from "./chunk-3SF5YHWG.mjs";
6
+ import "./chunk-YLT5TFLD.mjs";
7
7
 
8
8
  // src/jsx-dev-runtime.tsx
9
9
  function jsxDEV(type, props, key, isStaticChildren, _source, _self) {
@@ -3025,6 +3025,24 @@ function injectRule(rule) {
3025
3025
  } catch {
3026
3026
  }
3027
3027
  }
3028
+ var _globalStyleEl = null;
3029
+ function getGlobalStyleEl() {
3030
+ if (_globalStyleEl) return _globalStyleEl;
3031
+ _globalStyleEl = document.createElement("style");
3032
+ _globalStyleEl.setAttribute("data-kbach-global", "");
3033
+ document.head.insertBefore(_globalStyleEl, getStyleEl());
3034
+ return _globalStyleEl;
3035
+ }
3036
+ function injectGlobalStyles(theme) {
3037
+ if (typeof document === "undefined") return;
3038
+ const rules = [];
3039
+ const ff = theme.fontFamily;
3040
+ if (ff.sans && ff.sans !== "System") {
3041
+ const family = Array.isArray(ff.sans) ? ff.sans.join(", ") : ff.sans;
3042
+ rules.push(`body { font-family: ${family}; }`);
3043
+ }
3044
+ getGlobalStyleEl().textContent = rules.join("\n");
3045
+ }
3028
3046
  var MODIFIER_TO_PSEUDO = {
3029
3047
  hover: ":hover",
3030
3048
  focus: ":focus",
@@ -3426,6 +3444,7 @@ function buildConfig(userConfig) {
3426
3444
  for (const plugin of resolved.plugins) {
3427
3445
  plugin(pluginAPI);
3428
3446
  }
3447
+ injectGlobalStyles(resolved.theme);
3429
3448
  return resolved;
3430
3449
  }
3431
3450
  function makePluginAPI(theme) {
@@ -2,8 +2,8 @@ import {
2
2
  Fragment,
3
3
  jsx,
4
4
  jsxs
5
- } from "./chunk-BQJS4P2Z.mjs";
6
- import "./chunk-MNDU7U43.mjs";
5
+ } from "./chunk-3SF5YHWG.mjs";
6
+ import "./chunk-YLT5TFLD.mjs";
7
7
  export {
8
8
  Fragment,
9
9
  jsx,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kbach/react",
3
- "version": "0.5.6",
3
+ "version": "0.5.7",
4
4
  "description": "React / React Native components and hooks for the Kbach framework",
5
5
  "source": "./src/index.ts",
6
6
  "main": "./dist/index.js",