-
Notifications
You must be signed in to change notification settings - Fork 2
Course Cards Component #2302
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
Merged
Merged
Course Cards Component #2302
Changes from all commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
ddb1dfa
Basic setup of the new strapi graphql system
msquance-stem 392932f
Updating test suite to cover all the new graphql features and adding …
msquance-stem aaa9339
Creating new card type, course card
msquance-stem 5321f35
Updating other components needed to get the primary-teachers page mig…
msquance-stem 23bf4c5
Fixing test issues
msquance-stem 48a4fa7
Moving page title query to a more appropriate location and updating b…
msquance-stem 07d13c9
Fixing old version of the resource that has been replaced
msquance-stem cc9114f
Adding course card graphql tests
msquance-stem 76fce4c
Adding testing for the Cms::ImageComponent
msquance-stem 9e68e66
Fixing standard errors
msquance-stem 59d3ab7
Addressing PR comments
msquance-stem File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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
6 changes: 4 additions & 2 deletions
6
app/components/cms/card_wrapper_component/card_wrapper_component.html.erb
This file contains hidden or 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 hidden or 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,19 @@ | ||
| # frozen_string_literal: true | ||
|
|
||
| class Cms::CourseCardComponent < ViewComponent::Base | ||
| delegate :course_type_short, :course_meta_icon_class, | ||
| :course_duration_text, | ||
| to: :helpers | ||
|
|
||
| def initialize(title:, banner_text:, course:, description:, image:) | ||
| @title = title | ||
| @banner_text = banner_text | ||
| @course = course | ||
| @description = description | ||
| @image = image | ||
| end | ||
|
|
||
| def render? | ||
| @course.present? | ||
| end | ||
| end |
30 changes: 30 additions & 0 deletions
30
app/components/cms/course_card_component/course_card_component.html.erb
This file contains hidden or 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,30 @@ | ||
| <div class="courses-cms-card"> | ||
|
|
||
| <div class="courses-cms-card__image-wrapper"> | ||
| <%= render Cms::ImageComponent.new(@image, show_caption: false, classes: "courses-cms-card__image") %> | ||
| <% if @banner_text %> | ||
| <span class="govuk-body-s courses-cms-card__banner"> | ||
| <%= @banner_text.upcase %> | ||
| </span> | ||
| <% end %> | ||
| </div> | ||
|
|
||
| <%= link_to @title, course_path(id: @course.activity_code, name: @course.title.parameterize), class: 'govuk-!-font-weight-bold govuk-body ncce-link' %> | ||
| <div class="courses-cms-card__details"> | ||
| <p class="govuk-body"> | ||
| <%= render @description.render %> | ||
| </p> | ||
| <div class="courses-cms-card__icons"> | ||
| <div> | ||
| <span class="govuk-body-s <%= course_meta_icon_class(@course) %> courses-cms-card__type"> | ||
| <%= course_type_short(@course) %> | ||
| </span> | ||
| </div> | ||
| <div> | ||
| <%= content_tag :span, class: ['govuk-body-s', 'icon-clock', 'courses-cms-card__time', { 'govuk-!-margin-left-0': "".blank? }] do %> | ||
| <%= course_duration_text(@course) %> | ||
| <% end %> | ||
| </div> | ||
| </div> | ||
| </div> | ||
| </div> |
70 changes: 70 additions & 0 deletions
70
app/components/cms/course_card_component/course_card_component.scss
This file contains hidden or 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,70 @@ | ||
|
|
||
| .courses-cms-card { | ||
|
|
||
| &__image-wrapper { | ||
| margin-bottom: 12px; | ||
| max-height: 175px; | ||
| overflow: hidden; | ||
| position: relative; | ||
|
|
||
| @include govuk-media-query($from: tablet) { | ||
| margin-bottom: 8px; | ||
| max-height: unset; | ||
| } | ||
| } | ||
|
|
||
| &__banner { | ||
| background: $purple-dark; | ||
| color: $white; | ||
| font-weight: bold; | ||
| font-size: 14px; | ||
| left: 0; | ||
| padding: 2px 8px; | ||
| position: absolute; | ||
| top: 0; | ||
| } | ||
|
|
||
| &__image { | ||
| img { | ||
| width: 100%; | ||
| height: 190px; | ||
| object-fit: cover; | ||
| } | ||
| } | ||
|
|
||
| &__details { | ||
| display: flex; | ||
| flex-direction: column; | ||
| justify-content: space-between; | ||
| } | ||
|
|
||
| &__icons { | ||
| height: 22px; | ||
| padding: 10px; | ||
| display: flex; | ||
| flex-direction: row; | ||
| justify-content: space-between; | ||
| } | ||
|
|
||
| &__type { | ||
| display: inline-block; | ||
| margin-bottom: 0; | ||
| background-size: 16px 16px; | ||
|
|
||
| @include govuk-media-query($from: tablet) { | ||
| background-size: 20px 20px; | ||
| } | ||
| } | ||
|
|
||
| &__time { | ||
| display: inline-block; | ||
| margin-bottom: 0; | ||
| background-size: 16px 16px; | ||
|
|
||
| @include govuk-media-query($from: tablet) { | ||
| background-size: 20px 20px; | ||
| } | ||
| } | ||
| } | ||
|
|
||
|
|
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 @@ | ||
| module Cms | ||
| module DynamicComponents | ||
| class CourseCard | ||
| attr_accessor :title, :banner_text, :course, :description, :image | ||
|
|
||
| def initialize(title:, banner_text:, course_code:, description:, image:) | ||
| @title = title | ||
| @banner_text = banner_text | ||
| @description = description | ||
| @image = image | ||
| @course = begin | ||
| Achiever::Course::Template.find_by_activity_code(course_code) | ||
| rescue ActiveRecord::RecordNotFound | ||
| nil | ||
| end | ||
| end | ||
|
|
||
| def render | ||
| Cms::CourseCardComponent.new(title:, banner_text:, course:, description:, image:) | ||
| end | ||
| end | ||
| end | ||
| end |
This file contains hidden or 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 hidden or 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
15 changes: 15 additions & 0 deletions
15
app/services/cms/providers/strapi/mocks/course_card_section.rb
This file contains hidden or 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,15 @@ | ||
| module Cms | ||
| module Providers | ||
| module Strapi | ||
| module Mocks | ||
| class CourseCardSection < StrapiMock | ||
| strapi_component "blocks.course-cards-section" | ||
|
|
||
| attribute(:sectionTitle) { Faker::Lorem.sentence } | ||
| attribute(:introText) { RichBlocks.generate_data } | ||
| attribute(:cards) { Array.new(3) { DynamicComponents::CourseCard.generate_data } } | ||
| end | ||
| end | ||
| end | ||
| end | ||
| end | ||
19 changes: 19 additions & 0 deletions
19
app/services/cms/providers/strapi/mocks/dynamic_components/course_card.rb
This file contains hidden or 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,19 @@ | ||
| module Cms | ||
| module Providers | ||
| module Strapi | ||
| module Mocks | ||
| module DynamicComponents | ||
| class CourseCard < StrapiMock | ||
| strapi_component "content-blocks.course-card" | ||
|
|
||
| attribute(:title) { Faker::Lorem.words(number: 5).join(" ") } | ||
| attribute(:bannerText) { Faker::Lorem.words(number: 3).join(" ") } | ||
| attribute(:image) { Image.generate_data } | ||
| attribute(:description) { RichBlocks.generate_data } | ||
| attribute(:courseCode) { "CP199" } | ||
| end | ||
| end | ||
| end | ||
| end | ||
| end | ||
| end |
This file contains hidden or 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 hidden or 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
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Mr nit-picky here again. We usually have a space between strapi_component and attributes