Skip to content

Commit 7213ba7

Browse files
Resolving merge conflicts
2 parents f6264da + ded4110 commit 7213ba7

File tree

11 files changed

+324
-252
lines changed

11 files changed

+324
-252
lines changed

addon/components/es-blog-heading.js

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
import Component from '@ember/component';
2+
import layout from '../templates/components/es-blog-heading';
3+
import {
4+
BlogPostType,
5+
} from '../constants/es-blog-heading';
6+
import {
7+
computed,
8+
} from '@ember/object';
9+
10+
export default Component.extend({
11+
layout,
12+
classNames: ['es-blog-heading'],
13+
14+
author: null,
15+
postDate: null,
16+
postTitle: null,
17+
postType: null,
18+
postUrl: null,
19+
20+
isGuestPost: computed.equal('postType', BlogPostType.GUEST),
21+
isNonStandardPost: computed.readOnly('postType'),
22+
});

addon/constants/es-blog-heading.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
export const BlogPostType = {
2+
REGULAR: 'regular',
3+
GUEST: 'guest',
4+
SYNDICATED: 'syndicated',
5+
};

addon/styles/_es-blog-heading.scss

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
.es-blog-heading {
2+
.post-title {
3+
&.page-view {
4+
color: $secondary;
5+
font-size: 2.25em;
6+
margin-bottom: 0.01em;
7+
margin-top: 0.7em;
8+
}
9+
10+
&.list-view {
11+
color: $orange-darkest;
12+
font-size: 1.75em;
13+
font-weight: bold;
14+
letter-spacing: none;
15+
line-height: 1;
16+
margin-bottom: 0.19em;
17+
margin-top: 0.2em;
18+
a {
19+
color: $orange-darker;
20+
text-decoration: none;
21+
&:hover {
22+
text-decoration: underline;
23+
}
24+
}
25+
}
26+
}
27+
28+
.post-date {
29+
color: $gray;
30+
display: block;
31+
font-size: 0.8em;
32+
text-transform: uppercase;
33+
padding: 0.2em 0.25em 0 0;
34+
@media screen and (min-width: 768px) {
35+
display: inline-block;
36+
padding: 0 0.25em 0 0;
37+
}
38+
}
39+
40+
.post-author {
41+
color: $blue;
42+
display: inline-block;
43+
font-size: 0.8em;
44+
font-weight: bold;
45+
text-transform: uppercase;
46+
}
47+
48+
.post-tag {
49+
clear: both;
50+
display: block;
51+
font-size: 0.8em;
52+
line-height: 1;
53+
text-transform: uppercase;
54+
margin-top: 0.35em;
55+
&.syndicated {
56+
color: $blue;
57+
}
58+
&.guest {
59+
color: $gray;
60+
}
61+
}
62+
}

addon/styles/addon.scss

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
@import 'es-ulist';
2222
@import 'es-note';
2323
@import 'es-accordion';
24+
@import 'es-blog-heading';
2425

2526
body {
2627
font-family: $font-family;

addon/styles/variables.scss

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ $primary-dark: #EF4326;
99
$secondary: #4A4A4A;
1010
$secondary-light: #969696;
1111
$secondary-dark: #303030;
12+
$blue: #1e719b;
1213
$black: #212121; //never pure black
1314
$white: #fdfdfd; //never pure white
1415
$success: green; //come back to these state colors and put proper colors in here
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
{{#if postUrl}}
2+
<h2 class="post-title list-view">
3+
<a href={{postUrl}}>{{postTitle}}</a>
4+
</h2>
5+
{{else}}
6+
<h1 class="post-title page-view">{{postTitle}}</h1>
7+
{{/if}}
8+
<div class="post-date">{{moment-format postDate 'MMM DD, YYYY' 'MM-DD-YYYY'}}</div>
9+
<div class="post-author">By {{author}}</div>
10+
{{#if isNonStandardPost}}
11+
<div class="post-tag {{if isGuestPost "guest" "syndicated"}}">
12+
{{if isGuestPost "Guest" "Syndicated"}} Post
13+
</div>
14+
{{/if}}

app/components/es-blog-heading.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
export { default } from 'ember-styleguide/components/es-blog-heading';

package.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@
3939
"ember-cli-htmlbars-inline-precompile": "^1.0.0",
4040
"ember-cli-inject-live-reload": "^1.4.1",
4141
"ember-cli-mirage": "^0.3.4",
42+
"ember-cli-moment-shim": "^3.5.0",
4243
"ember-cli-qunit": "^4.1.1",
4344
"ember-cli-shims": "^1.2.0",
4445
"ember-cli-sri": "^2.1.0",
@@ -48,6 +49,7 @@
4849
"ember-export-application-global": "^2.0.0",
4950
"ember-font-awesome": "^3.0.5",
5051
"ember-load-initializers": "^1.0.0",
52+
"ember-moment": "^7.6.0",
5153
"ember-native-dom-helpers": "^0.5.10",
5254
"ember-resolver": "^4.0.0",
5355
"ember-sinon": "^1.0.1",

tests/dummy/app/templates/index.hbs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,4 +41,4 @@
4141
{{#es-ulist/image item=item as |item|}}
4242
{{es-ulist/link item=item isExternal=true}}
4343
{{/es-ulist/image}}
44-
{{/es-ulist}}
44+
{{/es-ulist}}
Lines changed: 125 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,125 @@
1+
import { moduleForComponent, test } from 'ember-qunit';
2+
import hbs from 'htmlbars-inline-precompile';
3+
import {
4+
find,
5+
} from 'ember-native-dom-helpers';
6+
import {
7+
set,
8+
setProperties,
9+
} from '@ember/object';
10+
import {
11+
run,
12+
} from '@ember/runloop';
13+
14+
let author, postDate, postUrl, postTitle, postType;
15+
16+
moduleForComponent('es-blog-heading', 'Integration | Component | es blog heading', {
17+
integration: true,
18+
beforeEach() {
19+
author = 'Sara Poster';
20+
postDate = '03-20-2018';
21+
postUrl = 'https://emberjs.com/blog';
22+
postTitle = 'Pretty Awesome Blog Post';
23+
postType = null;
24+
25+
setProperties(this, {
26+
author,
27+
postDate,
28+
postUrl,
29+
postTitle,
30+
postType,
31+
});
32+
33+
this.render(hbs`
34+
{{es-blog-heading
35+
author=author
36+
postDate=postDate
37+
postType=postType
38+
postUrl=postUrl
39+
postTitle=postTitle
40+
}}
41+
`);
42+
},
43+
afterEach() {
44+
author = postDate = postUrl = postTitle = postType = null;
45+
}
46+
});
47+
48+
test('it renders', function(assert) {
49+
assert.equal(
50+
find('.post-title.list-view a'),
51+
postUrl,
52+
'displays title as link'
53+
);
54+
assert.equal(
55+
find('.post-title.list-view').textContent.trim(),
56+
postTitle,
57+
'displays title'
58+
);
59+
assert.equal(
60+
find('.post-date').textContent.trim(),
61+
'Mar 20, 2018',
62+
'displays formatted date'
63+
);
64+
assert.equal(
65+
find('.post-author').textContent.trim(),
66+
`By ${author}`,
67+
'displays author'
68+
);
69+
assert.notOk(
70+
find('.post-tag'),
71+
'does not display tag if not set'
72+
);
73+
});
74+
75+
test('displays proper tag', function(assert) {
76+
assert.notOk(
77+
find('.post-tag'),
78+
'does not display tag if not set'
79+
);
80+
81+
run(() => {
82+
set(this, 'postType', 'guest');
83+
});
84+
85+
assert.equal(
86+
find('.post-tag').textContent.trim(),
87+
'Guest Post',
88+
'displays guest tag'
89+
);
90+
91+
run(() => {
92+
set(this, 'postType', 'syndicated');
93+
});
94+
95+
assert.equal(
96+
find('.post-tag').textContent.trim(),
97+
'Syndicated Post',
98+
'displays syndicated tag'
99+
);
100+
});
101+
102+
test('renders correct title format', function(assert) {
103+
assert.equal(
104+
find('.post-title.list-view a'),
105+
postUrl,
106+
'displays title as link when url is provided'
107+
);
108+
assert.ok(
109+
find('.post-title.list-view'),
110+
'displays list view title when a url is provided'
111+
);
112+
113+
run(() => {
114+
set(this, 'postUrl', null);
115+
});
116+
117+
assert.notOk(
118+
find('.post-title.list-view a'),
119+
'does not display title as link when a url is not provided'
120+
);
121+
assert.ok(
122+
find('.post-title.page-view'),
123+
'displays page view title when a url is provided'
124+
);
125+
});

0 commit comments

Comments
 (0)