Skip to content

Best practices first version#1455

Open
dydome wants to merge 7 commits intodevelopfrom
feature/best-practices
Open

Best practices first version#1455
dydome wants to merge 7 commits intodevelopfrom
feature/best-practices

Conversation

@dydome
Copy link
Contributor

@dydome dydome commented Apr 25, 2022

close #1454

Copy link
Contributor

@szczepaniak-michal szczepaniak-michal left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are you sure that you want to commit .DS_Store files? Seems as if they are some macOS files that should not be here

dydome and others added 3 commits April 27, 2022 15:04
Co-authored-by: Michal Szczepaniak <97286147+szczepaniak-michal@users.noreply.github.com>
…est-practices.md

Co-authored-by: Michal Szczepaniak <97286147+szczepaniak-michal@users.noreply.github.com>
Co-authored-by: Michal Szczepaniak <97286147+szczepaniak-michal@users.noreply.github.com>
Copy link

@mateuszo mateuszo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good job ;)

})
export class CustomCartTotalsComponent extends CartTotalsComponent implements OnInit {

constructor(

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If we're not changing the dependencies of the component, we can omit constructor overriding because it would be inherited. Omitting the constructor, in this case, has the benefit that after the Spartacus version upgrade we don't need to do any modifications to our custom code.

At the same time it would be valuable to add an additional example where we do need to add an additional dependency to our component.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is to be mentioned somewhere else but I always suggest to add a custom prefix to all the elements. Here it is easy to mistake custom CartTotalsModule with the core one.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is to be mentioned somewhere else but I always suggest to add a custom prefix to all the elements. Here it is easy to mistake custom CartTotalsModule with the core one.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think that customI18nConfig is more readable

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For some reason "our Storefront Module" sounds strange to me. Maybe because you're writing this as a core team member and in this case, "our" may refer to the core code ;).
I would write either:

  • your Storefront Module, or
  • our custom Storefront Module

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't know if you want to add this but I personally don't recommend using breakpoints in the layout config, because it affects performance and causes flickering in SSR. Responsiveness should be achieved via CSS whenever it's possible.


### Extending pageMetaResolvers and normalizers

Extending Page Meta Resolvers or Normalizer looks the same as with adapters, the only difference is providing them.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it would be worthwhile to mention why we need to add it as multi-provider and how resolvers are being selected (getScore() method) - this is usually difficult to understand for the newcomers.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I guess this will undergo proofreading but using "will" sounds bad to me here. It sounds like you don't suggest/recommend something yet. I think it should be:

  • "we suggest"
  • "we recommend"

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same as above

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure whether cms components should go into a shared folder. They are usually feature specific and they are used only once in the source code - in the mapping configuration. In my opinion putting them into shared folder might result in accidentally importing the mapping multiple times.

Copy link
Contributor Author

@dydome dydome Apr 29, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@mateuszo It is only for shared elements. So if somebody has for example cms-component which is used under the cart, it will be under the cart feature module folder. But if it is banner-component we can put it in shared/cms-components/banner...

Sounds better for you?

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

Successfully merging this pull request may close these issues.

Best Practices doc

3 participants

Comments