Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WIP: Safer cell sizing option #2795

Open
wants to merge 1 commit into
base: develop
Choose a base branch
from
Open
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
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