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

Style Parent Element #210

Closed
peetzweg opened this issue Oct 21, 2016 · 6 comments
Closed

Style Parent Element #210

peetzweg opened this issue Oct 21, 2016 · 6 comments

Comments

@peetzweg
Copy link

I can't find a way to properly style the parent element the text is rendered into. Can't provide a class or style property.

@jamuhl
Copy link
Member

jamuhl commented Oct 21, 2016

You mean for the Interpolate Component?!? What you want to render? Could you paste some code snipplet?!?

@peetzweg
Copy link
Author

I'am using a Component from the Material-UI framework, which receives a plain text as a secondaryText prop. Just dropping a Text with the Interpolate component with the default span parent breaks it's styling, the p element at least displays it in a block as it should be.

Using the HOC method to translate the text worked like charm before, however I switched to the Interpolate method because I had issues calculating the size of the Element the text is rendered into.

<ListItem
    secondaryText={
        <Interpolate 
            parent={'p'} 
            i18nKey={notification.message.content}
        />
    }
>

@jamuhl
Copy link
Member

jamuhl commented Oct 21, 2016

I'm rather sure we allow className on that: https://github.com/i18next/react-i18next/blob/master/src/interpolate.js#L47

think we should do the same for style prop?!? If you like you might add a PR for that to speed new version up...else i will add this asap (but not earlier ;))

@peetzweg
Copy link
Author

Ah okay, with this i could create a workaround. However a style prop would be cleaner, at best the parent should be an actual component instead of a plain string.

@jamuhl
Copy link
Member

jamuhl commented Oct 21, 2016

You can pass your own component as parent - but obviously useless right now as no props get passed to it beside the className. For that we would need to remove all props that where used in for the interpolation and pass the rest of the props down to the parent component.

Should be possible...but like said...hard on time so don't expect this to land very soon. PR would be very welcome.

@jamuhl
Copy link
Member

jamuhl commented Dec 16, 2016

style prop will be passed to the interpolate container in next version

@jamuhl jamuhl closed this as completed Dec 16, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants