|
| 1 | +// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. |
| 2 | +// SPDX-License-Identifier: Apache-2.0 |
| 3 | +import React, { useState } from 'react'; |
| 4 | + |
| 5 | +import { Box, Button, Input, SpaceBetween } from '~components'; |
| 6 | +import AttributeEditor from '~components/attribute-editor'; |
| 7 | + |
| 8 | +import ScreenshotArea from '../utils/screenshot-area'; |
| 9 | + |
| 10 | +export default function AttributeEditorPage() { |
| 11 | + const [items] = useState([ |
| 12 | + { key: 'example', value: 'value' }, |
| 13 | + { key: 'example 2', value: 'value 2' }, |
| 14 | + ]); |
| 15 | + |
| 16 | + const definition = [ |
| 17 | + { |
| 18 | + label: 'Key', |
| 19 | + control: ({ key = '' }) => <Input value={key} readOnly={true} />, |
| 20 | + }, |
| 21 | + { |
| 22 | + label: 'Value', |
| 23 | + control: ({ value = '' }) => <Input value={value} readOnly={true} />, |
| 24 | + }, |
| 25 | + ]; |
| 26 | + |
| 27 | + return ( |
| 28 | + <Box margin="xl"> |
| 29 | + <h1>Attribute Editor - Additional Actions</h1> |
| 30 | + <ScreenshotArea> |
| 31 | + <SpaceBetween size="m"> |
| 32 | + <AttributeEditor |
| 33 | + addButtonText={'Add Item'} |
| 34 | + hideAddButton={false} |
| 35 | + additionalActions={[ |
| 36 | + <Button key="import" variant="normal"> |
| 37 | + Import |
| 38 | + </Button>, |
| 39 | + <Button key="export" variant="normal"> |
| 40 | + Export |
| 41 | + </Button>, |
| 42 | + <Button key="long-text" variant="normal"> |
| 43 | + A very long button text to try out wrapping to a second row |
| 44 | + </Button>, |
| 45 | + ]} |
| 46 | + items={items} |
| 47 | + definition={definition} |
| 48 | + removeButtonText="Remove" |
| 49 | + empty="No items" |
| 50 | + /> |
| 51 | + <AttributeEditor |
| 52 | + addButtonText={'Add Item'} |
| 53 | + hideAddButton={true} |
| 54 | + additionalActions={[ |
| 55 | + <Button key="import" variant="primary"> |
| 56 | + Import |
| 57 | + </Button>, |
| 58 | + <Button key="export" variant="normal"> |
| 59 | + Export |
| 60 | + </Button>, |
| 61 | + <Button key="long-text" variant="normal"> |
| 62 | + A very long button text to try out wrapping to a second row |
| 63 | + </Button>, |
| 64 | + ]} |
| 65 | + items={items} |
| 66 | + definition={definition} |
| 67 | + removeButtonText="Remove" |
| 68 | + empty="No items" |
| 69 | + /> |
| 70 | + <AttributeEditor |
| 71 | + addButtonText={'Add Item'} |
| 72 | + hideAddButton={true} |
| 73 | + items={items} |
| 74 | + definition={definition} |
| 75 | + removeButtonText="Remove" |
| 76 | + empty="No items" |
| 77 | + /> |
| 78 | + </SpaceBetween> |
| 79 | + </ScreenshotArea> |
| 80 | + </Box> |
| 81 | + ); |
| 82 | +} |
0 commit comments