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

[Text] textalign should implement 'justify' css property #529

Closed
sanketr opened this issue Mar 31, 2015 · 26 comments
Closed

[Text] textalign should implement 'justify' css property #529

sanketr opened this issue Mar 31, 2015 · 26 comments
Labels
Good first issue Interested in collaborating? Take a stab at fixing one of these issues. Resolution: Locked This issue was locked by the bot.

Comments

@sanketr
Copy link

sanketr commented Mar 31, 2015

"justify" property seems to be crucial in order to implement nice text alignment we know so well from newspapers and magazines (and latex). Right now, it doesn't seem to be implemented. If it is a simple implementation, I could try to take a stab at it, if someone shows me how it is implemented for other values.

@wesleycho
Copy link

Couldn't you use the flexbox styling?

@sanketr
Copy link
Author

sanketr commented Mar 31, 2015

Nope, it seems only supported styling as documented in the api here can be used:
https://facebook.github.io/react-native/docs/style.html#content

Please correct me with a working example if I am wrong. Ability to apply flexbox styling will be big relief! I know it can be applied to reactjs vanilla library. Native ios version seems to be different beast.

@wesleycho
Copy link

@sanketr
Copy link
Author

sanketr commented Mar 31, 2015

Oh, it is the same one I am trying. The hitch is that "justify" property is not available for textAlign - so, I can't get newspaper like layout. A sample code below:

var styleTest = StyleSheet.create({

 title: {
   fontSize : 20,
   color : 'rgb(0,0,255)',
   textAlign: "justify"
  }
});

Here is an example of how it looks like in css: http://www.w3schools.com/cssref/tryit.asp?filename=trycss_text-align_all

@sanketr
Copy link
Author

sanketr commented Mar 31, 2015

I did some more research about justified text alignment. It seems that on the web, text alignment isn't done as well as desktop publishing tools like latex because of lack of hypenations. So, something like hypenator.js might be of interest. CSS3 now includes hypens property.

@brentvatne brentvatne changed the title textalign should implement 'justify' css property [Text] textalign should implement 'justify' css property May 31, 2015
@brentvatne
Copy link
Collaborator

@vjeux - any particular reason for not including justify? If not, we can tag this as a good first task

@vjeux
Copy link
Contributor

vjeux commented May 31, 2015

We had justify and then realized Android doesn't support justify so we removed it.

Probably worth adding it back and figure out something on android side, pretty crazy that it is not supported

@brentvatne brentvatne added the Good first issue Interested in collaborating? Take a stab at fixing one of these issues. label May 31, 2015
@ide
Copy link
Contributor

ide commented Jun 1, 2015

+1 to shipping it on iOS. Seems ok for Android to fall back to left or center alignment since the app is still usable, sort of like how older browsers just drop rules they don't understand on the web until one day the property is supported.

@vjeux
Copy link
Contributor

vjeux commented Jun 1, 2015

Agreed. Pull request welcome

@jim-lake
Copy link

jim-lake commented Dec 2, 2015

textAlign: 'justify', brings up the "Error while updating property 'textAlign' of a view managed by: RCTText. on Android. Would be nice if it just did left or center or anything but crashing.

@satya164
Copy link
Contributor

satya164 commented Dec 3, 2015

@jim-lake Can you open a new issue for this?

@L3V147H4N
Copy link

👍

@L3V147H4N
Copy link

new issue for this #5408

ghost pushed a commit that referenced this issue Apr 24, 2016
Summary:Fixes #5408 as per ide and vjeux suggestions here #529 (comment)

Could've been probably done in a single `if` clause, but this is more explicit and leaves potential place for future implementation (if we ever decide to do so)
Closes #7197

Differential Revision: D3217740

Pulled By: vjeux

fb-gh-sync-id: aa08a5c42e43c1abe17b72a424ee96146f2667f6
fbshipit-source-id: aa08a5c42e43c1abe17b72a424ee96146f2667f6
ptmt pushed a commit to ptmt/react-native that referenced this issue May 9, 2016
Summary:Fixes facebook#5408 as per ide and vjeux suggestions here facebook#529 (comment)

Could've been probably done in a single `if` clause, but this is more explicit and leaves potential place for future implementation (if we ever decide to do so)
Closes facebook#7197

Differential Revision: D3217740

Pulled By: vjeux

fb-gh-sync-id: aa08a5c42e43c1abe17b72a424ee96146f2667f6
fbshipit-source-id: aa08a5c42e43c1abe17b72a424ee96146f2667f6
rozele referenced this issue in microsoft/react-native-windows May 25, 2016
Summary:
Finished adding support for justified text on iOS... just had to expose a prop value.
Fixes #529

