Skip to content

Commit 6bb81e3

Browse files
Merge branch 'migtools:main' into main
2 parents a404ee1 + 0cb74ce commit 6bb81e3

File tree

10 files changed

+52
-238
lines changed

10 files changed

+52
-238
lines changed

src/components/LabelCustomColor/LabelCustomColor.stories.mdx

Lines changed: 0 additions & 56 deletions
This file was deleted.

src/components/LabelCustomColor/LabelCustomColor.stories.tsx

Lines changed: 0 additions & 79 deletions
This file was deleted.

src/components/LabelCustomColor/LabelCustomColor.tsx

Lines changed: 0 additions & 71 deletions
This file was deleted.

src/components/LabelCustomColor/index.ts

Lines changed: 0 additions & 1 deletion
This file was deleted.

src/hooks/useStorage/useLocalStorage.stories.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ and it supports TypeScript [generics](https://www.typescriptlang.org/docs/handbo
3333
infer its return types based on the `defaultValue`.
3434

3535
```ts
36-
const [value, setValue] = useLocalStorage<T>(key: string, defaultValue: T);
36+
const [value, setValue] = useLocalStorage<T>({ key: string, defaultValue: T });
3737
```
3838

3939
## Notes

src/hooks/useStorage/useLocalStorage.stories.tsx

Lines changed: 22 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ import { ValidatedTextInput } from '../../components/ValidatedTextInput';
2020
import TimesIcon from '@patternfly/react-icons/dist/esm/icons/times-icon';
2121

2222
export const PersistentCounterExample: React.FunctionComponent = () => {
23-
const [count, setCount] = useLocalStorage('exampleCounter', 0);
23+
const [count, setCount] = useLocalStorage({ key: 'exampleCounter', defaultValue: 0 });
2424
return (
2525
<NumberInput
2626
value={count}
@@ -36,7 +36,7 @@ export const PersistentCounterExample: React.FunctionComponent = () => {
3636
};
3737

3838
export const PersistentTextFieldExample: React.FunctionComponent = () => {
39-
const [value, setValue] = useLocalStorage('exampleTextField', '');
39+
const [value, setValue] = useLocalStorage({ key: 'exampleTextField', defaultValue: '' });
4040
return (
4141
<TextInput
4242
aria-label="Persistent text field example input"
@@ -47,7 +47,10 @@ export const PersistentTextFieldExample: React.FunctionComponent = () => {
4747
};
4848

4949
export const PersistentCheckboxExample: React.FunctionComponent = () => {
50-
const [isChecked, setIsChecked] = useLocalStorage('exampleCheckboxChecked', false);
50+
const [isChecked, setIsChecked] = useLocalStorage({
51+
key: 'exampleCheckboxChecked',
52+
defaultValue: false,
53+
});
5154
return (
5255
<Checkbox
5356
id="checkbox-example"
@@ -60,7 +63,10 @@ export const PersistentCheckboxExample: React.FunctionComponent = () => {
6063

6164
export const WelcomeModalExample: React.FunctionComponent = () => {
6265
const ExamplePage: React.FunctionComponent = () => {
63-
const [isModalDisabled, setIsModalDisabled] = useLocalStorage('welcomeModalDisabled', false);
66+
const [isModalDisabled, setIsModalDisabled] = useLocalStorage({
67+
key: 'welcomeModalDisabled',
68+
defaultValue: false,
69+
});
6470
const [isModalOpen, setIsModalOpen] = React.useState(!isModalDisabled);
6571
return (
6672
<>
@@ -121,7 +127,10 @@ export const WelcomeModalExample: React.FunctionComponent = () => {
121127
export const ReusedKeyExample: React.FunctionComponent = () => {
122128
// In a real app each of these components would be in separate files.
123129
const ComponentA: React.FunctionComponent = () => {
124-
const [value, setValue] = useLocalStorage('exampleReusedKey', 'default value here');
130+
const [value, setValue] = useLocalStorage({
131+
key: 'exampleReusedKey',
132+
defaultValue: 'default value here',
133+
});
125134
return (
126135
<div className={spacing.mbLg}>
127136
<TextContent className={spacing.mbSm}>
@@ -136,7 +145,10 @@ export const ReusedKeyExample: React.FunctionComponent = () => {
136145
);
137146
};
138147
const ComponentB: React.FunctionComponent = () => {
139-
const [value] = useLocalStorage('exampleReusedKey', 'default value here');
148+
const [value] = useLocalStorage({
149+
key: 'exampleReusedKey',
150+
defaultValue: 'default value here',
151+
});
140152
return (
141153
<div className={spacing.mbLg}>
142154
<TextContent className={spacing.mbSm}>
@@ -157,7 +169,8 @@ export const ReusedKeyExample: React.FunctionComponent = () => {
157169

158170
export const CustomHookExample: React.FunctionComponent = () => {
159171
// This could be exported from its own file and imported in multiple component files.
160-
const useMyStoredValue = () => useLocalStorage('myStoredValue', 'default defined once');
172+
const useMyStoredValue = () =>
173+
useLocalStorage({ key: 'myStoredValue', defaultValue: 'default defined once' });
161174

162175
// In a real app each of these components would be in separate files.
163176
const ComponentA: React.FunctionComponent = () => {
@@ -176,7 +189,7 @@ export const CustomHookExample: React.FunctionComponent = () => {
176189
);
177190
};
178191
const ComponentB: React.FunctionComponent = () => {
179-
const [value] = useLocalStorage('exampleReusedKey', 'default value here');
192+
const [value] = useMyStoredValue();
180193
return (
181194
<div className={spacing.mbLg}>
182195
<TextContent className={spacing.mbSm}>
@@ -197,7 +210,7 @@ export const CustomHookExample: React.FunctionComponent = () => {
197210

198211
export const ComplexValueExample: React.FunctionComponent = () => {
199212
type Item = { name: string; description?: string };
200-
const [items, setItems] = useLocalStorage<Item[]>('exampleArray', []);
213+
const [items, setItems] = useLocalStorage<Item[]>({ key: 'exampleArray', defaultValue: [] });
201214

202215
const addForm = useFormState({
203216
name: useFormField('', yup.string().required().label('Name')),

src/hooks/useStorage/useSessionStorage.stories.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ and it supports TypeScript [generics](https://www.typescriptlang.org/docs/handbo
2828
infer its return types based on the `defaultValue`.
2929

3030
```ts
31-
const [value, setValue] = useSessionStorage<T>(key: string, defaultValue: T);
31+
const [value, setValue] = useSessionStorage<T>({ key: string, defaultValue: T });
3232
```
3333

3434
## Notes

src/hooks/useStorage/useSessionStorage.stories.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ import { ValidatedTextInput } from '../../components/ValidatedTextInput';
1818
import TimesIcon from '@patternfly/react-icons/dist/esm/icons/times-icon';
1919

2020
export const PersistentCounterExample: React.FunctionComponent = () => {
21-
const [count, setCount] = useSessionStorage('exampleCounter', 0);
21+
const [count, setCount] = useSessionStorage({ key: 'exampleCounter', defaultValue: 0 });
2222
return (
2323
<NumberInput
2424
value={count}
@@ -34,7 +34,7 @@ export const PersistentCounterExample: React.FunctionComponent = () => {
3434
};
3535

3636
export const PersistentTextFieldExample: React.FunctionComponent = () => {
37-
const [value, setValue] = useSessionStorage('exampleTextField', '');
37+
const [value, setValue] = useSessionStorage({ key: 'exampleTextField', defaultValue: '' });
3838
return (
3939
<TextInput
4040
aria-label="Persistent text field example input"
@@ -46,7 +46,7 @@ export const PersistentTextFieldExample: React.FunctionComponent = () => {
4646

4747
export const ComplexValueExample: React.FunctionComponent = () => {
4848
type Item = { name: string; description?: string };
49-
const [items, setItems] = useSessionStorage<Item[]>('exampleArray', []);
49+
const [items, setItems] = useSessionStorage<Item[]>({ key: 'exampleArray', defaultValue: [] });
5050

5151
const addForm = useFormState({
5252
name: useFormField('', yup.string().required().label('Name')),

0 commit comments

Comments
 (0)