Skip to content

Commit

Permalink
Update summary to handle being embeded within a question page (#360)
Browse files Browse the repository at this point in the history
  • Loading branch information
bameyrick authored May 9, 2019
1 parent 1a46ed7 commit 8e08d3c
Show file tree
Hide file tree
Showing 4 changed files with 35 additions and 7 deletions.
13 changes: 7 additions & 6 deletions src/components/summary/_macro-options.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
| Name | Type | Required | Description |
| ------- | ----------------- | -------- | ----------------------------------------- |
| rows | Array<SummaryRow> | true | An array of rows to summarise |
| title | string | false | The title for the summary block |
| classes | string | false | Classes to add to the summary component |
| hub | boolean | false | Whether to render the summary in as a hub |
| Name | Type | Required | Description |
| -------------- | ----------------- | -------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| rows | Array<SummaryRow> | true | An array of rows to summarise |
| title | string | false | The title for the summary block |
| classes | string | false | Classes to add to the summary component |
| hub | boolean | false | Whether to render the summary in as a hub |
| withinQuestion | boolean | false | Whether the summary is being rendered within a question page. If true the first row will not have a top border, and the last item will not have a bottom border |

## SummaryRow

Expand Down
16 changes: 15 additions & 1 deletion src/components/summary/_macro.njk
Original file line number Diff line number Diff line change
@@ -1,5 +1,19 @@
{% macro onsSummary(params) %}
<div class="summary{{ " " + params.classes if params.classes else "" }}{{ " summary--hub" if params.hub else "" }}">
{% set className = "summary" %}

{% if params.classes %}
{% set className = className + " " + params.classes %}
{% endif %}

{% if params.hub %}
{% set className = className + " summary--hub" %}
{% endif %}

{% if params.withinQuestion %}
{% set className = className + " summary--within-question" %}
{% endif %}

<div class="{{ className }}">
{% if params.title %}
<h2 class="u-fs-m">{{ params.title }}</h2>
{% endif %}
Expand Down
12 changes: 12 additions & 0 deletions src/components/summary/_summary.scss
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,18 @@ $hub-row-spacing: 1.3rem;
}
}

&--within-question & {
&__item {
&:first-child {
border-top: 0;
}

&:last-child {
border-bottom: 0;
}
}
}

// Breakpoints
@include mq(xs, s, none, '<') {
&__item-title,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
{% from "components/summary/_macro.njk" import onsSummary %}

{{ onsSummary({
"withinQuestion": true,
"rows": [
{
"title": "Joe Bloggs (You)",
Expand Down

0 comments on commit 8e08d3c

Please sign in to comment.