Skip to content

Commit

Permalink
Implemented a new size for Cell that fits to content better
Browse files Browse the repository at this point in the history
Enact-DCO-1.0-Signed-off-by: Blake Stephens <[email protected]>
  • Loading branch information
Blake Stephens committed Jun 20, 2020
1 parent cf2bc88 commit 94be90c
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 10 deletions.
20 changes: 11 additions & 9 deletions packages/ui/Layout/Cell.js
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ const CellBase = kind({
* @default 'div'
* @public
*/
component: EnactPropTypes.renderable,
component: EnactPropTypes.renderable,

/**
* Called with a reference to [component]{@link ui/Cell.Cell#component}
Expand Down Expand Up @@ -116,25 +116,27 @@ const CellBase = kind({
},

computed: {
className: ({shrink, size, styler}) => styler.append({shrink, grow: (!shrink && !size)}),
className: ({shrink, size, styler}) => styler.append({shrink, grow: (!shrink && !size), content: (size === 'content')}),
style: ({align, shrink, size, style}) => {
if (typeof size === 'number') size = ri.unit(ri.scale(size), 'rem');
if (typeof size === 'number') size = ri.scaleToRem(size);

let cellSize = size;
if (!size) {
if (shrink) {
cellSize = '100%';
let cellSize;
if (size) {
if (size === 'content') {
size = 'auto';
} else {
cellSize = 'none';
cellSize = size;
}
} else if (shrink) {
cellSize = '100%';
}

return {
...style,
alignSelf: toFlexAlign(align),
flexBasis: (shrink ? null : size),
// Setting 100% below in the presence of `shrink`` and absense of `size` prevents overflow
'--cell-size': cellSize
'--cell-size': (cellSize || 'initial')
};
}
},
Expand Down
2 changes: 1 addition & 1 deletion packages/ui/Layout/Layout.js
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,7 @@ const LayoutBase = kind({
* @default 'div'
* @public
*/
component: EnactPropTypes.renderable,
component: EnactPropTypes.renderable,

/**
* Called with a reference to [component]{@link ui/Layout.Layout#component}
Expand Down
4 changes: 4 additions & 0 deletions packages/ui/Layout/Layout.module.less
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,10 @@
&.shrink {
flex: 0 0 auto;
}

&.content {
flex: 0 1 auto;
}
}

// Modes
Expand Down

0 comments on commit 94be90c

Please sign in to comment.