Skip to content

Commit d3e0ba3

Browse files
authored
chore(docs): update storage browser to include components override.git (#6684)
1 parent 3e9570b commit d3e0ba3

File tree

3 files changed

+85
-0
lines changed

3 files changed

+85
-0
lines changed
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
import React from 'react';
2+
import {
3+
createStorageBrowser,
4+
CreateStorageBrowserInput,
5+
} from '@aws-amplify/ui-react-storage/browser';
6+
import { Breadcrumbs, View, Text, Loader } from '@aws-amplify/ui-react';
7+
import { mockConfig } from './mockConfig';
8+
import { defaultActions } from './defaultActions';
9+
10+
const components: CreateStorageBrowserInput['components'] = {
11+
Navigation: ({ items }) => (
12+
<Breadcrumbs.Container>
13+
{items.map(({ isCurrent, name, onNavigate }) => (
14+
<Breadcrumbs.Item key={name}>
15+
<Breadcrumbs.Link isCurrent={isCurrent} onClick={onNavigate}>
16+
🏠 {name}
17+
</Breadcrumbs.Link>
18+
</Breadcrumbs.Item>
19+
))}
20+
</Breadcrumbs.Container>
21+
),
22+
23+
LoadingIndicator: ({ isLoading }) =>
24+
isLoading ? (
25+
<View textAlign="center" padding="large">
26+
<Loader size="large" />
27+
<Text>⏳ Loading your files...</Text>
28+
</View>
29+
) : null,
30+
31+
Title: ({ title }) => (
32+
<Text fontSize="xl" fontWeight="bold" color="brand.primary.80">
33+
📁 {title}
34+
</Text>
35+
),
36+
};
37+
38+
const { StorageBrowser } = createStorageBrowser({
39+
config: mockConfig,
40+
actions: { default: defaultActions },
41+
components, // Pass custom components here
42+
});
43+
44+
export default function Example() {
45+
return <StorageBrowser />;
46+
}

docs/src/pages/[platform]/connected-components/storage/storage-browser/examples/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,3 +8,4 @@ export { default as Theming } from './Theming';
88
export { default as Icons } from './Icons';
99
export { default as Default } from './Default';
1010
export { default as GenerateUrlViewComposed } from './GenerateUrlViewComposed';
11+
export { default as ComponentOverride } from './ComponentOverride';

docs/src/pages/[platform]/connected-components/storage/storage-browser/react.mdx

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import {
1111
Theming,
1212
Icons,
1313
GenerateUrlViewComposed,
14+
ComponentOverride,
1415
} from './examples'
1516

1617

@@ -313,6 +314,43 @@ You can use the `<IconsProvider>` to customize the icons used in the `StorageBro
313314
</ExampleCode>
314315
</Example>
315316

317+
### Component Override
318+
319+
You can override any of the default components used in Storage Browser by passing custom components to the `components` prop of `createStorageBrowser`. When you provide a component (e.g., `Navigation`, `DataTable`, `SearchField`), it will completely replace the default implementation.
320+
321+
322+
<Example>
323+
<ComponentOverride />
324+
<ExampleCode>
325+
```jsx file=./examples/ComponentOverride.tsx
326+
```
327+
</ExampleCode>
328+
</Example>
329+
330+
**Available Components to Override:**
331+
- `ActionCancel`
332+
- `ActionDestination`
333+
- `ActionExit`
334+
- `ActionStart`
335+
- `ActionsList`
336+
- `AddFiles`
337+
- `AddFolder`
338+
- `DataRefresh`
339+
- `DataTable`
340+
- `DropZone`
341+
- `FolderNameField`
342+
- `LoadingIndicator`
343+
- `Message`
344+
- `Navigation`
345+
- `OverwriteToggle`
346+
- `Pagination`
347+
- `SearchField`
348+
- `SearchSubfoldersToggle`
349+
- `StatusDisplay`
350+
- `Title`
351+
352+
Each component receives the same props as the default implementation, so you can access all the data and callbacks.
353+
316354
### Display Text
317355

318356
You can customize all of the text (except S3 data like keys and bucket names) used in Storage Browser by using the `displayText` prop which is a nested object organized by view. You don't need to provide an entire object; the `StorageBrowser` component will merge your input with the default strings. Some texts are plain strings and others are are functions that take some input, like a date, and return a string.

0 commit comments

Comments
 (0)