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

find and apply promos #4476

Open
wants to merge 8 commits into
base: master
Choose a base branch
from
Open

find and apply promos #4476

wants to merge 8 commits into from

Conversation

jenhadfield-dfe
Copy link
Contributor

Trello card

https://trello.com/c/vew5h4zh/7152-redesign-and-build-find-promo

Context

Changes proposed in this pull request

Guidance to review

@github-actions github-actions bot added ruby Pull requests that update Ruby code test labels Jan 13, 2025
@jenhadfield-dfe jenhadfield-dfe marked this pull request as ready for review January 14, 2025 15:05
@jenhadfield-dfe jenhadfield-dfe changed the title exploring using simple component find and apply promos Jan 14, 2025
martyn-w
martyn-w previously approved these changes Jan 15, 2025
Copy link
Contributor

@martyn-w martyn-w left a comment

Choose a reason for hiding this comment

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

👍 LGTM

@martyn-w
Copy link
Contributor

NB: For the link rendered as button, add a role="button" to improve accessibility. And to make click tracking easier add a data-promo-type attribute, e.g.

<a class="button" role="button" data-promo-type="apply" href="https://www.gov.uk/apply-for-teacher-training">Apply for a <span>course</span></a>

class ApplyComponent < ViewComponent::Base
attr_accessor :icon, :title, :text, :link

def initialize(icon:, link_text: nil, link_target: nil, title: nil, text: nil, hide_on_mobile: false, hide_on_tablet: false, hide_on_desktop: false)
Copy link
Contributor Author

Choose a reason for hiding this comment

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

@martyn-w is there a way to set the default arguments here? so it makes it easier for content on the markdown file

eg. something like this? or is this the wrong place to do that? as i tried it and it didn't like it when i removed the arguments from the markdown file

def initialize(
  icon: "icon-school-black",
  link_text: "Apply for a course",
  link_target: "https://www.gov.uk/apply-for-teacher-training",
  title: "Start your application",
  text: "Create an account and start your application for a teacher training course.",
  hide_on_mobile: false,
  hide_on_tablet: false,
  hide_on_desktop: false
)
  super

Copy link
Contributor

@martyn-w martyn-w Jan 16, 2025

Choose a reason for hiding this comment

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

Hi @jenhadfield-dfe i've just tested and your suggested fix for default arguments does work - you might need to restart the application to get the defaults to load. Could you try again?

Screenshot 2025-01-16 at 09 39 52 Screenshot 2025-01-16 at 09 40 22 Screenshot 2025-01-16 at 09 40 38

Copy link
Contributor Author

Choose a reason for hiding this comment

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

ah thank you! the minimum it will let me leave is just one argument in there, if i take them all out it breaks, but it's ok as long as i leave one in. Is this due to the line in the component:

def before_render
fail(ArgumentError, "a title or text/content must be present") if [title, text, content].all?(&:nil?)

Copy link
Contributor

Choose a reason for hiding this comment

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

yep - you could remove that constraint if it isn't required

Copy link
Contributor Author

Choose a reason for hiding this comment

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

thanks, I've removed. But if i just put -

calls_to_action:
find:
name: find

in the markdown it still breaks, but if i keep one argument in it seems to work ok. It's not the end of the world to have one argument in there, but would be nice to have it as simple as possible

end
end
end

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@martyn-w is it everything below line 83 that needs removing from the spec files?

Copy link

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
content Content changes Review ruby Pull requests that update Ruby code Style test
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants