Skip to content

Commit

Permalink
feat: add support for fontVariants
Browse files Browse the repository at this point in the history
  • Loading branch information
jpudysz committed Mar 27, 2024
1 parent bfa4a41 commit f85af90
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
6 changes: 5 additions & 1 deletion examples/expo/src/examples/TypeScriptValidatorTest.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import React from 'react'
import { PlatformColor, View } from 'react-native'
import { PlatformColor, View, Text } from 'react-native'
import { mq, createStyleSheet, useStyles } from 'react-native-unistyles'

export const TypeScriptValidatorTest: React.FunctionComponent = () => {
Expand All @@ -14,6 +14,7 @@ export const TypeScriptValidatorTest: React.FunctionComponent = () => {
<View style={styles.nestedProps} />
<View style={styles.dynamicContainer(1)} />
<View style={styles.text} />
<Text style={styles.fontVariantsText} />
</View>
)
}
Expand Down Expand Up @@ -148,5 +149,8 @@ const stylesheet = createStyleSheet(theme => ({
width: 3,
height: 3
}
},
fontVariantsText: {
fontVariant: ['tabular-nums', 'small-caps']
}
}))
6 changes: 6 additions & 0 deletions src/utils/styles.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,12 @@ export const parseStyle = <T extends RNStyle>(
return acc
}

if (key === 'fontVariant' && Array.isArray(value)) {
acc[key] = value

return acc
}

// values or platform colors
if (typeof value !== 'object' || isPlatformColor(value)) {
acc[key as keyof T] = value
Expand Down

0 comments on commit f85af90

Please sign in to comment.