|
| 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 from '~components/box'; |
| 6 | +import Container from '~components/container'; |
| 7 | +import Header from '~components/header'; |
| 8 | +import Card from '~components/internal/components/card'; |
| 9 | + |
| 10 | +import ScreenshotArea from '../utils/screenshot-area'; |
| 11 | + |
| 12 | +const getRandomId = () => Math.floor(Math.random() * 1e12).toString(); |
| 13 | + |
| 14 | +const accounts = [ |
| 15 | + { |
| 16 | + accountAlias: 'Account alias', |
| 17 | + accountId: getRandomId(), |
| 18 | + role: 'Dev', |
| 19 | + |
| 20 | + lastLogin: '1 minute ago', |
| 21 | + }, |
| 22 | + { |
| 23 | + accountId: getRandomId(), |
| 24 | + role: 'ReadOnly', |
| 25 | + |
| 26 | + lastLogin: '10 minute ago', |
| 27 | + }, |
| 28 | + { |
| 29 | + accountId: getRandomId(), |
| 30 | + role: 'Root', |
| 31 | + lastLogin: '2 hours ago', |
| 32 | + }, |
| 33 | + { |
| 34 | + accountAlias: 'acme-staging-infra', |
| 35 | + accountId: getRandomId(), |
| 36 | + role: 'Admin', |
| 37 | + |
| 38 | + lastLogin: '3 hours ago', |
| 39 | + }, |
| 40 | + { |
| 41 | + accountAlias: 'acme-prod-monitoring', |
| 42 | + accountId: getRandomId(), |
| 43 | + role: 'PowerUser', |
| 44 | + |
| 45 | + lastLogin: '10 hours ago', |
| 46 | + }, |
| 47 | +]; |
| 48 | + |
| 49 | +export default function ButtonsScenario() { |
| 50 | + const [activeId, setActiveId] = useState<string>(); |
| 51 | + return ( |
| 52 | + <article> |
| 53 | + <h1>Action card: list selection</h1> |
| 54 | + <ScreenshotArea> |
| 55 | + <div style={{ inlineSize: 550, marginInline: 'auto' }}> |
| 56 | + <Container header={<Header variant="h2">Choose an active session</Header>}> |
| 57 | + <ol style={{ display: 'flex', flexDirection: 'column', gap: 16, margin: 0, padding: 0 }}> |
| 58 | + {accounts.map(({ accountAlias, accountId, role, email, lastLogin }) => ( |
| 59 | + <Card |
| 60 | + tagName="li" |
| 61 | + header={accountAlias ? `${accountAlias} (${accountId})` : `Account ID: ${accountId}`} |
| 62 | + description={[role, email].filter(Boolean).join('/')} |
| 63 | + key={accountId} |
| 64 | + variant="action" |
| 65 | + active={activeId === accountId} |
| 66 | + onClick={() => setActiveId(accountId)} |
| 67 | + > |
| 68 | + <Box color="text-body-secondary" fontSize="body-s">{`Logged in ${lastLogin}`}</Box> |
| 69 | + </Card> |
| 70 | + ))} |
| 71 | + </ol> |
| 72 | + </Container> |
| 73 | + </div> |
| 74 | + </ScreenshotArea> |
| 75 | + </article> |
| 76 | + ); |
| 77 | +} |
0 commit comments