@tamagui/create-system-font 0.0.0-bootstrap.0 → 3.0.0-0.canary.1791056644527
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 +21 -0
- package/dist/cjs/index.cjs +111 -0
- package/dist/cjs/index.native.cjs +129 -0
- package/dist/cjs/index.native.js +131 -0
- package/dist/cjs/index.native.js.map +1 -0
- package/dist/esm/index.js +81 -0
- package/dist/esm/index.js.map +1 -0
- package/dist/esm/index.mjs +81 -0
- package/dist/esm/index.mjs.map +1 -0
- package/dist/esm/index.native.js +97 -0
- package/dist/esm/index.native.js.map +1 -0
- package/package.json +47 -5
- package/src/index.ts +152 -0
- package/types/index.d.ts +69 -0
- package/types/index.d.ts.map +11 -0
- package/README.md +0 -1
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,111 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
|
+
var __export = (target, all) => {
|
|
6
|
+
for (var name in all) __defProp(target, name, {
|
|
7
|
+
get: all[name],
|
|
8
|
+
enumerable: true
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
var __copyProps = (to, from, except, desc) => {
|
|
12
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
13
|
+
for (let key of __getOwnPropNames(from)) if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
|
|
14
|
+
get: () => from[key],
|
|
15
|
+
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
|
|
16
|
+
});
|
|
17
|
+
}
|
|
18
|
+
return to;
|
|
19
|
+
};
|
|
20
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
21
|
+
var index_exports = {};
|
|
22
|
+
__export(index_exports, {
|
|
23
|
+
createSystemFont: () => createSystemFont,
|
|
24
|
+
defaultSystemFontLineHeight: () => defaultSystemFontLineHeight,
|
|
25
|
+
defaultSystemFontSizes: () => defaultSystemFontSizes,
|
|
26
|
+
nativeSystemFontSizes: () => nativeSystemFontSizes,
|
|
27
|
+
systemFontFamily: () => systemFontFamily,
|
|
28
|
+
v5NativeSystemFontSizes: () => v5NativeSystemFontSizes,
|
|
29
|
+
v5SystemFontLineHeight: () => v5SystemFontLineHeight,
|
|
30
|
+
v5SystemFontSizes: () => v5SystemFontSizes,
|
|
31
|
+
v5WebSystemFontSizes: () => v5WebSystemFontSizes,
|
|
32
|
+
webSystemFontSizes: () => webSystemFontSizes
|
|
33
|
+
});
|
|
34
|
+
module.exports = __toCommonJS(index_exports);
|
|
35
|
+
var import_core = require("@tamagui/core");
|
|
36
|
+
const systemFontFamily = {
|
|
37
|
+
web: "-apple-system, system-ui, BlinkMacSystemFont, \"Segoe UI\", Roboto, Helvetica, Arial, sans-serif",
|
|
38
|
+
native: "System"
|
|
39
|
+
};
|
|
40
|
+
const ramp = (start) => {
|
|
41
|
+
const out = {};
|
|
42
|
+
let px = start;
|
|
43
|
+
for (let i = 1; i <= 16; i++) {
|
|
44
|
+
out[i] = Math.round(px);
|
|
45
|
+
px *= Math.min(1.19, 1.05 + i * .019);
|
|
46
|
+
}
|
|
47
|
+
return out;
|
|
48
|
+
};
|
|
49
|
+
const webSystemFontSizes = ramp(11);
|
|
50
|
+
const nativeSystemFontSizes = ramp(13);
|
|
51
|
+
const defaultSystemFontSizes = webSystemFontSizes;
|
|
52
|
+
const defaultSystemFontLineHeight = (size) => Math.round(size * 1.35 + 3);
|
|
53
|
+
const v5WebSystemFontSizes = {
|
|
54
|
+
1: 12,
|
|
55
|
+
2: 13,
|
|
56
|
+
3: 14,
|
|
57
|
+
4: 15,
|
|
58
|
+
5: 16,
|
|
59
|
+
6: 18,
|
|
60
|
+
7: 22,
|
|
61
|
+
8: 26,
|
|
62
|
+
9: 30,
|
|
63
|
+
10: 40,
|
|
64
|
+
11: 46,
|
|
65
|
+
12: 52,
|
|
66
|
+
13: 60,
|
|
67
|
+
14: 70,
|
|
68
|
+
15: 85,
|
|
69
|
+
16: 100
|
|
70
|
+
};
|
|
71
|
+
const v5NativeSystemFontSizes = {
|
|
72
|
+
1: 11,
|
|
73
|
+
2: 12,
|
|
74
|
+
3: 15,
|
|
75
|
+
4: 17,
|
|
76
|
+
5: 20,
|
|
77
|
+
6: 22,
|
|
78
|
+
7: 24,
|
|
79
|
+
8: 28,
|
|
80
|
+
9: 32,
|
|
81
|
+
10: 40,
|
|
82
|
+
11: 46,
|
|
83
|
+
12: 52,
|
|
84
|
+
13: 60,
|
|
85
|
+
14: 70,
|
|
86
|
+
15: 85,
|
|
87
|
+
16: 100
|
|
88
|
+
};
|
|
89
|
+
const v5SystemFontSizes = v5WebSystemFontSizes;
|
|
90
|
+
const v5SystemFontLineHeight = (size) => {
|
|
91
|
+
const ratio = 1.5 - Math.max(0, (size - 20) * .004);
|
|
92
|
+
return Math.round(size * ratio);
|
|
93
|
+
};
|
|
94
|
+
const createSystemFont = (options = {}) => {
|
|
95
|
+
const { sizeLineHeight = defaultSystemFontLineHeight, sizeSize = (size2) => Math.round(size2), family = systemFontFamily.web, weight = { 1: "400" }, letterSpacing = { 4: 0 } } = options;
|
|
96
|
+
const font = options.font;
|
|
97
|
+
const sizes = options.sizes ?? defaultSystemFontSizes;
|
|
98
|
+
const fontSizes = font?.size ?? {};
|
|
99
|
+
const size = Object.fromEntries(Object.entries({
|
|
100
|
+
...sizes,
|
|
101
|
+
...fontSizes
|
|
102
|
+
}).map(([key, value]) => [key, sizeSize(+value)]));
|
|
103
|
+
return (0, import_core.createFont)({
|
|
104
|
+
family,
|
|
105
|
+
lineHeight: Object.fromEntries(Object.entries(size).map(([key, value]) => [key, sizeLineHeight((0, import_core.getVariableValue)(value))])),
|
|
106
|
+
weight,
|
|
107
|
+
letterSpacing,
|
|
108
|
+
...font,
|
|
109
|
+
size
|
|
110
|
+
});
|
|
111
|
+
};
|
|
@@ -0,0 +1,129 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
|
+
var __export = (target, all) => {
|
|
8
|
+
for (var name in all) __defProp(target, name, {
|
|
9
|
+
get: all[name],
|
|
10
|
+
enumerable: true
|
|
11
|
+
});
|
|
12
|
+
};
|
|
13
|
+
var __copyProps = (to, from, except, desc) => {
|
|
14
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
15
|
+
for (let key of __getOwnPropNames(from)) if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
|
|
16
|
+
get: () => from[key],
|
|
17
|
+
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
|
|
18
|
+
});
|
|
19
|
+
}
|
|
20
|
+
return to;
|
|
21
|
+
};
|
|
22
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
23
|
+
var index_exports = {};
|
|
24
|
+
__export(index_exports, {
|
|
25
|
+
createSystemFont: () => createSystemFont,
|
|
26
|
+
defaultSystemFontLineHeight: () => defaultSystemFontLineHeight,
|
|
27
|
+
defaultSystemFontSizes: () => defaultSystemFontSizes,
|
|
28
|
+
nativeSystemFontSizes: () => nativeSystemFontSizes,
|
|
29
|
+
systemFontFamily: () => systemFontFamily,
|
|
30
|
+
v5NativeSystemFontSizes: () => v5NativeSystemFontSizes,
|
|
31
|
+
v5SystemFontLineHeight: () => v5SystemFontLineHeight,
|
|
32
|
+
v5SystemFontSizes: () => v5SystemFontSizes,
|
|
33
|
+
v5WebSystemFontSizes: () => v5WebSystemFontSizes,
|
|
34
|
+
webSystemFontSizes: () => webSystemFontSizes
|
|
35
|
+
});
|
|
36
|
+
module.exports = __toCommonJS(index_exports);
|
|
37
|
+
var import_core = require("@tamagui/core");
|
|
38
|
+
var isWeb = false;
|
|
39
|
+
var isNative = true;
|
|
40
|
+
var systemFontFamily = {
|
|
41
|
+
web: "-apple-system, system-ui, BlinkMacSystemFont, \"Segoe UI\", Roboto, Helvetica, Arial, sans-serif",
|
|
42
|
+
native: "System"
|
|
43
|
+
};
|
|
44
|
+
var ramp = function(start) {
|
|
45
|
+
var out = {};
|
|
46
|
+
var px = start;
|
|
47
|
+
for (var i = 1; i <= 16; i++) {
|
|
48
|
+
out[i] = Math.round(px);
|
|
49
|
+
px *= Math.min(1.19, 1.05 + i * .019);
|
|
50
|
+
}
|
|
51
|
+
return out;
|
|
52
|
+
};
|
|
53
|
+
var webSystemFontSizes = ramp(11);
|
|
54
|
+
var nativeSystemFontSizes = ramp(13);
|
|
55
|
+
var defaultSystemFontSizes = isNative ? nativeSystemFontSizes : webSystemFontSizes;
|
|
56
|
+
var defaultSystemFontLineHeight = function(size) {
|
|
57
|
+
return isNative ? Math.round(size * 1.2 + 4) : Math.round(size * 1.35 + 3);
|
|
58
|
+
};
|
|
59
|
+
var v5WebSystemFontSizes = {
|
|
60
|
+
1: 12,
|
|
61
|
+
2: 13,
|
|
62
|
+
3: 14,
|
|
63
|
+
4: 15,
|
|
64
|
+
5: 16,
|
|
65
|
+
6: 18,
|
|
66
|
+
7: 22,
|
|
67
|
+
8: 26,
|
|
68
|
+
9: 30,
|
|
69
|
+
10: 40,
|
|
70
|
+
11: 46,
|
|
71
|
+
12: 52,
|
|
72
|
+
13: 60,
|
|
73
|
+
14: 70,
|
|
74
|
+
15: 85,
|
|
75
|
+
16: 100
|
|
76
|
+
};
|
|
77
|
+
var v5NativeSystemFontSizes = {
|
|
78
|
+
1: 11,
|
|
79
|
+
2: 12,
|
|
80
|
+
3: 15,
|
|
81
|
+
4: 17,
|
|
82
|
+
5: 20,
|
|
83
|
+
6: 22,
|
|
84
|
+
7: 24,
|
|
85
|
+
8: 28,
|
|
86
|
+
9: 32,
|
|
87
|
+
10: 40,
|
|
88
|
+
11: 46,
|
|
89
|
+
12: 52,
|
|
90
|
+
13: 60,
|
|
91
|
+
14: 70,
|
|
92
|
+
15: 85,
|
|
93
|
+
16: 100
|
|
94
|
+
};
|
|
95
|
+
var v5SystemFontSizes = isNative ? v5NativeSystemFontSizes : v5WebSystemFontSizes;
|
|
96
|
+
var v5SystemFontLineHeight = function(size) {
|
|
97
|
+
if (isNative) return Math.round(size + 5);
|
|
98
|
+
var ratio = 1.5 - Math.max(0, (size - 20) * .004);
|
|
99
|
+
return Math.round(size * ratio);
|
|
100
|
+
};
|
|
101
|
+
var createSystemFont = function() {
|
|
102
|
+
var options = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : {};
|
|
103
|
+
var { sizeLineHeight = defaultSystemFontLineHeight, sizeSize = function(size2) {
|
|
104
|
+
return Math.round(size2);
|
|
105
|
+
}, family = isWeb ? systemFontFamily.web : systemFontFamily.native, weight = { 1: "400" }, letterSpacing = { 4: 0 } } = options;
|
|
106
|
+
var font = options.font;
|
|
107
|
+
var _options_sizes;
|
|
108
|
+
var sizes = (_options_sizes = options.sizes) !== null && _options_sizes !== void 0 ? _options_sizes : defaultSystemFontSizes;
|
|
109
|
+
var _font_size;
|
|
110
|
+
var fontSizes = (_font_size = font === null || font === void 0 ? void 0 : font.size) !== null && _font_size !== void 0 ? _font_size : {};
|
|
111
|
+
var size = Object.fromEntries(Object.entries({
|
|
112
|
+
...sizes,
|
|
113
|
+
...fontSizes
|
|
114
|
+
}).map(function(param) {
|
|
115
|
+
var [key, value] = param;
|
|
116
|
+
return [key, sizeSize(+value)];
|
|
117
|
+
}));
|
|
118
|
+
return (0, import_core.createFont)({
|
|
119
|
+
family,
|
|
120
|
+
lineHeight: Object.fromEntries(Object.entries(size).map(function(param) {
|
|
121
|
+
var [key, value] = param;
|
|
122
|
+
return [key, sizeLineHeight((0, import_core.getVariableValue)(value))];
|
|
123
|
+
})),
|
|
124
|
+
weight,
|
|
125
|
+
letterSpacing,
|
|
126
|
+
...font,
|
|
127
|
+
size
|
|
128
|
+
});
|
|
129
|
+
};
|
|
@@ -0,0 +1,131 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
|
+
var __export = (target, all) => {
|
|
8
|
+
for (var name in all) __defProp(target, name, {
|
|
9
|
+
get: all[name],
|
|
10
|
+
enumerable: true
|
|
11
|
+
});
|
|
12
|
+
};
|
|
13
|
+
var __copyProps = (to, from, except, desc) => {
|
|
14
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
15
|
+
for (let key of __getOwnPropNames(from)) if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
|
|
16
|
+
get: () => from[key],
|
|
17
|
+
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
|
|
18
|
+
});
|
|
19
|
+
}
|
|
20
|
+
return to;
|
|
21
|
+
};
|
|
22
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
23
|
+
var index_exports = {};
|
|
24
|
+
__export(index_exports, {
|
|
25
|
+
createSystemFont: () => createSystemFont,
|
|
26
|
+
defaultSystemFontLineHeight: () => defaultSystemFontLineHeight,
|
|
27
|
+
defaultSystemFontSizes: () => defaultSystemFontSizes,
|
|
28
|
+
nativeSystemFontSizes: () => nativeSystemFontSizes,
|
|
29
|
+
systemFontFamily: () => systemFontFamily,
|
|
30
|
+
v5NativeSystemFontSizes: () => v5NativeSystemFontSizes,
|
|
31
|
+
v5SystemFontLineHeight: () => v5SystemFontLineHeight,
|
|
32
|
+
v5SystemFontSizes: () => v5SystemFontSizes,
|
|
33
|
+
v5WebSystemFontSizes: () => v5WebSystemFontSizes,
|
|
34
|
+
webSystemFontSizes: () => webSystemFontSizes
|
|
35
|
+
});
|
|
36
|
+
module.exports = __toCommonJS(index_exports);
|
|
37
|
+
var import_core = require("@tamagui/core");
|
|
38
|
+
var isWeb = false;
|
|
39
|
+
var isNative = true;
|
|
40
|
+
var systemFontFamily = {
|
|
41
|
+
web: "-apple-system, system-ui, BlinkMacSystemFont, \"Segoe UI\", Roboto, Helvetica, Arial, sans-serif",
|
|
42
|
+
native: "System"
|
|
43
|
+
};
|
|
44
|
+
var ramp = function(start) {
|
|
45
|
+
var out = {};
|
|
46
|
+
var px = start;
|
|
47
|
+
for (var i = 1; i <= 16; i++) {
|
|
48
|
+
out[i] = Math.round(px);
|
|
49
|
+
px *= Math.min(1.19, 1.05 + i * .019);
|
|
50
|
+
}
|
|
51
|
+
return out;
|
|
52
|
+
};
|
|
53
|
+
var webSystemFontSizes = ramp(11);
|
|
54
|
+
var nativeSystemFontSizes = ramp(13);
|
|
55
|
+
var defaultSystemFontSizes = isNative ? nativeSystemFontSizes : webSystemFontSizes;
|
|
56
|
+
var defaultSystemFontLineHeight = function(size) {
|
|
57
|
+
return isNative ? Math.round(size * 1.2 + 4) : Math.round(size * 1.35 + 3);
|
|
58
|
+
};
|
|
59
|
+
var v5WebSystemFontSizes = {
|
|
60
|
+
1: 12,
|
|
61
|
+
2: 13,
|
|
62
|
+
3: 14,
|
|
63
|
+
4: 15,
|
|
64
|
+
5: 16,
|
|
65
|
+
6: 18,
|
|
66
|
+
7: 22,
|
|
67
|
+
8: 26,
|
|
68
|
+
9: 30,
|
|
69
|
+
10: 40,
|
|
70
|
+
11: 46,
|
|
71
|
+
12: 52,
|
|
72
|
+
13: 60,
|
|
73
|
+
14: 70,
|
|
74
|
+
15: 85,
|
|
75
|
+
16: 100
|
|
76
|
+
};
|
|
77
|
+
var v5NativeSystemFontSizes = {
|
|
78
|
+
1: 11,
|
|
79
|
+
2: 12,
|
|
80
|
+
3: 15,
|
|
81
|
+
4: 17,
|
|
82
|
+
5: 20,
|
|
83
|
+
6: 22,
|
|
84
|
+
7: 24,
|
|
85
|
+
8: 28,
|
|
86
|
+
9: 32,
|
|
87
|
+
10: 40,
|
|
88
|
+
11: 46,
|
|
89
|
+
12: 52,
|
|
90
|
+
13: 60,
|
|
91
|
+
14: 70,
|
|
92
|
+
15: 85,
|
|
93
|
+
16: 100
|
|
94
|
+
};
|
|
95
|
+
var v5SystemFontSizes = isNative ? v5NativeSystemFontSizes : v5WebSystemFontSizes;
|
|
96
|
+
var v5SystemFontLineHeight = function(size) {
|
|
97
|
+
if (isNative) return Math.round(size + 5);
|
|
98
|
+
var ratio = 1.5 - Math.max(0, (size - 20) * .004);
|
|
99
|
+
return Math.round(size * ratio);
|
|
100
|
+
};
|
|
101
|
+
var createSystemFont = function() {
|
|
102
|
+
var options = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : {};
|
|
103
|
+
var { sizeLineHeight = defaultSystemFontLineHeight, sizeSize = function(size2) {
|
|
104
|
+
return Math.round(size2);
|
|
105
|
+
}, family = isWeb ? systemFontFamily.web : systemFontFamily.native, weight = { 1: "400" }, letterSpacing = { 4: 0 } } = options;
|
|
106
|
+
var font = options.font;
|
|
107
|
+
var _options_sizes;
|
|
108
|
+
var sizes = (_options_sizes = options.sizes) !== null && _options_sizes !== void 0 ? _options_sizes : defaultSystemFontSizes;
|
|
109
|
+
var _font_size;
|
|
110
|
+
var fontSizes = (_font_size = font === null || font === void 0 ? void 0 : font.size) !== null && _font_size !== void 0 ? _font_size : {};
|
|
111
|
+
var size = Object.fromEntries(Object.entries({
|
|
112
|
+
...sizes,
|
|
113
|
+
...fontSizes
|
|
114
|
+
}).map(function(param) {
|
|
115
|
+
var [key, value] = param;
|
|
116
|
+
return [key, sizeSize(+value)];
|
|
117
|
+
}));
|
|
118
|
+
return (0, import_core.createFont)({
|
|
119
|
+
family,
|
|
120
|
+
lineHeight: Object.fromEntries(Object.entries(size).map(function(param) {
|
|
121
|
+
var [key, value] = param;
|
|
122
|
+
return [key, sizeLineHeight((0, import_core.getVariableValue)(value))];
|
|
123
|
+
})),
|
|
124
|
+
weight,
|
|
125
|
+
letterSpacing,
|
|
126
|
+
...font,
|
|
127
|
+
size
|
|
128
|
+
});
|
|
129
|
+
};
|
|
130
|
+
|
|
131
|
+
//# sourceMappingURL=index.native.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.native.js","names":[],"sources":["cjs/index.native.js"],"sourcesContent":["\"use strict\";\nvar __defProp = Object.defineProperty;\nvar __getOwnPropDesc = Object.getOwnPropertyDescriptor;\nvar __getOwnPropNames = Object.getOwnPropertyNames;\nvar __hasOwnProp = Object.prototype.hasOwnProperty;\nvar __export = (target, all) => {\n\tfor (var name in all) __defProp(target, name, {\n\t\tget: all[name],\n\t\tenumerable: true\n\t});\n};\nvar __copyProps = (to, from, except, desc) => {\n\tif (from && typeof from === \"object\" || typeof from === \"function\") {\n\t\tfor (let key of __getOwnPropNames(from)) if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {\n\t\t\tget: () => from[key],\n\t\t\tenumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable\n\t\t});\n\t}\n\treturn to;\n};\nvar __toCommonJS = (mod) => __copyProps(__defProp({}, \"__esModule\", { value: true }), mod);\nvar index_exports = {};\n__export(index_exports, {\n\tcreateSystemFont: () => createSystemFont,\n\tdefaultSystemFontLineHeight: () => defaultSystemFontLineHeight,\n\tdefaultSystemFontSizes: () => defaultSystemFontSizes,\n\tnativeSystemFontSizes: () => nativeSystemFontSizes,\n\tsystemFontFamily: () => systemFontFamily,\n\tv5NativeSystemFontSizes: () => v5NativeSystemFontSizes,\n\tv5SystemFontLineHeight: () => v5SystemFontLineHeight,\n\tv5SystemFontSizes: () => v5SystemFontSizes,\n\tv5WebSystemFontSizes: () => v5WebSystemFontSizes,\n\twebSystemFontSizes: () => webSystemFontSizes\n});\nmodule.exports = __toCommonJS(index_exports);\nvar import_core = require(\"@tamagui/core\");\nvar isWeb = false;\nvar isNative = true;\nvar systemFontFamily = {\n\tweb: \"-apple-system, system-ui, BlinkMacSystemFont, \\\"Segoe UI\\\", Roboto, Helvetica, Arial, sans-serif\",\n\tnative: \"System\"\n};\nvar ramp = function(start) {\n\tvar out = {};\n\tvar px = start;\n\tfor (var i = 1; i <= 16; i++) {\n\t\tout[i] = Math.round(px);\n\t\tpx *= Math.min(1.19, 1.05 + i * .019);\n\t}\n\treturn out;\n};\nvar webSystemFontSizes = ramp(11);\nvar nativeSystemFontSizes = ramp(13);\nvar defaultSystemFontSizes = isNative ? nativeSystemFontSizes : webSystemFontSizes;\nvar defaultSystemFontLineHeight = function(size) {\n\treturn isNative ? Math.round(size * 1.2 + 4) : Math.round(size * 1.35 + 3);\n};\nvar v5WebSystemFontSizes = {\n\t1: 12,\n\t2: 13,\n\t3: 14,\n\t4: 15,\n\t5: 16,\n\t6: 18,\n\t7: 22,\n\t8: 26,\n\t9: 30,\n\t10: 40,\n\t11: 46,\n\t12: 52,\n\t13: 60,\n\t14: 70,\n\t15: 85,\n\t16: 100\n};\nvar v5NativeSystemFontSizes = {\n\t1: 11,\n\t2: 12,\n\t3: 15,\n\t4: 17,\n\t5: 20,\n\t6: 22,\n\t7: 24,\n\t8: 28,\n\t9: 32,\n\t10: 40,\n\t11: 46,\n\t12: 52,\n\t13: 60,\n\t14: 70,\n\t15: 85,\n\t16: 100\n};\nvar v5SystemFontSizes = isNative ? v5NativeSystemFontSizes : v5WebSystemFontSizes;\nvar v5SystemFontLineHeight = function(size) {\n\tif (isNative) return Math.round(size + 5);\n\tvar ratio = 1.5 - Math.max(0, (size - 20) * .004);\n\treturn Math.round(size * ratio);\n};\nvar createSystemFont = function() {\n\tvar options = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : {};\n\tvar { sizeLineHeight = defaultSystemFontLineHeight, sizeSize = function(size2) {\n\t\treturn Math.round(size2);\n\t}, family = isWeb ? systemFontFamily.web : systemFontFamily.native, weight = { 1: \"400\" }, letterSpacing = { 4: 0 } } = options;\n\tvar font = options.font;\n\tvar _options_sizes;\n\tvar sizes = (_options_sizes = options.sizes) !== null && _options_sizes !== void 0 ? _options_sizes : defaultSystemFontSizes;\n\tvar _font_size;\n\tvar fontSizes = (_font_size = font === null || font === void 0 ? void 0 : font.size) !== null && _font_size !== void 0 ? _font_size : {};\n\tvar size = Object.fromEntries(Object.entries({\n\t\t...sizes,\n\t\t...fontSizes\n\t}).map(function(param) {\n\t\tvar [key, value] = param;\n\t\treturn [key, sizeSize(+value)];\n\t}));\n\treturn (0, import_core.createFont)({\n\t\tfamily,\n\t\tlineHeight: Object.fromEntries(Object.entries(size).map(function(param) {\n\t\t\tvar [key, value] = param;\n\t\t\treturn [key, sizeLineHeight((0, import_core.getVariableValue)(value))];\n\t\t})),\n\t\tweight,\n\t\tletterSpacing,\n\t\t...font,\n\t\tsize\n\t});\n};\n//# sourceMappingURL=index.js.map\n"],"mappings":";;;AACA,IAAI,YAAY,OAAO;AACvB,IAAI,mBAAmB,OAAO;AAC9B,IAAI,oBAAoB,OAAO;AAC/B,IAAI,eAAe,OAAO,UAAU;AACpC,IAAI,YAAY,QAAQ,QAAQ;CAC/B,KAAK,IAAI,QAAQ,KAAK,UAAU,QAAQ,MAAM;EAC7C,KAAK,IAAI;EACT,YAAY;CACb,CAAC;AACF;AACA,IAAI,eAAe,IAAI,MAAM,QAAQ,SAAS;CAC7C,IAAI,QAAQ,OAAO,SAAS,YAAY,OAAO,SAAS,YAAY;EACnE,KAAK,IAAI,OAAO,kBAAkB,IAAI,GAAG,IAAI,CAAC,aAAa,KAAK,IAAI,GAAG,KAAK,QAAQ,QAAQ,UAAU,IAAI,KAAK;GAC9G,WAAW,KAAK;GAChB,YAAY,EAAE,OAAO,iBAAiB,MAAM,GAAG,MAAM,KAAK;EAC3D,CAAC;CACF;CACA,OAAO;AACR;AACA,IAAI,gBAAgB,QAAQ,YAAY,UAAU,CAAC,GAAG,cAAc,EAAE,OAAO,KAAK,CAAC,GAAG,GAAG;AACzF,IAAI,gBAAgB,CAAC;AACrB,SAAS,eAAe;CACvB,wBAAwB;CACxB,mCAAmC;CACnC,8BAA8B;CAC9B,6BAA6B;CAC7B,wBAAwB;CACxB,+BAA+B;CAC/B,8BAA8B;CAC9B,yBAAyB;CACzB,4BAA4B;CAC5B,0BAA0B;AAC3B,CAAC;AACD,OAAO,UAAU,aAAa,aAAa;AAC3C,IAAI,cAAc,QAAQ,eAAe;AACzC,IAAI,QAAQ;AACZ,IAAI,WAAW;AACf,IAAI,mBAAmB;CACtB,KAAK;CACL,QAAQ;AACT;AACA,IAAI,OAAO,SAAS,OAAO;CAC1B,IAAI,MAAM,CAAC;CACX,IAAI,KAAK;CACT,KAAK,IAAI,IAAI,GAAG,KAAK,IAAI,KAAK;EAC7B,IAAI,KAAK,KAAK,MAAM,EAAE;EACtB,MAAM,KAAK,IAAI,MAAM,OAAO,IAAI,IAAI;CACrC;CACA,OAAO;AACR;AACA,IAAI,qBAAqB,KAAK,EAAE;AAChC,IAAI,wBAAwB,KAAK,EAAE;AACnC,IAAI,yBAAyB,WAAW,wBAAwB;AAChE,IAAI,8BAA8B,SAAS,MAAM;CAChD,OAAO,WAAW,KAAK,MAAM,OAAO,MAAM,CAAC,IAAI,KAAK,MAAM,OAAO,OAAO,CAAC;AAC1E;AACA,IAAI,uBAAuB;CAC1B,GAAG;CACH,GAAG;CACH,GAAG;CACH,GAAG;CACH,GAAG;CACH,GAAG;CACH,GAAG;CACH,GAAG;CACH,GAAG;CACH,IAAI;CACJ,IAAI;CACJ,IAAI;CACJ,IAAI;CACJ,IAAI;CACJ,IAAI;CACJ,IAAI;AACL;AACA,IAAI,0BAA0B;CAC7B,GAAG;CACH,GAAG;CACH,GAAG;CACH,GAAG;CACH,GAAG;CACH,GAAG;CACH,GAAG;CACH,GAAG;CACH,GAAG;CACH,IAAI;CACJ,IAAI;CACJ,IAAI;CACJ,IAAI;CACJ,IAAI;CACJ,IAAI;CACJ,IAAI;AACL;AACA,IAAI,oBAAoB,WAAW,0BAA0B;AAC7D,IAAI,yBAAyB,SAAS,MAAM;CAC3C,IAAI,UAAU,OAAO,KAAK,MAAM,OAAO,CAAC;CACxC,IAAI,QAAQ,MAAM,KAAK,IAAI,IAAI,OAAO,MAAM,IAAI;CAChD,OAAO,KAAK,MAAM,OAAO,KAAK;AAC/B;AACA,IAAI,mBAAmB,WAAW;CACjC,IAAI,UAAU,UAAU,SAAS,KAAK,UAAU,OAAO,KAAK,IAAI,UAAU,KAAK,CAAC;CAChF,IAAI,EAAE,iBAAiB,6BAA6B,WAAW,SAAS,OAAO;EAC9E,OAAO,KAAK,MAAM,KAAK;CACxB,GAAG,SAAS,QAAQ,iBAAiB,MAAM,iBAAiB,QAAQ,SAAS,EAAE,GAAG,MAAM,GAAG,gBAAgB,EAAE,GAAG,EAAE,MAAM;CACxH,IAAI,OAAO,QAAQ;CACnB,IAAI;CACJ,IAAI,SAAS,iBAAiB,QAAQ,WAAW,QAAQ,mBAAmB,KAAK,IAAI,iBAAiB;CACtG,IAAI;CACJ,IAAI,aAAa,aAAa,SAAS,QAAQ,SAAS,KAAK,IAAI,KAAK,IAAI,KAAK,UAAU,QAAQ,eAAe,KAAK,IAAI,aAAa,CAAC;CACvI,IAAI,OAAO,OAAO,YAAY,OAAO,QAAQ;EAC5C,GAAG;EACH,GAAG;CACJ,CAAC,CAAC,CAAC,IAAI,SAAS,OAAO;EACtB,IAAI,CAAC,KAAK,SAAS;EACnB,OAAO,CAAC,KAAK,SAAS,CAAC,KAAK,CAAC;CAC9B,CAAC,CAAC;CACF,QAAQ,GAAG,YAAY,WAAU,CAAE;EAClC;EACA,YAAY,OAAO,YAAY,OAAO,QAAQ,IAAI,CAAC,CAAC,IAAI,SAAS,OAAO;GACvE,IAAI,CAAC,KAAK,SAAS;GACnB,OAAO,CAAC,KAAK,gBAAgB,GAAG,YAAY,iBAAgB,CAAE,KAAK,CAAC,CAAC;EACtE,CAAC,CAAC;EACF;EACA;EACA,GAAG;EACH;CACD,CAAC;AACF"}
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
import { createFont, getVariableValue } from "@tamagui/core";
|
|
2
|
+
|
|
3
|
+
const systemFontFamily = {
|
|
4
|
+
web: "-apple-system, system-ui, BlinkMacSystemFont, \"Segoe UI\", Roboto, Helvetica, Arial, sans-serif",
|
|
5
|
+
native: "System"
|
|
6
|
+
};
|
|
7
|
+
const ramp = (start) => {
|
|
8
|
+
const out = {};
|
|
9
|
+
let px = start;
|
|
10
|
+
for (let i = 1; i <= 16; i++) {
|
|
11
|
+
out[i] = Math.round(px);
|
|
12
|
+
px *= Math.min(1.19, 1.05 + i * .019);
|
|
13
|
+
}
|
|
14
|
+
return out;
|
|
15
|
+
};
|
|
16
|
+
const webSystemFontSizes = ramp(11);
|
|
17
|
+
const nativeSystemFontSizes = ramp(13);
|
|
18
|
+
const defaultSystemFontSizes = webSystemFontSizes;
|
|
19
|
+
const defaultSystemFontLineHeight = (size) => Math.round(size * 1.35 + 3);
|
|
20
|
+
const v5WebSystemFontSizes = {
|
|
21
|
+
1: 12,
|
|
22
|
+
2: 13,
|
|
23
|
+
3: 14,
|
|
24
|
+
4: 15,
|
|
25
|
+
5: 16,
|
|
26
|
+
6: 18,
|
|
27
|
+
7: 22,
|
|
28
|
+
8: 26,
|
|
29
|
+
9: 30,
|
|
30
|
+
10: 40,
|
|
31
|
+
11: 46,
|
|
32
|
+
12: 52,
|
|
33
|
+
13: 60,
|
|
34
|
+
14: 70,
|
|
35
|
+
15: 85,
|
|
36
|
+
16: 100
|
|
37
|
+
};
|
|
38
|
+
const v5NativeSystemFontSizes = {
|
|
39
|
+
1: 11,
|
|
40
|
+
2: 12,
|
|
41
|
+
3: 15,
|
|
42
|
+
4: 17,
|
|
43
|
+
5: 20,
|
|
44
|
+
6: 22,
|
|
45
|
+
7: 24,
|
|
46
|
+
8: 28,
|
|
47
|
+
9: 32,
|
|
48
|
+
10: 40,
|
|
49
|
+
11: 46,
|
|
50
|
+
12: 52,
|
|
51
|
+
13: 60,
|
|
52
|
+
14: 70,
|
|
53
|
+
15: 85,
|
|
54
|
+
16: 100
|
|
55
|
+
};
|
|
56
|
+
const v5SystemFontSizes = v5WebSystemFontSizes;
|
|
57
|
+
const v5SystemFontLineHeight = (size) => {
|
|
58
|
+
const ratio = 1.5 - Math.max(0, (size - 20) * .004);
|
|
59
|
+
return Math.round(size * ratio);
|
|
60
|
+
};
|
|
61
|
+
const createSystemFont = (options = {}) => {
|
|
62
|
+
const { sizeLineHeight = defaultSystemFontLineHeight, sizeSize = (size2) => Math.round(size2), family = systemFontFamily.web, weight = { 1: "400" }, letterSpacing = { 4: 0 } } = options;
|
|
63
|
+
const font = options.font;
|
|
64
|
+
const sizes = options.sizes ?? defaultSystemFontSizes;
|
|
65
|
+
const fontSizes = font?.size ?? {};
|
|
66
|
+
const size = Object.fromEntries(Object.entries({
|
|
67
|
+
...sizes,
|
|
68
|
+
...fontSizes
|
|
69
|
+
}).map(([key, value]) => [key, sizeSize(+value)]));
|
|
70
|
+
return createFont({
|
|
71
|
+
family,
|
|
72
|
+
lineHeight: Object.fromEntries(Object.entries(size).map(([key, value]) => [key, sizeLineHeight(getVariableValue(value))])),
|
|
73
|
+
weight,
|
|
74
|
+
letterSpacing,
|
|
75
|
+
...font,
|
|
76
|
+
size
|
|
77
|
+
});
|
|
78
|
+
};
|
|
79
|
+
|
|
80
|
+
export { createSystemFont, defaultSystemFontLineHeight, defaultSystemFontSizes, nativeSystemFontSizes, systemFontFamily, v5NativeSystemFontSizes, v5SystemFontLineHeight, v5SystemFontSizes, v5WebSystemFontSizes, webSystemFontSizes };
|
|
81
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","names":[],"sources":["esm/index.js"],"sourcesContent":["import { createFont, getVariableValue } from \"@tamagui/core\";\n\nconst systemFontFamily = {\n\tweb: \"-apple-system, system-ui, BlinkMacSystemFont, \\\"Segoe UI\\\", Roboto, Helvetica, Arial, sans-serif\",\n\tnative: \"System\"\n};\nconst ramp = (start) => {\n\tconst out = {};\n\tlet px = start;\n\tfor (let i = 1; i <= 16; i++) {\n\t\tout[i] = Math.round(px);\n\t\tpx *= Math.min(1.19, 1.05 + i * .019);\n\t}\n\treturn out;\n};\nconst webSystemFontSizes = ramp(11);\nconst nativeSystemFontSizes = ramp(13);\nconst defaultSystemFontSizes = webSystemFontSizes;\nconst defaultSystemFontLineHeight = (size) => Math.round(size * 1.35 + 3);\nconst v5WebSystemFontSizes = {\n\t1: 12,\n\t2: 13,\n\t3: 14,\n\t4: 15,\n\t5: 16,\n\t6: 18,\n\t7: 22,\n\t8: 26,\n\t9: 30,\n\t10: 40,\n\t11: 46,\n\t12: 52,\n\t13: 60,\n\t14: 70,\n\t15: 85,\n\t16: 100\n};\nconst v5NativeSystemFontSizes = {\n\t1: 11,\n\t2: 12,\n\t3: 15,\n\t4: 17,\n\t5: 20,\n\t6: 22,\n\t7: 24,\n\t8: 28,\n\t9: 32,\n\t10: 40,\n\t11: 46,\n\t12: 52,\n\t13: 60,\n\t14: 70,\n\t15: 85,\n\t16: 100\n};\nconst v5SystemFontSizes = v5WebSystemFontSizes;\nconst v5SystemFontLineHeight = (size) => {\n\tconst ratio = 1.5 - Math.max(0, (size - 20) * .004);\n\treturn Math.round(size * ratio);\n};\nconst createSystemFont = (options = {}) => {\n\tconst { sizeLineHeight = defaultSystemFontLineHeight, sizeSize = (size2) => Math.round(size2), family = systemFontFamily.web, weight = { 1: \"400\" }, letterSpacing = { 4: 0 } } = options;\n\tconst font = options.font;\n\tconst sizes = options.sizes ?? defaultSystemFontSizes;\n\tconst fontSizes = font?.size ?? {};\n\tconst size = Object.fromEntries(Object.entries({\n\t\t...sizes,\n\t\t...fontSizes\n\t}).map(([key, value]) => [key, sizeSize(+value)]));\n\treturn createFont({\n\t\tfamily,\n\t\tlineHeight: Object.fromEntries(Object.entries(size).map(([key, value]) => [key, sizeLineHeight(getVariableValue(value))])),\n\t\tweight,\n\t\tletterSpacing,\n\t\t...font,\n\t\tsize\n\t});\n};\n\nexport { createSystemFont, defaultSystemFontLineHeight, defaultSystemFontSizes, nativeSystemFontSizes, systemFontFamily, v5NativeSystemFontSizes, v5SystemFontLineHeight, v5SystemFontSizes, v5WebSystemFontSizes, webSystemFontSizes };"],"mappings":";;;AAEA,MAAM,mBAAmB;CACxB,KAAK;CACL,QAAQ;AACT;AACA,MAAM,QAAQ,UAAU;CACvB,MAAM,MAAM,CAAC;CACb,IAAI,KAAK;CACT,KAAK,IAAI,IAAI,GAAG,KAAK,IAAI,KAAK;EAC7B,IAAI,KAAK,KAAK,MAAM,EAAE;EACtB,MAAM,KAAK,IAAI,MAAM,OAAO,IAAI,IAAI;CACrC;CACA,OAAO;AACR;AACA,MAAM,qBAAqB,KAAK,EAAE;AAClC,MAAM,wBAAwB,KAAK,EAAE;AACrC,MAAM,yBAAyB;AAC/B,MAAM,+BAA+B,SAAS,KAAK,MAAM,OAAO,OAAO,CAAC;AACxE,MAAM,uBAAuB;CAC5B,GAAG;CACH,GAAG;CACH,GAAG;CACH,GAAG;CACH,GAAG;CACH,GAAG;CACH,GAAG;CACH,GAAG;CACH,GAAG;CACH,IAAI;CACJ,IAAI;CACJ,IAAI;CACJ,IAAI;CACJ,IAAI;CACJ,IAAI;CACJ,IAAI;AACL;AACA,MAAM,0BAA0B;CAC/B,GAAG;CACH,GAAG;CACH,GAAG;CACH,GAAG;CACH,GAAG;CACH,GAAG;CACH,GAAG;CACH,GAAG;CACH,GAAG;CACH,IAAI;CACJ,IAAI;CACJ,IAAI;CACJ,IAAI;CACJ,IAAI;CACJ,IAAI;CACJ,IAAI;AACL;AACA,MAAM,oBAAoB;AAC1B,MAAM,0BAA0B,SAAS;CACxC,MAAM,QAAQ,MAAM,KAAK,IAAI,IAAI,OAAO,MAAM,IAAI;CAClD,OAAO,KAAK,MAAM,OAAO,KAAK;AAC/B;AACA,MAAM,oBAAoB,UAAU,CAAC,MAAM;CAC1C,MAAM,EAAE,iBAAiB,6BAA6B,YAAY,UAAU,KAAK,MAAM,KAAK,GAAG,SAAS,iBAAiB,KAAK,SAAS,EAAE,GAAG,MAAM,GAAG,gBAAgB,EAAE,GAAG,EAAE,MAAM;CAClL,MAAM,OAAO,QAAQ;CACrB,MAAM,QAAQ,QAAQ,SAAS;CAC/B,MAAM,YAAY,MAAM,QAAQ,CAAC;CACjC,MAAM,OAAO,OAAO,YAAY,OAAO,QAAQ;EAC9C,GAAG;EACH,GAAG;CACJ,CAAC,CAAC,CAAC,KAAK,CAAC,KAAK,WAAW,CAAC,KAAK,SAAS,CAAC,KAAK,CAAC,CAAC,CAAC;CACjD,OAAO,WAAW;EACjB;EACA,YAAY,OAAO,YAAY,OAAO,QAAQ,IAAI,CAAC,CAAC,KAAK,CAAC,KAAK,WAAW,CAAC,KAAK,eAAe,iBAAiB,KAAK,CAAC,CAAC,CAAC,CAAC;EACzH;EACA;EACA,GAAG;EACH;CACD,CAAC;AACF"}
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
import { createFont, getVariableValue } from "@tamagui/core";
|
|
2
|
+
|
|
3
|
+
const systemFontFamily = {
|
|
4
|
+
web: "-apple-system, system-ui, BlinkMacSystemFont, \"Segoe UI\", Roboto, Helvetica, Arial, sans-serif",
|
|
5
|
+
native: "System"
|
|
6
|
+
};
|
|
7
|
+
const ramp = (start) => {
|
|
8
|
+
const out = {};
|
|
9
|
+
let px = start;
|
|
10
|
+
for (let i = 1; i <= 16; i++) {
|
|
11
|
+
out[i] = Math.round(px);
|
|
12
|
+
px *= Math.min(1.19, 1.05 + i * .019);
|
|
13
|
+
}
|
|
14
|
+
return out;
|
|
15
|
+
};
|
|
16
|
+
const webSystemFontSizes = ramp(11);
|
|
17
|
+
const nativeSystemFontSizes = ramp(13);
|
|
18
|
+
const defaultSystemFontSizes = webSystemFontSizes;
|
|
19
|
+
const defaultSystemFontLineHeight = (size) => Math.round(size * 1.35 + 3);
|
|
20
|
+
const v5WebSystemFontSizes = {
|
|
21
|
+
1: 12,
|
|
22
|
+
2: 13,
|
|
23
|
+
3: 14,
|
|
24
|
+
4: 15,
|
|
25
|
+
5: 16,
|
|
26
|
+
6: 18,
|
|
27
|
+
7: 22,
|
|
28
|
+
8: 26,
|
|
29
|
+
9: 30,
|
|
30
|
+
10: 40,
|
|
31
|
+
11: 46,
|
|
32
|
+
12: 52,
|
|
33
|
+
13: 60,
|
|
34
|
+
14: 70,
|
|
35
|
+
15: 85,
|
|
36
|
+
16: 100
|
|
37
|
+
};
|
|
38
|
+
const v5NativeSystemFontSizes = {
|
|
39
|
+
1: 11,
|
|
40
|
+
2: 12,
|
|
41
|
+
3: 15,
|
|
42
|
+
4: 17,
|
|
43
|
+
5: 20,
|
|
44
|
+
6: 22,
|
|
45
|
+
7: 24,
|
|
46
|
+
8: 28,
|
|
47
|
+
9: 32,
|
|
48
|
+
10: 40,
|
|
49
|
+
11: 46,
|
|
50
|
+
12: 52,
|
|
51
|
+
13: 60,
|
|
52
|
+
14: 70,
|
|
53
|
+
15: 85,
|
|
54
|
+
16: 100
|
|
55
|
+
};
|
|
56
|
+
const v5SystemFontSizes = v5WebSystemFontSizes;
|
|
57
|
+
const v5SystemFontLineHeight = (size) => {
|
|
58
|
+
const ratio = 1.5 - Math.max(0, (size - 20) * .004);
|
|
59
|
+
return Math.round(size * ratio);
|
|
60
|
+
};
|
|
61
|
+
const createSystemFont = (options = {}) => {
|
|
62
|
+
const { sizeLineHeight = defaultSystemFontLineHeight, sizeSize = (size2) => Math.round(size2), family = systemFontFamily.web, weight = { 1: "400" }, letterSpacing = { 4: 0 } } = options;
|
|
63
|
+
const font = options.font;
|
|
64
|
+
const sizes = options.sizes ?? defaultSystemFontSizes;
|
|
65
|
+
const fontSizes = font?.size ?? {};
|
|
66
|
+
const size = Object.fromEntries(Object.entries({
|
|
67
|
+
...sizes,
|
|
68
|
+
...fontSizes
|
|
69
|
+
}).map(([key, value]) => [key, sizeSize(+value)]));
|
|
70
|
+
return createFont({
|
|
71
|
+
family,
|
|
72
|
+
lineHeight: Object.fromEntries(Object.entries(size).map(([key, value]) => [key, sizeLineHeight(getVariableValue(value))])),
|
|
73
|
+
weight,
|
|
74
|
+
letterSpacing,
|
|
75
|
+
...font,
|
|
76
|
+
size
|
|
77
|
+
});
|
|
78
|
+
};
|
|
79
|
+
|
|
80
|
+
export { createSystemFont, defaultSystemFontLineHeight, defaultSystemFontSizes, nativeSystemFontSizes, systemFontFamily, v5NativeSystemFontSizes, v5SystemFontLineHeight, v5SystemFontSizes, v5WebSystemFontSizes, webSystemFontSizes };
|
|
81
|
+
//# sourceMappingURL=index.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","names":[],"sources":["esm/index.js"],"sourcesContent":["import { createFont, getVariableValue } from \"@tamagui/core\";\n\nconst systemFontFamily = {\n\tweb: \"-apple-system, system-ui, BlinkMacSystemFont, \\\"Segoe UI\\\", Roboto, Helvetica, Arial, sans-serif\",\n\tnative: \"System\"\n};\nconst ramp = (start) => {\n\tconst out = {};\n\tlet px = start;\n\tfor (let i = 1; i <= 16; i++) {\n\t\tout[i] = Math.round(px);\n\t\tpx *= Math.min(1.19, 1.05 + i * .019);\n\t}\n\treturn out;\n};\nconst webSystemFontSizes = ramp(11);\nconst nativeSystemFontSizes = ramp(13);\nconst defaultSystemFontSizes = webSystemFontSizes;\nconst defaultSystemFontLineHeight = (size) => Math.round(size * 1.35 + 3);\nconst v5WebSystemFontSizes = {\n\t1: 12,\n\t2: 13,\n\t3: 14,\n\t4: 15,\n\t5: 16,\n\t6: 18,\n\t7: 22,\n\t8: 26,\n\t9: 30,\n\t10: 40,\n\t11: 46,\n\t12: 52,\n\t13: 60,\n\t14: 70,\n\t15: 85,\n\t16: 100\n};\nconst v5NativeSystemFontSizes = {\n\t1: 11,\n\t2: 12,\n\t3: 15,\n\t4: 17,\n\t5: 20,\n\t6: 22,\n\t7: 24,\n\t8: 28,\n\t9: 32,\n\t10: 40,\n\t11: 46,\n\t12: 52,\n\t13: 60,\n\t14: 70,\n\t15: 85,\n\t16: 100\n};\nconst v5SystemFontSizes = v5WebSystemFontSizes;\nconst v5SystemFontLineHeight = (size) => {\n\tconst ratio = 1.5 - Math.max(0, (size - 20) * .004);\n\treturn Math.round(size * ratio);\n};\nconst createSystemFont = (options = {}) => {\n\tconst { sizeLineHeight = defaultSystemFontLineHeight, sizeSize = (size2) => Math.round(size2), family = systemFontFamily.web, weight = { 1: \"400\" }, letterSpacing = { 4: 0 } } = options;\n\tconst font = options.font;\n\tconst sizes = options.sizes ?? defaultSystemFontSizes;\n\tconst fontSizes = font?.size ?? {};\n\tconst size = Object.fromEntries(Object.entries({\n\t\t...sizes,\n\t\t...fontSizes\n\t}).map(([key, value]) => [key, sizeSize(+value)]));\n\treturn createFont({\n\t\tfamily,\n\t\tlineHeight: Object.fromEntries(Object.entries(size).map(([key, value]) => [key, sizeLineHeight(getVariableValue(value))])),\n\t\tweight,\n\t\tletterSpacing,\n\t\t...font,\n\t\tsize\n\t});\n};\n\nexport { createSystemFont, defaultSystemFontLineHeight, defaultSystemFontSizes, nativeSystemFontSizes, systemFontFamily, v5NativeSystemFontSizes, v5SystemFontLineHeight, v5SystemFontSizes, v5WebSystemFontSizes, webSystemFontSizes };"],"mappings":";;;AAEA,MAAM,mBAAmB;CACxB,KAAK;CACL,QAAQ;AACT;AACA,MAAM,QAAQ,UAAU;CACvB,MAAM,MAAM,CAAC;CACb,IAAI,KAAK;CACT,KAAK,IAAI,IAAI,GAAG,KAAK,IAAI,KAAK;EAC7B,IAAI,KAAK,KAAK,MAAM,EAAE;EACtB,MAAM,KAAK,IAAI,MAAM,OAAO,IAAI,IAAI;CACrC;CACA,OAAO;AACR;AACA,MAAM,qBAAqB,KAAK,EAAE;AAClC,MAAM,wBAAwB,KAAK,EAAE;AACrC,MAAM,yBAAyB;AAC/B,MAAM,+BAA+B,SAAS,KAAK,MAAM,OAAO,OAAO,CAAC;AACxE,MAAM,uBAAuB;CAC5B,GAAG;CACH,GAAG;CACH,GAAG;CACH,GAAG;CACH,GAAG;CACH,GAAG;CACH,GAAG;CACH,GAAG;CACH,GAAG;CACH,IAAI;CACJ,IAAI;CACJ,IAAI;CACJ,IAAI;CACJ,IAAI;CACJ,IAAI;CACJ,IAAI;AACL;AACA,MAAM,0BAA0B;CAC/B,GAAG;CACH,GAAG;CACH,GAAG;CACH,GAAG;CACH,GAAG;CACH,GAAG;CACH,GAAG;CACH,GAAG;CACH,GAAG;CACH,IAAI;CACJ,IAAI;CACJ,IAAI;CACJ,IAAI;CACJ,IAAI;CACJ,IAAI;CACJ,IAAI;AACL;AACA,MAAM,oBAAoB;AAC1B,MAAM,0BAA0B,SAAS;CACxC,MAAM,QAAQ,MAAM,KAAK,IAAI,IAAI,OAAO,MAAM,IAAI;CAClD,OAAO,KAAK,MAAM,OAAO,KAAK;AAC/B;AACA,MAAM,oBAAoB,UAAU,CAAC,MAAM;CAC1C,MAAM,EAAE,iBAAiB,6BAA6B,YAAY,UAAU,KAAK,MAAM,KAAK,GAAG,SAAS,iBAAiB,KAAK,SAAS,EAAE,GAAG,MAAM,GAAG,gBAAgB,EAAE,GAAG,EAAE,MAAM;CAClL,MAAM,OAAO,QAAQ;CACrB,MAAM,QAAQ,QAAQ,SAAS;CAC/B,MAAM,YAAY,MAAM,QAAQ,CAAC;CACjC,MAAM,OAAO,OAAO,YAAY,OAAO,QAAQ;EAC9C,GAAG;EACH,GAAG;CACJ,CAAC,CAAC,CAAC,KAAK,CAAC,KAAK,WAAW,CAAC,KAAK,SAAS,CAAC,KAAK,CAAC,CAAC,CAAC;CACjD,OAAO,WAAW;EACjB;EACA,YAAY,OAAO,YAAY,OAAO,QAAQ,IAAI,CAAC,CAAC,KAAK,CAAC,KAAK,WAAW,CAAC,KAAK,eAAe,iBAAiB,KAAK,CAAC,CAAC,CAAC,CAAC;EACzH;EACA;EACA,GAAG;EACH;CACD,CAAC;AACF"}
|
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
import { createFont, getVariableValue } from "@tamagui/core";
|
|
2
|
+
|
|
3
|
+
var isWeb = false;
|
|
4
|
+
var isNative = true;
|
|
5
|
+
var systemFontFamily = {
|
|
6
|
+
web: "-apple-system, system-ui, BlinkMacSystemFont, \"Segoe UI\", Roboto, Helvetica, Arial, sans-serif",
|
|
7
|
+
native: "System"
|
|
8
|
+
};
|
|
9
|
+
var ramp = function(start) {
|
|
10
|
+
var out = {};
|
|
11
|
+
var px = start;
|
|
12
|
+
for (var i = 1; i <= 16; i++) {
|
|
13
|
+
out[i] = Math.round(px);
|
|
14
|
+
px *= Math.min(1.19, 1.05 + i * .019);
|
|
15
|
+
}
|
|
16
|
+
return out;
|
|
17
|
+
};
|
|
18
|
+
var webSystemFontSizes = ramp(11);
|
|
19
|
+
var nativeSystemFontSizes = ramp(13);
|
|
20
|
+
var defaultSystemFontSizes = isNative ? nativeSystemFontSizes : webSystemFontSizes;
|
|
21
|
+
var defaultSystemFontLineHeight = function(size) {
|
|
22
|
+
return isNative ? Math.round(size * 1.2 + 4) : Math.round(size * 1.35 + 3);
|
|
23
|
+
};
|
|
24
|
+
var v5WebSystemFontSizes = {
|
|
25
|
+
1: 12,
|
|
26
|
+
2: 13,
|
|
27
|
+
3: 14,
|
|
28
|
+
4: 15,
|
|
29
|
+
5: 16,
|
|
30
|
+
6: 18,
|
|
31
|
+
7: 22,
|
|
32
|
+
8: 26,
|
|
33
|
+
9: 30,
|
|
34
|
+
10: 40,
|
|
35
|
+
11: 46,
|
|
36
|
+
12: 52,
|
|
37
|
+
13: 60,
|
|
38
|
+
14: 70,
|
|
39
|
+
15: 85,
|
|
40
|
+
16: 100
|
|
41
|
+
};
|
|
42
|
+
var v5NativeSystemFontSizes = {
|
|
43
|
+
1: 11,
|
|
44
|
+
2: 12,
|
|
45
|
+
3: 15,
|
|
46
|
+
4: 17,
|
|
47
|
+
5: 20,
|
|
48
|
+
6: 22,
|
|
49
|
+
7: 24,
|
|
50
|
+
8: 28,
|
|
51
|
+
9: 32,
|
|
52
|
+
10: 40,
|
|
53
|
+
11: 46,
|
|
54
|
+
12: 52,
|
|
55
|
+
13: 60,
|
|
56
|
+
14: 70,
|
|
57
|
+
15: 85,
|
|
58
|
+
16: 100
|
|
59
|
+
};
|
|
60
|
+
var v5SystemFontSizes = isNative ? v5NativeSystemFontSizes : v5WebSystemFontSizes;
|
|
61
|
+
var v5SystemFontLineHeight = function(size) {
|
|
62
|
+
if (isNative) return Math.round(size + 5);
|
|
63
|
+
var ratio = 1.5 - Math.max(0, (size - 20) * .004);
|
|
64
|
+
return Math.round(size * ratio);
|
|
65
|
+
};
|
|
66
|
+
var createSystemFont = function() {
|
|
67
|
+
var options = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : {};
|
|
68
|
+
var { sizeLineHeight = defaultSystemFontLineHeight, sizeSize = function(size2) {
|
|
69
|
+
return Math.round(size2);
|
|
70
|
+
}, family = isWeb ? systemFontFamily.web : systemFontFamily.native, weight = { 1: "400" }, letterSpacing = { 4: 0 } } = options;
|
|
71
|
+
var font = options.font;
|
|
72
|
+
var _options_sizes;
|
|
73
|
+
var sizes = (_options_sizes = options.sizes) !== null && _options_sizes !== void 0 ? _options_sizes : defaultSystemFontSizes;
|
|
74
|
+
var _font_size;
|
|
75
|
+
var fontSizes = (_font_size = font === null || font === void 0 ? void 0 : font.size) !== null && _font_size !== void 0 ? _font_size : {};
|
|
76
|
+
var size = Object.fromEntries(Object.entries({
|
|
77
|
+
...sizes,
|
|
78
|
+
...fontSizes
|
|
79
|
+
}).map(function(param) {
|
|
80
|
+
var [key, value] = param;
|
|
81
|
+
return [key, sizeSize(+value)];
|
|
82
|
+
}));
|
|
83
|
+
return createFont({
|
|
84
|
+
family,
|
|
85
|
+
lineHeight: Object.fromEntries(Object.entries(size).map(function(param) {
|
|
86
|
+
var [key, value] = param;
|
|
87
|
+
return [key, sizeLineHeight(getVariableValue(value))];
|
|
88
|
+
})),
|
|
89
|
+
weight,
|
|
90
|
+
letterSpacing,
|
|
91
|
+
...font,
|
|
92
|
+
size
|
|
93
|
+
});
|
|
94
|
+
};
|
|
95
|
+
|
|
96
|
+
export { createSystemFont, defaultSystemFontLineHeight, defaultSystemFontSizes, nativeSystemFontSizes, systemFontFamily, v5NativeSystemFontSizes, v5SystemFontLineHeight, v5SystemFontSizes, v5WebSystemFontSizes, webSystemFontSizes };
|
|
97
|
+
//# sourceMappingURL=index.native.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.native.js","names":[],"sources":["esm/index.native.js"],"sourcesContent":["import { createFont, getVariableValue } from \"@tamagui/core\";\n\nvar isWeb = false;\nvar isNative = true;\nvar systemFontFamily = {\n\tweb: \"-apple-system, system-ui, BlinkMacSystemFont, \\\"Segoe UI\\\", Roboto, Helvetica, Arial, sans-serif\",\n\tnative: \"System\"\n};\nvar ramp = function(start) {\n\tvar out = {};\n\tvar px = start;\n\tfor (var i = 1; i <= 16; i++) {\n\t\tout[i] = Math.round(px);\n\t\tpx *= Math.min(1.19, 1.05 + i * .019);\n\t}\n\treturn out;\n};\nvar webSystemFontSizes = ramp(11);\nvar nativeSystemFontSizes = ramp(13);\nvar defaultSystemFontSizes = isNative ? nativeSystemFontSizes : webSystemFontSizes;\nvar defaultSystemFontLineHeight = function(size) {\n\treturn isNative ? Math.round(size * 1.2 + 4) : Math.round(size * 1.35 + 3);\n};\nvar v5WebSystemFontSizes = {\n\t1: 12,\n\t2: 13,\n\t3: 14,\n\t4: 15,\n\t5: 16,\n\t6: 18,\n\t7: 22,\n\t8: 26,\n\t9: 30,\n\t10: 40,\n\t11: 46,\n\t12: 52,\n\t13: 60,\n\t14: 70,\n\t15: 85,\n\t16: 100\n};\nvar v5NativeSystemFontSizes = {\n\t1: 11,\n\t2: 12,\n\t3: 15,\n\t4: 17,\n\t5: 20,\n\t6: 22,\n\t7: 24,\n\t8: 28,\n\t9: 32,\n\t10: 40,\n\t11: 46,\n\t12: 52,\n\t13: 60,\n\t14: 70,\n\t15: 85,\n\t16: 100\n};\nvar v5SystemFontSizes = isNative ? v5NativeSystemFontSizes : v5WebSystemFontSizes;\nvar v5SystemFontLineHeight = function(size) {\n\tif (isNative) return Math.round(size + 5);\n\tvar ratio = 1.5 - Math.max(0, (size - 20) * .004);\n\treturn Math.round(size * ratio);\n};\nvar createSystemFont = function() {\n\tvar options = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : {};\n\tvar { sizeLineHeight = defaultSystemFontLineHeight, sizeSize = function(size2) {\n\t\treturn Math.round(size2);\n\t}, family = isWeb ? systemFontFamily.web : systemFontFamily.native, weight = { 1: \"400\" }, letterSpacing = { 4: 0 } } = options;\n\tvar font = options.font;\n\tvar _options_sizes;\n\tvar sizes = (_options_sizes = options.sizes) !== null && _options_sizes !== void 0 ? _options_sizes : defaultSystemFontSizes;\n\tvar _font_size;\n\tvar fontSizes = (_font_size = font === null || font === void 0 ? void 0 : font.size) !== null && _font_size !== void 0 ? _font_size : {};\n\tvar size = Object.fromEntries(Object.entries({\n\t\t...sizes,\n\t\t...fontSizes\n\t}).map(function(param) {\n\t\tvar [key, value] = param;\n\t\treturn [key, sizeSize(+value)];\n\t}));\n\treturn createFont({\n\t\tfamily,\n\t\tlineHeight: Object.fromEntries(Object.entries(size).map(function(param) {\n\t\t\tvar [key, value] = param;\n\t\t\treturn [key, sizeLineHeight(getVariableValue(value))];\n\t\t})),\n\t\tweight,\n\t\tletterSpacing,\n\t\t...font,\n\t\tsize\n\t});\n};\n\nexport { createSystemFont, defaultSystemFontLineHeight, defaultSystemFontSizes, nativeSystemFontSizes, systemFontFamily, v5NativeSystemFontSizes, v5SystemFontLineHeight, v5SystemFontSizes, v5WebSystemFontSizes, webSystemFontSizes };"],"mappings":";;;AAEA,IAAI,QAAQ;AACZ,IAAI,WAAW;AACf,IAAI,mBAAmB;CACtB,KAAK;CACL,QAAQ;AACT;AACA,IAAI,OAAO,SAAS,OAAO;CAC1B,IAAI,MAAM,CAAC;CACX,IAAI,KAAK;CACT,KAAK,IAAI,IAAI,GAAG,KAAK,IAAI,KAAK;EAC7B,IAAI,KAAK,KAAK,MAAM,EAAE;EACtB,MAAM,KAAK,IAAI,MAAM,OAAO,IAAI,IAAI;CACrC;CACA,OAAO;AACR;AACA,IAAI,qBAAqB,KAAK,EAAE;AAChC,IAAI,wBAAwB,KAAK,EAAE;AACnC,IAAI,yBAAyB,WAAW,wBAAwB;AAChE,IAAI,8BAA8B,SAAS,MAAM;CAChD,OAAO,WAAW,KAAK,MAAM,OAAO,MAAM,CAAC,IAAI,KAAK,MAAM,OAAO,OAAO,CAAC;AAC1E;AACA,IAAI,uBAAuB;CAC1B,GAAG;CACH,GAAG;CACH,GAAG;CACH,GAAG;CACH,GAAG;CACH,GAAG;CACH,GAAG;CACH,GAAG;CACH,GAAG;CACH,IAAI;CACJ,IAAI;CACJ,IAAI;CACJ,IAAI;CACJ,IAAI;CACJ,IAAI;CACJ,IAAI;AACL;AACA,IAAI,0BAA0B;CAC7B,GAAG;CACH,GAAG;CACH,GAAG;CACH,GAAG;CACH,GAAG;CACH,GAAG;CACH,GAAG;CACH,GAAG;CACH,GAAG;CACH,IAAI;CACJ,IAAI;CACJ,IAAI;CACJ,IAAI;CACJ,IAAI;CACJ,IAAI;CACJ,IAAI;AACL;AACA,IAAI,oBAAoB,WAAW,0BAA0B;AAC7D,IAAI,yBAAyB,SAAS,MAAM;CAC3C,IAAI,UAAU,OAAO,KAAK,MAAM,OAAO,CAAC;CACxC,IAAI,QAAQ,MAAM,KAAK,IAAI,IAAI,OAAO,MAAM,IAAI;CAChD,OAAO,KAAK,MAAM,OAAO,KAAK;AAC/B;AACA,IAAI,mBAAmB,WAAW;CACjC,IAAI,UAAU,UAAU,SAAS,KAAK,UAAU,OAAO,KAAK,IAAI,UAAU,KAAK,CAAC;CAChF,IAAI,EAAE,iBAAiB,6BAA6B,WAAW,SAAS,OAAO;EAC9E,OAAO,KAAK,MAAM,KAAK;CACxB,GAAG,SAAS,QAAQ,iBAAiB,MAAM,iBAAiB,QAAQ,SAAS,EAAE,GAAG,MAAM,GAAG,gBAAgB,EAAE,GAAG,EAAE,MAAM;CACxH,IAAI,OAAO,QAAQ;CACnB,IAAI;CACJ,IAAI,SAAS,iBAAiB,QAAQ,WAAW,QAAQ,mBAAmB,KAAK,IAAI,iBAAiB;CACtG,IAAI;CACJ,IAAI,aAAa,aAAa,SAAS,QAAQ,SAAS,KAAK,IAAI,KAAK,IAAI,KAAK,UAAU,QAAQ,eAAe,KAAK,IAAI,aAAa,CAAC;CACvI,IAAI,OAAO,OAAO,YAAY,OAAO,QAAQ;EAC5C,GAAG;EACH,GAAG;CACJ,CAAC,CAAC,CAAC,IAAI,SAAS,OAAO;EACtB,IAAI,CAAC,KAAK,SAAS;EACnB,OAAO,CAAC,KAAK,SAAS,CAAC,KAAK,CAAC;CAC9B,CAAC,CAAC;CACF,OAAO,WAAW;EACjB;EACA,YAAY,OAAO,YAAY,OAAO,QAAQ,IAAI,CAAC,CAAC,IAAI,SAAS,OAAO;GACvE,IAAI,CAAC,KAAK,SAAS;GACnB,OAAO,CAAC,KAAK,eAAe,iBAAiB,KAAK,CAAC,CAAC;EACrD,CAAC,CAAC;EACF;EACA;EACA,GAAG;EACH;CACD,CAAC;AACF"}
|
package/package.json
CHANGED
|
@@ -1,13 +1,55 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tamagui/create-system-font",
|
|
3
|
-
"version": "
|
|
4
|
-
"description": "Tamagui v3 package bootstrap",
|
|
5
|
-
"repository": "https://github.com/tamagui/tamagui",
|
|
3
|
+
"version": "3.0.0-0.canary.1791056644527",
|
|
6
4
|
"license": "MIT",
|
|
7
5
|
"files": [
|
|
8
|
-
"
|
|
6
|
+
"src",
|
|
7
|
+
"types",
|
|
8
|
+
"dist"
|
|
9
9
|
],
|
|
10
|
+
"type": "module",
|
|
11
|
+
"sideEffects": false,
|
|
12
|
+
"main": "dist/cjs",
|
|
13
|
+
"module": "dist/esm",
|
|
14
|
+
"types": "./types/index.d.ts",
|
|
15
|
+
"exports": {
|
|
16
|
+
"./package.json": "./package.json",
|
|
17
|
+
".": {
|
|
18
|
+
"types": "./types/index.d.ts",
|
|
19
|
+
"react-native": "./dist/esm/index.native.js",
|
|
20
|
+
"browser": "./dist/esm/index.mjs",
|
|
21
|
+
"module": "./dist/esm/index.mjs",
|
|
22
|
+
"import": "./dist/esm/index.mjs",
|
|
23
|
+
"require": "./dist/cjs/index.cjs",
|
|
24
|
+
"default": "./dist/esm/index.mjs"
|
|
25
|
+
}
|
|
26
|
+
},
|
|
10
27
|
"publishConfig": {
|
|
11
28
|
"access": "public"
|
|
12
|
-
}
|
|
29
|
+
},
|
|
30
|
+
"scripts": {
|
|
31
|
+
"build": "tamagui-build",
|
|
32
|
+
"watch": "tamagui-build --watch",
|
|
33
|
+
"clean": "tamagui-build clean",
|
|
34
|
+
"clean:build": "tamagui-build clean:build",
|
|
35
|
+
"test": "vitest --run tests",
|
|
36
|
+
"test:web": "bun run test"
|
|
37
|
+
},
|
|
38
|
+
"dependencies": {
|
|
39
|
+
"@tamagui/core": "3.0.0-0.canary.1791056644527"
|
|
40
|
+
},
|
|
41
|
+
"devDependencies": {
|
|
42
|
+
"@tamagui/build": "3.0.0-0.canary.1791056644527",
|
|
43
|
+
"react": "19.2.3",
|
|
44
|
+
"vitest": "4.1.0"
|
|
45
|
+
},
|
|
46
|
+
"peerDependencies": {
|
|
47
|
+
"react": ">=19"
|
|
48
|
+
},
|
|
49
|
+
"repository": {
|
|
50
|
+
"type": "git",
|
|
51
|
+
"url": "git+https://github.com/tamagui/tamagui.git",
|
|
52
|
+
"directory": "code/core/create-system-font"
|
|
53
|
+
},
|
|
54
|
+
"releaseSourceCommit": "e09267246167b52afd620a498678f5cce456cb5a"
|
|
13
55
|
}
|
package/src/index.ts
ADDED
|
@@ -0,0 +1,152 @@
|
|
|
1
|
+
import type { FillInFont, GenericFont } from '@tamagui/core'
|
|
2
|
+
import { createFont, getVariableValue } from '@tamagui/core'
|
|
3
|
+
|
|
4
|
+
type SystemFontSizes = Record<string | number, number>
|
|
5
|
+
type SystemFontKeys<Sizes extends SystemFontSizes> = keyof Sizes & (string | number)
|
|
6
|
+
|
|
7
|
+
type CreateSystemFontOptions<A extends GenericFont, Sizes extends SystemFontSizes> = {
|
|
8
|
+
font?: Partial<A>
|
|
9
|
+
sizes?: Sizes
|
|
10
|
+
sizeLineHeight?: (fontSize: number) => number
|
|
11
|
+
sizeSize?: (size: number) => number
|
|
12
|
+
family?: string
|
|
13
|
+
weight?: GenericFont['weight']
|
|
14
|
+
letterSpacing?: GenericFont['letterSpacing']
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
const isWeb = process.env.TAMAGUI_TARGET === 'web'
|
|
18
|
+
const isNative = process.env.TAMAGUI_TARGET === 'native'
|
|
19
|
+
|
|
20
|
+
export const systemFontFamily = {
|
|
21
|
+
web: '-apple-system, system-ui, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif',
|
|
22
|
+
native: 'System',
|
|
23
|
+
} as const
|
|
24
|
+
|
|
25
|
+
// the whole ramp from one equation. each step is a little bigger than the one
|
|
26
|
+
// before it, 8% at the UI sizes easing up to 19% at the display sizes, because
|
|
27
|
+
// small text wants about a point between steps and big text wants a proportion.
|
|
28
|
+
// the tables this replaced had cliffs: web went 30 to 40 from size 9 to 10, a
|
|
29
|
+
// 33% step sitting between two 15% ones, and native jumped 25% from 2 to 3.
|
|
30
|
+
export type SystemFontScale = Record<
|
|
31
|
+
1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16,
|
|
32
|
+
number
|
|
33
|
+
>
|
|
34
|
+
|
|
35
|
+
const ramp = (start: number): SystemFontScale => {
|
|
36
|
+
const out: Record<number, number> = {}
|
|
37
|
+
let px = start
|
|
38
|
+
for (let i = 1; i <= 16; i++) {
|
|
39
|
+
out[i] = Math.round(px)
|
|
40
|
+
px *= Math.min(1.19, 1.05 + i * 0.019)
|
|
41
|
+
}
|
|
42
|
+
return out as SystemFontScale
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
// 11 12 13 14 16 18 21 25 30 36 42 50 60 71 85 101
|
|
46
|
+
export const webSystemFontSizes: SystemFontScale = ramp(11)
|
|
47
|
+
|
|
48
|
+
// 13 14 15 17 19 22 25 30 35 42 50 60 71 84 100 119
|
|
49
|
+
export const nativeSystemFontSizes: SystemFontScale = ramp(13)
|
|
50
|
+
|
|
51
|
+
export const defaultSystemFontSizes: SystemFontScale = isNative
|
|
52
|
+
? nativeSystemFontSizes
|
|
53
|
+
: webSystemFontSizes
|
|
54
|
+
|
|
55
|
+
// eases from about 1.6x at label sizes to 1.35x at display sizes. native runs
|
|
56
|
+
// tighter because its text box has no half leading above the cap line
|
|
57
|
+
export const defaultSystemFontLineHeight = (size: number): number =>
|
|
58
|
+
isNative ? Math.round(size * 1.2 + 4) : Math.round(size * 1.35 + 3)
|
|
59
|
+
|
|
60
|
+
// the v5 config pins these so upgrading the package does not resize a v5 app
|
|
61
|
+
export const v5WebSystemFontSizes = {
|
|
62
|
+
1: 12,
|
|
63
|
+
2: 13,
|
|
64
|
+
3: 14,
|
|
65
|
+
4: 15,
|
|
66
|
+
5: 16,
|
|
67
|
+
6: 18,
|
|
68
|
+
7: 22,
|
|
69
|
+
8: 26,
|
|
70
|
+
9: 30,
|
|
71
|
+
10: 40,
|
|
72
|
+
11: 46,
|
|
73
|
+
12: 52,
|
|
74
|
+
13: 60,
|
|
75
|
+
14: 70,
|
|
76
|
+
15: 85,
|
|
77
|
+
16: 100,
|
|
78
|
+
} as const
|
|
79
|
+
|
|
80
|
+
export const v5NativeSystemFontSizes = {
|
|
81
|
+
1: 11,
|
|
82
|
+
2: 12,
|
|
83
|
+
3: 15,
|
|
84
|
+
4: 17,
|
|
85
|
+
5: 20,
|
|
86
|
+
6: 22,
|
|
87
|
+
7: 24,
|
|
88
|
+
8: 28,
|
|
89
|
+
9: 32,
|
|
90
|
+
10: 40,
|
|
91
|
+
11: 46,
|
|
92
|
+
12: 52,
|
|
93
|
+
13: 60,
|
|
94
|
+
14: 70,
|
|
95
|
+
15: 85,
|
|
96
|
+
16: 100,
|
|
97
|
+
} as const
|
|
98
|
+
|
|
99
|
+
export const v5SystemFontSizes:
|
|
100
|
+
| typeof v5NativeSystemFontSizes
|
|
101
|
+
| typeof v5WebSystemFontSizes = isNative
|
|
102
|
+
? v5NativeSystemFontSizes
|
|
103
|
+
: v5WebSystemFontSizes
|
|
104
|
+
|
|
105
|
+
export const v5SystemFontLineHeight = (size: number): number => {
|
|
106
|
+
if (isNative) return Math.round(size + 5)
|
|
107
|
+
const ratio = 1.5 - Math.max(0, (size - 20) * 0.004)
|
|
108
|
+
return Math.round(size * ratio)
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
export const createSystemFont = <
|
|
112
|
+
A extends GenericFont,
|
|
113
|
+
Sizes extends SystemFontSizes = typeof webSystemFontSizes,
|
|
114
|
+
>(
|
|
115
|
+
options: CreateSystemFontOptions<A, Sizes> = {}
|
|
116
|
+
): FillInFont<A, SystemFontKeys<Sizes>> => {
|
|
117
|
+
const {
|
|
118
|
+
sizeLineHeight = defaultSystemFontLineHeight,
|
|
119
|
+
sizeSize = (size) => Math.round(size),
|
|
120
|
+
family = isWeb ? systemFontFamily.web : systemFontFamily.native,
|
|
121
|
+
weight = {
|
|
122
|
+
1: '400',
|
|
123
|
+
},
|
|
124
|
+
letterSpacing = {
|
|
125
|
+
4: 0,
|
|
126
|
+
},
|
|
127
|
+
} = options
|
|
128
|
+
const font = options.font
|
|
129
|
+
const sizes = options.sizes ?? defaultSystemFontSizes
|
|
130
|
+
const fontSizes = font?.size ?? {}
|
|
131
|
+
|
|
132
|
+
const size = Object.fromEntries(
|
|
133
|
+
Object.entries({
|
|
134
|
+
...sizes,
|
|
135
|
+
...fontSizes,
|
|
136
|
+
}).map(([key, value]) => [key, sizeSize(+value)])
|
|
137
|
+
)
|
|
138
|
+
|
|
139
|
+
return createFont({
|
|
140
|
+
family,
|
|
141
|
+
lineHeight: Object.fromEntries(
|
|
142
|
+
Object.entries(size).map(([key, value]) => [
|
|
143
|
+
key,
|
|
144
|
+
sizeLineHeight(getVariableValue(value)),
|
|
145
|
+
])
|
|
146
|
+
),
|
|
147
|
+
weight,
|
|
148
|
+
letterSpacing,
|
|
149
|
+
...(font as any),
|
|
150
|
+
size,
|
|
151
|
+
}) as FillInFont<A, SystemFontKeys<Sizes>>
|
|
152
|
+
}
|
package/types/index.d.ts
ADDED
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
import type { FillInFont, GenericFont } from "@tamagui/core";
|
|
2
|
+
type SystemFontSizes = Record<string | number, number>;
|
|
3
|
+
type SystemFontKeys<Sizes extends SystemFontSizes> = keyof Sizes & (string | number);
|
|
4
|
+
type CreateSystemFontOptions<
|
|
5
|
+
A extends GenericFont,
|
|
6
|
+
Sizes extends SystemFontSizes
|
|
7
|
+
> = {
|
|
8
|
+
font?: Partial<A>;
|
|
9
|
+
sizes?: Sizes;
|
|
10
|
+
sizeLineHeight?: (fontSize: number) => number;
|
|
11
|
+
sizeSize?: (size: number) => number;
|
|
12
|
+
family?: string;
|
|
13
|
+
weight?: GenericFont["weight"];
|
|
14
|
+
letterSpacing?: GenericFont["letterSpacing"];
|
|
15
|
+
};
|
|
16
|
+
export declare const systemFontFamily: {
|
|
17
|
+
readonly web: "-apple-system, system-ui, BlinkMacSystemFont, \"Segoe UI\", Roboto, Helvetica, Arial, sans-serif";
|
|
18
|
+
readonly native: "System";
|
|
19
|
+
};
|
|
20
|
+
export type SystemFontScale = Record<1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16, number>;
|
|
21
|
+
export declare const webSystemFontSizes: SystemFontScale;
|
|
22
|
+
export declare const nativeSystemFontSizes: SystemFontScale;
|
|
23
|
+
export declare const defaultSystemFontSizes: SystemFontScale;
|
|
24
|
+
export declare const defaultSystemFontLineHeight: (size: number) => number;
|
|
25
|
+
export declare const v5WebSystemFontSizes: {
|
|
26
|
+
readonly 1: 12;
|
|
27
|
+
readonly 2: 13;
|
|
28
|
+
readonly 3: 14;
|
|
29
|
+
readonly 4: 15;
|
|
30
|
+
readonly 5: 16;
|
|
31
|
+
readonly 6: 18;
|
|
32
|
+
readonly 7: 22;
|
|
33
|
+
readonly 8: 26;
|
|
34
|
+
readonly 9: 30;
|
|
35
|
+
readonly 10: 40;
|
|
36
|
+
readonly 11: 46;
|
|
37
|
+
readonly 12: 52;
|
|
38
|
+
readonly 13: 60;
|
|
39
|
+
readonly 14: 70;
|
|
40
|
+
readonly 15: 85;
|
|
41
|
+
readonly 16: 100;
|
|
42
|
+
};
|
|
43
|
+
export declare const v5NativeSystemFontSizes: {
|
|
44
|
+
readonly 1: 11;
|
|
45
|
+
readonly 2: 12;
|
|
46
|
+
readonly 3: 15;
|
|
47
|
+
readonly 4: 17;
|
|
48
|
+
readonly 5: 20;
|
|
49
|
+
readonly 6: 22;
|
|
50
|
+
readonly 7: 24;
|
|
51
|
+
readonly 8: 28;
|
|
52
|
+
readonly 9: 32;
|
|
53
|
+
readonly 10: 40;
|
|
54
|
+
readonly 11: 46;
|
|
55
|
+
readonly 12: 52;
|
|
56
|
+
readonly 13: 60;
|
|
57
|
+
readonly 14: 70;
|
|
58
|
+
readonly 15: 85;
|
|
59
|
+
readonly 16: 100;
|
|
60
|
+
};
|
|
61
|
+
export declare const v5SystemFontSizes: typeof v5NativeSystemFontSizes | typeof v5WebSystemFontSizes;
|
|
62
|
+
export declare const v5SystemFontLineHeight: (size: number) => number;
|
|
63
|
+
export declare const createSystemFont: <
|
|
64
|
+
A extends GenericFont,
|
|
65
|
+
Sizes extends SystemFontSizes = typeof webSystemFontSizes
|
|
66
|
+
>(options?: CreateSystemFontOptions<A, Sizes>) => FillInFont<A, SystemFontKeys<Sizes>>;
|
|
67
|
+
export {};
|
|
68
|
+
|
|
69
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
{
|
|
2
|
+
"mappings": "AAAA,cAAc,YAAY,mBAAmB;KAGxC,kBAAkB;KAClB,eAAe,cAAc,yBAAyB;KAEtD;CAAwB,UAAU;CAAa,cAAc;IAAmB;CACnF,OAAO,QAAQ;CACf,QAAQ;CACR,kBAAkB;CAClB,YAAY;CACZ;CACA,SAAS,YAAY;CACrB,gBAAgB,YAAY;;AAM9B,OAAO,cAAM;UACX,KAAK;UACL,QAAQ;;AAQV,YAAY,kBAAkB,OAC5B,IAAI,IAAI,IAAI,IAAI,IAAI,IAAI,IAAI,IAAI,IAAI,KAAK,KAAK,KAAK,KAAK,KAAK,KAAK;AAepE,OAAO,cAAM,oBAAoB;AAGjC,OAAO,cAAM,uBAAuB;AAEpC,OAAO,cAAM,wBAAwB;AAMrC,OAAO,cAAM,8BAA+B;AAI5C,OAAO,cAAM;UACX,GAAG;UACH,GAAG;UACH,GAAG;UACH,GAAG;UACH,GAAG;UACH,GAAG;UACH,GAAG;UACH,GAAG;UACH,GAAG;UACH,IAAI;UACJ,IAAI;UACJ,IAAI;UACJ,IAAI;UACJ,IAAI;UACJ,IAAI;UACJ,IAAI;;AAGN,OAAO,cAAM;UACX,GAAG;UACH,GAAG;UACH,GAAG;UACH,GAAG;UACH,GAAG;UACH,GAAG;UACH,GAAG;UACH,GAAG;UACH,GAAG;UACH,IAAI;UACJ,IAAI;UACJ,IAAI;UACJ,IAAI;UACJ,IAAI;UACJ,IAAI;UACJ,IAAI;;AAGN,OAAO,cAAM,0BACF,iCACA;AAIX,OAAO,cAAM,yBAA0B;AAMvC,OAAO,cAAM;CACX,UAAU;CACV,cAAc,yBAAyB;EAEvC,UAAS,wBAAwB,GAAG,WACnC,WAAW,GAAG,eAAe",
|
|
3
|
+
"names": [],
|
|
4
|
+
"sources": [
|
|
5
|
+
"src/index.ts"
|
|
6
|
+
],
|
|
7
|
+
"version": 3,
|
|
8
|
+
"sourcesContent": [
|
|
9
|
+
"import type { FillInFont, GenericFont } from '@tamagui/core'\nimport { createFont, getVariableValue } from '@tamagui/core'\n\ntype SystemFontSizes = Record<string | number, number>\ntype SystemFontKeys<Sizes extends SystemFontSizes> = keyof Sizes & (string | number)\n\ntype CreateSystemFontOptions<A extends GenericFont, Sizes extends SystemFontSizes> = {\n font?: Partial<A>\n sizes?: Sizes\n sizeLineHeight?: (fontSize: number) => number\n sizeSize?: (size: number) => number\n family?: string\n weight?: GenericFont['weight']\n letterSpacing?: GenericFont['letterSpacing']\n}\n\nconst isWeb = process.env.TAMAGUI_TARGET === 'web'\nconst isNative = process.env.TAMAGUI_TARGET === 'native'\n\nexport const systemFontFamily = {\n web: '-apple-system, system-ui, BlinkMacSystemFont, \"Segoe UI\", Roboto, Helvetica, Arial, sans-serif',\n native: 'System',\n} as const\n\n// the whole ramp from one equation. each step is a little bigger than the one\n// before it, 8% at the UI sizes easing up to 19% at the display sizes, because\n// small text wants about a point between steps and big text wants a proportion.\n// the tables this replaced had cliffs: web went 30 to 40 from size 9 to 10, a\n// 33% step sitting between two 15% ones, and native jumped 25% from 2 to 3.\nexport type SystemFontScale = Record<\n 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16,\n number\n>\n\nconst ramp = (start: number): SystemFontScale => {\n const out: Record<number, number> = {}\n let px = start\n for (let i = 1; i <= 16; i++) {\n out[i] = Math.round(px)\n px *= Math.min(1.19, 1.05 + i * 0.019)\n }\n return out as SystemFontScale\n}\n\n// 11 12 13 14 16 18 21 25 30 36 42 50 60 71 85 101\nexport const webSystemFontSizes: SystemFontScale = ramp(11)\n\n// 13 14 15 17 19 22 25 30 35 42 50 60 71 84 100 119\nexport const nativeSystemFontSizes: SystemFontScale = ramp(13)\n\nexport const defaultSystemFontSizes: SystemFontScale = isNative\n ? nativeSystemFontSizes\n : webSystemFontSizes\n\n// eases from about 1.6x at label sizes to 1.35x at display sizes. native runs\n// tighter because its text box has no half leading above the cap line\nexport const defaultSystemFontLineHeight = (size: number): number =>\n isNative ? Math.round(size * 1.2 + 4) : Math.round(size * 1.35 + 3)\n\n// the v5 config pins these so upgrading the package does not resize a v5 app\nexport const v5WebSystemFontSizes = {\n 1: 12,\n 2: 13,\n 3: 14,\n 4: 15,\n 5: 16,\n 6: 18,\n 7: 22,\n 8: 26,\n 9: 30,\n 10: 40,\n 11: 46,\n 12: 52,\n 13: 60,\n 14: 70,\n 15: 85,\n 16: 100,\n} as const\n\nexport const v5NativeSystemFontSizes = {\n 1: 11,\n 2: 12,\n 3: 15,\n 4: 17,\n 5: 20,\n 6: 22,\n 7: 24,\n 8: 28,\n 9: 32,\n 10: 40,\n 11: 46,\n 12: 52,\n 13: 60,\n 14: 70,\n 15: 85,\n 16: 100,\n} as const\n\nexport const v5SystemFontSizes:\n | typeof v5NativeSystemFontSizes\n | typeof v5WebSystemFontSizes = isNative\n ? v5NativeSystemFontSizes\n : v5WebSystemFontSizes\n\nexport const v5SystemFontLineHeight = (size: number): number => {\n if (isNative) return Math.round(size + 5)\n const ratio = 1.5 - Math.max(0, (size - 20) * 0.004)\n return Math.round(size * ratio)\n}\n\nexport const createSystemFont = <\n A extends GenericFont,\n Sizes extends SystemFontSizes = typeof webSystemFontSizes,\n>(\n options: CreateSystemFontOptions<A, Sizes> = {}\n): FillInFont<A, SystemFontKeys<Sizes>> => {\n const {\n sizeLineHeight = defaultSystemFontLineHeight,\n sizeSize = (size) => Math.round(size),\n family = isWeb ? systemFontFamily.web : systemFontFamily.native,\n weight = {\n 1: '400',\n },\n letterSpacing = {\n 4: 0,\n },\n } = options\n const font = options.font\n const sizes = options.sizes ?? defaultSystemFontSizes\n const fontSizes = font?.size ?? {}\n\n const size = Object.fromEntries(\n Object.entries({\n ...sizes,\n ...fontSizes,\n }).map(([key, value]) => [key, sizeSize(+value)])\n )\n\n return createFont({\n family,\n lineHeight: Object.fromEntries(\n Object.entries(size).map(([key, value]) => [\n key,\n sizeLineHeight(getVariableValue(value)),\n ])\n ),\n weight,\n letterSpacing,\n ...(font as any),\n size,\n }) as FillInFont<A, SystemFontKeys<Sizes>>\n}\n"
|
|
10
|
+
]
|
|
11
|
+
}
|
package/README.md
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
# @tamagui/create-system-font
|