Road to 2.0 #41
Replies: 25 comments 85 replies
-
As far as dropping |
Beta Was this translation helpful? Give feedback.
-
Postponing it as it has a low priority. |
Beta Was this translation helpful? Give feedback.
-
I will keep this task, as the codebase will slightly change. |
Beta Was this translation helpful? Give feedback.
-
If anyone is interested code is available on the branch 2.0. |
Beta Was this translation helpful? Give feedback.
-
I have edited my original post to cover what will be available in version 2.0. |
Beta Was this translation helpful? Give feedback.
-
Here is my proposal for improved media query syntax. I wasn't satisfied with writing it as plain text. We can discuss whether to shorten it further to something like:
or not. This is a working example (POC) and will help me reduce the time spent parsing the queries. It will also help me minimize the number of TypeScript types. This change is backward compatible as it uses the existing syntax. It will also support single values like:
const stylesheet = createStyleSheet((theme, mq) => ({
// styles
})) Let me know what do you think about it! |
Beta Was this translation helpful? Give feedback.
-
ICYMI - variants are available from alpha 11! |
Beta Was this translation helpful? Give feedback.
-
What is the point of having a C++ core? Is it performance? How is performance improved if everything is loaded loaded into React state at the end of the day anyway? |
Beta Was this translation helpful? Give feedback.
-
I've finalized API for plugins: |
Beta Was this translation helpful? Give feedback.
-
Hello, Thank you so much for this upgrade and this library, glad to tell you that I am testing it heavily with you! I had a question in my mind, what is the best way to achieve multiple/nested variants/customizations using this library? On the top of my mind I thought about 2 solutions but honestly neither of them felt super clean and I am checking with you if you have a better third option.
I would prefer if I can keep it as one style instead of combining multiple styles for each variant (the way you have it for single variant), so the question is do you have any other solution for nested variants or a plan to support such thing or what? something like this: https://cva.style/docs/getting-started/variants Thanks again for all of your effort! |
Beta Was this translation helpful? Give feedback.
-
Update on Unistyles-2.0.0-alpha.15 and alpha16. What's new?
Media queriesDue to changes in TypeScript 5.3, my previous workaround for media queries syntax is no longer viable. I have adopted a new syntax that doesn’t confuse the TypeScript engine. Note that this change only affects the syntax for defining media queries, not their functionality.
const stylesheet = createStyleSheet(theme => ({
container: {
width: {
[mq.width(100, 200)]: 200,
[mq.width(undefined, 500).height(200)]: 300
}
}
})
const stylesheet = createStyleSheet(theme => ({
container: {
width: {
[mq.only.width(100, 200)]: 200,
[mq.width(undefined, 500).and.height(200)]: 300
}
}
}) TypeScript is now happy, and so do I. If you don't like new syntax with /only/ & /and/ - let me know in the comments. We're still in alpha and it can be adjusted. I'm looking forward to your feedback! VariantsVariants are truly variants now :) You can now specify multiple variants in your stylesheet. A variant is an object that contains variant groups. Each group has a variant key: const stylesheet = createStyleSheet(theme => ({
container: {
variants: {
// groups (any name you like)
size: {
// variant key (any name you like)
small: {
// React Native styles
height: 50,
width: 50
},
medium: {
// or breakpoints!
height: {
xs: 100,
md: 150
},
width: {
xs: 100,
md: 150
}
},
large: {
// or media queries!
height: {
[mq.only.width(200)]: 100,
[mq.only.width('sm')]: 150
},
width: {
[mq.only.width(200)]: 100,
[mq.only.width('sm')]: 150
}
}
},
color: {
// other styles, you can mix them and /primary/ may have another keys than /secondary/
primary: {},
secondary: {},
// this is a special case - if you specify 'default' option it will be automatically selected for no variant
default: {}
},
// other groups
}
}
// other components with other or the same groups/names
}) Now, with defined groups we need to select the variant: // means - I don't care about variants, select 'default' if any
const { styles } = useStyles(stylesheet)
// means the same, every key is optional
const { styles } = useStyles(stylesheet, {})
// select only /size/ variant, for /color/ may fallback to 'default'
const { styles } = useStyles(stylesheet, {
// TS will hint you with the available options
size: 'small', // TS: small/medium/large/undefined
})
// select all variants
const { styles } = useStyles(stylesheet, {
size: 'large',
color: 'primary'
}) I hope you like it! |
Beta Was this translation helpful? Give feedback.
-
So do you mean we should allow to use: const { style } = useStyles(stylesheet) // -> select default if any
const { style } = useStyles(stylesheet, {}) // -> select default if any
const { style } = useStyles(stylesheet, {
size: 'large'
}) // -> selects size variant with large option
// but not
const { style } = useStyles(stylesheet, {
size: undefined
}) |
Beta Was this translation helpful? Give feedback.
-
I'm using "react-native-unistyles": "^2.0.0-alpha.17", but I'm encountering a TypeScript error: |
Beta Was this translation helpful? Give feedback.
-
@xieyezi From what I understand you want to dynamically create themes? |
Beta Was this translation helpful? Give feedback.
-
Hello everyone! We have just reached beta.1 with FULL Android support, demonstrating the power of a shared core in C++ 🚀 . |
Beta Was this translation helpful? Give feedback.
-
I've just released beta.2 with FULL Web support! 🚀 |
Beta Was this translation helpful? Give feedback.
-
@jpudysz you are on fire! Thanks for your amazing work, I'm looking forward to the docs and migrate from v1. |
Beta Was this translation helpful? Give feedback.
-
@jpudysz I guess we have an issue in variants. What is the expected disabledButton styles in this case? since I am passing 'primary' as variant but 'primary' has no value in disabledButton, it should select default right? It is not selecting default, here is the output of the console: |
Beta Was this translation helpful? Give feedback.
-
Hello, I've been trying to test unistyles v2 on an expo (49) app with expo go, but I keep getting the error "Unistyles runtime is not available. Make sure you followed the installation instructions". I wonder if there are some additional steps to take installing v2, or I just have to wait for the release. |
Beta Was this translation helpful? Give feedback.
-
Hi @jpudysz ! First of all, thank you for your work 👏 I would like to test the lib but I can't build my android app, you will find below my react native info and the build error : React native Info
and Build error
and
Note : I'm already using some jsi libs like react-native-mmkv or react-native-quick-base64 and I'm running with react-native-unistyles ^2.0.0-beta.4 |
Beta Was this translation helpful? Give feedback.
-
It's me again ! When I want to reload my app, I'm getting the following native error :
I don't know what this method is suppose to do, so I can't help with that... |
Beta Was this translation helpful? Give feedback.
-
when changing the theme, native alerts don't match it, it matches the device theme. any plans to implement such feature ? |
Beta Was this translation helpful? Give feedback.
-
Thank you all for the support during these weeks! The last task is to add unit tests as we have somethine like ~82% 😄 |
Beta Was this translation helpful? Give feedback.
-
Unistyles 1.0.0 was designed to run entirely in JavaScript at runtime, providing a strong foundation that many projects can build upon due to its simplicity. While it's already a robust tool, I envision numerous enhancements in the future. My commitment is to continually refine it, ensuring a simple yet powrful API complemented by innovative extensions.
Given the dynamic nature of development, this roadmap might evolve, especially as I delve into diverse subjects to optimize developer experience and performance. To elevate Unistyles even more, my next step is integrating a compiler for generating static stylesheets, alongside inherent support for CSS variables and media queries.
There's a lot of tasks ahead, and I genuinely appreciate all contributions, whether they're PRs, suggestions, or bug fixes. But if you're wondering how to support me even further, a shoutout for Unistyles on Twitter or sponsorship on GitHub would mean the world.
Let's shape the future of React Native styling together! 🦄 🔥 🏁
// EDITED, current roadmap
We can highlight 8 major areas that will be improved in version 2.0:
Before RC:
I have decided to move the custom compiler to version 3.0, as there are already many changes.
My goal is to release it in December 2023.
How to upgrade from Unistyles 1.0. to 2.0?
UnistylesTheme
createUnistyles
declare module
(optional)UnistylesRegistry
(optional)Full example (configuration):
Full example (component):
More examples are here:
https://github.com/jpudysz/react-native-unistyles/tree/2.0/examples/expo/src/examples
Beta Was this translation helpful? Give feedback.
All reactions