This repository was archived by the owner on Mar 12, 2020. It is now read-only.
File tree Expand file tree Collapse file tree 6 files changed +64
-26
lines changed Expand file tree Collapse file tree 6 files changed +64
-26
lines changed Original file line number Diff line number Diff line change
1
+ {
2
+ "name" : " n-teaser" ,
3
+ "homepage" : " https://github.com/financial-times/n-teaser" ,
4
+ "description" : " n-card's replacement - better styles, simpler combinations & more basic templating" ,
5
+ "ignore" : [
6
+ " **/.*" ,
7
+ " node_modules" ,
8
+ " bower_components" ,
9
+ " test" ,
10
+ " tests"
11
+ ]
12
+ }
Original file line number Diff line number Diff line change 11
11
< script src ="//cdnjs.cloudflare.com/ajax/libs/handlebars.js/4.0.5/handlebars.min.js "> </ script >
12
12
</ head >
13
13
< body >
14
-
15
14
< div id ="opinion " class ="card "> </ div >
16
-
15
+ < div id =" landscape " class =" card " > </ div >
17
16
< script src ="script.js "> </ script >
18
17
</ body >
19
18
</ html >
Original file line number Diff line number Diff line change 1
- fetch ( '../templates/opinion.mustache' )
2
- . then ( res => res . text ( ) )
3
- . then ( source => {
4
- const template = Handlebars . compile ( source ) ;
5
- const context = {
6
- img : {
7
- src : 'http://image.webservices.ft.com/v1/images/raw/fthead:mrs-moneypenny?source=origami&width=60' ,
8
- alt : 'demo image'
9
- } ,
10
- tag : 'Mrs Moneypenny' ,
11
- heading : 'Japan sells negative yield 10-year bonds' ,
12
- datetime : {
13
- raw : '2016-02-29T12:35:48Z' ,
14
- formatted : '2016-02-29T12:35:48Z'
15
- }
16
- } ;
17
- document . querySelector ( '#opinion' ) . innerHTML = template ( context ) ;
18
- } ) ;
1
+ const data = {
2
+ img : {
3
+ alt : 'demo image'
4
+ } ,
5
+ tag : 'Mrs Moneypenny' ,
6
+ heading : 'Japan sells negative yield 10-year bonds' ,
7
+ datetime : {
8
+ raw : '2016-02-29T12:35:48Z' ,
9
+ formatted : '2016-02-29T12:35:48Z'
10
+ }
11
+ } ;
12
+
13
+ const images = {
14
+ landscape : 'https://image.webservices.ft.com/v1/images/raw/http%3A%2F%2Fim.ft-static.com%2Fcontent%2Fimages%2Fa60ae24b-b87f-439c-bf1b-6e54946b4cf2.img?source=o-card-demo' ,
15
+ opinion : 'http://image.webservices.ft.com/v1/images/raw/fthead:mrs-moneypenny?source=origami&width=60'
16
+ } ;
17
+
18
+ [ 'landscape' , 'opinion' ] . forEach ( style => {
19
+ fetch ( `../templates/${ style } .mustache` )
20
+ . then ( res => res . text ( ) )
21
+ . then ( source => {
22
+ const template = Handlebars . compile ( source ) ;
23
+ data . img . src = images [ style ] ;
24
+ document . querySelector ( `#${ style } ` ) . innerHTML = template ( data ) ;
25
+ } ) ;
26
+ } ) ;
Original file line number Diff line number Diff line change 1
1
.card {
2
2
margin : 1em ;
3
+ }
4
+
5
+ # opinion {
3
6
width : 20em ;
4
- }
7
+ }
8
+
9
+ # landscape {
10
+ width : 30em ;
11
+ }
Original file line number Diff line number Diff line change
1
+ <div class =" o-card o-card--landscape o-card--image-left" data-o-component =" o-card" >
2
+ <div class =" o-card__image o-card__image--left" >
3
+ <img src =" { { { img.src} } } " alt =" { { img.alt} } " ></img >
4
+ </div >
5
+ <div class =" o-card__content" >
6
+ <div class =" o-card__meta" >
7
+ <a href =" #" class =" o-card__tag" >{ {tag} }</a >
8
+ </div >
9
+ <h2 class =" o-card__heading" ><a href =" #" >{ {heading} }</a ></h2 >
10
+ <time data-o-component =" o-date" class =" o-date o-card__timestamp" datetime =" { { datetime.raw} } " >{ {datetime.formatted} }</time >
11
+ </div >
12
+ </div >
Original file line number Diff line number Diff line change 1
- <div class =" o-card o-card--opinion o-card--image- " data-o-component =" o-card" >
1
+ <div class =" o-card o-card--opinion" data-o-component =" o-card" >
2
2
<div class =" o-card__content" >
3
3
<div class =" o-card__meta" >
4
- <div class =" o-card__meta-image o-card__meta-image--rounded" >
5
- <img src =" { { { img.src} } } " alt =" { { img.alt} } " ></img >
6
- </div >
4
+ <div class =" o-card__meta-image o-card__meta-image--rounded" >
5
+ <img src =" { { { img.src} } } " alt =" { { img.alt} } " ></img >
6
+ </div >
7
7
<a href =" #" class =" o-card__tag" >{ {tag} }</a >
8
8
</div >
9
9
<h2 class =" o-card__heading" ><a href =" #" >{ {heading} }</a ></h2 >
10
- <time data-o-component =" o-date" class =" o-date o-card__timestamp" datetime =" { { datetime.raw} } " >{ {datetime.formatted} }</time >
10
+ <time data-o-component =" o-date" class =" o-date o-card__timestamp" datetime =" { { datetime.raw} } " >{ {datetime.formatted} }</time >
11
11
</div >
12
12
</div >
You can’t perform that action at this time.
0 commit comments