@tamagui/core 1.0.1-beta.150 → 1.0.1-beta.151

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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tamagui/core",
3
- "version": "1.0.1-beta.150",
3
+ "version": "1.0.1-beta.151",
4
4
  "source": "src/index.ts",
5
5
  "main": "dist/cjs",
6
6
  "module": "dist/esm",
@@ -27,14 +27,14 @@
27
27
  ],
28
28
  "dependencies": {
29
29
  "@expo/match-media": "^0.3.0",
30
- "@tamagui/compose-refs": "^1.0.1-beta.150",
31
- "@tamagui/helpers": "^1.0.1-beta.150",
32
- "@tamagui/normalize-css-color-lite": "^1.0.1-beta.150",
33
- "@tamagui/rnw": "^1.0.1-beta.150",
34
- "@tamagui/rnw-lite": "^1.0.1-beta.150",
35
- "@tamagui/use-debounce": "^1.0.1-beta.150",
36
- "@tamagui/use-event": "^1.0.1-beta.150",
37
- "@tamagui/use-force-update": "^1.0.1-beta.150",
30
+ "@tamagui/compose-refs": "^1.0.1-beta.151",
31
+ "@tamagui/helpers": "^1.0.1-beta.151",
32
+ "@tamagui/normalize-css-color-lite": "^1.0.1-beta.151",
33
+ "@tamagui/rnw": "^1.0.1-beta.151",
34
+ "@tamagui/rnw-lite": "^1.0.1-beta.151",
35
+ "@tamagui/use-debounce": "^1.0.1-beta.151",
36
+ "@tamagui/use-event": "^1.0.1-beta.151",
37
+ "@tamagui/use-force-update": "^1.0.1-beta.151",
38
38
  "expo-screen-orientation": "^4.3.0",
39
39
  "hyphenate-style-name": "^1.0.4"
40
40
  },
@@ -43,7 +43,7 @@
43
43
  "react-dom": "*"
44
44
  },
45
45
  "devDependencies": {
46
- "@tamagui/build": "^1.0.1-beta.150",
46
+ "@tamagui/build": "^1.0.1-beta.151",
47
47
  "@types/react": "^18.0.15",
48
48
  "csstype": "^3.0.10",
49
49
  "esbuild": "^0.14.49",
@@ -707,7 +707,34 @@ export function createComponent<
707
707
  }
708
708
 
709
709
  viewProps.style = style
710
- } else {
710
+ }
711
+
712
+ if (process.env.TAMAGUI_TARGET === 'native') {
713
+ // swap out the right family based on weight/style
714
+ if (splitStyles.fontFamily) {
715
+ const faceInfo = config.fontsParsed[splitStyles.fontFamily]?.face
716
+ if (faceInfo) {
717
+ const [weight, style] = (() => {
718
+ let weight: string | undefined
719
+ let style: string | undefined
720
+ for (let i = styles.length; i >= 0; i--) {
721
+ weight ??= styles[i]?.fontWeight
722
+ style ??= styles[i]?.fontStyle
723
+ }
724
+ return [weight || '400', style || 'normal'] as const
725
+ })()
726
+ const overrideFace = faceInfo[weight]?.[style]?.val
727
+ if (overrideFace) {
728
+ for (const style of styles) {
729
+ if (style?.fontFamily) {
730
+ style.fontFamily = overrideFace
731
+ }
732
+ }
733
+ }
734
+ }
735
+ }
736
+
737
+ // assign styles
711
738
  viewProps.style = styles
712
739
  }
713
740
 
