0
Fork 0
mirror of https://github.com/TryGhost/Ghost.git synced 2025-02-24 23:48:13 -05:00

Added support for text custom theme settings

refs https://github.com/TryGhost/Team/issues/1109

- added basic `<CustomThemeSettings::Text>`  component that is displayed for any custom theme settings with the type `'text'`
This commit is contained in:
Kevin Ansfield 2021-10-14 15:40:22 +01:00
parent f4596a0add
commit 0b267098ea
3 changed files with 39 additions and 0 deletions

View file

@ -0,0 +1,17 @@
<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.inputId}}>
{{humanize-setting-key @setting.key}}
</label>
<input
type="text"
class="gh-input"
value={{@setting.value}}
id={{this.inputId}}
name={{this.inputName}}
{{on "input" this.updateValue}}
{{on "blur" this.triggerOnChange}}
/>
</div>
</div>

View file

@ -0,0 +1,19 @@
import Component from '@glimmer/component';
import {action} from '@ember/object';
import {camelize} from '@ember/string';
import {guidFor} from '@ember/object/internals';
export default class CustomThemeSettingsTextComponent extends Component {
inputId = `input-${guidFor(this)}`;
inputName = camelize(this.args.setting.key);
@action
updateValue(event) {
this.args.setting.set('value', event.target.value);
}
@action
triggerOnChange() {
this.args.onChange?.();
}
}

View file

@ -10,6 +10,9 @@
{{#if (eq setting.type "color")}}
<CustomThemeSettings::Color @setting={{setting}} @index={{index}} @onChange={{@updatePreview}} />
{{/if}}
{{#if (eq setting.type "text")}}
<CustomThemeSettings::Text @setting={{setting}} @index={{index}} @onChange={{@updatePreview}} />
{{/if}}
{{/each}}
</form>
</div>