Skip to content

Commit

Permalink
Merge branch 'migtools:main' into main
Browse files Browse the repository at this point in the history
  • Loading branch information
wise-king-sullyman authored Oct 10, 2023
2 parents a404ee1 + 0cb74ce commit 6bb81e3
Show file tree
Hide file tree
Showing 10 changed files with 52 additions and 238 deletions.
56 changes: 0 additions & 56 deletions src/components/LabelCustomColor/LabelCustomColor.stories.mdx

This file was deleted.

79 changes: 0 additions & 79 deletions src/components/LabelCustomColor/LabelCustomColor.stories.tsx

This file was deleted.

71 changes: 0 additions & 71 deletions src/components/LabelCustomColor/LabelCustomColor.tsx

This file was deleted.

1 change: 0 additions & 1 deletion src/components/LabelCustomColor/index.ts

This file was deleted.

2 changes: 1 addition & 1 deletion src/hooks/useStorage/useLocalStorage.stories.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ and it supports TypeScript [generics](https://www.typescriptlang.org/docs/handbo
infer its return types based on the `defaultValue`.

```ts
const [value, setValue] = useLocalStorage<T>(key: string, defaultValue: T);
const [value, setValue] = useLocalStorage<T>({ key: string, defaultValue: T });
```

## Notes
Expand Down
31 changes: 22 additions & 9 deletions src/hooks/useStorage/useLocalStorage.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ import { ValidatedTextInput } from '../../components/ValidatedTextInput';
import TimesIcon from '@patternfly/react-icons/dist/esm/icons/times-icon';

export const PersistentCounterExample: React.FunctionComponent = () => {
const [count, setCount] = useLocalStorage('exampleCounter', 0);
const [count, setCount] = useLocalStorage({ key: 'exampleCounter', defaultValue: 0 });
return (
<NumberInput
value={count}
Expand All @@ -36,7 +36,7 @@ export const PersistentCounterExample: React.FunctionComponent = () => {
};

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

export const PersistentCheckboxExample: React.FunctionComponent = () => {
const [isChecked, setIsChecked] = useLocalStorage('exampleCheckboxChecked', false);
const [isChecked, setIsChecked] = useLocalStorage({
key: 'exampleCheckboxChecked',
defaultValue: false,
});
return (
<Checkbox
id="checkbox-example"
Expand All @@ -60,7 +63,10 @@ export const PersistentCheckboxExample: React.FunctionComponent = () => {

export const WelcomeModalExample: React.FunctionComponent = () => {
const ExamplePage: React.FunctionComponent = () => {
const [isModalDisabled, setIsModalDisabled] = useLocalStorage('welcomeModalDisabled', false);
const [isModalDisabled, setIsModalDisabled] = useLocalStorage({
key: 'welcomeModalDisabled',
defaultValue: false,
});
const [isModalOpen, setIsModalOpen] = React.useState(!isModalDisabled);
return (
<>
Expand Down Expand Up @@ -121,7 +127,10 @@ export const WelcomeModalExample: React.FunctionComponent = () => {
export const ReusedKeyExample: React.FunctionComponent = () => {
// In a real app each of these components would be in separate files.
const ComponentA: React.FunctionComponent = () => {
const [value, setValue] = useLocalStorage('exampleReusedKey', 'default value here');
const [value, setValue] = useLocalStorage({
key: 'exampleReusedKey',
defaultValue: 'default value here',
});
return (
<div className={spacing.mbLg}>
<TextContent className={spacing.mbSm}>
Expand All @@ -136,7 +145,10 @@ export const ReusedKeyExample: React.FunctionComponent = () => {
);
};
const ComponentB: React.FunctionComponent = () => {
const [value] = useLocalStorage('exampleReusedKey', 'default value here');
const [value] = useLocalStorage({
key: 'exampleReusedKey',
defaultValue: 'default value here',
});
return (
<div className={spacing.mbLg}>
<TextContent className={spacing.mbSm}>
Expand All @@ -157,7 +169,8 @@ export const ReusedKeyExample: React.FunctionComponent = () => {

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

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

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

const addForm = useFormState({
name: useFormField('', yup.string().required().label('Name')),
Expand Down
2 changes: 1 addition & 1 deletion src/hooks/useStorage/useSessionStorage.stories.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ and it supports TypeScript [generics](https://www.typescriptlang.org/docs/handbo
infer its return types based on the `defaultValue`.

```ts
const [value, setValue] = useSessionStorage<T>(key: string, defaultValue: T);
const [value, setValue] = useSessionStorage<T>({ key: string, defaultValue: T });
```

## Notes
Expand Down
6 changes: 3 additions & 3 deletions src/hooks/useStorage/useSessionStorage.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import { ValidatedTextInput } from '../../components/ValidatedTextInput';
import TimesIcon from '@patternfly/react-icons/dist/esm/icons/times-icon';

export const PersistentCounterExample: React.FunctionComponent = () => {
const [count, setCount] = useSessionStorage('exampleCounter', 0);
const [count, setCount] = useSessionStorage({ key: 'exampleCounter', defaultValue: 0 });
return (
<NumberInput
value={count}
Expand All @@ -34,7 +34,7 @@ export const PersistentCounterExample: React.FunctionComponent = () => {
};

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

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

const addForm = useFormState({
name: useFormField('', yup.string().required().label('Name')),
Expand Down
Loading

0 comments on commit 6bb81e3

Please sign in to comment.