Skip to content

Commit

Permalink
Fix grid item showing model.field and 'fake content'
Browse files Browse the repository at this point in the history
- Uses conditional template for model vs no model
- Moves _checkDistributedNodesAsync to field template
  • Loading branch information
anthonykoerber committed Oct 19, 2016
1 parent 9695e09 commit ebc6c16
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 8 deletions.
12 changes: 7 additions & 5 deletions src/strand-grid-item/strand-grid-item.html
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,15 @@
<strand-icon width="10" height="10" type="carat" on-tap="_onItemExpanded"></strand-icon>
</div>
<div id="columnContainer">
<template is="dom-repeat" items="{{scope._columns}}" as="column" on-dom-change="_checkDistributedNodesAsync">
<template is="dom-repeat" items="{{scope._columns}}" as="column">
<div class$="{{_computeColumnClass(column.alignColumn)}}" style$="{{_computeColumnStyle(column.width)}}" id="{{column.field}}">
<div class="columnContentWrapper">
<span class="columnContent" hidden$="{{!model}}">
<content id="{{column.field}}" select$="{{_columnContentSelector(column.field)}}"></content>
</span>
<span class="columnContent" hidden$="{{_isOverridden(column.field, _overridden.*)}}">[[_computeColumnValue(column.field, model, model.*)]]</span>
<template is="dom-if" if="{{model}}" on-dom-change="_checkDistributedNodesAsync">
<span class="columnContent">
<content id="{{column.field}}" select$="{{_columnContentSelector(column.field)}}"></content>
</span>
<span class="columnContent" hidden$="{{_isOverridden(column.field, _overridden.*)}}">[[_computeColumnValue(column.field, model, model.*)]]</span>
</template>
<template is="dom-if" if="{{!model}}">
<span class="columnContent fake-content" style$="width:[[_setRandomWidth(column.field)]];">&nbsp;</span>
</template>
Expand Down
2 changes: 1 addition & 1 deletion src/strand-grid-item/strand-grid-item.js
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@
_setRandomWidth: function(field) {
var n = 0.5;
var width = Math.random() * (1.0 - n) + n;
return String(width*100 + "%");
return String(Math.round(width*100) + "%");
},

_onItemSelected: function(e, detail, sender) {
Expand Down
6 changes: 4 additions & 2 deletions src/strand-grid-item/strand-grid-item.scss
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ polyfill-next-selector { content: ':host ._mm_item'; }
}

.columnContentWrapper {
display: inline-block;
width: 0;
min-width: 100%;
position: relative;
Expand All @@ -53,10 +52,13 @@ polyfill-next-selector { content: ':host ._mm_item'; }

.fake-content {
display: block;
margin: 2px 0;
background: $color-A10;
}

.right .fake-content {
float: right;
}

::content [field] {
overflow: inherit;
text-overflow: inherit;
Expand Down

0 comments on commit ebc6c16

Please sign in to comment.