|
| 1 | +// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. |
| 2 | +// SPDX-License-Identifier: Apache-2.0 |
| 3 | +import React from 'react'; |
| 4 | + |
| 5 | +import { Button, Container, Link, Select, SpaceBetween } from '~components'; |
| 6 | +import Header, { HeaderProps } from '~components/header'; |
| 7 | + |
| 8 | +import ScreenshotArea from '../utils/screenshot-area'; |
| 9 | + |
| 10 | +const variants: HeaderProps.Variant[] = ['h1', 'h2', 'h3', 'awsui-h1-sticky']; |
| 11 | + |
| 12 | +const secondaryContent = ( |
| 13 | + <Select |
| 14 | + ariaLabel="Time range" |
| 15 | + selectedOption={{ value: '1h', label: 'Last hour' }} |
| 16 | + options={[{ value: '1h', label: 'Last hour' }]} |
| 17 | + onChange={() => {}} |
| 18 | + /> |
| 19 | +); |
| 20 | + |
| 21 | +const actions = ( |
| 22 | + <SpaceBetween direction="horizontal" size="xs"> |
| 23 | + <Button>Refresh</Button> |
| 24 | + <Button variant="primary">Create resource</Button> |
| 25 | + </SpaceBetween> |
| 26 | +); |
| 27 | + |
| 28 | +function Row({ variant }: { variant: HeaderProps.Variant }) { |
| 29 | + return ( |
| 30 | + <SpaceBetween size="m"> |
| 31 | + <Header variant={variant} secondaryContent={secondaryContent}> |
| 32 | + Title only |
| 33 | + </Header> |
| 34 | + <Header variant={variant} secondaryContent={secondaryContent} actions={actions}> |
| 35 | + With actions |
| 36 | + </Header> |
| 37 | + <Header |
| 38 | + variant={variant} |
| 39 | + counter="(12)" |
| 40 | + info={<Link variant="info">Info</Link>} |
| 41 | + description="A description shown below the title of this header." |
| 42 | + secondaryContent={secondaryContent} |
| 43 | + actions={actions} |
| 44 | + > |
| 45 | + Counter, info and description |
| 46 | + </Header> |
| 47 | + <Header variant={variant} secondaryContent={secondaryContent} actions={actions}> |
| 48 | + A much longer title that is likely to wrap onto a second line in narrower layouts |
| 49 | + </Header> |
| 50 | + </SpaceBetween> |
| 51 | + ); |
| 52 | +} |
| 53 | + |
| 54 | +export default function HeaderSecondaryContentPage() { |
| 55 | + return ( |
| 56 | + <article> |
| 57 | + <h1>Header - secondary content</h1> |
| 58 | + <ScreenshotArea disableAnimations={true}> |
| 59 | + <SpaceBetween size="xl"> |
| 60 | + {variants.map(variant => ( |
| 61 | + <Container key={variant} header={<Header variant="h3">{`variant="${variant}"`}</Header>}> |
| 62 | + <Row variant={variant} /> |
| 63 | + </Container> |
| 64 | + ))} |
| 65 | + <Container |
| 66 | + header={ |
| 67 | + <Header variant="h2" secondaryContent={secondaryContent} actions={actions}> |
| 68 | + As a container header |
| 69 | + </Header> |
| 70 | + } |
| 71 | + > |
| 72 | + Container content |
| 73 | + </Container> |
| 74 | + </SpaceBetween> |
| 75 | + </ScreenshotArea> |
| 76 | + </article> |
| 77 | + ); |
| 78 | +} |
0 commit comments