mirror of
https://github.com/bitburner-official/bitburner-src.git
synced 2024-11-30 03:23:48 +01:00
fixes for editor and tabs when names too long
* coupled some of the styles to avoid breaking this later on * added tooltip incase its too long/ too small * changes to use elipsis and RTL to read the end of file name
This commit is contained in:
parent
9ddb1c4379
commit
d586743bf6
@ -754,7 +754,11 @@ export function Root(props: IProps): React.ReactElement {
|
|||||||
// 44px bottom tool bar + 16px margin
|
// 44px bottom tool bar + 16px margin
|
||||||
// + vim bar 34px
|
// + vim bar 34px
|
||||||
const editorHeight = dimensions.height - (130 + (options.vim ? 34 : 0));
|
const editorHeight = dimensions.height - (130 + (options.vim ? 34 : 0));
|
||||||
|
const tabsMaxWidth = 1640
|
||||||
|
const tabMargin = 5
|
||||||
|
const tabMaxWidth = openScripts.length ? (tabsMaxWidth / openScripts.length) - tabMargin : 0
|
||||||
|
const tabIconWidth = 25
|
||||||
|
const tabTextWidth = tabMaxWidth - (tabIconWidth * 2)
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<div style={{ display: currentScript !== null ? "block" : "none", height: "100%", width: "100%" }}>
|
<div style={{ display: currentScript !== null ? "block" : "none", height: "100%", width: "100%" }}>
|
||||||
@ -762,7 +766,7 @@ export function Root(props: IProps): React.ReactElement {
|
|||||||
<Droppable droppableId="tabs" direction="horizontal">
|
<Droppable droppableId="tabs" direction="horizontal">
|
||||||
{(provided, snapshot) => (
|
{(provided, snapshot) => (
|
||||||
<Box
|
<Box
|
||||||
maxWidth="1640px"
|
maxWidth={`${tabsMaxWidth}px`}
|
||||||
display="flex"
|
display="flex"
|
||||||
flexDirection="row"
|
flexDirection="row"
|
||||||
alignItems="center"
|
alignItems="center"
|
||||||
@ -778,8 +782,8 @@ export function Root(props: IProps): React.ReactElement {
|
|||||||
>
|
>
|
||||||
{openScripts.map(({ fileName, hostname }, index) => {
|
{openScripts.map(({ fileName, hostname }, index) => {
|
||||||
const iconButtonStyle = {
|
const iconButtonStyle = {
|
||||||
maxWidth: "25px",
|
maxWidth: `${tabIconWidth}px`,
|
||||||
minWidth: "25px",
|
minWidth: `${tabIconWidth}px`,
|
||||||
minHeight: '38.5px',
|
minHeight: '38.5px',
|
||||||
maxHeight: '38.5px',
|
maxHeight: '38.5px',
|
||||||
...(currentScript?.fileName === openScripts[index].fileName ? {
|
...(currentScript?.fileName === openScripts[index].fileName ? {
|
||||||
@ -792,6 +796,8 @@ export function Root(props: IProps): React.ReactElement {
|
|||||||
color: Settings.theme.secondary
|
color: Settings.theme.secondary
|
||||||
})
|
})
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const scriptTabText = `${hostname}:~/${fileName} ${dirty(index)}`
|
||||||
return (
|
return (
|
||||||
<Draggable
|
<Draggable
|
||||||
key={fileName + hostname}
|
key={fileName + hostname}
|
||||||
@ -806,11 +812,14 @@ export function Root(props: IProps): React.ReactElement {
|
|||||||
{...provided.dragHandleProps}
|
{...provided.dragHandleProps}
|
||||||
style={{
|
style={{
|
||||||
...provided.draggableProps.style,
|
...provided.draggableProps.style,
|
||||||
marginRight: "5px",
|
minWidth: '200px',
|
||||||
|
maxWidth: `${tabMaxWidth}px`,
|
||||||
|
marginRight: `${tabMargin}px`,
|
||||||
flexShrink: 0,
|
flexShrink: 0,
|
||||||
border: '1px solid ' + Settings.theme.well,
|
border: '1px solid ' + Settings.theme.well,
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
|
<Tooltip title={scriptTabText}>
|
||||||
<Button
|
<Button
|
||||||
onClick={() => onTabClick(index)}
|
onClick={() => onTabClick(index)}
|
||||||
onMouseDown={e => {
|
onMouseDown={e => {
|
||||||
@ -818,6 +827,8 @@ export function Root(props: IProps): React.ReactElement {
|
|||||||
if (e.button === 1) onTabClose(index);
|
if (e.button === 1) onTabClose(index);
|
||||||
}}
|
}}
|
||||||
style={{
|
style={{
|
||||||
|
maxWidth: `${tabTextWidth}px`,
|
||||||
|
overflow: "hidden",
|
||||||
...(currentScript?.fileName === openScripts[index].fileName ? {
|
...(currentScript?.fileName === openScripts[index].fileName ? {
|
||||||
background: Settings.theme.button,
|
background: Settings.theme.button,
|
||||||
borderColor: Settings.theme.button,
|
borderColor: Settings.theme.button,
|
||||||
@ -829,8 +840,11 @@ export function Root(props: IProps): React.ReactElement {
|
|||||||
})
|
})
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
{hostname}:~/{fileName} {dirty(index)}
|
<span style={{ overflow: 'hidden', direction: 'rtl', textOverflow: "ellipsis" }}>
|
||||||
|
{scriptTabText}
|
||||||
|
</span>
|
||||||
</Button>
|
</Button>
|
||||||
|
</Tooltip>
|
||||||
<Tooltip title="Overwrite editor content with saved file content">
|
<Tooltip title="Overwrite editor content with saved file content">
|
||||||
<Button onClick={() => onTabUpdate(index)} style={iconButtonStyle} >
|
<Button onClick={() => onTabUpdate(index)} style={iconButtonStyle} >
|
||||||
<SyncIcon fontSize='small' />
|
<SyncIcon fontSize='small' />
|
||||||
|
Loading…
Reference in New Issue
Block a user