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

Theming the default contact form #759

Open
wants to merge 15 commits into
base: main
Choose a base branch
from

Conversation

mgurjanov
Copy link
Contributor

@mgurjanov mgurjanov commented Nov 21, 2024

#726

  • install and enable webform module
  • add Form PT with webform reference field
  • wire and style Form PT
  • enable Form PT on Landing Page CT
  • update Contact Webform to match core Contact form (submit confirmation email is set to be sent to user as ntification email to site owner)
  • add tests
  • uninstall core Contact module
Edit View
ds_form_pt_edit ds_form_pt

Copy link
Collaborator

@mariano-dagostino mariano-dagostino left a comment

Choose a reason for hiding this comment

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

@mgurjanov Looks good, should we disable the contact module now?

@mgurjanov
Copy link
Contributor Author

@mariano-dagostino You stole my question! I was thinking of same. So you agree?

@mgurjanov
Copy link
Contributor Author

@mariano-dagostino I removed core contact!

@mgurjanov
Copy link
Contributor Author

@sonvir249 Please take a look.

* @return array
* Render array.
*/
public function buildFull(array $build, ParagraphInterface $entity): array {
Copy link
Contributor Author

@mgurjanov mgurjanov Nov 26, 2024

Choose a reason for hiding this comment

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

@amitaibu This is what I actually wanted to point out before but didn't put it together well. If we can use smaller trait component methods (FE methods) to build render array step by step, do we need to pass title, body, items etc like we do with other PT PEVB plugins in DS? To me adding another trait method just for this PT or adding a twig doesn't seem needed. Or even using some method like: buildElementLayoutTitleBodyAndItems. Or do we always have to use trait methods only from other trait methods?

Copy link
Member

Choose a reason for hiding this comment

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

What we should improve here, is that PEVB shouldn't be calling stuff like buildParagraphTitle directly.

Instead it would call a trait with a buildWebform(string $title, array $description = [], array $form = []): array();

By having this buildWebform, we could show it on the style guide.

So it's not about calling traits from other traits. It's about separation of conecerns. PEVB is about extracting the dynamic data, and the FE traits are about getting raw data, and theming it.

Does it answer? :)

Copy link
Collaborator

Choose a reason for hiding this comment

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

For me it's also about knowing where things come from. So we have server-theme-accordion.html.twig? Then we have AccordionTrait, accordion.pcss, accordion.js etc and that's super easy to navigate with Ctrl+N on phpstorm. Before when we have InnerElementTrait and InnerElementLayoutTrait etc it was super confusing to me at least and also tedious when trying to work out a general overview of how the element is put together.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thank you both. I get it now. I was a bit confused with some implementations on other projects where we have not so uniform implementation.

Copy link
Collaborator

@bboro bboro Nov 26, 2024

Choose a reason for hiding this comment

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

@mgurjanov no worries, and yes other projects may be confusing because we were still working out how to do this :)

For me personally, I'd prefer "easier to understand/maintain" more than "elegant". So for example, personally I'd prefer doing the layout, styling etc of a piece of text in its own server-theme-element-- twig, rather than have it split over multiple smaller server-theme-inner-element-layout-- etc twigs.

But for much smaller elements like button, responsive-font-size, vertical-spacing etc, it makes sense to have traits that do this, so it's easier to maintain (change one twig and the whole site is updated)

So it's not really exact science, there's lot of arbitration, on my part at least, and I think we'll get there eventually :)

Copy link
Member

Choose a reason for hiding this comment

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

For me personally, I'd prefer "easier to understand/maintain" more than "elegant"

Same 😄

personally I'd prefer doing the layout, styling etc of a piece of text in its own server-theme-element-- twig, rather than have it split over multiple smaller server-theme-inner-element-layout-- etc twigs.

@bboro can you please give an example, I'm not sure I understand.

Copy link
Collaborator

Choose a reason for hiding this comment

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

I mean I personally prefer having server-theme-element--awesome-card.html.twig which defines its own grid grid-cols-2 etc layout, than having to compose this through wrapInnerElementLayoutAwesomeCard.

Copy link
Member

Choose a reason for hiding this comment

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

I see your point; thanks. But I'd still advocate being stingy with creating new Twigs, as I’ve seen it’s all too easy to add custom styles rather than reuse existing ones within the Twig.

So, as we break things down into smaller pieces, the goal is to guide devs away from adding new Twigs unnecessarily. New Twigs are the devil! 🤣

Copy link
Collaborator

@bboro bboro Nov 26, 2024

Choose a reason for hiding this comment

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

New Twigs are the devil! 🤣

🤣 Or maybe you can think of them as just an ever growing number of minions. 😄 😄 😄 😄

Comment on lines +62 to +65
$webform = $this->entityTypeManager->getStorage('webform')->load($webform_name);
if (empty($webform) || !$webform->isOpen()) {
return [];
}
Copy link
Member

Choose a reason for hiding this comment

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

Move up the func

* @return array
* Render array.
*/
public function buildFull(array $build, ParagraphInterface $entity): array {
Copy link
Member

Choose a reason for hiding this comment

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

What we should improve here, is that PEVB shouldn't be calling stuff like buildParagraphTitle directly.

Instead it would call a trait with a buildWebform(string $title, array $description = [], array $form = []): array();

By having this buildWebform, we could show it on the style guide.

So it's not about calling traits from other traits. It's about separation of conecerns. PEVB is about extracting the dynamic data, and the FE traits are about getting raw data, and theming it.

Does it answer? :)

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.

4 participants