Skip to content

Commit

Permalink
Fix colors in preview
Browse files Browse the repository at this point in the history
  • Loading branch information
ehmicky committed Aug 29, 2021
1 parent e743f71 commit 297fd60
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 8 deletions.
14 changes: 10 additions & 4 deletions src/report/handle.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,17 @@ import { wrapRows } from './utils/wrap.js'
// lines will be eventually filled (e.g. when combinations stats become
// available).
export const handleContent = function ({ content, output, format, colors }) {
const padding = FORMATS[format].padding !== undefined
const contentA = handleContentString({ content, padding, colors })
return { content: contentA, output }
}

export const handleContentString = function ({ content, padding, colors }) {
const contentA = handleColors(content, colors)
const contentB = trimEnd(contentA)
const contentC = wrapRows(contentB)
const contentD = padContents(contentC, format)
return { content: contentD, output }
const contentD = padContents(contentC, padding)
return contentD
}

// Reporters should always assume `colors` are true, but the core remove this
Expand All @@ -33,8 +39,8 @@ const trimEndLine = function (line) {
return line.trimEnd()
}

const padContents = function (joinedContents, format) {
if (FORMATS[format].padding === undefined) {
const padContents = function (joinedContents, padding) {
if (!padding) {
return joinedContents
}

Expand Down
19 changes: 15 additions & 4 deletions src/run/preview/update/bottom_bar.js
Original file line number Diff line number Diff line change
@@ -1,17 +1,28 @@
import stripFinalNewline from 'strip-final-newline'

import { handleContentString } from '../../../report/handle.js'
import { goodColor, noteColor } from '../../../report/utils/colors.js'
import { addPadding } from '../../../report/utils/indent.js'
import { wrapPaddedRows } from '../../../report/utils/wrap.js'

// Retrieve bottom bar of preview
export const getBottomBar = function ({
previewState: { actions },
previewState: {
actions,
reporters: [
{
config: { colors },
},
],
},
leftWidth,
progressRow,
counterRow,
}) {
const actionsA = getActions(actions, leftWidth)
const rows = addPadding(`${progressRow}\n\n${counterRow}\n\n${actionsA}`)
return rows
const content = `${progressRow}\n\n${counterRow}\n\n${actionsA}`
const bottomBar = handleContentString({ content, padding: true, colors })
const bottomBarA = stripFinalNewline(bottomBar)
return bottomBarA
}

// Show keys available for user actions in previews.
Expand Down

0 comments on commit 297fd60

Please sign in to comment.