-
Notifications
You must be signed in to change notification settings - Fork 27
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(detail-pages): add <{Info,Form,CustomForm}DetailPage> components #2594
Conversation
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
🦋 Changeset detectedLatest commit: 120bc42 The changes in this PR will be included in the next version bump. This PR includes changesets to release 8 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
docs: improvments
docs: improvements #2
revert: defaultProps
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.
Thanks for working on this 🙌
Had a quick look with some questions. Will have another look later.
.changeset/old-otters-arrive.md
Outdated
|
||
## InfoDetailPage | ||
|
||
Form Detail pages are controlled components used to render a page with detailed data. |
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.
Form Detail pages are controlled components used to render a page with detailed data. | |
Info Detail pages are controlled components used to render a page with detailed data. |
/** | ||
* Makes page top bar visible | ||
*/ | ||
showPageTopBar?: boolean; |
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.
Is this a new prop? What's the purpose of it? 🤔
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.
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.
The other though I had was to render it conditionally based on the
onPreviousPathClick
Yeah maybe that's better so we don't need an extra prop for that.
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.
Awesome work 💪
I just left a comment with something to maybe discuss about.
.changeset/old-otters-arrive.md
Outdated
<FormDetailPage | ||
title="Manage your account" | ||
showPageTopBar | ||
onPreviousPathClick={() => history.push('/starting-page')} | ||
isPrimaryButtonDisabled={formik.isSubmitting} | ||
onSecondaryButtonClick={() => { | ||
formik.resetForm(); | ||
}} | ||
onPrimaryButtonClick={formik.handleSubmit} | ||
> | ||
<TextField | ||
name="email" | ||
title="Email" | ||
isRequired={true} | ||
value={formik.values.email} | ||
errors={formik.errors.email} | ||
touched={formik.touched.email} | ||
onChange={formik.handleChange} | ||
onBlur={formik.handleBlur} | ||
/> | ||
</FormDetailPage> |
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.
For both FormDetailPage
and CustomFormDetailPage
I'm missing the form
html tag wrapping the input fields.
Personally, I would expect those components to internally add that element but, if we don't want that solution, at least I find it necessary to add it into the examples (both in the changelog and in the docs).
If we include the form tag in our components, perhaps we would also want to link the primary button to it using the form attribute (HTML attributes; form attribute explained). Although this can be tricky with the current implementation.
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 pushed a branch (cm-details-pages) with an implementation idea (not a working solution) of what I meant with my previous comment in case we want to discuss adding the form tag to the new form components.
Changes can be seen here.
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.
FYI: I think using the form
element is a valid point and we should discuss this separately, as we're also not really using it in many parts of the MC at the moment.
@CarlosCortizasCT Can you maybe open a discussion or issue to talk about it and how we plan to use it? We should also check with the other teams if there are other concerns about having it set by default in the components.
Thanks
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'd also value this as I know many locations inside the MC where it's not used. Let's discuss it separately. I think we can either scan the next child and if it's a form
not wrap it or have a disableWrapByForm
prop which is false
by default but can be disabled for instance. Similar to Next.js Link
migration strategy which has a oldBehaviour
prop.
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.
💯
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.
Super cool. Can't wait to get rid of more homegrown internal things inside the MC with this 💟.
.changeset/old-otters-arrive.md
Outdated
'@commercetools-website/components-playground': minor | ||
--- | ||
|
||
Add three new layout components: `<InfoDetailPage>`, `<FormDetailPage>` and `<CustomFormDetailPage>`. |
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.
Add three new layout components: `<InfoDetailPage>`, `<FormDetailPage>` and `<CustomFormDetailPage>`. | |
Adds three new layout components: `<InfoDetailPage>`, `<FormDetailPage>` and `<CustomFormDetailPage>`. |
.changeset/old-otters-arrive.md
Outdated
onClick={() => { | ||
formik.resetForm(); | ||
}} |
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.
Nit as we do that below
onClick={() => { | |
formik.resetForm(); | |
}} | |
onClick={formik.resetForm} |
@@ -0,0 +1,59 @@ | |||
import Text from '@commercetools-uikit/text'; |
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.
GitHub doesn't have syntax highlighting on this file but I guess that's unrelated to the file itself.
<Spec label="InfoDetailPage" size="xl"> | ||
<DetailPageContainer onPreviousPathClick={() => alert('Go back clicked')}> | ||
<Text.Body> | ||
{`Lorem ipsum dolor sit amet, consectetur adipiscing elit. Curabitur nec turpis in risus elementum fringilla. Vestibulum nec vulputate metus, fringilla luctus nisl. Vestibulum mattis ultricies augue sagittis vestibulum. Nulla facilisi. Quisque tempor pulvinar efficitur. Praesent interdum ultrices leo. Vivamus non ex maximus justo egestas suscipit eget sed purus. Aliquam ut venenatis nulla. Fusce ac ligula viverra, blandit augue eget, congue turpis. Curabitur a sagittis leo. Nunc sed quam dictum, placerat nunc quis, luctus erat.`} |
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 don't think we need tow rap these in {``}
. There are some places in this PR we do so and others we don't.
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.
Thanks. This looks good from my view.
Deploy preview for merchant-center-application-kit ready! ✅ Preview Built with commit 120bc42. |
@kark Looks good, thanks! One minor thing: the list of components got longer now and I think it would be nice to group things a bit (e.g. Dialogs, Modal pages, Detail pages, etc.) Can also be a follow up. |
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.
🚀
Let's do the docs improvements as a follow up, as discussed. Thanks!
onClick={() => { | ||
formikProps.resetForm(); | ||
}} |
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 would keep it like this actually, as resetForm
accepts an argument as the nextState
and that could lead to unexpected issues if the function is called with the event resetForm(event)
.
https://formik.org/docs/api/formik#resetform-nextstate-partialformikstatevalues--void
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.
Thanks 😊
Summary
The aim of this PR was to implement new
<InfoDetailPage>
,<FormDetailPage>
and<CustomFormDetailPage>
components.closes #2551