Skip to content

Commit

Permalink
Update hub design (#376)
Browse files Browse the repository at this point in the history
  • Loading branch information
bameyrick authored May 16, 2019
1 parent f23ce1d commit 419decf
Show file tree
Hide file tree
Showing 11 changed files with 176 additions and 416 deletions.
53 changes: 53 additions & 0 deletions src/components/hub/_hub.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
$hub-spacing: 1rem;

.hub {
&__row {
padding: $hub-spacing 0;

&:not(:first-child) {
border-top: 1px solid $color-grey-2;
}
}

&__title {
position: relative;
margin: 0 0 ($hub-spacing / 2);

&--complete {
padding-left: $hub-spacing + 1rem;

&:before {
@include icon('check-green');

content: '';
position: absolute;
top: 50%;
left: 0;
transform: translateY(-50%);
}
}
}

&__status {
@extend .u-fs-r--b;

margin: 0;
}

@include mq('s') {
&__row {
display: flex;
justify-content: space-between;
}

&__title {
margin: 0 ($hub-spacing / 2) 0 0;
}

&__status {
margin: 0 0 0 ($hub-spacing / 2);
text-align: right;
white-space: nowrap;
}
}
}
13 changes: 13 additions & 0 deletions src/components/hub/_macro-options.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
| Name | Type | Required | Description |
| -------- | ----------------- | -------- | -------------------- |
| sections | Array<HubSection> | true | An array of sections |

## HubSection

| Name | Type | Required | Description |
| --------- | ------- | -------- | ------------------------------------------------------------------------- |
| completed | boolean | true | Whether or not the section has been completed |
| title | string | true | The name of the section (e.g. Your accommodation) |
| ariaLabel | string | true | Aria label for the title link (e.g. Continue section: Your accommodation) |
| url | string | true | URL for the title link |
| status | string | true | Status text for the section (e.g. Partially complete) |
14 changes: 14 additions & 0 deletions src/components/hub/_macro.njk
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{% macro onsHub(params) %}
<dl class="hub{% if params.classes %} {{ params.classes }}{% endif %}">
{% for section in (params.sections if params.sections is iterable else params.sections.items()) %}
<div class="hub__row">
<dt class="hub__title{% if section.completed %} hub__title--complete{% endif %}">
<a href="{{ section.url }}" aria-label="{{ section.ariaLabel }}">{{ section.title }}</a>
</dt>
<dd class="hub__status">
{{ section.status }}
</dd>
</div>
{% endfor %}
</dl>
{% endmacro %}
85 changes: 85 additions & 0 deletions src/components/hub/examples/hub/index.njk
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
---
layout: none
---
{% extends "styles/page-template/_template.njk" %}

{% from "components/panel/_macro.njk" import onsPanel %}
{% from "components/hub/_macro.njk" import onsHub %}
{% from "components/button/_macro.njk" import onsButton %}

{% set page = {
"title": "Hub Example",
"signoutButton": {
"text": "Save and complete later"
}
} %}

{% block main %}
<h1 class="u-mt-m">Choose another section to complete</h1>

{% call onsPanel() %}
<p><strong>You must complete all sections in order to submit this survey</strong></p>
{% endcall %}

{{ onsHub({
"classes": "u-mt-m",
"sections": [
{
"title": "People who live here",
"ariaLabel": "View and change answers for: People who live here",
"url": "#",
"completed": true,
"status": "Completed"
},
{
"title": "Accommodation",
"ariaLabel": "View and change answers for: Accommodation",
"url": "#",
"completed": true,
"status": "Completed"
},
{
"title": "Mary Smith (you)",
"ariaLabel": "View and change answers for: Mary Smith",
"url": "#",
"completed": true,
"status": "Completed"
},
{
"title": "John Smith",
"ariaLabel": "Continue section: John Smith",
"url": "#",
"completed": false,
"status": "Partially complete"
},
{
"title": "Billy Smith",
"ariaLabel": "Start section: Billy Smith",
"url": "#",
"completed": false,
"status": "Not started"
},
{
"title": "Sally Smith",
"ariaLabel": "Start section: Sally Smith",
"url": "#",
"completed": false,
"status": "Not started"
},
{
"title": "Wilhelmina Susannah Clementine-Smith (Visitor)",
"ariaLabel": "Start section: Wilhelmina Susannah Clementine-Smith",
"url": "#",
"completed": false,
"status": "Not started"
}
]
}) }}

{{
onsButton({
"text": 'Continue',
"classes": 'u-mb-m u-mt-l'
})
}}
{% endblock %}
11 changes: 5 additions & 6 deletions src/components/summary/_macro-options.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
| 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 |

## SummaryRow

Expand Down
17 changes: 1 addition & 16 deletions src/components/summary/_macro.njk
Original file line number Diff line number Diff line change
@@ -1,15 +1,5 @@
{% macro onsSummary(params) %}
{% set className = "summary" %}

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

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

<div class="{{ className }}">
<div class="summary{% if params.classes %} {{ params.classes }}{% endif %}">
{% if params.title %}
<h2>{{ params.title }}</h2>
{% endif %}
Expand Down Expand Up @@ -38,11 +28,6 @@
{% endif %}

{{ rowItem.title | default(row.title) }} {{ hasIcons }}

{# Render section status for mobile if is hub #}
{% if params.hub and rowItem.valueList %}
<span class="u-d-no@s u-fs-r"> — {{ rowItem.valueList[0].text | safe }}</span>
{% endif %}
</td>
{% if rowItem.valueList %}
<td
Expand Down
38 changes: 4 additions & 34 deletions src/components/summary/_summary.scss
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
$summary-row-spacing: 1rem;
$summary-col-spacing: 1rem;
$hub-row-spacing: 1.3rem;

.summary {
&__items {
Expand Down Expand Up @@ -57,6 +56,10 @@ $hub-row-spacing: 1.3rem;
left: 0;
}

&__values {
@extend .u-fs-r--b;
}

&__actions {
white-space: nowrap;
}
Expand Down Expand Up @@ -109,38 +112,13 @@ $hub-row-spacing: 1.3rem;
}
}

// Modifiers
&--hub & {
&__actions {
padding: 0 0 $hub-row-spacing;
}

&__item-title {
@extend .u-fs-r--b;

padding-top: $hub-row-spacing;
}
}

&:not(&--hub) & {
&__values {
@extend .u-fs-r--b;
}
}

// Breakpoints
@include mq(xs, s, none, '<') {
&__item-title,
&__values,
&__actions {
display: block;
}

&--hub & {
&__values {
display: none;
}
}
}

@include mq(s) {
Expand All @@ -165,13 +143,5 @@ $hub-row-spacing: 1.3rem;
width: 50%;
}
}

&--hub & {
&__item-title,
&__values,
&__actions {
padding-top: $hub-row-spacing;
}
}
}
}
Loading

0 comments on commit 419decf

Please sign in to comment.