@tamagui/get-font-sized 1.88.13 → 1.89.0-1706308641099

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/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2020 Nate Wienert
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,47 @@
1
+ import { getTokens } from "@tamagui/core";
2
+ const getFontSized = (sizeTokenIn = "$true", {
3
+ font,
4
+ fontFamily,
5
+ props
6
+ }) => {
7
+ if (!font) {
8
+ process.env.NODE_ENV === "development" && console.warn("Warning: No font found in props", {
9
+ ...props
10
+ }, 'For a sized text component, you either need to set fontFamily directly, or through the "defaultFont" setting in your createTamagui config.');
11
+ return;
12
+ }
13
+ const sizeToken = sizeTokenIn === "$true" ? getDefaultSizeToken(font) : sizeTokenIn,
14
+ fontSize = font.size[sizeToken],
15
+ lineHeight = font.lineHeight?.[sizeToken],
16
+ fontWeight = font.weight?.[sizeToken],
17
+ letterSpacing = font.letterSpacing?.[sizeToken],
18
+ textTransform = font.transform?.[sizeToken],
19
+ fontStyle = props.fontStyle ?? font.style?.[sizeToken],
20
+ style = {
21
+ color: props.color ?? font.color?.[sizeToken],
22
+ fontStyle,
23
+ textTransform,
24
+ fontFamily,
25
+ fontWeight,
26
+ letterSpacing,
27
+ fontSize,
28
+ lineHeight
29
+ };
30
+ return process.env.NODE_ENV === "development" && props.debug && props.debug === "verbose" && (console.groupCollapsed(" \u{1F539} getFontSized", sizeTokenIn, sizeToken), console.info({
31
+ style,
32
+ props,
33
+ font
34
+ }), console.groupEnd()), style;
35
+ },
36
+ cache = /* @__PURE__ */new WeakMap();
37
+ function getDefaultSizeToken(font) {
38
+ if (typeof font == "object" && cache.has(font)) return cache.get(font);
39
+ const sizeTokens = "$true" in font.size ? font.size : getTokens().size,
40
+ sizeDefault = sizeTokens.$true,
41
+ sizeDefaultSpecific = sizeDefault ? Object.keys(sizeTokens).find(x => x !== "$true" && sizeTokens[x].val === sizeDefault.val) : null;
42
+ return !sizeDefault || !sizeDefaultSpecific ? (process.env.NODE_ENV === "development" && console.warn(`No default size is set in your tokens for the "true" key, fonts will be inconsistent.
43
+
44
+ Fix this by having consistent tokens across fonts and sizes and setting a true key for your size tokens, or
45
+ set true keys for all your font tokens: "size", "lineHeight", "fontStyle", etc.`), Object.keys(font.size)[3]) : (cache.set(font, sizeDefaultSpecific), sizeDefaultSpecific);
46
+ }
47
+ export { getFontSized };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tamagui/get-font-sized",
3
- "version": "1.88.13",
3
+ "version": "1.89.0-1706308641099",
4
4
  "types": "./types/index.d.ts",
5
5
  "main": "dist/cjs",
6
6
  "module": "dist/esm",
@@ -18,10 +18,10 @@
18
18
  "clean:build": "tamagui-build clean:build"
19
19
  },
20
20
  "dependencies": {
21
- "@tamagui/core": "1.88.13"
21
+ "@tamagui/core": "1.89.0-1706308641099"
22
22
  },
23
23
  "devDependencies": {
24
- "@tamagui/build": "1.88.13",
24
+ "@tamagui/build": "1.89.0-1706308641099",
25
25
  "react": "^18.2.0"
26
26
  },
27
27
  "peerDependencies": {