package/src/createFont.ts CHANGED
@@ -4,8 +4,11 @@ export const createFont = <A extends GenericFont>(font: A): A => {
4
4
  // fills in any missing values based on size keys being standard
5
5
  const sizeKeys = Object.keys(font.size)
6
6
 
7
+ // fill in intermediate values
7
8
  for (const key in font) {
8
- if (key === 'size' || key === 'family') continue
9
+ if (key === 'size' || key === 'family' || key === 'face') {
10
+ continue
11
+ }
9
12
  const section = font[key] as Object
10
13
  const keys = Object.keys(section)
11
14
 
@@ -392,6 +392,9 @@ export const getSplitStyles: StyleSplitter = (
392
392
  for (const key in mediaStyle) {
393
393
  usedKeys.add(key)
394
394
  style[key] = mediaStyle[key]
395
+ if (key === 'fontFamily') {
396
+ fontFamily = mediaStyle[key]
397
+ }
395
398
  }
396
399
  }
397
400
  }
package/src/insertFont.ts CHANGED
@@ -27,7 +27,7 @@ export function parseFont<A extends GenericFont>(definition: A): DeepVariableObj
27
27
  const parsed: any = {}
28
28
  for (const attrKey in definition) {
29
29
  const attr = definition[attrKey]
30
- if (attrKey === 'family') {
30
+ if (attrKey === 'family' || attrKey === 'face') {
31
31
  parsed[attrKey] = attr
32
32
  continue
33
33
  }
package/src/types.tsx CHANGED
@@ -336,6 +336,8 @@ export type GenericFont<Key extends number | string = number | string> = {
336
336
  style?: Partial<{ [key in Key]: TextStyle['fontStyle'] | Variable }>
337
337
  transform?: Partial<{ [key in Key]: TextStyle['textTransform'] | Variable }>
338
338
  color?: Partial<{ [key in Key]: string | Variable }>
339
+ // for native use only, lets you map to alternative fonts
340
+ face?: { [key in FontWeightSteps]: { normal?: string; italic?: string } }
339
341
  }
340
342
 
341
343
  // media
@@ -429,9 +431,8 @@ export type RadiusTokens = GetTokenString<keyof Tokens['radius']> | number
429
431
  export type FontTokens = GetTokenString<keyof TamaguiConfig['fonts']>
430
432
  export type FontSizeTokens = GetTokenString<GetTokenFontKeysFor<'size'>> | number
431
433
  export type FontLineHeightTokens = `$${GetTokenFontKeysFor<'lineHeight'>}` | number
432
- export type FontWeightTokens =
433
- | `$${GetTokenFontKeysFor<'weight'>}`
434
- | `${1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9}00`
434
+ export type FontWeightSteps = `${1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9}00`
435
+ export type FontWeightTokens = `$${GetTokenFontKeysFor<'weight'>}` | FontWeightSteps
435
436
  export type FontColorTokens = `$${GetTokenFontKeysFor<'color'>}` | number
436
437
  export type FontLetterSpacingTokens = `$${GetTokenFontKeysFor<'letterSpacing'>}` | number
437
438
  export type FontStyleTokens = `$${GetTokenFontKeysFor<'style'>}` | TextStyle['fontStyle']
package/types/types.d.ts CHANGED
@@ -205,6 +205,12 @@ export declare type GenericFont<Key extends number | string = number | string> =
205
205
  color?: Partial<{
206
206
  [key in Key]: string | Variable;
207
207
  }>;
208
+ face?: {
209
+ [key in FontWeightSteps]: {
210
+ normal?: string;
211
+ italic?: string;
212
+ };
213
+ };
208
214
  };
209
215
  export declare type MediaQueryObject = {
210
216
  [key: string]: string | number | string;
@@ -264,7 +270,8 @@ export declare type RadiusTokens = GetTokenString<keyof Tokens['radius']> | numb
264
270
  export declare type FontTokens = GetTokenString<keyof TamaguiConfig['fonts']>;
265
271
  export declare type FontSizeTokens = GetTokenString<GetTokenFontKeysFor<'size'>> | number;
266
272
  export declare type FontLineHeightTokens = `$${GetTokenFontKeysFor<'lineHeight'>}` | number;
267
- export declare type FontWeightTokens = `$${GetTokenFontKeysFor<'weight'>}` | `${1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9}00`;
273
+ export declare type FontWeightSteps = `${1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9}00`;
274
+ export declare type FontWeightTokens = `$${GetTokenFontKeysFor<'weight'>}` | FontWeightSteps;
268
275
  export declare type FontColorTokens = `$${GetTokenFontKeysFor<'color'>}` | number;
269
276
  export declare type FontLetterSpacingTokens = `$${GetTokenFontKeysFor<'letterSpacing'>}` | number;
270
277
  export declare type FontStyleTokens = `$${GetTokenFontKeysFor<'style'>}` | TextStyle['fontStyle'];