@dtdot/lego 1.2.0 → 1.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -50,6 +50,14 @@ export const InputStyles = css `
|
|
|
50
50
|
&::placeholder {
|
|
51
51
|
color: ${(props) => getThemeControlColours(props.theme).placeholder};
|
|
52
52
|
}
|
|
53
|
+
|
|
54
|
+
&:disabled {
|
|
55
|
+
color: ${(props) => getThemeControlColours(props.theme).font};
|
|
56
|
+
opacity: 1;
|
|
57
|
+
-webkit-text-fill-color: ${(props) => getThemeControlColours(props.theme).font};
|
|
58
|
+
background-color: ${(props) => props.theme.colours.controlBackgroundDisabled};
|
|
59
|
+
border: none;
|
|
60
|
+
}
|
|
53
61
|
`;
|
|
54
62
|
const StyledInput = styled(motion.input) `
|
|
55
63
|
${InputStyles}
|
|
@@ -99,7 +107,7 @@ const messageVariants = {
|
|
|
99
107
|
errorFocus: { opacity: 1, y: -4 },
|
|
100
108
|
};
|
|
101
109
|
const Input = React.forwardRef(function ForwardRefInput(props, ref) {
|
|
102
|
-
const { label, name, placeholder, type = 'text', autoFocus, value, 'error': propsError, onChange, onFocus, onBlur, 'data-cy': dataCy, } = props;
|
|
110
|
+
const { label, name, placeholder, disabled, type = 'text', autoFocus, value, 'error': propsError, onChange, onFocus, onBlur, 'data-cy': dataCy, } = props;
|
|
103
111
|
const [isFocused, setIsFocused] = useState(false);
|
|
104
112
|
const { value: contextValue, error: contextError, onChange: contextOnChange } = useFormNode(name);
|
|
105
113
|
const error = contextError || propsError;
|
|
@@ -127,7 +135,7 @@ const Input = React.forwardRef(function ForwardRefInput(props, ref) {
|
|
|
127
135
|
return (React.createElement("div", null,
|
|
128
136
|
label && React.createElement(InputLabel, { htmlFor: name }, label),
|
|
129
137
|
React.createElement(InputContainer, { "data-cy": dataCy },
|
|
130
|
-
React.createElement(StyledInput, { ref: ref, animate: animationVariant, variants: inputVariants, transition: { type: 'spring', duration: 0.3 }, type: type, name: name, placeholder: placeholder, value: getValue(value, contextValue), onChange: handleChange, onFocus: handleFocus, onBlur: handleBlur, autoFocus: autoFocus, "data-cy": 'input' }),
|
|
138
|
+
React.createElement(StyledInput, { ref: ref, animate: animationVariant, variants: inputVariants, transition: { type: 'spring', duration: 0.3 }, type: type, name: name, placeholder: placeholder, disabled: disabled, value: getValue(value, contextValue), onChange: handleChange, onFocus: handleFocus, onBlur: handleBlur, autoFocus: autoFocus, "data-cy": 'input' }),
|
|
131
139
|
React.createElement(ErrorContainer, { animate: error ? 'show' : undefined, style: { opacity: 0 }, variants: errorVariants, transition: { type: 'spring', duration: 0.3 }, "data-cy": 'error-indicator' },
|
|
132
140
|
React.createElement(ErrorInner, null,
|
|
133
141
|
React.createElement(FontAwesomeIcon, { icon: faExclamationCircle }))),
|
|
@@ -25,6 +25,7 @@ const defaultTheme = {
|
|
|
25
25
|
defaultBorder: colours.grey20,
|
|
26
26
|
faintBorder: colours.grey20,
|
|
27
27
|
controlBackground: colours.white,
|
|
28
|
+
controlBackgroundDisabled: colours.grey20,
|
|
28
29
|
controlBorder: colours.grey20,
|
|
29
30
|
controlBorderFocus: colours.grey50,
|
|
30
31
|
controlBorderHover: colours.grey30,
|