-
-
Notifications
You must be signed in to change notification settings - Fork 588
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
classesStyles properties don't override baseFontStyle properties #102
Comments
classesStyles
properties not always override baseFontStyle
properties
Hi, thanks for the very precise explanation and reproduction of this issue. Could you try replacing the line 444 from from : const textElementStyles = this.filterBaseFontStyles(element, classStyles, props); to const textElementStyles = parentTag && TEXT_TAGS.indexOf(parentTag) !== -1 ? {} : this.filterBaseFontStyles(element, classStyles, props); Basically, what I've done here is not to apply I'm pretty concerned with regressions, and the demo isn't complete enough for me to check all use cases. I'd like you to tell me if it fixed it for you, and if you see any potential drawbacks. |
Hey, @Exilz Your solution doesn't seem to work properly :/. |
Allright, so I took some more time to dig into this problem, which seems closely tied to #119 and it's way more complicated than what I originally thought. I think the whole logic of text style inheritance needs to be rewritten, Here's the logic I came up with that I need to try out :
Let's take this snippet as an example : <p>
Texte paragraphe
<span class="red-p">red span </span>
<span class="blue-p">
blue<em> span</em>
</span>
</p> And those props : baseFontStyle: { fontSize: 20, color: 'green' },
classesStyles: {
'red-p': { fontSize: 10, color: 'red' },
'blue-p': { fontSize: 10, color: 'blue' }
} If I'm not mistaken, the above algorithm should map this HTML to the following native components : <Text paragraph>
<Text raw style={{ fontSize: 20, color: 'green' }}>Texte paragraphe</Text>
<Text span>
<Text raw style={{ fontSize: 10, color: 'red' }}>red span</Text>
</Text>
<Text span>
<Text raw style={{ fontSize: 10, color: 'blue' }}>blue</Text>
<Text em>
<Text raw style={{ fontSize: 10, color: 'blue', fontStyle: 'italic' }}>span</Text>
</Text>
</Text>
</Text> I'll try to implement this and keep you posted. |
This should be a much needed improvement addressing some of the oldest issues of this plugin. The new algorithm to be tried is explained [here](#102 (comment) ssuecomment-375594792)
A first version of these changes is available for testing in the development branch. I'm looking forward to your feedback. |
Thanks, I’ll take a look on monday. |
@Exilz I had a related problem using version 3.9.1. fontSize would not apply, when I was using classesStyles. Here is a test to reproduce it: The test branch works:
|
@CarstenHoyer glad to hear the development branch fixed this for you. I have been testing these changes on our applications, and it looks like it fixed a lot of wrong behaviors. However, please note this broke some renderers that shouldn't have been working before but were using bugs to their advantage. I'll be releasing this soon, along with some small new features. More reviews are always welcome :) |
I've tested this as well and the dev branch works nicely for me. |
This should be a much needed improvement addressing some of the oldest issues of this plugin. The new algorithm to be tried is explained [here](meliorence#102 (comment) ssuecomment-375594792)
This should be a much needed improvement addressing some of the oldest issues of this plugin. The new algorithm to be tried is explained [here](meliorence/react-native-render-html#102 (comment) ssuecomment-375594792)
classesStyles
properties override the correspondingbaseFontStyle
properties only if the tagsStyles have the same properties.For example:
fontSize
andcolor
properties ofsmallRedFont
class won't overridefontSize
andcolor
ofbaseFontStyle
, becausetagsStyles
forp
doesn't include these properties.In this case, however,
fontSize
andcolor
properties ofsmallRedFont
class will overridefontSize
andcolor
ofbaseFontStyle
, becausetagsStyles
forp
does have these properties.The text was updated successfully, but these errors were encountered: