@dtdot/lego 1.6.0 → 1.7.1

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.
@@ -4,6 +4,7 @@ export declare const InputStyles: import("styled-components").FlattenInterpolati
4
4
  export interface IInputProps {
5
5
  'name'?: string;
6
6
  'label'?: string;
7
+ 'description'?: string;
7
8
  'placeholder'?: string;
8
9
  'disabled'?: boolean;
9
10
  'type'?: string;
@@ -21,6 +21,17 @@ const InputLabel = styled.label `
21
21
  font-family: ${(props) => props.theme.fonts.default.family};
22
22
  font-size: ${(props) => props.theme.fonts.default.size};
23
23
  `;
24
+ const InputDescription = styled.div `
25
+ color: ${(props) => props.theme.colours.controlDescriptionColour};
26
+ font-family: ${(props) => props.theme.fonts.emphasis.family};
27
+ font-size: ${(props) => props.theme.fonts.emphasis.size};
28
+ font-weight: ${(props) => props.theme.fonts.emphasis.weight};
29
+ line-height: 18px;
30
+
31
+ padding-top: 4px;
32
+ padding-bottom: 6px;
33
+ font-style: italic;
34
+ `;
24
35
  export const InputStyles = css `
25
36
  outline: none;
26
37
  box-shadow: none;
@@ -107,10 +118,11 @@ const messageVariants = {
107
118
  errorFocus: { opacity: 1, y: -4 },
108
119
  };
109
120
  const Input = React.forwardRef(function ForwardRefInput(props, ref) {
110
- const { label, name, placeholder, disabled, type = 'text', autoFocus, value, 'error': propsError, onChange, onFocus, onBlur, 'data-cy': dataCy, } = props;
121
+ const { label, name, description, placeholder, disabled, type = 'text', autoFocus, value, 'error': propsError, onChange, onFocus, onBlur, 'data-cy': dataCy, } = props;
111
122
  const [isFocused, setIsFocused] = useState(false);
112
123
  const { value: contextValue, error: contextError, onChange: contextOnChange } = useFormNode(name);
113
124
  const error = contextError || propsError;
125
+ const splitDescription = description ? description.split('\\n').map((str) => str.trim()) : undefined;
114
126
  const handleChange = (e) => {
115
127
  if (onChange) {
116
128
  onChange(e.target.value);
@@ -139,6 +151,9 @@ const Input = React.forwardRef(function ForwardRefInput(props, ref) {
139
151
  React.createElement(ErrorContainer, { animate: error ? 'show' : undefined, style: { opacity: 0 }, variants: errorVariants, transition: { type: 'spring', duration: 0.3 }, "data-cy": 'error-indicator' },
140
152
  React.createElement(ErrorInner, null,
141
153
  React.createElement(FontAwesomeIcon, { icon: faExclamationCircle }))),
142
- error && (React.createElement(ErrorMessage, { style: { opacity: 0, y: 0 }, animate: animationVariant, variants: messageVariants, transition: { type: 'spring', duration: 0.3 }, "data-cy": 'error-message' }, error)))));
154
+ error && (React.createElement(ErrorMessage, { style: { opacity: 0, y: 0 }, animate: animationVariant, variants: messageVariants, transition: { type: 'spring', duration: 0.3 }, "data-cy": 'error-message' }, error))),
155
+ splitDescription && (React.createElement(InputDescription, null, splitDescription.map((line, index) => (React.createElement(React.Fragment, null,
156
+ index !== 0 && React.createElement("br", null),
157
+ line)))))));
143
158
  });
144
159
  export default Input;
@@ -29,6 +29,7 @@ const darkTheme = {
29
29
  controlBorderFocus: '#4289de',
30
30
  controlBorderHover: '#4a4949',
31
31
  controlPlaceholder: '#949494',
32
+ controlDescriptionColour: '#cbcbcb',
32
33
  uploadBackground: '#5e6167',
33
34
  uploadIcon: '#e2e2e2',
34
35
  cardBackground: '#494b50',
@@ -55,6 +56,11 @@ const darkTheme = {
55
56
  },
56
57
  },
57
58
  fonts: {
59
+ emphasis: {
60
+ family: `'Roboto', sans-serif`,
61
+ size: '14px',
62
+ weight: '400',
63
+ },
58
64
  default: {
59
65
  family: `'Roboto', sans-serif`,
60
66
  size: '16px',
@@ -30,6 +30,7 @@ const defaultTheme = {
30
30
  controlBorderFocus: colours.grey50,
31
31
  controlBorderHover: colours.grey30,
32
32
  controlPlaceholder: colours.grey30,
33
+ controlDescriptionColour: colours.grey90,
33
34
  uploadBackground: colours.grey20,
34
35
  uploadIcon: colours.grey10,
35
36
  cardBackground: colours.white,
@@ -56,6 +57,11 @@ const defaultTheme = {
56
57
  },
57
58
  },
58
59
  fonts: {
60
+ emphasis: {
61
+ family: `'Roboto', sans-serif`,
62
+ size: '14px',
63
+ weight: '400',
64
+ },
59
65
  default: {
60
66
  family: `'Roboto', sans-serif`,
61
67
  size: '16px',
@@ -34,6 +34,7 @@ export interface LegoTheme {
34
34
  controlBorderFocus: string;
35
35
  controlBorderHover: string;
36
36
  controlPlaceholder: string;
37
+ controlDescriptionColour: string;
37
38
  uploadBackground: string;
38
39
  uploadIcon: string;
39
40
  cardBackground: string;
@@ -44,6 +45,7 @@ export interface LegoTheme {
44
45
  statusDanger: IStatus;
45
46
  };
46
47
  fonts: {
48
+ emphasis: IFont;
47
49
  default: IFont;
48
50
  heading: IFont;
49
51
  subHeading: IFont;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dtdot/lego",
3
- "version": "1.6.0",
3
+ "version": "1.7.1",
4
4
  "description": "Some reusable components for building my applications",
5
5
  "main": "build/index.js",
6
6
  "scripts": {