-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
cb05f87
commit b3aa513
Showing
9 changed files
with
190 additions
and
2 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
<%= tag.div(class: "routes--border-top") if border %> | ||
<%= tag.div class: classes do %> | ||
<div class="routes__left"> | ||
<%= image_pack_tag(image, | ||
**helpers.image_alt_attribs_for_text(""), | ||
class: "routes__image") | ||
%> | ||
</div> | ||
|
||
<div class="routes__right"> | ||
<h2 class="heading-l"> | ||
<%= tag.span title if title.present? %> | ||
</h2> | ||
<%= tag.p text, class: 'routes__text' if text.present? %> | ||
<p></p> | ||
<%= link_to link_text, link_target, class: "button", role: "button", data: { "promo-type": "routes" } if link_text.present? && link_target.present? %> | ||
</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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
class CallsToAction::RoutesComponent < ViewComponent::Base | ||
attr_reader :title, :text, :image, :link_text, :link_target, :classes, :border | ||
|
||
def initialize( | ||
title: "Find your route into teaching", | ||
text: "An adviser with years of teaching experience can help you to become a teacher. Chat by phone, text, or email as little or often as you need.", | ||
image: "static/images/routes.png", | ||
link_text: "Find your route into teaching", | ||
link_target: "/find-your-route-into-teaching", | ||
classes: [], | ||
border: true | ||
) | ||
super | ||
|
||
@title = title | ||
@text = text | ||
@image = image | ||
@link_text = link_text | ||
@link_target = link_target | ||
@classes = ["routes", *classes].compact.join(" ") | ||
@border = border | ||
end | ||
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
3 changes: 3 additions & 0 deletions
3
app/views/content/train-to-be-a-teacher/promos/_routes-promo.html.erb
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 |
---|---|---|
@@ -0,0 +1,3 @@ | ||
<%= render CallsToAction::RoutesComponent.new( | ||
text: "Answer 3 questions to see which routes you could take into teaching.", | ||
) %> |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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 |
---|---|---|
@@ -0,0 +1,81 @@ | ||
.routes { | ||
max-width: $content-max-width; | ||
display: flex; | ||
flex-direction: column; | ||
gap: $indent-amount * .5; | ||
margin: 0 auto; | ||
background-color: $grey; | ||
|
||
@include mq($from: tablet) { | ||
flex-direction: row; | ||
margin: 0 auto; | ||
gap: 2 * $indent-amount; | ||
} | ||
|
||
@include mq($until: tablet) { | ||
&--border-top { | ||
display: none; | ||
} | ||
} | ||
|
||
@include mq($from: tablet) { | ||
&--border-top { | ||
display: block; | ||
border-top: 1px solid $grey-mid; | ||
padding-top: 3em; | ||
margin: 0 auto; | ||
max-width: $content-max-width; | ||
} | ||
} | ||
|
||
&:last-of-type { | ||
margin-bottom: 3em; | ||
} | ||
|
||
&__image { | ||
height: 11em; | ||
width: auto; | ||
} | ||
|
||
&__left { | ||
flex: 0 1 45%; | ||
padding-block: 2em; | ||
min-height: 8em; | ||
background-color: $grey; | ||
padding: 1em; | ||
align-content: center; | ||
text-align: center; | ||
} | ||
|
||
&__right { | ||
flex: 0 1 55%; | ||
align-items: flex-start; | ||
display: flex; | ||
flex-direction: column; | ||
padding-right: $indent-amount; | ||
padding-bottom: 2 * $indent-amount; | ||
|
||
@include mq($until: tablet) { | ||
padding-left: $indent-amount; | ||
} | ||
|
||
@include mq($from: tablet) { | ||
padding-top: 2 * $indent-amount; | ||
} | ||
|
||
p, | ||
h2 { | ||
margin-top: 0; | ||
} | ||
|
||
label { | ||
font-weight: bold; | ||
display: block; | ||
} | ||
|
||
label, | ||
input { | ||
margin-bottom: .4em; | ||
} | ||
} | ||
} |
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
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 |
---|---|---|
@@ -0,0 +1,62 @@ | ||
require "rails_helper" | ||
|
||
RSpec.describe CallsToAction::RoutesComponent, type: :component do | ||
let(:title) { "Some Title" } | ||
let(:text) { "Lorum ipsum dollar" } | ||
let(:image) { "static/images/routes.png" } | ||
let(:link_text) { "Find your route into teaching" } | ||
let(:link_target) { "/somewhere" } | ||
|
||
describe "rendering the component" do | ||
let(:kwargs) { { title: title, text: text, image: image, link_text: link_text, link_target: link_target } } | ||
let(:component) { described_class.new(**kwargs) } | ||
|
||
before { render_inline(component) { content } } | ||
|
||
specify "renders the routes component" do | ||
expect(page).to have_css(".routes") | ||
end | ||
|
||
specify "the image is present" do | ||
image_element = page.find("img") | ||
|
||
expect(image_element[:src]).to match(Regexp.new(File.basename(image, ".*"))) | ||
expect(image_element[:alt]).to eql("") | ||
end | ||
|
||
specify "the title is present" do | ||
expect(page).to have_css(".heading-l", text: title) | ||
end | ||
|
||
specify "the text is present" do | ||
expect(page).to have_css("p.routes__text", text: text) | ||
end | ||
|
||
specify "the link is present" do | ||
expect(page).to have_link(link_text, href: link_target) | ||
end | ||
|
||
context "when no title is present" do | ||
let(:kwargs) { { text: text, image: image, link_text: link_text, link_target: link_target } } | ||
|
||
specify "it should use the default title" do | ||
expect(page).to have_css(".heading-l", text: "Find your route into teaching") | ||
end | ||
end | ||
|
||
context "when no link is present" do | ||
let(:link_text) { nil } | ||
let(:link_target) { nil } | ||
|
||
it { expect(page).not_to have_css("a") } | ||
end | ||
|
||
context "when no text is present" do | ||
let(:text) { nil } | ||
|
||
specify "no paragraph tag should be rendered" do | ||
expect(page).not_to have_css("p.routes__text") | ||
end | ||
end | ||
end | ||
end |