diff --git a/app/assets/stylesheets/components/_figure.scss b/app/assets/stylesheets/components/_figure.scss index 7d11a5871..e7d7973d0 100644 --- a/app/assets/stylesheets/components/_figure.scss +++ b/app/assets/stylesheets/components/_figure.scss @@ -1,13 +1,16 @@ @import "govuk_publishing_components/individual_component_support"; -@import "../mixins/margins"; .app-c-figure { @include govuk-clearfix; - @include responsive-bottom-margin; border-top: 1px solid $govuk-border-colour; padding-top: govuk-spacing(3); margin: 0; + margin-bottom: govuk-spacing(8); + + @include govuk-media-query($until: tablet) { + margin-bottom: govuk-spacing(6); + } } .app-c-figure__image { @@ -28,7 +31,6 @@ display: block; vertical-align: top; - box-sizing: border-box; float: left; padding-left: govuk-spacing(3); @@ -41,9 +43,7 @@ } .app-c-figure__figcaption-text { + @include govuk-font(16); margin: 0; - - @include govuk-media-query($from: tablet) { - margin-bottom: govuk-spacing(2); - } + margin-bottom: govuk-spacing(2); } diff --git a/app/views/components/_figure.html.erb b/app/views/components/_figure.html.erb index f33ee1b89..d0a100e82 100644 --- a/app/views/components/_figure.html.erb +++ b/app/views/components/_figure.html.erb @@ -8,16 +8,18 @@ <% if src.present? %> <%= alt %> <% end %> -
- <% if caption.present? %> -

- <%= caption %> -

- <% end %> - <% if credit.present? %> -

+ <% if caption.present? || credit.present? %> +

+ <% if caption.present? %> +

+ <%= caption %> +

+ <% end %> + <% if credit.present? %> +

<%= I18n.t("components.figure.image_credit", credit: credit) %>

- <% end %> -
+ <% end %> +
+ <% end %> diff --git a/app/views/components/docs/figure.yml b/app/views/components/docs/figure.yml index 9c797e76d..7e39361a6 100644 --- a/app/views/components/docs/figure.yml +++ b/app/views/components/docs/figure.yml @@ -32,3 +32,12 @@ examples: caption: 'تأشيرات' context: right_to_left: true + figure_with_credit: + data: + src: 'https://assets.publishing.service.gov.uk/government/uploads/system/uploads/feature/image/54374/s630_the_lords_chamber.jpg' + credit: Wallis Crankled + figure_with_caption_and_credit: + data: + src: 'https://assets.publishing.service.gov.uk/government/uploads/system/uploads/feature/image/54374/s630_the_lords_chamber.jpg' + caption: The Lords Chamber + credit: Wallis Crankled diff --git a/test/components/figure_test.rb b/test/components/figure_test.rb index b52147321..01b8e6467 100644 --- a/test/components/figure_test.rb +++ b/test/components/figure_test.rb @@ -33,7 +33,7 @@ def component_name render_component(src: "/image", alt: "image alt text", credit: "Creative Commons") assert_select ".app-c-figure__image[src=\"/image\"]" assert_select ".app-c-figure__image[alt=\"image alt text\"]" - assert_select ".app-c-figure__figcaption .app-c-figure__figcaption-credit", text: "Image credit: Creative Commons" + assert_select ".app-c-figure__figcaption .app-c-figure__figcaption-text", text: "Image credit: Creative Commons" end test "renders a figure with caption and credit correctly" do @@ -41,6 +41,6 @@ def component_name assert_select ".app-c-figure__image[src=\"/image\"]" assert_select ".app-c-figure__image[alt=\"image alt text\"]" assert_select ".app-c-figure__figcaption .app-c-figure__figcaption-text", text: "This is a caption" - assert_select ".app-c-figure__figcaption .app-c-figure__figcaption-credit", text: "Image credit: Creative Commons" + assert_select ".app-c-figure__figcaption .app-c-figure__figcaption-text", text: "Image credit: Creative Commons" end end