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

Custom Named Predefined Styles #72

Open
DeVoresyah opened this issue Aug 30, 2023 · 0 comments
Open

Custom Named Predefined Styles #72

DeVoresyah opened this issue Aug 30, 2023 · 0 comments
Labels
enhancement New feature or request

Comments

@DeVoresyah
Copy link
Member

Background

I found an interesting case from this repo => https://github.com/hanyang7427/SpaceX/blob/main/src/preDefine.ts
It's kinda painful when someone wants to create a custom-named predefined style and use it in some file. They need to define first, then export, and import. It takes effort.

So, let's improve by making a behavior similar to the web CSS. We can assume this custom predefined looks like a class name in web CSS.

Approach

Adding new props on OsmiProvider

let's store all the custom-named predefined style into provider to make it easy to access later.

const styleUtilities = {
  container: 'flex items-center justify-center'
}
<OsmiProvider utilities={styleUtilities}>
</OsmiProvider>

Usage

<View style={apply("container")}>
  <Text>Hello World</Text>
</View>

notice that we can use container from style utilities directly on apply method. This will be easier other than you defined and import manually like below:

import globalStyles from '/globalStyles.ts'

apply(globalStyles.container)
@DeVoresyah DeVoresyah added the enhancement New feature or request label Aug 30, 2023
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

1 participant