Skip to content

Commit

Permalink
Render GOV.UK chat on some browse pages
Browse files Browse the repository at this point in the history
If the page's `base_path` matches one in a predefined list, we
want to render the GOV.UK Chat promo to point users to the new chat
service.

This adds the markup to the browse and 2nd level browse pages.

For the second level it's pretty straightfoward, as we already have a
2/3 width `div` on the left and we just want to put the promo to the
right of it, so we can drop it in a 1/3 width `div` immediately after in
the markup.

For the top level browse page it's a tiny bit more complicated. There's
a "Popular tasks" element which spans the full width and has a bottom
blue border. We need to embed the promo to the right of this content so
that it shares the border. So we just need to wrap everything in a row,
and then render the "Popular tasks" content in a full-width `div` if
we're not showing the promo, and a 2/3 width `div` if we are showing the
promo.
  • Loading branch information
jackbot committed Aug 21, 2024
1 parent 93ff7ce commit 3b5f92c
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 11 deletions.
32 changes: 21 additions & 11 deletions app/views/browse/show.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -39,18 +39,28 @@
<div class="govuk-grid-row">
<div class="govuk-grid-column-full">
<div class="browse__action-links">
<%= render "govuk_publishing_components/components/heading", {
text: t("browse.popular_tasks"),
margin_bottom: 6,
font_size: "m"
} %>
<ul class="govuk-list govuk-!-margin-bottom-7">
<% popular_links_for_slug(page.slug).each do |link| %>
<li>
<%= render partial: "shared/browse_action_link", locals: {link:} %>
</li>
<div class="govuk-grid-row">
<div class="<%= show_govuk_chat_promo?(page.base_path) ? "govuk-grid-column-two-thirds" : "govuk-grid-column-full" %>">
<%= render "govuk_publishing_components/components/heading", {
text: t("browse.popular_tasks"),
margin_bottom: 6,
font_size: "m"
} %>
<ul class="govuk-list govuk-!-margin-bottom-7">
<% popular_links_for_slug(page.slug).each do |link| %>
<li>
<%= render partial: "shared/browse_action_link", locals: {link:} %>
</li>
<% end %>
</ul>
</div>

<% if show_govuk_chat_promo?(page.base_path) %>
<div class="govuk-grid-column-one-third">
<%= render "shared/govuk_chat_promo" %>
</div>
<% end %>
</ul>
</div>
</div>
</div>
</div>
Expand Down
6 changes: 6 additions & 0 deletions app/views/second_level_browse_page/show_curated.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -37,5 +37,11 @@
<div class="govuk-grid-column-two-thirds" data-module="ga4-link-tracker">
<%= render partial: curated_partial, locals: { page: page } %>
</div>

<% if show_govuk_chat_promo?(page.base_path) %>
<div class="govuk-grid-column-one-third">
<%= render "shared/govuk_chat_promo" %>
</div>
<% end %>
</div>
</div>

0 comments on commit 3b5f92c

Please sign in to comment.