@tamagui/get-font-sized 1.0.1-beta.194

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.
@@ -0,0 +1,66 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+ var src_exports = {};
20
+ __export(src_exports, {
21
+ getFontSized: () => getFontSized
22
+ });
23
+ module.exports = __toCommonJS(src_exports);
24
+ var import_core = require("@tamagui/core");
25
+ const getFontSized = (val = "$4", { fonts, theme, props }) => {
26
+ var _a, _b, _c;
27
+ const family = (0, import_core.getVariableValue)(props.fontFamily) || "$body";
28
+ const font = fonts[family] || fonts["$body"];
29
+ if (!font) {
30
+ if (process.env.NODE_ENV === "development") {
31
+ console.warn("\u26A0\uFE0F no font found", { family, fontTokens: Object.keys(fonts), val });
32
+ }
33
+ return {};
34
+ }
35
+ const fontFamily = font.family;
36
+ const fontSize = props.fontSize || font.size[val];
37
+ const lineHeight = props.lineHeight || font.lineHeight[val];
38
+ const fontWeight = props.fontWeight || font.weight[val];
39
+ const letterSpacing = props.letterSpacing || font.letterSpacing[val];
40
+ const fontStyle = props.fontStyle || ((_a = font.style) == null ? void 0 : _a[val]);
41
+ const textTransform = props.textTransform || ((_b = font.transform) == null ? void 0 : _b[val]);
42
+ const color = props.color || ((_c = font.color) == null ? void 0 : _c[val]) || theme.color;
43
+ const style = {
44
+ color,
45
+ fontStyle,
46
+ textTransform,
47
+ fontFamily,
48
+ fontWeight,
49
+ letterSpacing,
50
+ fontSize,
51
+ lineHeight
52
+ };
53
+ if (process.env.NODE_ENV === "development") {
54
+ if (props["debug"]) {
55
+ console.groupCollapsed(" \u{1F539} getFont", val, props["fontWeight"], props["fow"]);
56
+ console.log({ style, props, font });
57
+ console.groupEnd();
58
+ }
59
+ }
60
+ return style;
61
+ };
62
+ // Annotate the CommonJS export names for ESM import in node:
63
+ 0 && (module.exports = {
64
+ getFontSized
65
+ });
66
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../src/index.ts"],
4
+ "sourcesContent": ["import { getVariableValue } from '@tamagui/core'\nimport type { FontSizeTokens, TextProps, VariantSpreadFunction } from '@tamagui/core'\n\nexport const getFontSized: VariantSpreadFunction<TextProps, FontSizeTokens> = (\n val = '$4',\n { fonts, theme, props }\n) => {\n const family = getVariableValue(props.fontFamily) || '$body'\n const font = fonts[family] || fonts['$body']\n if (!font) {\n if (process.env.NODE_ENV === 'development') {\n // eslint-disable-next-line no-console\n console.warn('\u26A0\uFE0F no font found', { family, fontTokens: Object.keys(fonts), val })\n }\n return {} as any\n }\n const fontFamily = font.family\n const fontSize = props.fontSize || font.size[val]\n const lineHeight = props.lineHeight || font.lineHeight[val]\n const fontWeight = props.fontWeight || font.weight[val]\n const letterSpacing = props.letterSpacing || font.letterSpacing[val]\n const fontStyle = props.fontStyle || font.style?.[val]\n const textTransform = props.textTransform || font.transform?.[val]\n const color = props.color || font.color?.[val] || theme.color\n const style = {\n color,\n fontStyle,\n textTransform,\n fontFamily,\n fontWeight,\n letterSpacing,\n fontSize,\n lineHeight,\n }\n if (process.env.NODE_ENV === 'development') {\n if (props['debug']) {\n // eslint-disable-next-line no-console\n console.groupCollapsed(' \uD83D\uDD39 getFont', val, props['fontWeight'], props['fow'])\n // eslint-disable-next-line no-console\n console.log({ style, props, font })\n // eslint-disable-next-line no-console\n console.groupEnd()\n }\n }\n return style\n}\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,kBAAiC;AAG1B,MAAM,eAAiE,CAC5E,MAAM,MACN,EAAE,OAAO,OAAO,MAAM,MACnB;AANL;AAOE,QAAM,aAAS,8BAAiB,MAAM,UAAU,KAAK;AACrD,QAAM,OAAO,MAAM,WAAW,MAAM;AACpC,MAAI,CAAC,MAAM;AACT,QAAI,QAAQ,IAAI,aAAa,eAAe;AAE1C,cAAQ,KAAK,8BAAoB,EAAE,QAAQ,YAAY,OAAO,KAAK,KAAK,GAAG,IAAI,CAAC;AAAA,IAClF;AACA,WAAO,CAAC;AAAA,EACV;AACA,QAAM,aAAa,KAAK;AACxB,QAAM,WAAW,MAAM,YAAY,KAAK,KAAK;AAC7C,QAAM,aAAa,MAAM,cAAc,KAAK,WAAW;AACvD,QAAM,aAAa,MAAM,cAAc,KAAK,OAAO;AACnD,QAAM,gBAAgB,MAAM,iBAAiB,KAAK,cAAc;AAChE,QAAM,YAAY,MAAM,eAAa,UAAK,UAAL,mBAAa;AAClD,QAAM,gBAAgB,MAAM,mBAAiB,UAAK,cAAL,mBAAiB;AAC9D,QAAM,QAAQ,MAAM,WAAS,UAAK,UAAL,mBAAa,SAAQ,MAAM;AACxD,QAAM,QAAQ;AAAA,IACZ;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EACF;AACA,MAAI,QAAQ,IAAI,aAAa,eAAe;AAC1C,QAAI,MAAM,UAAU;AAElB,cAAQ,eAAe,uBAAgB,KAAK,MAAM,eAAe,MAAM,MAAM;AAE7E,cAAQ,IAAI,EAAE,OAAO,OAAO,KAAK,CAAC;AAElC,cAAQ,SAAS;AAAA,IACnB;AAAA,EACF;AACA,SAAO;AACT;",
6
+ "names": []
7
+ }
@@ -0,0 +1,42 @@
1
+ import { getVariableValue } from "@tamagui/core";
2
+ const getFontSized = (val = "$4", { fonts, theme, props }) => {
3
+ var _a, _b, _c;
4
+ const family = getVariableValue(props.fontFamily) || "$body";
5
+ const font = fonts[family] || fonts["$body"];
6
+ if (!font) {
7
+ if (process.env.NODE_ENV === "development") {
8
+ console.warn("\u26A0\uFE0F no font found", { family, fontTokens: Object.keys(fonts), val });
9
+ }
10
+ return {};
11
+ }
12
+ const fontFamily = font.family;
13
+ const fontSize = props.fontSize || font.size[val];
14
+ const lineHeight = props.lineHeight || font.lineHeight[val];
15
+ const fontWeight = props.fontWeight || font.weight[val];
16
+ const letterSpacing = props.letterSpacing || font.letterSpacing[val];
17
+ const fontStyle = props.fontStyle || ((_a = font.style) == null ? void 0 : _a[val]);
18
+ const textTransform = props.textTransform || ((_b = font.transform) == null ? void 0 : _b[val]);
19
+ const color = props.color || ((_c = font.color) == null ? void 0 : _c[val]) || theme.color;
20
+ const style = {
21
+ color,
22
+ fontStyle,
23
+ textTransform,
24
+ fontFamily,
25
+ fontWeight,
26
+ letterSpacing,
27
+ fontSize,
28
+ lineHeight
29
+ };
30
+ if (process.env.NODE_ENV === "development") {
31
+ if (props["debug"]) {
32
+ console.groupCollapsed(" \u{1F539} getFont", val, props["fontWeight"], props["fow"]);
33
+ console.log({ style, props, font });
34
+ console.groupEnd();
35
+ }
36
+ }
37
+ return style;
38
+ };
39
+ export {
40
+ getFontSized
41
+ };
42
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../src/index.ts"],
4
+ "sourcesContent": ["import { getVariableValue } from '@tamagui/core'\nimport type { FontSizeTokens, TextProps, VariantSpreadFunction } from '@tamagui/core'\n\nexport const getFontSized: VariantSpreadFunction<TextProps, FontSizeTokens> = (\n val = '$4',\n { fonts, theme, props }\n) => {\n const family = getVariableValue(props.fontFamily) || '$body'\n const font = fonts[family] || fonts['$body']\n if (!font) {\n if (process.env.NODE_ENV === 'development') {\n // eslint-disable-next-line no-console\n console.warn('\u26A0\uFE0F no font found', { family, fontTokens: Object.keys(fonts), val })\n }\n return {} as any\n }\n const fontFamily = font.family\n const fontSize = props.fontSize || font.size[val]\n const lineHeight = props.lineHeight || font.lineHeight[val]\n const fontWeight = props.fontWeight || font.weight[val]\n const letterSpacing = props.letterSpacing || font.letterSpacing[val]\n const fontStyle = props.fontStyle || font.style?.[val]\n const textTransform = props.textTransform || font.transform?.[val]\n const color = props.color || font.color?.[val] || theme.color\n const style = {\n color,\n fontStyle,\n textTransform,\n fontFamily,\n fontWeight,\n letterSpacing,\n fontSize,\n lineHeight,\n }\n if (process.env.NODE_ENV === 'development') {\n if (props['debug']) {\n // eslint-disable-next-line no-console\n console.groupCollapsed(' \uD83D\uDD39 getFont', val, props['fontWeight'], props['fow'])\n // eslint-disable-next-line no-console\n console.log({ style, props, font })\n // eslint-disable-next-line no-console\n console.groupEnd()\n }\n }\n return style\n}\n"],
5
+ "mappings": "AAAA,SAAS,wBAAwB;AAG1B,MAAM,eAAiE,CAC5E,MAAM,MACN,EAAE,OAAO,OAAO,MAAM,MACnB;AANL;AAOE,QAAM,SAAS,iBAAiB,MAAM,UAAU,KAAK;AACrD,QAAM,OAAO,MAAM,WAAW,MAAM;AACpC,MAAI,CAAC,MAAM;AACT,QAAI,QAAQ,IAAI,aAAa,eAAe;AAE1C,cAAQ,KAAK,8BAAoB,EAAE,QAAQ,YAAY,OAAO,KAAK,KAAK,GAAG,IAAI,CAAC;AAAA,IAClF;AACA,WAAO,CAAC;AAAA,EACV;AACA,QAAM,aAAa,KAAK;AACxB,QAAM,WAAW,MAAM,YAAY,KAAK,KAAK;AAC7C,QAAM,aAAa,MAAM,cAAc,KAAK,WAAW;AACvD,QAAM,aAAa,MAAM,cAAc,KAAK,OAAO;AACnD,QAAM,gBAAgB,MAAM,iBAAiB,KAAK,cAAc;AAChE,QAAM,YAAY,MAAM,eAAa,UAAK,UAAL,mBAAa;AAClD,QAAM,gBAAgB,MAAM,mBAAiB,UAAK,cAAL,mBAAiB;AAC9D,QAAM,QAAQ,MAAM,WAAS,UAAK,UAAL,mBAAa,SAAQ,MAAM;AACxD,QAAM,QAAQ;AAAA,IACZ;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EACF;AACA,MAAI,QAAQ,IAAI,aAAa,eAAe;AAC1C,QAAI,MAAM,UAAU;AAElB,cAAQ,eAAe,uBAAgB,KAAK,MAAM,eAAe,MAAM,MAAM;AAE7E,cAAQ,IAAI,EAAE,OAAO,OAAO,KAAK,CAAC;AAElC,cAAQ,SAAS;AAAA,IACnB;AAAA,EACF;AACA,SAAO;AACT;",
6
+ "names": []
7
+ }
package/package.json ADDED
@@ -0,0 +1,31 @@
1
+ {
2
+ "name": "@tamagui/get-font-sized",
3
+ "version": "1.0.1-beta.194",
4
+ "types": "./types/index.d.ts",
5
+ "main": "dist/cjs",
6
+ "module": "dist/esm",
7
+ "files": [
8
+ "src",
9
+ "types",
10
+ "dist"
11
+ ],
12
+ "scripts": {
13
+ "build": "tamagui-build",
14
+ "watch": "tamagui-build --watch",
15
+ "lint": "eslint",
16
+ "lint:fix": "yarn lint --fix",
17
+ "clean": "tamagui-build clean",
18
+ "clean:build": "tamagui-build clean:build"
19
+ },
20
+ "dependencies": {
21
+ "@tamagui/core": "^1.0.1-beta.194",
22
+ "react": "*"
23
+ },
24
+ "devDependencies": {
25
+ "@tamagui/build": "^1.0.1-beta.194",
26
+ "@types/react": "^18.0.15"
27
+ },
28
+ "publishConfig": {
29
+ "access": "public"
30
+ }
31
+ }
package/src/index.ts ADDED
@@ -0,0 +1,46 @@
1
+ import { getVariableValue } from '@tamagui/core'
2
+ import type { FontSizeTokens, TextProps, VariantSpreadFunction } from '@tamagui/core'
3
+
4
+ export const getFontSized: VariantSpreadFunction<TextProps, FontSizeTokens> = (
5
+ val = '$4',
6
+ { fonts, theme, props }
7
+ ) => {
8
+ const family = getVariableValue(props.fontFamily) || '$body'
9
+ const font = fonts[family] || fonts['$body']
10
+ if (!font) {
11
+ if (process.env.NODE_ENV === 'development') {
12
+ // eslint-disable-next-line no-console
13
+ console.warn('⚠️ no font found', { family, fontTokens: Object.keys(fonts), val })
14
+ }
15
+ return {} as any
16
+ }
17
+ const fontFamily = font.family
18
+ const fontSize = props.fontSize || font.size[val]
19
+ const lineHeight = props.lineHeight || font.lineHeight[val]
20
+ const fontWeight = props.fontWeight || font.weight[val]
21
+ const letterSpacing = props.letterSpacing || font.letterSpacing[val]
22
+ const fontStyle = props.fontStyle || font.style?.[val]
23
+ const textTransform = props.textTransform || font.transform?.[val]
24
+ const color = props.color || font.color?.[val] || theme.color
25
+ const style = {
26
+ color,
27
+ fontStyle,
28
+ textTransform,
29
+ fontFamily,
30
+ fontWeight,
31
+ letterSpacing,
32
+ fontSize,
33
+ lineHeight,
34
+ }
35
+ if (process.env.NODE_ENV === 'development') {
36
+ if (props['debug']) {
37
+ // eslint-disable-next-line no-console
38
+ console.groupCollapsed(' 🔹 getFont', val, props['fontWeight'], props['fow'])
39
+ // eslint-disable-next-line no-console
40
+ console.log({ style, props, font })
41
+ // eslint-disable-next-line no-console
42
+ console.groupEnd()
43
+ }
44
+ }
45
+ return style
46
+ }
@@ -0,0 +1,3 @@
1
+ import type { FontSizeTokens, TextProps, VariantSpreadFunction } from '@tamagui/core';
2
+ export declare const getFontSized: VariantSpreadFunction<TextProps, FontSizeTokens>;
3
+ //# sourceMappingURL=index.d.ts.map