Skip to content

Commit

Permalink
Merge pull request #63 from Christine-horrocks/WEBDEV-922_Reorganise-…
Browse files Browse the repository at this point in the history
…heading

[WEBDEV-922] reorganise heading
  • Loading branch information
naseberry committed Nov 12, 2018
2 parents 7383f77 + 8fa5bf7 commit a60458c
Show file tree
Hide file tree
Showing 29 changed files with 50 additions and 91 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "pugin-components",
"version": "0.8.3",
"version": "0.8.4",
"description": "A shunter npm package containing dust components for beta.parliament.uk",
"main": "index.js",
"scripts": {
Expand Down
2 changes: 1 addition & 1 deletion test/fixtures/html/components/card/generic-all.html
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<source srcset="https://www.parliament.com"><img alt="Add translation key here!!" src="https://www.parliament.com"></picture>
</a></figure>
<div class="card__details">
<h2><a href="https://www.parliament.com">Dianne Abbot</a></h2>
<h2>Dianne Abbot</h2>
<p>Here is a picture of Dianne Abbott</p><a download href="https://www.parliament.com">Cool bananas</a></div>
<div class="count"><span class="count--number">63</span><span class="count--context">Devs</span></div>
</div>
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<div class="card--inline">
<div class="card__details">
<h3><a href="/mps">MPs</a></h3>
<h3>MPs</h3>
</div>
<div class="count"><span class="count--number">63</span><span class="count--context">Devs</span></div>
</div>
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<div class="card--inline">
<div class="card__details">
<h3><a href="/mps">MPs</a></h3>
<h3>MPs</h3>
<dl><dt>telephone</dt>
<dd>012349586</dd>
</dl>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<div class="card--inline">
<div class="card__details">
<h3><a href="/mps">MPs</a></h3>
<h3>MPs</h3>
<ul class="list ">
<li><a href='http://www.parliament.uk'>Current Parliament.uk website</a></li>
<li><a href='/meta/cookie-policy'>Cookie Policy</a></li>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,6 @@
<source srcset="https://www.parliament.com"><img alt="Add translation key here!!" src="https://www.parliament.com"></picture>
</a></figure>
<div class="card__details">
<h3><a href="/mps">MPs</a></h3>
<h3>MPs</h3>
<p>Find all members of the House of Commons.</p><a download href="https://www.parliament.com">Cool bananas</a></div>
</div>
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<source srcset="https://www.parliament.com"><img alt="Add translation key here!!" src="https://www.parliament.com"></picture>
</a></figure>
<div class="card__details">
<h3><a href="/mps">MPs</a></h3>
<h3>MPs</h3>
<p>Find all members of the House of Commons.</p>
</div>
</div>
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<div class="card--inline">
<div class="card__details">
<h3><a href="/mps">MPs</a></h3>
<h3>MPs</h3>
<p>Find all members of the House of Commons.</p>
</div>
</div>
2 changes: 1 addition & 1 deletion test/fixtures/html/components/card/generic-heading.html
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<div class="card--inline">
<div class="card__details">
<h3><a href="/mps">MPs</a></h3>
<h3>MPs</h3>
</div>
</div>
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<div class="card--inline">
<div class="card__details"><small>Guides</small>
<h3><a href="/mps">MPs</a></h3>
<h3>MPs</h3>
</div>
</div>
1 change: 0 additions & 1 deletion test/fixtures/html/components/heading-link.html

This file was deleted.

5 changes: 2 additions & 3 deletions test/fixtures/json/components/card/generic-all.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,8 @@
"heading": {
"name": "heading",
"data": {
"content": ["Dianne Abbot"],
"size": 2,
"link": "https://www.parliament.com"
"content": "Dianne Abbot",
"size": 2
}
},
"paragraph": {
Expand Down
5 changes: 2 additions & 3 deletions test/fixtures/json/components/card/generic-heading-count.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,8 @@
"heading": {
"name": "heading",
"data": {
"content": ["home.mps-heading"],
"size": 3,
"link": "/mps"
"content": "home.mps-heading",
"size": 3
}
},
"count": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,8 @@
"heading": {
"name": "heading",
"data": {
"content": ["home.mps-heading"],
"size": 3,
"link": "/mps"
"content": "home.mps-heading",
"size": 3
}
},
"list-description": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,8 @@
"heading": {
"name": "heading",
"data": {
"content": ["home.mps-heading"],
"size": 3,
"link": "/mps"
"content": "home.mps-heading",
"size": 3
}
},
"list-generic": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,8 @@
"heading": {
"name": "heading",
"data": {
"content": ["home.mps-heading"],
"size": 3,
"link": "/mps"
"content": "home.mps-heading",
"size": 3
}
},
"paragraph": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,8 @@
"heading": {
"name": "heading",
"data": {
"content": ["home.mps-heading"],
"size": 3,
"link": "/mps"
"content": "home.mps-heading",
"size": 3
}
},
"paragraph": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,8 @@
"heading": {
"name": "heading",
"data": {
"content": ["home.mps-heading"],
"size": 3,
"link": "/mps"
"content": "home.mps-heading",
"size": 3
}
},
"paragraph": {
Expand Down
5 changes: 2 additions & 3 deletions test/fixtures/json/components/card/generic-heading.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,8 @@
"heading": {
"name": "heading",
"data": {
"content": ["home.mps-heading"],
"size": 3,
"link": "/mps"
"content": "home.mps-heading",
"size": 3
}
}
}
Expand Down
5 changes: 2 additions & 3 deletions test/fixtures/json/components/card/generic-small-heading.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,8 @@
"heading": {
"name": "heading",
"data": {
"content": ["home.mps-heading"],
"size": 3,
"link": "/mps"
"content": "home.mps-heading",
"size": 3
}
}
}
Expand Down
8 changes: 0 additions & 8 deletions test/fixtures/json/components/heading-link.json

This file was deleted.

2 changes: 1 addition & 1 deletion test/fixtures/json/components/heading-string.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "heading",
"data": {
"content": ["search.results-heading"],
"content": "search.results-heading",
"size": 1
}
}
11 changes: 5 additions & 6 deletions test/fixtures/json/components/heading-translation.json
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
{
"name": "heading",
"data": {
"translation": {
"key": "search.count",
"data": {
"count": "850"
}
},
"content": "search.count",
"data": {
"count": "850"
}
,
"size": 2
}
}
4 changes: 3 additions & 1 deletion test/fixtures/json/components/partials/small.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
"name": "partials__small",
"data": {
"content": "shared.footer.cookie-policy",
"link": "/guides"
"data": {
"link": "/guides"
}
}
}
10 changes: 4 additions & 6 deletions test/fixtures/json/components/section/section-flag.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,13 @@
{
"name": "heading",
"data": {
"translation": {
"key": "search.count",
"data": {
"count": "850"
}
"content": "search.count",
"data": {
"count": "850"
},
"size": 2
}
}
}
]
}
}
8 changes: 3 additions & 5 deletions test/fixtures/json/components/section/section-no-flag.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,9 @@
{
"name": "heading",
"data": {
"translation": {
"key": "search.count",
"data": {
"count": "850"
}
"content": "search.count",
"data": {
"count": "850"
},
"size": 2
}
Expand Down
7 changes: 2 additions & 5 deletions test/unit/components/heading.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,13 @@ const testHelper = require('../../helpers/test-helper');
describe('Heading dust component', function() {
testHelper.setupBefore()

it('when given a translation, should return html from the dust component', function(done) {
it('when given a translation key, should return html from the dust component', function(done) {

testHelper.shunterTest('heading-translation', 'components__heading', 'components', done)
});

it('when given a string, should return html from the dust component', function(done){
testHelper.shunterTest('heading-string', 'components__heading', 'components', done)
});

it('when given a link should return html with and a tag from the dust component', function(done){
testHelper.shunterTest('heading-link', 'components__heading', 'components', done)
});

});
23 changes: 3 additions & 20 deletions view/components/heading.dust
Original file line number Diff line number Diff line change
@@ -1,25 +1,8 @@

<h{data.size}>

{! this section allows for the heading to be made into a link. !}
{#data}
{@t key="{content|s}" data=data /}
{/data}

{?data.link}
<a href="{data.link}">
{/data.link}

{! This translation sections allows translation keys to be passed in along with data from the back end. !}

{?data.translation}
{@t key="{data.translation.key}" data=data.translation.data /}
{/data.translation}

{! This loops over an array of content and surrounds each element with <h> tags, but they will all be the same size. !}

{#data.content}
{@t key="{.|s}" /}
{/data.content}

{?data.link}
</a>
{/data.link}
</h{data.size}>
2 changes: 1 addition & 1 deletion view/components/partials/small.dust
Original file line number Diff line number Diff line change
@@ -1 +1 @@
<small>{@t key="{data.content|s}" data=data /}</small>
<small>{@t key="{data.content|s}" data=data.data/}</small>

0 comments on commit a60458c

Please sign in to comment.