Added default value for backgroundColor In NumberInput (#4378)

* fix: added background styles for number input

* fix: removed additional f from the background color property

* fix: added backgroundColor property from styles

* fixes: default bg color for dark mode

Co-authored-by: arpitnath <arpitnath42@gmail.com>
Co-authored-by: Kavin Venkatachalam <kavin.saratha@gmail.com>
This commit is contained in:
Abhushan Gautam 2022-11-17 14:57:02 +05:45 committed by GitHub
parent fcbc5fbc03
commit e1ef96ce7a
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 17 additions and 9 deletions

View file

@ -9,7 +9,7 @@ export const NumberInput = function NumberInput({
darkMode,
fireEvent,
}) {
const { visibility, borderRadius, borderColor } = styles;
const { visibility, borderRadius, borderColor, backgroundColor } = styles;
const textColor = darkMode && ['#232e3c', '#000000ff'].includes(styles.textColor) ? '#fff' : styles.textColor;
@ -43,6 +43,15 @@ export const NumberInput = function NumberInput({
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [value]);
const computedStyles = {
height,
display: visibility ? '' : 'none',
borderRadius: `${borderRadius}px`,
borderColor,
color: textColor,
backgroundColor: darkMode && ['#ffffff', '#ffffffff'].includes(backgroundColor) ? '#000000' : backgroundColor,
};
return (
<input
disabled={styles.disabledState}
@ -50,13 +59,7 @@ export const NumberInput = function NumberInput({
type="number"
className="form-control"
placeholder={properties.placeholder}
style={{
height,
display: visibility ? '' : 'none',
borderRadius: `${borderRadius}px`,
borderColor,
color: textColor,
}}
style={computedStyles}
value={value}
data-cy={`draggable-widget-${String(component.name).toLowerCase()}`}
/>

View file

@ -1100,6 +1100,10 @@ export const widgets = [
schema: { type: 'union', schemas: [{ type: 'string' }, { type: 'number' }] },
},
},
backgroundColor: {
type: 'color',
displayName: 'Background Color',
},
borderColor: {
type: 'color',
displayName: 'Border Color',
@ -1132,6 +1136,7 @@ export const widgets = [
visibility: { value: '{{true}}' },
disabledState: { value: '{{false}}' },
borderRadius: { value: '{{0}}' },
backgroundColor: { value: '#ffffffff' },
borderColor: { value: '#fff' },
textColor: { value: '#232e3c' },
},
@ -1220,7 +1225,7 @@ export const widgets = [
visibility: { value: '{{true}}' },
disabledState: { value: '{{false}}' },
borderRadius: { value: '{{0}}' },
backgroundColor: { value: '#fff' },
backgroundColor: { value: '#ffffff' },
},
},
},