-
Notifications
You must be signed in to change notification settings - Fork 2
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
feat(StrapiFormComponents): add StrapiCheckbox #418
Conversation
Co-authored-by: Pram Gurusinga <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Puh...I think I get where you're coming from (although, maybe not really - could you explain the reason for changing the structure?)
What I personally don't like about this concept:
- We tried to separate components from Strapi as much as possible before, which was a consious decision to declutter the two (Remember when we still had them very close together? I know this doesn't reintroduce the dependency, but definitely is one step in that direction again.
- Having a
.tsx
file within amodels
folder just feels reeeaaally weird to me and I think might be exactly the sign we're not doing the right thing here.
In the end, it is just another way of translation, so if you still think, it is the better option than a translation function, I'd put the translation (because of the .tsx
) closer to the component than the strapi model. - into the component itself or another separate folder (And then the question arises again - what's the advantage here?
Main reason is that we are removing one level of complexity (intransparent props destructuring + untyped
The CMS service (should probably be named This isn't moving it out of the service but rather closer to the context of each component instead of a generic
I agree on the naming, but would rather rename |
@@ -84,6 +85,8 @@ function cmsToReact(cms: StrapiContent, templateReplacements: Replacements) { | |||
return <RadioGroup {...getRadioGroupProps(replacedTemplate)} key={key} />; | |||
case "form-elements.dropdown": | |||
return <Select {...getDropdownProps(replacedTemplate)} key={key} />; | |||
case "form-elements.checkbox": | |||
return renderCheckboxFromStrapi(replacedTemplate); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Side note while looking at this - we'll need to also include the key here, right? Otherwise it will result in a log/error?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I was also thinking about this but I don't see the reason for it - the only .map()
call happens inside PageContent()
, which adds the key for the child <div>
element. the elements contained in that don't need the same key again afaik?
Ah yes, I get it. Especially the double-parsing part. |
Co-Authored-By: Pram Gurusinga <[email protected]>
Kudos, SonarCloud Quality Gate passed! |
Proposal: Mapping the CMS component to React component inside the function (see
renderCheckboxFromStrapi()
) rather than mapping the props