-
Notifications
You must be signed in to change notification settings - Fork 170
/
Copy pathfull-page-cards.page.tsx
110 lines (100 loc) · 2.87 KB
/
full-page-cards.page.tsx
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
// SPDX-License-Identifier: Apache-2.0
import React, { useState } from 'react';
import range from 'lodash/range';
import { AppLayoutToolbar } from '~components';
import Button from '~components/button';
import Cards, { CardsProps } from '~components/cards';
import Header from '~components/header';
import Link from '~components/link';
import * as toolsContent from '../app-layout//utils/tools-content';
import { Breadcrumbs, Footer, Navigation, Notifications, Tools } from '../app-layout/utils/content-blocks';
import labels from '../app-layout/utils/labels';
import ScreenshotArea from '../utils/screenshot-area';
interface Item {
number: number;
text: string;
}
function createSimpleItems(count: number) {
const texts = ['One', 'Two', 'Three', 'Four', 'Five'];
return range(count).map(number => ({ number, text: texts[number % texts.length] }));
}
const cardDefinition: CardsProps.CardDefinition<Item> = {
header: item => item.text,
sections: [
{
id: 'description',
header: 'Number',
content: item => item.number,
},
{
id: 'type',
header: 'Text',
content: item => item.text,
},
],
};
const config: CardsProps['cardsPerRow'] = [
{
cards: 1,
},
{
minWidth: 400,
cards: 2,
},
{
cards: 3,
minWidth: 700,
},
{
cards: 4,
minWidth: 1000,
},
];
const items = createSimpleItems(16);
export default function () {
const [toolsOpen, setToolsOpen] = useState(false);
const [selectedTool, setSelectedTool] = useState<keyof typeof toolsContent>('long');
function openHelp(article: keyof typeof toolsContent) {
setToolsOpen(true);
setSelectedTool(article);
}
return (
<ScreenshotArea gutters={false}>
<AppLayoutToolbar
ariaLabels={labels}
breadcrumbs={<Breadcrumbs />}
navigation={<Navigation />}
contentType="cards"
tools={<Tools>{toolsContent[selectedTool]}</Tools>}
toolsOpen={toolsOpen}
onToolsChange={({ detail }) => setToolsOpen(detail.open)}
notifications={<Notifications />}
content={
<Cards<Item>
items={items}
cardDefinition={cardDefinition}
stickyHeader={true}
variant="full-page"
header={
<Header
variant="awsui-h1-sticky"
description="Demo page with footer"
info={
<Link variant="info" onFollow={() => openHelp('long')}>
Long help text
</Link>
}
actions={<Button variant="primary">Create</Button>}
>
Sticky Scrollbar Example
</Header>
}
cardsPerRow={config}
/>
}
/>
<Footer legacyConsoleNav={false} />
</ScreenshotArea>
);
}