Skip to content
This repository was archived by the owner on Dec 1, 2025. It is now read-only.

Commit 1aad11b

Browse files
authored
Merge pull request #82 from thepensionsregulator/feature-address-lookup-api
Feature address lookup api
2 parents 04eb497 + 771b5c4 commit 1aad11b

27 files changed

Lines changed: 275 additions & 100 deletions

File tree

.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,8 @@ docs.json
6565
.docz/public
6666
.idea/
6767

68-
68+
# Env variables
69+
.env
6970

7071
junit.xml
7172

docs/Playground.js

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import React from 'react';
22
import { Playground as DoczPlayground } from 'docz';
3-
import { CssResets } from '../packages/theming/src';
3+
import { CssResets } from '../packages/theming/src/theming';
4+
import fetch from 'node-fetch';
45

56
export const Playground = (props) => {
67
return (
@@ -9,3 +10,12 @@ export const Playground = (props) => {
910
</CssResets>
1011
);
1112
};
13+
14+
export const experianApiGet = (endpoint) => {
15+
return fetch(`https://api.edq.com/capture/address/v2/${endpoint}`, {
16+
method: 'get',
17+
headers: {
18+
'Auth-Token': process.env.GATSBY_LOOKUP_API_URL,
19+
},
20+
}).then((resp) => resp.json());
21+
};

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@
5454
"jest": "^26.0.1",
5555
"lerna": "^3.19.0",
5656
"lerna-changelog": "^1.0.0",
57+
"node-fetch": "^2.6.0",
5758
"node-sass": "^4.14.0",
5859
"npm-run-all": "^4.1.5",
5960
"prettier": "^2.0.4",

packages/forms/src/elements/checkbox/checkbox.module.scss

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,9 @@
2626
}
2727

2828
.hint {
29-
color: $colors-neutral-7;
29+
color: $colors-neutral-6;
3030
font-size: $font-size-2;
31+
font-weight: $font-weight-2;
3132
margin-top: $space-2;
32-
margin-left: 50px;
33+
margin-left: 60px;
3334
}

packages/forms/src/elements/checkbox/checkbox.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ export const Checkbox: React.FC<Partial<CheckboxIconProps>> = ({
3838
) : (
3939
<CheckboxBlank className={styles.checkbox} />
4040
)}
41-
<P cfg={{ ml: 2 }}>{label}</P>
41+
<P cfg={{ ml: 4, fontWeight: 3 }}>{label}</P>
4242
</label>
4343
{hint && <P className={styles.hint}>{hint}</P>}
4444
</StyledInputLabel>

packages/forms/src/elements/date/date.mdx

Lines changed: 34 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -10,23 +10,35 @@ import { FFInputDate } from './date';
1010
import { validate } from '../../validation';
1111
import { renderFields } from '../../renderFields';
1212

13-
# Date
13+
# Date Input
14+
15+
To input a date.
16+
17+
## When To Use
18+
19+
- By entering date number in each input box, you can create a date object.
1420

1521
## Usage
1622

23+
`Inside your React project directory, run the following:`
24+
1725
```js
18-
import { FFInputDate } from '@tpr/forms';
26+
yarn add @tpr/forms
1927
```
2028

21-
## Usage
29+
`or with npm`
30+
31+
```js
32+
npm install @tpr/forms
33+
```
2234

23-
Lorem ipsum dolor sit amet consectetur adipisicing elit. Ipsum nostrum omnis ea unde totam, est
24-
consectetur odio! Harum vitae, sed totam aperiam consequuntur nostrum repudiandae non nemo porro,
25-
dolorem nulla corrupti hic consectetur eaque fuga illo numquam modi similique ipsam recusandae! Harum,
26-
possimus suscipit. Quibusdam totam, fugiat officiis qui nisi tempora. Accusantium corrupti similique
27-
et at ipsum, eveniet tempore nostrum quasi est unde modi impedit quaerat suscipit aspernatur ratione
28-
quo corporis? Cum dignissimos adipisci itaque sint tempore, saepe dolorem fugit quia placeat officiis
29-
earum rerum aspernatur similique commodi voluptates? Id ut ab cum doloremque magnam illo ipsa officia nulla ipsum.
35+
`import items you wish to use from the library`
36+
37+
```js
38+
import { FFInputDate } from '@tpr/forms';
39+
```
40+
41+
## Examples
3042

