-
Notifications
You must be signed in to change notification settings - Fork 1
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
Spreadsheet increase inputsize #100
base: simplystore
Are you sure you want to change the base?
Changes from 4 commits
554a907
06b993c
9905cc5
533c235
3494ef9
0273c4e
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -418,13 +418,40 @@ const spreadsheet = (function() { | |
} | ||
|
||
function defaultViewer(rect,offset,el) { | ||
const spreadsheetElement = document.getElementById("slo-spreadsheet"); | ||
const spreadsheetSize = spreadsheetElement.getBoundingClientRect(); | ||
const boxWidth = spreadsheetSize.width/1.618 // golden ratio | ||
const iconSize = 60 | ||
const standardBoxWidth = 300 + iconSize | ||
const extraPadding = 30 | ||
|
||
let columnDef = getColumnDefinition(el) | ||
let row = getRow(el) | ||
selector.innerHTML = '' | ||
selector.style.top = Math.max(2, (rect.top - offset.top))+'px' | ||
selector.style.left = (rect.left - offset.left)+'px' | ||
selector.style.width = rect.width+'px' | ||
selector.style.width = Math.max(300, (rect.width))+'px' | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Do Math.min(spreadsheetSize.width, Math.max(300, rect.width)+'px' |
||
selector.style['min-height'] = rect.height+'px' | ||
selector.style.overflow = 'auto' | ||
|
||
if((rect.left + standardBoxWidth + extraPadding) > spreadsheetSize.width){ | ||
selector.style.left = (rect.left - rect.width - standardBoxWidth - extraPadding ) +'px' | ||
} | ||
|
||
if((rect.left - standardBoxWidth) < 0){ | ||
selector.style.left = (extraPadding) +'px' | ||
} | ||
|
||
if(el.scrollWidth > boxWidth){ // @TODO doublecheck during code review: | ||
selector.style.width = (boxWidth)+'px' | ||
if((rect.left + iconSize + boxWidth + extraPadding) > spreadsheetSize.width){ | ||
selector.style.left = (rect.left - rect.width - boxWidth - iconSize - extraPadding) +'px' | ||
} | ||
if((rect.left - boxWidth - extraPadding) < 0){ | ||
selector.style.left = (extraPadding) +'px' | ||
} | ||
} | ||
|
||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Please extra code above to a separate function, e.g. calculateOptimalPosition |
||
let value = row.columns[columnDef.value] || '' | ||
let header = '' | ||
if (columnDef.editor!==false) { | ||
|
@@ -435,6 +462,7 @@ const spreadsheet = (function() { | |
</use></svg> | ||
</button> | ||
` | ||
|
||
} | ||
switch(columnDef.type) { | ||
case 'id': | ||
|
@@ -466,12 +494,18 @@ const spreadsheet = (function() { | |
if (current.top+current.height > offset.top+offset.height) { | ||
if ((offset.height-current.height)<2) { | ||
selector.style.top = '2px' | ||
// selector.style.height = 'calc(100% - 40px)' | ||
|
||
// @NOTE: not sure if needed here | ||
selector.style.height = 'fit-content' | ||
selector.style.overflow = 'visible' | ||
} else { | ||
selector.style.top = (offset.height - current.height)+'px' | ||
// @NOTE: not sure if needed here | ||
selector.style.height = 'fit-content' | ||
selector.style.overflow = 'visible' | ||
} | ||
} else { | ||
|
||
selector.style.height = 'fit-content' | ||
selector.style.overflow = 'visible' | ||
} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If each branch of if/else has the same code, extract it outside the if/else branches |
||
selector.style.display = 'block' | ||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
add a const minSize = 300 and use that everywhere