claus / storyblok-rich-text-react-renderer

A React renderer for Storyblok rich text content
MIT License
87 stars 16 forks source link

[TS]: Separate interface for render options #12

Closed Dangoo closed 2 years ago

Dangoo commented 2 years ago

Thanks for bringing TS support (#4) with #9! It allowed us to remove our custom typings from the project :) But would it be possible to separate the interfaces of render arguments, so one can create the render options object outside of the function call?

Is:

render(richtextData, {
  [NODE_PARAGRAPH]: (children) => (
    <Paragraph>{children}</Paragraph>
  ),
  ...
})

Desired outcome:

import {render, RenderOptions} from 'storyblok-rich-text-react-renderer'

const richtextOptions: RenderOptions = {
  [NODE_PARAGRAPH]: (children) => (
    <Paragraph>{children}</Paragraph>
  ),
  ...
}

render(richtextData, richtextOptions)

Let me know what you think or if I can help in any way, cheers!

claus commented 2 years ago

@Dangoo Yeah that sounds like a good idea. Do you by chance have that locally already and could contribute? Or maybe @TGlide could take a look? Otherwise i can also look into that.

TGlide commented 2 years ago

I can take a look into that! I'll do that on monday

claus commented 2 years ago

Awesome, thank you @TGlide !

claus commented 2 years ago

Thanks so much, @TGlide! @Dangoo can you take a quick look at #13? Does that solve your issue?

Dangoo commented 2 years ago

@claus sure thing, just did :)

TGlide commented 2 years ago

Thanks for the comments! I'll take a look at the suggetions tomorrow, but at first glance they seem like good ideas IMO

claus commented 2 years ago

Published as 2.5.2 Thanks guys, i appreciate your help on this!