Properly handle placeholder fields in theme application

This commit is contained in:
Andreas Nedbal 2022-11-14 23:13:22 +01:00
parent 420a25872e
commit f35d49e575
2 changed files with 5 additions and 3 deletions

View File

@ -20,6 +20,7 @@ module ThemeHelper
'body_text' => 'body-text',
'input_color' => 'input-bg',
'input_text' => 'input-text',
'input_placeholder' => 'input-placeholder',
'muted_text' => 'muted-text'
}.freeze
@ -33,7 +34,7 @@ module ThemeHelper
theme.attributes.each do |k, v|
next unless ATTRIBUTE_MAP.key?(k)
if k.include? 'text'
if k.include? 'text' or k.include? 'placeholder'
hex = get_hex_color_from_theme_value(v)
body += "\t--#{ATTRIBUTE_MAP[k]}: #{get_decimal_triplet_from_hex(hex)};\n"
else

View File

@ -36,6 +36,7 @@ const generateTheme = (payload: Record<string, string>): void => {
'body_text': 'body-text',
'input_color': 'input-bg',
'input_text': 'input-text',
'input_placeholder': 'input-placeholder',
'muted_text': 'muted-text'
};
@ -43,7 +44,7 @@ const generateTheme = (payload: Record<string, string>): void => {
(Object.keys(payload)).forEach((payloadKey) => {
if (themeAttributeMap[payloadKey]) {
if (themeAttributeMap[payloadKey].includes('text')) {
if (themeAttributeMap[payloadKey].includes('text') || themeAttributeMap[payloadKey].includes('placeholder')) {
const hex = getHexColorFromThemeValue(payload[payloadKey]);
body += `--${themeAttributeMap[payloadKey]}: ${getDecimalTripletsFromHex(hex)};\n`;
}
@ -111,4 +112,4 @@ export function themeSubmitHandler(): void {
Array.from(document.querySelectorAll('#update .color')).forEach((color: HTMLInputElement) => {
color.value = String(parseInt(color.value.substr(1, 6), 16));
});
}
}