3143
[CodeSandbox](https://codesandbox.io/s/nice-dream-xs3zp)
3244

@@ -59,3 +71,15 @@ earum rerum aspernatur similique commodi voluptates? Id ut ab cum doloremque mag
5971
);
6072
}}
6173
</Playground>
74+
75+
## API
76+
77+
### Props
78+
79+
| Property | Required | Type | Description |
80+
| -------- | -------- | ------- | -------------------------------------------- |
81+
| cfg | false | object | FlexProps & SpaceProps |
82+
| disabled | false | boolean | Disable checkbox |
83+
| testId | false | string | data attribute for testers |
84+
| label | true | string | Checkbox description |
85+
| hint | false | string | More detailed description about the checkbox |

packages/forms/src/elements/date/date.tsx

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ type DateInputFieldProps = {
4747
maxInt: number;
4848
meta: any;
4949
label: string;
50+
disabled?: boolean;
5051
};
5152
const DateInputField: React.FC<DateInputFieldProps> = ({
5253
small = true,
@@ -59,12 +60,14 @@ const DateInputField: React.FC<DateInputFieldProps> = ({
5960
setMonth,
6061
onBlur,
6162
meta,
63+
disabled,
6264
}) => {
6365
return (
6466
<label className={small ? styles.inputSmall : styles.inputLarge}>
6567
<P cfg={{ fontSize: 2, fontWeight: 3, mb: 1 }}>{label}</P>
6668
<Input
6769
type="number"
70+
disabled={disabled}
6871
aria-label={ariaLabel}
6972
data-testid={testId}
7073
value={value}
@@ -85,7 +88,7 @@ const DateInputField: React.FC<DateInputFieldProps> = ({
8588

8689
type InputDateProps = FieldRenderProps<string> & FieldExtraProps;
8790
export const InputDate: React.FC<InputDateProps> = memo(
88-
({ label, hint, required, input, meta, testId = 'field', cfg }) => {
91+
({ label, hint, required, input, meta, testId = 'field', cfg, disabled }) => {
8992
// react-final-form types says it's a string, incorrect, it's a date object.
9093
const { dd, mm, yyyy } = transformDate(meta.initial);
9194
const [{ dd: day, mm: month, yyyy: year }, setState] = useReducer(
@@ -137,6 +140,7 @@ export const InputDate: React.FC<InputDateProps> = memo(
137140
setMonth={(mm: number) => setState({ mm })}
138141
onBlur={input.onBlur}
139142
meta={meta}
143+
disabled={disabled}
140144
/>
141145
<DateInputField
142146
label="Month"
@@ -148,6 +152,7 @@ export const InputDate: React.FC<InputDateProps> = memo(
148152
setMonth={(mm: number) => setState({ mm })}
149153
onBlur={input.onBlur}
150154
meta={meta}
155+
disabled={disabled}
151156
/>
152157
<DateInputField
153158
label="Year"
@@ -160,6 +165,7 @@ export const InputDate: React.FC<InputDateProps> = memo(
160165
setMonth={(mm: number) => setState({ mm })}
161166
onBlur={input.onBlur}
162167
meta={meta}
168+
disabled={disabled}
163169
/>
164170
</Flex>
165171
</StyledInputLabel>

packages/forms/src/elements/input/input.module.scss

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,9 @@
1919
}
2020

2121
.inputText:disabled {
22-
background: $colors-neutral-6;
22+
background: $colors-neutral-2;
23+
border-color: $colors-neutral-6;
24+
cursor: not-allowed;
2325
}
2426

2527
.inputText-error {

packages/forms/src/elements/number/number.mdx

Lines changed: 35 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,15 +12,35 @@ import { renderFields } from '../../renderFields';
1212

1313
# Number Input
1414

15+
Enter a number within certain range with the mouse or keyboard.
16+
17+
## When To Use
18+
19+
- When a numeric value needs to be provided
20+
1521
## Usage
1622

23+
`Inside your React project directory, run the following:`
24+
1725
```js
18-
import { Form, FFInputNumber } from '@tpr/forms';
26+
yarn add @tpr/forms
1927
```
2028

21-
[CodeSandbox](https://codesandbox.io)
29+
`or with npm`
2230

23-
Example using field level validation
31+
```js
32+
npm install @tpr/forms
33+
```
34+
35+
`import items you wish to use from the library`
36+
37+
```js
38+
import { FFInputNumber } from '@tpr/forms';
39+
```
40+
41+
## Examples
42+
43+
[CodeSandbox](https://codesandbox.io)
2444

2545
<Playground>
2646
<Form onSubmit={(values) => console.log(values)}>
@@ -81,3 +101,15 @@ import { Form, validate, renderFields } from '@tpr/forms';
81101
);
82102
}}
83103
</Playground>
104+
105+
## API
106+
107+
### Props
108+
109+
| Property | Required | Type | Description |
110+
| -------- | -------- | ------- | -------------------------------------------- |
111+
| cfg | false | object | FlexProps & SpaceProps |
112+
| disabled | false | boolean | Disable checkbox |
113+
| testId | false | string | data attribute for testers |
114+
| label | true | string | Checkbox description |
115+
| hint | false | string | More detailed description about the checkbox |

packages/forms/src/elements/radio/radio.mdx

Lines changed: 37 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -8,23 +8,36 @@ import { Playground } from '@playground';
88
import { Form } from 'react-final-form';
99
import { FFRadioButton } from './radio';
1010

11-
# Radio Button
11+
# Radio
12+
13+
Radio.
14+
15+
## When To Use
16+
17+
- Used to select a single state from multiple options.
18+
- The difference from Select is that Radio is visible to the user and can facilitate the comparison of choice, which means there shouldn't be too many of them.
1219

1320
## Usage
1421

22+
`Inside your React project directory, run the following:`
23+
1524
```js
16-
import { FFRadioButton } from '@tpr/forms';
25+
yarn add @tpr/forms
1726
```
1827

19-
## Usage
28+
`or with npm`
29+
30+
```js
31+
npm install @tpr/forms
32+
```
2033

21-
Lorem ipsum dolor sit amet consectetur adipisicing elit. Ipsum nostrum omnis ea unde totam, est
22-
consectetur odio! Harum vitae, sed totam aperiam consequuntur nostrum repudiandae non nemo porro,
23-
dolorem nulla corrupti hic consectetur eaque fuga illo numquam modi similique ipsam recusandae! Harum,
24-
possimus suscipit. Quibusdam totam, fugiat officiis qui nisi tempora. Accusantium corrupti similique
25-
et at ipsum, eveniet tempore nostrum quasi est unde modi impedit quaerat suscipit aspernatur ratione
26-
quo corporis? Cum dignissimos adipisci itaque sint tempore, saepe dolorem fugit quia placeat officiis
27-
earum rerum aspernatur similique commodi voluptates? Id ut ab cum doloremque magnam illo ipsa officia nulla ipsum.
34+
`import items you wish to use from the library`
35+
36+
```js
37+
import { FFRadioButton } from '@tpr/forms';
38+
```
39+
40+
## Examples
2841

2942
[CodeSandbox](https://codesandbox.io/s/lively-wood-rxcpu)
3043

@@ -75,3 +88,17 @@ earum rerum aspernatur similique commodi voluptates? Id ut ab cum doloremque mag
7588
);
7689
}}
7790
</Playground>
91+
92+
## API
93+
94+
### Props
95+
96+
| Property | Required | Type | Description |
97+
| -------- | -------- | -------------------- | --------------------------------------------------------------- |
98+
| cfg | false | object | FlexProps & SpaceProps |
99+
| disabled | false | boolean | Disable checkbox |
100+
| testId | false | string | data attribute for testers |
101+
| checked | true | boolean | Specifies whether the checkbox is selected. |
102+
| onChange | true | function(evt: Event) | The callback function that is triggered when the state changes. |
103+
| label | true | string | Checkbox description |
104+
| hint | false | string | More detailed description about the checkbox |

0 commit comments

Comments
 (0)