Skip to content

Commit

Permalink
Move logic
Browse files Browse the repository at this point in the history
  • Loading branch information
ehmicky committed Sep 12, 2021
1 parent 0808cdc commit 2221956
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 19 deletions.
17 changes: 0 additions & 17 deletions src/combination/ids.js
Original file line number Diff line number Diff line change
@@ -1,23 +1,6 @@
import { titleColor, noteColor } from '../report/utils/colors.js'

import { DIMENSIONS, USER_DIMENSIONS } from './dimensions.js'
import { getInputIds } from './inputs.js'

export const getCombinationName = function (combination) {
return getCombinationIds(combination)
.map(getCombinationNamePart)
.join(noteColor(', '))
}

const getCombinationNamePart = function ({ dimension, id }, index) {
const dimensionA = index === 0 ? titleize(dimension) : dimension
return `${noteColor(dimensionA)} ${titleColor(id)}`
}

const titleize = function (string) {
return `${string.charAt(0).toUpperCase()}${string.slice(1)}`
}

// Retrieve user-defined identifiers
export const getUserIds = function (combinations, inputs) {
const combinationsUserIds = getCombinationsIds(combinations).filter(isUserId)
Expand Down
20 changes: 20 additions & 0 deletions src/combination/name.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import { titleColor, noteColor } from '../report/utils/colors.js'

import { getCombinationIds } from './ids.js'

// Retrieve string with each combination's dimension id.
// Used to name combinations in: `dev` and preview bottom bar.
export const getCombinationName = function (combination) {
return getCombinationIds(combination)
.map(getCombinationNamePart)
.join(noteColor(', '))
}

const getCombinationNamePart = function ({ dimension, id }, index) {
const dimensionA = index === 0 ? titleize(dimension) : dimension
return `${noteColor(dimensionA)} ${titleColor(id)}`
}

const titleize = function (string) {
return `${string.charAt(0).toUpperCase()}${string.slice(1)}`
}
2 changes: 1 addition & 1 deletion src/dev/main.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { getCombinationName } from '../combination/ids.js'
import { getCombinationName } from '../combination/name.js'
import { titleColor } from '../report/utils/colors.js'
import { measureCombinations } from '../run/measure/main.js'

Expand Down
2 changes: 1 addition & 1 deletion src/run/preview/combination.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import now from 'precise-now'

import { getCombinationName } from '../../combination/ids.js'
import { getCombinationName } from '../../combination/name.js'

import { START_DESCRIPTION } from './description.js'
import { updatePreview } from './update/main.js'
Expand Down

0 comments on commit 2221956

Please sign in to comment.