Skip to content

Commit

Permalink
Rename
Browse files Browse the repository at this point in the history
  • Loading branch information
ehmicky committed Sep 12, 2021
1 parent 0d7e4e0 commit ef705e6
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 18 deletions.
16 changes: 8 additions & 8 deletions src/report/utils/name.js
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
import { titleColor } from './colors.js'
import { NAME_SEPARATOR, NAME_SEPARATOR_COLORED } from './separator.js'
import { TITLE_SEPARATOR, TITLE_SEPARATOR_COLORED } from './separator.js'

// Retrieve a combination's title with padding and color
export const getCombTitleColorPad = function (combination) {
return `${getCombinationTitleColor(combination)}${NAME_SEPARATOR_COLORED}`
return `${getCombinationTitleColor(combination)}${TITLE_SEPARATOR_COLORED}`
}

// Retrieve a combination's title with padding
export const getCombinationTitlePad = function (combination) {
return `${getCombinationTitle(combination)}${NAME_SEPARATOR}`
return `${getCombinationTitle(combination)}${TITLE_SEPARATOR}`
}

// Retrieve the prettified combination title to used as a first column
Expand All @@ -19,14 +19,14 @@ export const getCombinationTitleColor = function (combination) {
const getCombinationTitle = function ({ dimensions }) {
const combinationTitle = Object.values(dimensions)
.map(getTitlePadded)
.join(NAME_MIDDLE)
return `${NAME_START}${combinationTitle}${NAME_END}`
.join(COMBINATION_TITLE_MIDDLE)
return `${COMBINATION_TITLE_START}${combinationTitle}${COMBINATION_TITLE_END}`
}

const getTitlePadded = function ({ titlePadded }) {
return titlePadded
}

const NAME_MIDDLE = ' | '
const NAME_START = '[ '
const NAME_END = ' ]'
const COMBINATION_TITLE_START = '[ '
const COMBINATION_TITLE_END = ' ]'
const COMBINATION_TITLE_MIDDLE = ' | '
12 changes: 6 additions & 6 deletions src/report/utils/separator.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import { separatorColor } from './colors.js'

// Separator between first column and others
const NAME_SEPARATOR_SIGN = ''
const NAME_PADDING_WIDTH = 2
const NAME_PADDING = ' '.repeat(NAME_PADDING_WIDTH)
export const NAME_SEPARATOR = `${NAME_SEPARATOR_SIGN}${NAME_PADDING}`
export const NAME_SEPARATOR_COLORED = NAME_SEPARATOR
// Separator between combination title (first column) and rest
const TITLE_SEPARATOR_SIGN = ''
const TITLE_PADDING_WIDTH = 2
const TITLE_PADDING = ' '.repeat(TITLE_PADDING_WIDTH)
export const TITLE_SEPARATOR = `${TITLE_SEPARATOR_SIGN}${TITLE_PADDING}`
export const TITLE_SEPARATOR_COLORED = TITLE_SEPARATOR

// Separator between columns
// Works on all terminals
Expand Down
8 changes: 4 additions & 4 deletions src/report/utils/table.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ import stringWidth from 'string-width'

import { padString } from './pad.js'
import {
NAME_SEPARATOR,
NAME_SEPARATOR_COLORED,
TITLE_SEPARATOR,
TITLE_SEPARATOR_COLORED,
COLUMN_SEPARATOR,
COLUMN_SEPARATOR_COLORED,
} from './separator.js'
Expand All @@ -22,7 +22,7 @@ export const getTables = function (rows, screenWidth) {
const rowsRight = rows.map(getRowRight)
const leftWidth = Math.max(...rowsLeft.map(stringWidth))
const columnsWidth = Math.max(...rowsRight.flat().map(stringWidth))
const availableWidth = screenWidth - leftWidth - NAME_SEPARATOR.length
const availableWidth = screenWidth - leftWidth - TITLE_SEPARATOR.length
const tablesRows = getTablesRows(rowsRight, availableWidth, columnsWidth)
return tablesRows
.map((tableRows) =>
Expand Down Expand Up @@ -100,5 +100,5 @@ const getRow = function ({ row, leftCell, leftWidth, columnsWidth }) {
const rowA = row
.map((cell) => padString(cell, columnsWidth))
.join(COLUMN_SEPARATOR_COLORED)
return `${leftCellA}${NAME_SEPARATOR_COLORED}${rowA}\n`
return `${leftCellA}${TITLE_SEPARATOR_COLORED}${rowA}\n`
}

0 comments on commit ef705e6

Please sign in to comment.