diff --git a/app/assets/sass/application.scss b/app/assets/sass/application.scss index 6ae3080dd7..d4f2ed0174 100644 --- a/app/assets/sass/application.scss +++ b/app/assets/sass/application.scss @@ -15,4 +15,7 @@ $govuk-assets-path: '/govuk/assets/'; @import "patterns/task-list"; @import "patterns/related-items"; +// Components that aren’t in Frontend +@import "components/summary-card"; + // Add extra styles here, or re-organise the Sass files in whichever way makes most sense to you diff --git a/app/assets/sass/components/_summary-card.scss b/app/assets/sass/components/_summary-card.scss new file mode 100644 index 0000000000..0b54087874 --- /dev/null +++ b/app/assets/sass/components/_summary-card.scss @@ -0,0 +1,84 @@ +.app-summary-card { + border: 1px solid $govuk-border-colour; + + /* Card header */ + .app-summary-card__header { + align-items: center; + background-color: govuk-colour("light-grey"); + padding: govuk-spacing(3); + + @include govuk-media-query($from: desktop) { + display: flex; + justify-content: space-between; + align-items: start; + } + } + + .app-summary-card__title { + @include govuk-font($size: 19); + margin: 0; + } + + .app-summary-card__meta { + @include govuk-font($size: 16); + display: block; + margin: 0; + } + + .app-summary-card__actions { + @include govuk-font($size: 19); + } + + .app-summary-card__actions-list { + width: 100%; + margin: 0; + padding: 0; + } + + .app-summary-card__actions-list-item { + display: block; + white-space: nowrap; + + @include govuk-media-query($from: desktop) { + display: inline-block; + margin-left: govuk-spacing(2); + text-align: right; + } + } + + .app-summary-card__actions-list-item:first-child { + margin-left: 0; + } + + /* Card body */ + .app-summary-card__body { + @include govuk-font($size: 19); + padding: govuk-spacing(3); + } + + .govuk-table, + .govuk-summary-list, + .govuk-table { + margin-bottom: 0; + } + + .govuk-summary-list__row:last-child, + .govuk-summary-list__row:last-child > *, + .govuk-table__row:last-child .govuk-table__cell { + border-bottom: 0; + } +} + +.app-summary-card--large-title .app-summary-card__title { + @include govuk-font($size: 24, $weight: bold); +} + +@media print { + .app-summary-card__header { + break-inside: avoid; + } + + .app-summary-card__actions { + display: none; + } +} diff --git a/app/views/_components/summary-card/macro.njk b/app/views/_components/summary-card/macro.njk new file mode 100644 index 0000000000..e5220d7249 --- /dev/null +++ b/app/views/_components/summary-card/macro.njk @@ -0,0 +1,3 @@ +{% macro appSummaryCard(params) %} + {%- include "./template.njk" -%} +{% endmacro %} diff --git a/app/views/_components/summary-card/template.njk b/app/views/_components/summary-card/template.njk new file mode 100644 index 0000000000..fb4615896f --- /dev/null +++ b/app/views/_components/summary-card/template.njk @@ -0,0 +1,48 @@ +{%- macro _actionLink(action) %} + + {{ action.html | safe if action.html else action.text }} + {%- if action.visuallyHiddenText -%} + {{ action.visuallyHiddenText }} + {% endif -%} + +{% endmacro -%} + +
+ {% if params.titleHtml or params.titleText or params.actions %} +
+ {% set headingLevel = params.headingLevel if params.headingLevel else 2 %} + + {{ params.titleHtml | safe if params.titleHtml else params.titleText }} + + {% if params.actions.items.length %} +
+ {% if params.actions.items.length == 1 %} + {{ _actionLink(params.actions.items[0]) | indent(12) | trim }} + {% else %} +
    + {% for action in params.actions.items %} + {% if action %} +
  • + {{ _actionLink(action) | indent(18) | trim }} +
  • + {% endif %} + {% endfor %} +
+ {% endif %} +
+ {% endif %} + {% if params.actionsHtml %} +
+ {{ params.actionsHtml | safe }} +
+ {% endif %} +
+ {% endif %} + {% if params.html or params.text %} +
+ {{ params.html | safe if params.html else params.text }} +
+ {% endif %} +
diff --git a/app/views/layout.html b/app/views/layout.html index 3ec865aa6f..e3f67ad69f 100644 --- a/app/views/layout.html +++ b/app/views/layout.html @@ -31,6 +31,8 @@ {% from "govuk/components/textarea/macro.njk" import govukTextarea %} {% from "govuk/components/warning-text/macro.njk" import govukWarningText %} +{% from "_components/summary-card/macro.njk" import appSummaryCard %} + {% block head %} {% include "includes/head.html" %} {% endblock %}