Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Usability improvements for "style" #55

Open
shirakaba opened this issue Jun 7, 2020 · 3 comments
Open

Usability improvements for "style" #55

shirakaba opened this issue Jun 7, 2020 · 3 comments
Assignees
Labels
enhancement New feature or request

Comments

@shirakaba
Copy link
Owner

Should accept an array of styles (like React Native), and should not throw an error if an undefined style is passed in (because we've marked it as optional).

Should probably also be added to the typings of ViewBase so that it comes up in, e.g. FlexboxAttributes.

@shirakaba shirakaba self-assigned this Jun 7, 2020
@shirakaba shirakaba added the enhancement New feature or request label Jun 7, 2020
@shirakaba shirakaba changed the title [v1] Usability improvements for "style" Usability improvements for "style" Jul 14, 2020
@t1amat9409
Copy link

Funny I was looking at Styled Components and thought of a way I'd used them with RNS.

@shirakaba
Copy link
Owner Author

As for strongly-typed style objects (à la React Native's StyleSheet.create()), this seems to do the trick:

import type { RNSStyle } from "react-nativescript";

type RNSStyleSheet<T extends {}> = {
    [P in keyof T]: RNSStyle;
}
export const createStyleSheet = <T extends {}>(arg: RNSStyleSheet<T>): RNSStyleSheet<T> => arg;

@shirakaba
Copy link
Owner Author

RNS v2.2.0 now implements a provisional StyleSheet.create() API.

Accepting an array of styles is not yet supported, but now that I've fixed a styles issue, it may be not far off being implemented.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants