Skip to content

Commit 2217c03

Browse files
authored
Update examples to use new RADFish storage architecture (#697)
* Adjust indentation in the TextInput component example. * Adjust indentation and formatting in various examples across multiple README.md files to enhance clarity and maintainability. * Update storage using new version connectors. * Updated README.md to clarify the use of RADFish's storage system for persistent state management. * Update on-device storage example to utilize RADFish's schema-based storage with IndexedDB integration. * Update persisted form example to utilize RADFish's schema-based storage with IndexedDB integration. * Update server sync example to utilize RADFish's schema-based storage with IndexedDB integration. * Remove deprecated storage methods and related classes from the mock API package. * Update @nmfs-radfish/radfish dependency to version 1.1.1 across multiple example packages.
1 parent 21f0a49 commit 2217c03

File tree

38 files changed

+14106
-1076
lines changed

38 files changed

+14106
-1076
lines changed

examples/computed-form-fields/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
"version": "0.11.0",
44
"private": true,
55
"dependencies": {
6-
"@nmfs-radfish/radfish": "^1.0.0",
6+
"@nmfs-radfish/radfish": "^1.1.1",
77
"@nmfs-radfish/react-radfish": "^1.0.0",
88
"@testing-library/user-event": "^14.5.2",
99
"@trussworks/react-uswds": "^9.1.0",

examples/conditional-form-fields/README.md

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ return (
4848
<Form
4949
onSubmit={handleSubmit}
5050
className="maxw-full margin-205 padding-205 bg-white radius-8px shadow-2"
51-
>
51+
>
5252
<FormGroup>
5353
<Label className="text-bold" htmlFor={FULL_NAME}>
5454
Full Name
@@ -59,7 +59,7 @@ return (
5959
type="text"
6060
placeholder="Full Name"
6161
value={formData[FULL_NAME] || ""}
62-
/>
62+
/>
6363
```
6464
6565
### 4. Adding Input Handlers for Form Fields
@@ -95,19 +95,19 @@ Next, we want to conditionally render the `nickname` component. The condition de
9595
9696
```jsx
9797
{
98-
formData[FULL_NAME] && (
99-
<>
100-
<Label htmlFor={NICKNAME}>Nickname</Label>
101-
<TextInput
102-
id={NICKNAME}
103-
name={NICKNAME}
104-
type="text"
105-
placeholder="Nickname"
106-
value={formData[NICKNAME] || ""}
107-
onChange={(event) => handleNickNameChange(event, formData)}
108-
/>
109-
</>
110-
);
98+
formData[FULL_NAME] && (
99+
<>
100+
<Label htmlFor={NICKNAME}>Nickname</Label>
101+
<TextInput
102+
id={NICKNAME}
103+
name={NICKNAME}
104+
type="text"
105+
placeholder="Nickname"
106+
value={formData[NICKNAME] || ""}
107+
onChange={(event) => handleNickNameChange(event, formData)}
108+
/>
109+
</>
110+
)
111111
}
112112
```
113113

examples/conditional-form-fields/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
"version": "0.11.0",
44
"private": true,
55
"dependencies": {
6-
"@nmfs-radfish/radfish": "^1.0.0",
6+
"@nmfs-radfish/radfish": "^1.1.1",
77
"@nmfs-radfish/react-radfish": "^1.0.0",
88
"@testing-library/user-event": "^14.5.2",
99
"@trussworks/react-uswds": "^9.1.0",

examples/field-validators/README.md

Lines changed: 28 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -17,25 +17,25 @@ In this step, we add validation logic to our form inputs using an `onBlur` handl
1717
This function validates the input value. It uses the validation rules and updates the state with any validation errors:
1818
```jsx
1919
const handleBlur = (event, validators) => {
20-
const { name, value } = event.target;
21-
setValidationErrors((prev) => ({
22-
...prev,
23-
...handleInputValidationLogic(name, value, validators),
24-
}));
20+
const { name, value } = event.target;
21+
setValidationErrors((prev) => ({
22+
...prev,
23+
...handleInputValidationLogic(name, value, validators),
24+
}));
2525
};
2626
```
2727

2828
This helper function loops through the provided validators and checks if the input value passes the validation criteria. If not, it returns the appropriate error message:
2929
```jsx
3030
const handleInputValidationLogic = (name, value, validators) => {
31-
if (validators && validators.length > 0) {
32-
for (let validator of validators) {
33-
if (!validator.test(value)) {
34-
return { [name]: validator.message };
35-
}
31+
if (validators && validators.length > 0) {
32+
for (let validator of validators) {
33+
if (!validator.test(value)) {
34+
return { [name]: validator.message };
35+
}
36+
}
3637
}
37-
}
38-
return { [name]: null }; // Clear error if value is valid
38+
return { [name]: null }; // Clear error if value is valid
3939
};
4040
```
4141

@@ -50,7 +50,7 @@ Here’s how to use the onBlur handler in the TextInput component. The input dyn
5050
aria-invalid={validationErrors[FULL_NAME] ? "true" : "false"}
5151
validationStatus={validationErrors[FULL_NAME] ? "error" : undefined}
5252
onChange={handleChange}
53-
onBlur={(e) => handleBlur(e, fullNameValidators)}
53+
onBlur={(e) => handleBlur(e, fullNameValidators)}
5454
/>
5555
```
5656

@@ -60,10 +60,10 @@ We include the validator needed to check the contents of the field input. In thi
6060
```jsx
6161
// utilities/fieldValidators.js
6262
const fullNameValidators = [
63-
{
64-
test: (value) => !/\d/.test(value) || value === "",
65-
message: "Full Name should not contain numbers.",
66-
},
63+
{
64+
test: (value) => !/\d/.test(value) || value === "",
65+
message: "Full Name should not contain numbers.",
66+
},
6767
];
6868

6969
export { fullNameValidators };
@@ -77,17 +77,17 @@ We can update the properties on our input so the validation logic gets triggered
7777

7878
```jsx
7979
<TextInput
80-
id={FULL_NAME}
81-
name={FULL_NAME}
82-
type="text"
83-
placeholder="Full Name"
84-
value={formData[FULL_NAME] || ""}
85-
aria-invalid={validationErrors[FULL_NAME] ? "true" : "false"}
86-
validationStatus={validationErrors[FULL_NAME] ? "error" : undefined}
87-
onChange={handleChange}
88-
onBlur={(e) => handleBlur(e, fullNameValidators)}
89-
/>;
80+
id={FULL_NAME}
81+
name={FULL_NAME}
82+
type="text"
83+
placeholder="Full Name"
84+
value={formData[FULL_NAME] || ""}
85+
aria-invalid={validationErrors[FULL_NAME] ? "true" : "false"}
86+
validationStatus={validationErrors[FULL_NAME] ? "error" : undefined}
87+
onChange={handleChange}
88+
onBlur={(e) => handleBlur(e, fullNameValidators)}
89+
/>
9090
{
91-
validationErrors[FULL_NAME] && <ErrorMessage>{validationErrors[FULL_NAME]}</ErrorMessage>;
91+
validationErrors[FULL_NAME] && <ErrorMessage>{validationErrors[FULL_NAME]}</ErrorMessage>
9292
}
9393
```

examples/field-validators/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
"version": "0.11.0",
44
"private": true,
55
"dependencies": {
6-
"@nmfs-radfish/radfish": "^1.0.0",
6+
"@nmfs-radfish/radfish": "^1.1.1",
77
"@nmfs-radfish/react-radfish": "^1.0.0",
88
"@testing-library/user-event": "^14.5.2",
99
"@trussworks/react-uswds": "^9.1.0",

examples/form-structure/README.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ Use Trussworks `Grid` components to define the layout of your page in `src/pages
2121
<Grid row>
2222
<Grid col>
2323
<p className="text-bold text-center">
24-
Private Recreational Tilefish
24+
Private Recreational Tilefish
2525
</p>
2626
</Grid>
2727
</Grid>
@@ -83,7 +83,7 @@ const inputFocus = useRef(null);
8383
useEffect(() => {
8484
if (inputFocus.current) {
8585
inputFocus.current.focus(); // Set focus on the input field
86-
};
86+
}
8787
setResetToggle(false); // Reset the toggle state
8888
}, [resetToggle]);
8989

@@ -114,6 +114,6 @@ const handleSubmit = (event) => {
114114
// Reset for after triggering Submit
115115
event.target.reset();
116116
// Set focus on first input after form is submitted.
117-
setResetToggle(true)
118-
}
117+
setResetToggle(true);
118+
};
119119
```

examples/form-structure/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"name": "form-structure-example",
33
"version": "0.11.0",
44
"dependencies": {
5-
"@nmfs-radfish/radfish": "^1.0.0",
5+
"@nmfs-radfish/radfish": "^1.1.1",
66
"@nmfs-radfish/react-radfish": "^1.0.0",
77
"@testing-library/user-event": "^14.5.2",
88
"@trussworks/react-uswds": "^9.1.0",

0 commit comments

Comments
 (0)