Skip to content

Commit

Permalink
Fix preview separator
Browse files Browse the repository at this point in the history
  • Loading branch information
ehmicky committed Sep 5, 2021
1 parent 32d328b commit a03aa42
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 6 deletions.
13 changes: 11 additions & 2 deletions src/report/utils/line.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,21 @@
import { getPaddedScreenWidth } from '../tty.js'
import { getPaddedScreenWidth, getScreenWidth } from '../tty.js'

import { separatorColor } from './colors.js'

// Separator between different reporters and/or preview elements
// Separator between different reporters and/or footer
export const getLineSeparator = function () {
const paddedScreenWidth = getPaddedScreenWidth()
return `${separatorColor(HORIZONTAL_LINE.repeat(paddedScreenWidth))}\n`
}

// Works with all terminals
const HORIZONTAL_LINE = '\u2500'

// Separator above the preview bottom bar
export const getFullLineSeparator = function () {
const screenWidth = getScreenWidth()
return `${separatorColor(FULL_HORIZONTAL_LINE.repeat(screenWidth))}\n`
}

// Works with all terminals
const FULL_HORIZONTAL_LINE = '\u2500'
12 changes: 8 additions & 4 deletions src/run/preview/update/bottom_bar.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { handleContent } from '../../../report/handle.js'
import { getLineSeparator } from '../../../report/utils/line.js'
import { getFullLineSeparator } from '../../../report/utils/line.js'

import { getActions, ACTIONS_LABEL } from './actions.js'
import { getCounterRow, getCounter } from './counter.js'
Expand Down Expand Up @@ -32,13 +32,17 @@ export const getBottomBar = function ({
leftWidth,
})
const actionsA = getActions(actions, leftWidth)
const content = `${separator}${progressRow}\n${counterRow}\n${actionsA}`
const content = `${progressRow}\n${counterRow}\n${actionsA}`
const bottomBar = handleContent({ content, colors, padding: true })
return bottomBar
return `${separator}${bottomBar}`
}

// The separator is only present when there is some `report` to separate from.
// It has bottom padding to separate it from the `bottomBar` but no top padding
// to separate it from the `report`, to make it clear the `bottomBar` overlays
// it.
const getSeparator = function (report) {
return report === '' ? '' : `${getLineSeparator()}\n`
return report === '' ? '' : getFullLineSeparator()
}

const getLeftWidth = function ({ durationLeft, total }) {
Expand Down

0 comments on commit a03aa42

Please sign in to comment.