Skip to content

Commit

Permalink
feat: Add customizable border color for text input component (#4191)
Browse files Browse the repository at this point in the history
* feat: Add customizable border color for text input component

* Update widgetConfig.js

* chore: Fix linter issues
  • Loading branch information
bsantosh909 committed Oct 26, 2022
1 parent 0853685 commit 0c895e2
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 3 deletions.
11 changes: 8 additions & 3 deletions frontend/src/Editor/Components/TextInput.jsx
Expand Up @@ -13,13 +13,18 @@ export const TextInput = function TextInput({
}) {
const textInputRef = useRef();

const textColor = darkMode && styles.textColor === '#000' ? '#fff' : styles.textColor;

const [disable, setDisable] = useState(styles.disabledState);
const [value, setValue] = useState(properties.value);
const [visibility, setVisibility] = useState(styles.visibility);
const { isValid, validationError } = validate(value);

const computedStyles = {
height,
borderRadius: `${styles.borderRadius}px`,
color: darkMode && styles.textColor === '#000' ? '#fff' : styles.textColor,
borderColor: styles.borderColor,
};

useEffect(() => {
disable !== styles.disabledState && setDisable(styles.disabledState);
}, [styles.disabledState]);
Expand Down Expand Up @@ -98,7 +103,7 @@ export const TextInput = function TextInput({
darkMode && 'dark-theme-placeholder'
}`}
placeholder={properties.placeholder}
style={{ height, borderRadius: `${styles.borderRadius}px`, color: textColor }}
style={computedStyles}
value={value}
data-cy={`draggable-widget-${String(component.name).toLowerCase()}`}
/>
Expand Down
6 changes: 6 additions & 0 deletions frontend/src/Editor/WidgetManager/widgetConfig.js
Expand Up @@ -954,6 +954,11 @@ export const widgets = [
displayName: 'Text Color',
validation: { schema: { type: 'string' } },
},
borderColor: {
type: 'color',
displayName: 'Border Color',
validation: { schema: { type: 'string' } },
},
borderRadius: {
type: 'code',
displayName: 'Border radius',
Expand Down Expand Up @@ -1012,6 +1017,7 @@ export const widgets = [
events: [],
styles: {
textColor: { value: '#000' },
borderColor: { value: '#dadcde' },
borderRadius: { value: '{{0}}' },
visibility: { value: '{{true}}' },
disabledState: { value: '{{false}}' },
Expand Down

0 comments on commit 0c895e2

Please sign in to comment.