Fixed capitalization of API and CTA in theme setting labels

no issue

- added `{{humanize-setting-key}}` helper that uses the base `humanize` output but then forces capitalization for known acronyms
- updated `<CustomThemeSettings::Select>` to use the new helper
This commit is contained in:
Kevin Ansfield 2021-10-12 10:11:24 +01:00
parent d3539655a0
commit 4fa13bfa9f
2 changed files with 17 additions and 1 deletions

View File

@ -1,7 +1,7 @@
<div class="gh-stack-item {{if (eq @index 0) "gh-setting-first"}}">
<div class="flex-grow-1">
<label class="gh-setting-title gh-theme-setting-title" for={{this.selectId}}>
{{humanize @setting.key}}
{{humanize-setting-key @setting.key}}
</label>
<select class="ember-select" name={{this.selectName}} id={{this.selectId}} {{on "change" this.setSelection}}>

View File

@ -0,0 +1,16 @@
import {helper} from '@ember/component/helper';
import {humanize} from 'ember-cli-string-helpers/helpers/humanize';
export function humanizeSettingKey([key]) {
let humanized = humanize([key]);
const allCaps = ['API', 'CTA'];
allCaps.forEach((str) => {
const regex = new RegExp(`(^| )(${str})( |$)`, 'gi');
humanized = humanized.replace(regex, `$1${str}$3`);
});
return humanized;
}
export default helper(humanizeSettingKey);