Closes facebook/react-native#1486
Github Author: James Ide <ide@jameside.com>

Test Plan:
 View the Text example in the UIExplorer and see that all but the last lines of text in the justified text example are justified and extend to the far right of the available space. Tested on iOS 8, iPhone 6 simulator.

![text](https://cloud.githubusercontent.com/assets/379606/7926252/a90d2e98-0884-11e5-9f12-5cbb27505a0b.png)
zebulgar pushed a commit to nightingale/react-native that referenced this issue Jun 18, 2016
Summary:Fixes facebook#5408 as per ide and vjeux suggestions here facebook#529 (comment)

Could've been probably done in a single `if` clause, but this is more explicit and leaves potential place for future implementation (if we ever decide to do so)
Closes facebook#7197

Differential Revision: D3217740

Pulled By: vjeux

fb-gh-sync-id: aa08a5c42e43c1abe17b72a424ee96146f2667f6
fbshipit-source-id: aa08a5c42e43c1abe17b72a424ee96146f2667f6
samerce pushed a commit to iodine/react-native that referenced this issue Aug 23, 2016
Summary:Fixes facebook#5408 as per ide and vjeux suggestions here facebook#529 (comment)

Could've been probably done in a single `if` clause, but this is more explicit and leaves potential place for future implementation (if we ever decide to do so)
Closes facebook#7197

Differential Revision: D3217740

Pulled By: vjeux

fb-gh-sync-id: aa08a5c42e43c1abe17b72a424ee96146f2667f6
fbshipit-source-id: aa08a5c42e43c1abe17b72a424ee96146f2667f6
@NishantDesai1306
Copy link

NishantDesai1306 commented Oct 29, 2016

Do we have any alternative for text-align-last CSS property ? to align the contents of last line in a Text component ?
Here's an example of this property

  1. Without text-align-last property
    image
  2. With text-align-last property set to 'center'
    image

@ammichael
Copy link

Guys, why is not implemented in Android anyway? I just hit that issue, and makes no sense for me

@vjeux
Copy link
Contributor

vjeux commented Dec 29, 2016

@ammichael it is because Android itself doesn't support it, which is pretty crazy if you ask me. If we are really motivated we could probably hack around android itself to make it support it but this hasn't been high in the priority list. Hopefully they'll implement it at some point in the future and we can just use it in react native

@ammichael
Copy link

@vjeux 'Android itself doesn't support it'. Not sure if I should laugh or curse about it. For curiosity sake.. why not?

What's the alternative to get the same 'effect'?

@vjeux
Copy link
Contributor

vjeux commented Dec 29, 2016

@ammichael your guess is as good as mine: http://stackoverflow.com/a/1293541

People are using webviews to achieve that but this is insane and likely not performant at all. I'm not sure of any good workaround I'm afraid :(

@vjeux
Copy link
Contributor

vjeux commented Dec 29, 2016

Actually, there's now a 3rd party library for it: https://github.com/bluejamesbond/TextJustify-Android would be great to do bindings for it so it can be used inside of React Native :)

@ammichael
Copy link

Yeah, I found the same alternative, and I'll use the same word as you did to describe it: insane.
Makes no sense at all to me.

That lib seems to do the work, and seems more reasonable than to create a web view, and I would love to know how to create the bindings, but I don't :(

@vjeux
Copy link
Contributor

vjeux commented Dec 29, 2016

@ammichael
Copy link

Feels almost like a joke all that is needed just because 'text align justify'.

I'll give it a try later, then

@vjeux
Copy link
Contributor

vjeux commented Dec 29, 2016

cc @lacker

@afilp
Copy link

afilp commented Feb 3, 2017

@vjeux @lacker Any plans to incorporate "TextJustify-Android" native library to React Native? Or at least have a "react-native" related package, so that we can use it directly? Thanks for any feedback!

@alpfilho
Copy link

I need 'justify' option too

@jkomyno
Copy link

jkomyno commented May 9, 2017

It seems that textView.setJustify(true); will be ready in Android O.
https://developer.android.com/reference/android/widget/TextView.html#setJustify(boolean)

jpklein added a commit to jpklein/TwistedMind that referenced this issue Oct 21, 2017
@facebook facebook locked as resolved and limited conversation to collaborators Jun 16, 2018
@react-native-bot react-native-bot added the Resolution: Locked This issue was locked by the bot. label Jul 23, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Good first issue Interested in collaborating? Take a stab at fixing one of these issues. Resolution: Locked This issue was locked by the bot.
Projects
None yet
Development

Successfully merging a pull request may close this issue.