Skip to content

Commit

Permalink
Add user research recruitment banner
Browse files Browse the repository at this point in the history
Trello: https://trello.com/c/yGMU3sR2

This looks reasonable in Firefox on Linux but I need to check on a
wider variety of devices before deploying it.

We're only showing the banner on the dashboard so that we don't
overwhelm people by showing it everywhere.

Still to do:

- Hide the banner permanently once a user clicks on the "Sign up to take
  part in research" button.

- Allow users to hide the banner for the current session.

- Ensure it works and looks correct in all supported browsers.
  • Loading branch information
chrisroos committed Aug 3, 2023
1 parent cb17900 commit 1a5de2c
Show file tree
Hide file tree
Showing 6 changed files with 84 additions and 0 deletions.
18 changes: 18 additions & 0 deletions app/assets/stylesheets/_user_research_recruitment_banner.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
.user-research-recruitment-banner {
background-color: $govuk-brand-colour;
padding-top: 3em;
}

.user-research-recruitment-banner__divider {
margin-top: 0;
border-bottom: 1px solid govuk-colour("white");
}

.user-research-recruitment-banner__title {
color: govuk-colour("white");
margin-bottom: 25px;
}

.user-research-recruitment-banner__intro {
color: govuk-colour("white");
}
1 change: 1 addition & 0 deletions app/assets/stylesheets/application.scss
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
@import "govuk_publishing_components/all_components";
@import "user_research_recruitment_banner";

// TODO: move into component
.gem-c-success-alert,
Expand Down
5 changes: 5 additions & 0 deletions app/controllers/application_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -69,4 +69,9 @@ def notify_bad_request(_exception)
def redirect_to_prior_flow(args = {})
redirect_to stored_location_for("2sv") || :root, args
end

def show_user_research_recruitment_banner?
false
end
helper_method :show_user_research_recruitment_banner?
end
6 changes: 6 additions & 0 deletions app/controllers/root_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,10 @@ def index
def signin_required
@application = ::Doorkeeper::Application.find_by(id: session.delete(:signin_missing_for_application))
end

private

def show_user_research_recruitment_banner?
true
end
end
16 changes: 16 additions & 0 deletions app/views/layouts/admin_layout.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,22 @@
navigation_items: navigation_items,
}%>
<% if show_user_research_recruitment_banner? %>
<section class="user-research-recruitment-banner">
<div class="govuk-width-container">
<hr class="user-research-recruitment-banner__divider govuk-section-break govuk-section-break--l">
<h1 class="user-research-recruitment-banner__title govuk-heading-xl">Help us improve GOV.UK Publishing</h1>
<p class="user-research-recruitment-banner__intro govuk-body">We're holding research sessions to make Publishing work better.</p>
<div>
<%= link_to 'Sign up to take part in research',
'https://docs.google.com/forms/d/1Bdu_GqOrSR4j6mbuzXkFTQg6FRktRMQc8Y-q879Mny8/viewform',
class: 'govuk-!-font-size-24 govuk-!-font-weight-bold govuk-button govuk-button--inverse'
%>
</div>
</div>
</section>
<% end %>

<div class="govuk-width-container">
<% if yield(:back_link).present? %>
<%= render "govuk_publishing_components/components/back_link", href: yield(:back_link) %>
Expand Down
38 changes: 38 additions & 0 deletions test/integration/user_research_recruitment_banner_test.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
require "test_helper"

class UserResearchRecruitmentBannerTest < ActionDispatch::IntegrationTest
should "not display the banner on the login page" do
visit new_user_session_path

assert_not has_content?(user_research_recruitment_banner_title)
end

should "display the banner on the dashboard" do
user = create(:user, name: "user-name", email: "user@example.com")
visit new_user_session_path
signin_with(user)

assert has_content?(user_research_recruitment_banner_title)
assert has_link?("Sign up to take part in research", href: "https://docs.google.com/forms/d/1Bdu_GqOrSR4j6mbuzXkFTQg6FRktRMQc8Y-q879Mny8/viewform")
end

should "not display the banner on any page other than the dashboard" do
user = create(:user, name: "user-name", email: "user@example.com")
visit new_user_session_path
signin_with(user)

click_on "Change your email or password"

assert_not has_content?(user_research_recruitment_banner_title)
end

should "hide the banner until the next session"

should "hide the banner permanently if the user clicks the button to participate in user research"

private

Check failure on line 33 in test/integration/user_research_recruitment_banner_test.rb

View workflow job for this annotation

GitHub Actions / Lint Ruby / Run RuboCop

Layout/AccessModifierIndentation: Outdent access modifiers like `private`. (https://rubystyle.guide#indent-public-private-protected)

def user_research_recruitment_banner_title
"Help us improve GOV.UK Publishing"
end
end

0 comments on commit 1a5de2c

Please sign in to comment.