-
Notifications
You must be signed in to change notification settings - Fork 285
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(react): Add IconsProvider (#4268)
- Loading branch information
1 parent
29775e2
commit f8c5b77
Showing
76 changed files
with
1,509 additions
and
333 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
--- | ||
"@aws-amplify/ui-react-storage": minor | ||
"@aws-amplify/ui-react": minor | ||
--- | ||
|
||
feat(react): Add IconsProvider to customize icons globally for all Amplify UI components | ||
|
||
Components that use icons: | ||
* Alert | ||
* Checkbox | ||
* Expander | ||
* Field | ||
* Menu | ||
* Pagination | ||
* PasswordField | ||
* Rating | ||
* SearchField | ||
* Select | ||
* StepperField | ||
* StorageManager | ||
|
||
Wrap your application with the `<IconsProvider>` (or whatever part of your app you want to customize the icons). | ||
|
||
```jsx | ||
<IconsProvider icons={{ | ||
alert: { | ||
info: <MdInfo /> | ||
} | ||
}}> | ||
{/* ... */} | ||
</IconProvider> | ||
``` | ||
|
||
Works well with the react-icons package! |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
33 changes: 33 additions & 0 deletions
33
docs/src/pages/[platform]/components/alert/examples/AlertIconProviderExample.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
import { Alert, Flex, IconsProvider } from '@aws-amplify/ui-react'; | ||
import { | ||
FcMediumPriority, | ||
FcHighPriority, | ||
FcInfo, | ||
FcOk, | ||
FcMinus, | ||
} from 'react-icons/fc'; | ||
|
||
export const AlertIconProviderExample = () => ( | ||
<IconsProvider | ||
icons={{ | ||
alert: { | ||
info: <FcInfo />, | ||
success: <FcOk />, | ||
error: <FcHighPriority />, | ||
warning: <FcMediumPriority />, | ||
close: <FcMinus />, | ||
}, | ||
}} | ||
> | ||
<Flex direction="column"> | ||
<Alert variation="info" heading="Info"> | ||
Here is some info | ||
</Alert> | ||
<Alert variation="success" heading="Success" isDismissible> | ||
Hooray! | ||
</Alert> | ||
<Alert variation="warning" heading="Warning" /> | ||
<Alert variation="error" heading="Error" /> | ||
</Flex> | ||
</IconsProvider> | ||
); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
18 changes: 18 additions & 0 deletions
18
docs/src/pages/[platform]/components/checkboxfield/examples/CheckboxFieldIconExample.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
import { CheckboxField, Flex, IconsProvider } from '@aws-amplify/ui-react'; | ||
import { HiMinus, HiCheck } from 'react-icons/hi'; | ||
|
||
export const CheckboxFieldIconExample = () => ( | ||
<IconsProvider | ||
icons={{ | ||
checkbox: { | ||
checked: <HiCheck />, | ||
indeterminate: <HiMinus />, | ||
}, | ||
}} | ||
> | ||
<Flex direction="column"> | ||
<CheckboxField name="cat" label="Cat" value="cat" defaultChecked={true} /> | ||
<CheckboxField name="dog" label="Dog" value="dog" isIndeterminate /> | ||
</Flex> | ||
</IconsProvider> | ||
); |
1 change: 1 addition & 0 deletions
1
docs/src/pages/[platform]/components/checkboxfield/examples/index.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
18 changes: 18 additions & 0 deletions
18
docs/src/pages/[platform]/components/menu/examples/MenuIconExample.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
import { Menu, MenuItem, IconsProvider } from '@aws-amplify/ui-react'; | ||
import { FiMoreHorizontal } from 'react-icons/fi'; | ||
|
||
export const MenuIconExample = () => ( | ||
<IconsProvider | ||
icons={{ | ||
menu: { | ||
menu: <FiMoreHorizontal />, | ||
}, | ||
}} | ||
> | ||
<Menu> | ||
<MenuItem>Download</MenuItem> | ||
<MenuItem>Create a Copy</MenuItem> | ||
<MenuItem>Mark as Draft</MenuItem> | ||
</Menu> | ||
</IconsProvider> | ||
); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
23 changes: 23 additions & 0 deletions
23
docs/src/pages/[platform]/components/pagination/examples/PaginationIconExample.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
import { | ||
Pagination, | ||
usePagination, | ||
IconsProvider, | ||
} from '@aws-amplify/ui-react'; | ||
import { FiArrowLeft, FiArrowRight } from 'react-icons/fi'; | ||
|
||
export const PaginationIconExample = () => { | ||
const paginationProps = usePagination({ totalPages: 6 }); | ||
|
||
return ( | ||
<IconsProvider | ||
icons={{ | ||
pagination: { | ||
next: <FiArrowRight />, | ||
previous: <FiArrowLeft />, | ||
}, | ||
}} | ||
> | ||
<Pagination {...paginationProps} /> | ||
</IconsProvider> | ||
); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.