@tamagui/font 1.27.2 → 1.28.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/package.json +4 -4
- package/dist/esm/index.mjs +0 -69
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tamagui/font",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.28.0",
|
|
4
4
|
"sideEffects": false,
|
|
5
5
|
"source": "src/index.ts",
|
|
6
6
|
"types": "./types/index.d.ts",
|
|
@@ -17,14 +17,14 @@
|
|
|
17
17
|
"watch": "tamagui-build --watch"
|
|
18
18
|
},
|
|
19
19
|
"dependencies": {
|
|
20
|
-
"@tamagui/constants": "1.
|
|
21
|
-
"@tamagui/web": "1.
|
|
20
|
+
"@tamagui/constants": "1.28.0",
|
|
21
|
+
"@tamagui/web": "1.28.0"
|
|
22
22
|
},
|
|
23
23
|
"peerDependencies": {
|
|
24
24
|
"react": "*"
|
|
25
25
|
},
|
|
26
26
|
"devDependencies": {
|
|
27
|
-
"@tamagui/build": "1.
|
|
27
|
+
"@tamagui/build": "1.28.0",
|
|
28
28
|
"react": "^18.2.0"
|
|
29
29
|
},
|
|
30
30
|
"publishConfig": {
|
package/dist/esm/index.mjs
DELETED
|
@@ -1,69 +0,0 @@
|
|
|
1
|
-
import { isWeb } from "@tamagui/constants";
|
|
2
|
-
import {
|
|
3
|
-
createVariables,
|
|
4
|
-
getConfig,
|
|
5
|
-
parseFont,
|
|
6
|
-
registerFontVariables
|
|
7
|
-
} from "@tamagui/web";
|
|
8
|
-
function addFont(props) {
|
|
9
|
-
var _a;
|
|
10
|
-
const config = getConfig();
|
|
11
|
-
const { fontFamilyName: fontFamilyNameIn, fontFamily: fontFamilyIn } = props;
|
|
12
|
-
if (process.env.NODE_ENV === "development") {
|
|
13
|
-
if (!config) {
|
|
14
|
-
throw new Error("No config");
|
|
15
|
-
}
|
|
16
|
-
const fontFamily = config.fonts[fontFamilyNameIn];
|
|
17
|
-
if (!props.update && fontFamily) {
|
|
18
|
-
return { fontFamily };
|
|
19
|
-
}
|
|
20
|
-
}
|
|
21
|
-
config.fonts[fontFamilyNameIn] = fontFamilyIn;
|
|
22
|
-
const sep = process.env.NODE_ENV === "development" ? config.cssStyleSeparator || " " : "";
|
|
23
|
-
function declarationsToRuleSet(decs, selector = "") {
|
|
24
|
-
return `:root${selector} {${sep}${[...decs].join(`;${sep}`)}${sep}}`;
|
|
25
|
-
}
|
|
26
|
-
if (isWeb) {
|
|
27
|
-
const fontFamilyToken = createVariables(fontFamilyIn, "f", true);
|
|
28
|
-
const parsedFontFamily = parseFont(fontFamilyToken);
|
|
29
|
-
const fontFamilyNameParsed = `$${fontFamilyNameIn}`;
|
|
30
|
-
config.fontsParsed[fontFamilyNameParsed] = parsedFontFamily;
|
|
31
|
-
if (props.insertCSS) {
|
|
32
|
-
const [ff_name, ff_language] = fontFamilyNameParsed.includes("_") ? fontFamilyNameParsed.split("_") : [fontFamilyNameParsed];
|
|
33
|
-
const fontVars = registerFontVariables(parsedFontFamily);
|
|
34
|
-
const fontDeclaration = {
|
|
35
|
-
[fontFamilyNameIn]: {
|
|
36
|
-
name: ff_name.slice(1),
|
|
37
|
-
declarations: fontVars,
|
|
38
|
-
language: ff_language
|
|
39
|
-
}
|
|
40
|
-
};
|
|
41
|
-
const {
|
|
42
|
-
name,
|
|
43
|
-
declarations,
|
|
44
|
-
language = "default"
|
|
45
|
-
} = fontDeclaration[fontFamilyNameIn];
|
|
46
|
-
const fontSelector = `.font_${name}`;
|
|
47
|
-
const langSelector = `:root .t_lang-${name}-${language} ${fontSelector}`;
|
|
48
|
-
const selectors = language === "default" ? ` ${fontSelector}, ${langSelector}` : langSelector;
|
|
49
|
-
const cssRuleSets = declarationsToRuleSet(declarations, selectors);
|
|
50
|
-
const id = `t_font_style_${fontFamilyNameIn}`;
|
|
51
|
-
const existing = document.querySelector(`#${id}`);
|
|
52
|
-
const style = document.createElement("style");
|
|
53
|
-
style.id = id;
|
|
54
|
-
style.appendChild(document.createTextNode(`${cssRuleSets}`));
|
|
55
|
-
document.head.appendChild(style);
|
|
56
|
-
if (existing) {
|
|
57
|
-
(_a = existing.parentElement) == null ? void 0 : _a.removeChild(existing);
|
|
58
|
-
}
|
|
59
|
-
return {
|
|
60
|
-
fontFamilyToken,
|
|
61
|
-
fontDeclaration
|
|
62
|
-
};
|
|
63
|
-
}
|
|
64
|
-
}
|
|
65
|
-
}
|
|
66
|
-
export {
|
|
67
|
-
addFont
|
|
68
|
-
};
|
|
69
|
-
//# sourceMappingURL=index.mjs.map
|