Skip to content
This repository was archived by the owner on Jan 7, 2025. It is now read-only.

Conversation

@stephen-cox
Copy link
Member

}

// Search page form.
#views-exposed-form-localgov-sitewide-search-sitewide-search-page {
Copy link
Member

Choose a reason for hiding this comment

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

Is there a class we can use instead of an id for theming? Following Drupal standards we should not theme by ID.

Copy link
Member Author

Choose a reason for hiding this comment

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

I have updated this to use classes provided by views instead of the div

}

// Search results.
ol.search-results {
Copy link
Member

Choose a reason for hiding this comment

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

We should not need to use the ol element here. Within BEM classes should be styled independent of what element they are placed on.

Adding default styling of an element.class means the base theme that wants to override this will have to use something that is at least as specific as this, if not more specific.

Copy link
Member Author

Choose a reason for hiding this comment

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

Thanks. This is now nested in the view class and have removed the ol element.

padding: 0;
list-style-type: none;

.node--view-mode-search-result {
Copy link
Member

Choose a reason for hiding this comment

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

It would be good if this template had an item in the classes array for this node type called search-result, then we could use that as our Block class in BEM.

Copy link
Member Author

Choose a reason for hiding this comment

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

Yep - using BEM classes now.

margin-top: 0;
margin-bottom: 1em;

h3 {
Copy link
Member

Choose a reason for hiding this comment

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

If we had a .search-result class in the classes array, then we could use .search-result__title here instead of theming a h3 element. Drupal standards say we should not theme by element if at all possible.

Copy link
Member Author

Choose a reason for hiding this comment

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

Yep - using BEM classes now.

* @ingroup themeable
*/
#}{%
set classes = [
Copy link
Member

Choose a reason for hiding this comment

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

I think we should leave in the default drupal classes that we get with node node--unpublished etc.

Also, we could have a .search-result class here, then the other items can have BEM-based classes such as:

  • .search-result__title
  • .search-result__content
  • etc

Copy link
Member Author

Choose a reason for hiding this comment

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

Search result template has been updated to user BEM classes and add the default Drupal node classes to the search result wrapper.

<a href="{{ url }}">{{ label }}</a>
</h3>
{{ title_suffix }}
<p>{{ content|render|striptags|raw }}</p>
Copy link
Member

Choose a reason for hiding this comment

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

This should be a div and not a p so we can have more than one field rendered in the search result view mode. For example, an event might want to render the event date as well as a snippet of text.

<div class="search-result__content">
  {{ content }}
</div>

I think ^ would be better, so we don't need to have specific templates for any other content types, they can all render whatever content the site builders decide they should.

Copy link
Member Author

Choose a reason for hiding this comment

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

Yep - using a div now rather then a p

@@ -0,0 +1,95 @@
{#
Copy link
Member

Choose a reason for hiding this comment

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

This looks to me to be identical to a standard views-view.html.twig file. If that's the case, we probably don't need to add it here at all.

Copy link
Member Author

Choose a reason for hiding this comment

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

The difference between this template and the standard Drupal one is the view filters come before the header. This is so the search block appears at the top and the page and not under the 'Search results' heading.

Doing this in the template seemed the best way to achieve this. Are you aware of any other ways to swap page elements without CSS hacks?

Copy link
Member

Choose a reason for hiding this comment

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

I'm happy with that approach. I have a slightly modified views template in my default setup, where I use a variable to set things like that, then the custom views template just calls the default template and sets the variable to true. You can see a short write-up of it here:
https://mark.ie/blog/printing-regions-in-views-in-different-places-using-the-same-template

@stephen-cox
Copy link
Member Author

Thanks for the review @markconroy, I'll go through and address all the issue you found tomorrow.

The theming here is largely just to make things look okay. The actual styling should be reviewed and adjusted by someone who has more expertise than me on this.

@stephen-cox
Copy link
Member Author

stephen-cox commented Jun 17, 2021

@cjstevens78 I have a query about the search region in the theme. Do you know why this was hidden in the mobile menu section?

There's a requirement to add a sitewide search form to the header (localgovdrupal/localgov#256) so I moved the header region so it appears after the menus. See:

Is this going to cause problems?

@stephen-cox stephen-cox requested a review from cjstevens78 June 17, 2021 16:25
@stephen-cox stephen-cox requested a review from danchamp June 25, 2021 11:45
@stephen-cox
Copy link
Member Author

As the new theme is progressing this is just a stop gap for the demo site until the new theme is ready. Would be good to get this approved with the release of the search.

Copy link
Collaborator

@danchamp danchamp left a comment

Choose a reason for hiding this comment

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

@stephen-cox Happy enough with this for a release given it will be superceded by localgov_base in due course.

@stephen-cox stephen-cox merged commit cbb5fa3 into 1.x Jun 29, 2021
@stephen-cox stephen-cox deleted the feature/localgov-259-search-2.x branch June 29, 2021 09:41
@stephen-cox stephen-cox mentioned this pull request Jun 29, 2021
Copy link
Collaborator

@cjstevens78 cjstevens78 left a comment

Choose a reason for hiding this comment

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

Looks good to me. We dont use the sitewide search on Croydon so doubt it'll conflict.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants