@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.
@@ -5,6 +5,7 @@ export interface IInputProps {
5
5
  'name'?: string;
6
6
  'label'?: string;
7
7
  'placeholder'?: string;
8
+ 'disabled'?: boolean;
8
9
  'type'?: string;
9
10
  'autoFocus'?: boolean;
10
11
  'value'?: string;
@@ -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 }))),
@@ -24,6 +24,7 @@ const darkTheme = {
24
24
  defaultBorder: '#989898',
25
25
  faintBorder: '#cccccc1f',
26
26
  controlBackground: '#5e6167',
27
+ controlBackgroundDisabled: '#47494d',
27
28
  controlBorder: '#565656',
28
29
  controlBorderFocus: '#4289de',
29
30
  controlBorderHover: '#4a4949',
@@ -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,
@@ -28,6 +28,7 @@ export interface LegoTheme {
28
28
  defaultBorder: string;
29
29
  faintBorder: string;
30
30
  controlBackground: string;
31
+ controlBackgroundDisabled: string;
31
32
  controlBorder: string;
32
33
  controlBorderFocus: string;
33
34
  controlBorderHover: string;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dtdot/lego",
3
- "version": "1.2.0",
3
+ "version": "1.3.0",
4
4
  "description": "Some reusable components for building my applications",
5
5
  "main": "build/index.js",
6
6
  "scripts": {