Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions app/components/cms/feedback_banner_component.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# frozen_string_literal: true

class Cms::FeedbackBannerComponent < ViewComponent::Base
def initialize(title:, button:)
@title = title
@button = button
end
end
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<%= render GovGridRowComponent.new do |row| %>
<%= row.with_column("full") do %>
<div class="cms-feedback-banner-component">
<h2 class="govuk-heading-m"><%= @title %></h2>
<%= render @button.render %>
<p class="govuk-body govuk-!-margin-bottom-0">
Or email us at <a class="govuk-link ncce-link" href="mailto: info@teachcomputing.org">info@teachcomputing.org</a>
</p>
</div>
<% end %>
<% end %>
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
.cms-feedback-banner-component {
border: 3px solid $hyper-link-blue;
padding: 32px;

.govuk-button {
@include govuk-media-query($until: desktop) {
margin-bottom: 16px;
}
}
}
18 changes: 18 additions & 0 deletions app/services/cms/dynamic_components/blocks/feedback_banner.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
module Cms
module DynamicComponents
module Blocks
class FeedbackBanner
attr_accessor :title, :button

def initialize(title:, button:)
@title = title
@button = button
end

def render
Cms::FeedbackBannerComponent.new(title:, button:)
end
end
end
end
end
9 changes: 9 additions & 0 deletions app/services/cms/providers/strapi/factories/blocks_factory.rb
Original file line number Diff line number Diff line change
Expand Up @@ -67,9 +67,18 @@ def self.generate_component(component_name, strapi_data)
DynamicComponents::SecondaryQuestionBank.new(title: strapi_data[:title])
when "button-block"
to_button_block(strapi_data)
when "feedback-banner"
to_feedback_banner(strapi_data)
end
end

def self.to_feedback_banner(strapi_data)
DynamicComponents::Blocks::FeedbackBanner.new(
title: strapi_data[:title],
button: to_ncce_button(strapi_data[:button])
)
end

def self.to_button_block(strapi_data)
DynamicComponents::Blocks::ButtonBlock.new(
buttons: strapi_data[:buttons].map { to_ncce_button(_1) },
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
module Cms
module Providers
module Strapi
module Mocks
module DynamicComponents
module Blocks
class FeedbackBanner < StrapiMock
strapi_component "blocks.feedback-banner"

attribute(:title) { Faker::Lorem.sentence }
attribute(:button) { Cms::Mocks::NcceButton.generate_data }
end
end
end
end
end
end
end
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
module Cms
module Providers
module Strapi
module Queries
module Components
module Blocks
class FeedbackBanner < BaseComponentQuery
def self.name = "ComponentBlocksFeedbackBanner"

def self.base_fields
<<~GRAPHQL.freeze
fbb__title: title
fbb__button: #{Buttons::NcceButton.embed(:button)}
GRAPHQL
end
end
end
end
end
end
end
end
1 change: 1 addition & 0 deletions app/services/cms/providers/strapi/queries/dynamic_zone.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ class DynamicZone
Components::Blocks::CourseCardsSection,
Components::Blocks::EnrolmentSplitCourseCard,
Components::Blocks::EnrolmentTestimonial,
Components::Blocks::FeedbackBanner,
Components::Blocks::FullWidthBanner,
Components::Blocks::FullWidthImageBanner,
Components::Blocks::FullWidthText,
Expand Down
10 changes: 10 additions & 0 deletions previews/components/cms/feedback_banner_component_preview.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# frozen_string_literal: true

class Cms::FeedbackBannerComponentPreview < ViewComponent::Preview
def default
render(Cms::FeedbackBannerComponent.new(
title: "title",
button: Cms::Mocks::NcceButton.as_model
))
end
end
20 changes: 20 additions & 0 deletions spec/components/cms/feedback_banner_component_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# frozen_string_literal: true

require "rails_helper"

RSpec.describe Cms::FeedbackBannerComponent, type: :component do
before do
render_inline(described_class.new(
title: "Help us make these resources better",
button: Cms::Mocks::NcceButton.as_model
))
end

it "renders the title" do
expect(page).to have_text("Help us make these resources better")
end

it "renders the ncce button" do
expect(page).to have_css(".govuk-button")
end
end
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
require "rails_helper"

RSpec.describe Cms::DynamicComponents::Blocks::FeedbackBanner do
before do
@comp = Cms::Providers::Strapi::Factories::ComponentFactory.process_component(
Cms::Mocks::DynamicComponents::Blocks::FeedbackBanner.generate_raw_data
)
end

it "should render as Cms::FeedbackBannerComponent" do
expect(@comp.render).to be_a(Cms::FeedbackBannerComponent)
end
end
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
require "rails_helper"

RSpec.describe Cms::Providers::Strapi::Queries::Components::Blocks::FeedbackBanner do
it_should_behave_like "a strapi graphql component",
%w[
title
button
]
end