-
Notifications
You must be signed in to change notification settings - Fork 17
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #3486 from alphagov/published-dates-wrapper
Use component wrapper in published dates component
- Loading branch information
Showing
4 changed files
with
46 additions
and
47 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,46 +1,50 @@ | ||
<% add_app_component_stylesheet("published-dates") %> | ||
<% | ||
add_app_component_stylesheet("published-dates") | ||
|
||
published ||= false | ||
history ||= [] | ||
history = Array(history) | ||
last_updated ||= false | ||
link_to_history ||= false | ||
shared_helper = GovukPublishingComponents::Presenters::SharedHelper.new(local_assigns) | ||
classes = %w(app-c-published-dates) | ||
classes << "app-c-published-dates--history" if history.any? | ||
classes << shared_helper.get_margin_bottom if local_assigns[:margin_bottom] | ||
|
||
component_helper = GovukPublishingComponents::Presenters::ComponentWrapperHelper.new(local_assigns) | ||
component_helper.add_class("app-c-published-dates") | ||
component_helper.add_class("app-c-published-dates--history") if history.any? | ||
component_helper.set_id("full-publication-update-history") if history.any? | ||
component_helper.add_data_attribute({ module: "gem-toggle" }) if history.any? | ||
component_helper.set_lang("en") | ||
%> | ||
<% if published || last_updated %> | ||
<h2 class="govuk-visually-hidden"><%= t('components.published_dates.hidden_heading') %></h2> | ||
<div class="<%= classes.join(' ') %>" <% if history.any? %>id="full-publication-update-history" data-module="gem-toggle"<% end %> lang="en"> | ||
<% if published %> | ||
<%= t('components.published_dates.published', date: published) %> | ||
<% end %> | ||
<% if last_updated %> | ||
<% if published %><br /><% end %><%= t('components.published_dates.last_updated', date: last_updated) %> | ||
<% if link_to_history && history.empty? %> | ||
— <a href="#history" class="app-c-published-dates__history-link govuk-link"><%= t('components.published_dates.see_all_updates', locale: :en) %></a> | ||
<% elsif history.any? %> | ||
<a href="#full-history" | ||
class="app-c-published-dates__toggle govuk-link" | ||
data-controls="full-history" | ||
data-expanded="false" | ||
data-toggled-text="- <%= t('components.published_dates.hide_all_updates', locale: :en) %>" | ||
data-module="ga4-event-tracker" | ||
data-ga4-event="<%= {event_name: "select_content", type: "content history", section: "Footer"}.to_json %>" | ||
data-ga4-expandable | ||
>+ <%= t('components.published_dates.show_all_updates', locale: :en) %></a> | ||
<div class="app-c-published-dates__change-history js-hidden" id="full-history"> | ||
<ol class="app-c-published-dates__list"> | ||
<% history.each do |change| %> | ||
<li class="app-c-published-dates__change-item"> | ||
<time class="app-c-published-dates__change-date timestamp" datetime="<%= change[:timestamp] %>"><%= change[:display_time] %></time> | ||
<p class="app-c-published-dates__change-note"><%= change[:note].strip %></p> | ||
</li> | ||
<% end %> | ||
</ol> | ||
</div> | ||
<%= tag.div(**component_helper.all_attributes) do %> | ||
<h2 class="govuk-visually-hidden"><%= t('components.published_dates.hidden_heading') %></h2> | ||
<% if published %> | ||
<%= t('components.published_dates.published', date: published) %> | ||
<% end %> | ||
<% if last_updated %> | ||
<% if published %><br /><% end %><%= t('components.published_dates.last_updated', date: last_updated) %> | ||
<% if link_to_history && history.empty? %> | ||
— <a href="#history" class="app-c-published-dates__history-link govuk-link"><%= t('components.published_dates.see_all_updates', locale: :en) %></a> | ||
<% elsif history.any? %> | ||
<a href="#full-history" | ||
class="app-c-published-dates__toggle govuk-link" | ||
data-controls="full-history" | ||
data-expanded="false" | ||
data-toggled-text="- <%= t('components.published_dates.hide_all_updates', locale: :en) %>" | ||
data-module="ga4-event-tracker" | ||
data-ga4-event="<%= {event_name: "select_content", type: "content history", section: "Footer"}.to_json %>" | ||
data-ga4-expandable | ||
>+ <%= t('components.published_dates.show_all_updates', locale: :en) %></a> | ||
<div class="app-c-published-dates__change-history js-hidden" id="full-history"> | ||
<ol class="app-c-published-dates__list"> | ||
<% history.each do |change| %> | ||
<li class="app-c-published-dates__change-item"> | ||
<time class="app-c-published-dates__change-date timestamp" datetime="<%= change[:timestamp] %>"><%= change[:display_time] %></time> | ||
<p class="app-c-published-dates__change-note"><%= change[:note].strip %></p> | ||
</li> | ||
<% end %> | ||
</ol> | ||
</div> | ||
<% end %> | ||
<% end %> | ||
<% end %> | ||
</div> | ||
<% end %> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters