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

Proposal: PixelRatio.pixel() #5073

Closed
corbt opened this issue Jan 1, 2016 · 3 comments
Closed

Proposal: PixelRatio.pixel() #5073

corbt opened this issue Jan 1, 2016 · 3 comments
Labels
Resolution: Locked This issue was locked by the bot.

Comments

@corbt
Copy link
Contributor

corbt commented Jan 1, 2016

It seems like a fairly common pattern to want a line that's the thinnest possible width. Currently this can be accomplished with a style something like:

StyleSheet.create({
  myStyle: {
    borderBottomWidth: 1 / PixelRatio.get()
    [...]
  }
});

This works fine, but without reading the documentation of PixelRatio it's not obvious what's going on.

I propose adding a function PixelRatio.pixel (or alternatively PixelRatio.smallestPixel) that simply returns the inverse of PixelRatio.get. This would make it immediately clear what a style using it is trying to accomplish, even to someone who hasn't read the PixelRatio documentation.

I'm happy to implement and document this if there's general agreement that it's a good idea.

@facebook-github-bot
Copy link
Contributor

Hey corbt, thanks for reporting this issue!

React Native, as you've probably heard, is getting really popular and truth is we're getting a bit overwhelmed by the activity surrounding it. There are just too many issues for us to manage properly.

  • If you don't know how to do something or something is not working as you expect but not sure it's a bug, please ask on StackOverflow with the tag react-native or for more real time interactions, ask on Discord in the #react-native channel.
  • If this is a feature request or a bug that you would like to be fixed, please report it on Product Pains. It has a ranking feature that lets us focus on the most important issues the community is experiencing.
  • We welcome clear issues and PRs that are ready for in-depth discussion. Please provide screenshots where appropriate and always mention the version of React Native you're using. Thank you for your contributions!

@brentvatne
Copy link
Collaborator

I like this idea, let's move it into a pull request! 🚀

@corbt
Copy link
Contributor Author

corbt commented Jan 1, 2016

Cool, working on it.

ghost pushed a commit that referenced this issue Jan 15, 2016
Summary:
This implements #5073. It adds a static method `PixelRatio.pixel()` which returns the smallest drawable line width, primarily for use in styles.

It also updates the example apps to use the new function.
Closes #5076

Reviewed By: svcscm

Differential Revision: D2799849

Pulled By: nicklockwood

fb-gh-sync-id: b83a77790601fe882affbf65531114e7c5cf4bdf
christopherdro pushed a commit to wildlifela/react-native that referenced this issue Jan 20, 2016
Summary:
This implements facebook#5073. It adds a static method `PixelRatio.pixel()` which returns the smallest drawable line width, primarily for use in styles.

It also updates the example apps to use the new function.
Closes facebook#5076

Reviewed By: svcscm

Differential Revision: D2799849

Pulled By: nicklockwood

fb-gh-sync-id: b83a77790601fe882affbf65531114e7c5cf4bdf
rozele referenced this issue in microsoft/react-native-windows May 25, 2016
Summary:
This implements #5073. It adds a static method `PixelRatio.pixel()` which returns the smallest drawable line width, primarily for use in styles.

It also updates the example apps to use the new function.
Closes facebook/react-native#5076

Reviewed By: svcscm

Differential Revision: D2799849

Pulled By: nicklockwood

fb-gh-sync-id: b83a77790601fe882affbf65531114e7c5cf4bdf
@facebook facebook locked as resolved and limited conversation to collaborators May 24, 2018
@react-native-bot react-native-bot added the Resolution: Locked This issue was locked by the bot. label Jul 20, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Resolution: Locked This issue was locked by the bot.
Projects
None yet
Development

No branches or pull requests

4 participants