Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 5 additions & 3 deletions src/components/entity/state-info.html
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,11 @@
line-height: 40px;
}

.name[in-dialog] {
.name[in-dialog], :host([secondary-line]) .name {
line-height: 20px;
}

.time-ago {
.time-ago, ::slotted(*) {
@apply(--paper-font-common-nowrap);
color: var(--secondary-text-color);
}
Expand All @@ -48,7 +48,9 @@
<ha-relative-time datetime='[[stateObj.last_changed]]'></ha-relative-time>
</div>
</template>

<template is='dom-if' if='[[!inDialog]]'>
<slot>
</template>
</div>
</div>
</template>
Expand Down
26 changes: 26 additions & 0 deletions test/state-info-test.html
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,11 @@
<link rel="import" href="../src/components/entity/state-info.html">
</head>
<body>
<test-fixture id="state-info-secondary-line">
<template>
<state-info secondary-line><my-elem>text</my-elem></state-info>
</template>
</test-fixture>
<test-fixture id="state-info">
<template>
<state-info></state-info>
Expand Down Expand Up @@ -49,6 +54,7 @@
var name = lightOrShadow(si, '.name');
assert.isOk(name, '.name missing');
assert.equal(name.textContent, 'Name');
assert.equal(getComputedStyle(name).lineHeight, '40px');

assert.isNotOk(lightOrShadow(si, 'ha-relative-time'));
done();
Expand All @@ -60,17 +66,37 @@
si.inDialog = true;
flush(function() {
var relativeTime = lightOrShadow(si, 'ha-relative-time');
var name = lightOrShadow(si, '.name');

assert.isOk(relativeTime);
assert.notEqual(relativeTime.textContent, 'never');
assert.notEqual(relativeTime.textContent, '');

assert.isOk(name);
assert.equal(getComputedStyle(name).lineHeight, '20px');

si.stateObj = {entity_id: 'light.demo', state: 'off', attributes: {friendly_name: 'Name'}};
flush(function() {
assert.equal(relativeTime.textContent, 'never');
done();
});
});
});

test('secondary line', function(done) {
si = fixture('state-info-secondary-line');
si.stateObj = {entity_id: 'light.demo', last_changed: '2017-01-01T00:00:00+00:00', state: 'off', attributes: {friendly_name: 'Name'}};
si.inDialog = false;
flush(function() {
var name = lightOrShadow(si, '.name');
assert.isOk(name);
assert.equal(getComputedStyle(name).lineHeight, '20px');
var content = si.queryEffectiveChildren('my-elem');
assert.isOk(content);
assert.equal(content.textContent, 'text');
done();
});
});
});
</script>
</body>
Expand Down