Releases: jpudysz/react-native-unistyles
Release 2.3.0
2.3.0 (2024-02-08)
In this release I've brought you support for react-native-windows!
You can now build truly cross-platform desktop apps with Unistyles.
Also, there is one more improvement regarding boolean variants. Previously, if you defined only a true or false variant, they were converted respectively into a true or false string. This could be problematic if your props are of the boolean type. The error would indicate that the variant is expecting either true as a boolean or string. In this version, if you use a single true or false boolean variant, TypeScript will convert it to a generic boolean. Types won't be narrowed down to single values anymore.
Features
- add windows support
- add autolonking for windows
- narrow down boolean variants (543e696)
Release 2.3.0-beta.2
2.3.0-beta.2 (2024-02-07)
- add missing windows files to lib output
Release 2.3.0-beta.1
Release 2.3.0-beta.0
2.3.0-beta.0 (2024-02-05)
Features
Release 2.2.0
2.2.0 (2024-01-26)
Features
- update theme at runtime (35197ca)
You can now update the theme at runtime. This is useful if you want to show the user interface with default colors and later alter theme based on user preferences.
UnistylesRuntime.updateTheme('light', theme => ({
...theme,
// override theme here 😈
// if currently selected theme has been updated, unistyles will re-render
}))Docs: https://reactnativeunistyles.vercel.app/reference/theming/#update-theme-during-runtime
Release 2.1.1
Release 2.1.0
2.1.0 (2024-01-23)
Features
- boolean variants (f8623ea)
Example
You can now use boolean values to select the variants:
import { useStyles } from 'react-native-unistyles'
const Component = ({ isPrimary, isDisabled }) => {
const { styles } = useStyles(stylesheet, {
color: !isDisabled,
borderColor: isPrimary
// you can also use strings
// color: "true" | "false"
})
return (
<View style={styles.container} />
)
}
const stylesheet = createStyleSheet(theme => ({
container: {
// otter styles
variants: {
color: {
true: {
backgroundColor: theme.colors.primary
},
false: {
backgroundColor: theme.colors.disabled
},
// you can still specify a default variant
default: {
backgroundColor: theme.colors.barbie
}
// or other variants
special: {
backgroundColor: theme.colors.special
}
},
borderColor: {
true: {
borderColor: theme.colors.primary
}
// you can also skip "false" here
}
}
}
})If you specify a boolean variants like “true”, there is no requirement to specify a “false” variant (and vice versa). You can mix boolean variants with other variants as well.