forked from adobe/react-spectrum
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathApp.js
64 lines (59 loc) · 2.16 KB
/
App.js
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
import './App.css';
import {Provider, defaultTheme, Item, TagGroup, Cell, Column, Row, TableBody, TableHeader, TableView, Content, Heading} from '@adobe/react-spectrum';
import Lighting from './Lighting';
import {useState} from 'react'
import BodyContent from './BodyContent';
import {enableTableNestedRows} from '@react-stately/flags';
import {InlineAlert} from '@react-spectrum/inlinealert'
let columns = [
{name: 'Foo', key: 'foo'},
{name: 'Bar', key: 'bar'},
{name: 'Baz', key: 'baz'}
];
let nestedItems = [
{foo: 'Lvl 1 Foo 1', bar: 'Lvl 1 Bar 1', baz: 'Lvl 1 Baz 1', childRows: [
{foo: 'Lvl 2 Foo 1', bar: 'Lvl 2 Bar 1', baz: 'Lvl 2 Baz 1', childRows: [
{foo: 'Lvl 3 Foo 1', bar: 'Lvl 3 Bar 1', baz: 'Lvl 3 Baz 1'}
]},
{foo: 'Lvl 2 Foo 2', bar: 'Lvl 2 Bar 2', baz: 'Lvl 2 Baz 2'}
]}
];
function App() {
let [selected, setSelection] = useState(false);
enableTableNestedRows();
return (
<Provider theme={defaultTheme}
colorScheme={selected ? "light" : "dark"}
height="100%">
<div className="content-padding">
<Lighting selected={selected} switch={setSelection} />
<TagGroup aria-label="Static TagGroup items example">
<Item>News</Item>
<Item>Travel</Item>
<Item>Gaming</Item>
<Item>Shopping</Item>
</TagGroup>
<BodyContent />
<TableView aria-label="example table with nested rows" UNSTABLE_allowsExpandableRows width={500} height={200} >
<TableHeader columns={columns}>
{column => <Column>{column.name}</Column>}
</TableHeader>
<TableBody items={nestedItems}>
{(item) =>
(<Row key={item.foo} UNSTABLE_childItems={item.childRows}>
{(key) => {
return <Cell>{item[key]}</Cell>;
}}
</Row>)
}
</TableBody>
</TableView>
<InlineAlert>
<Heading>Payment Information</Heading>
<Content>Enter your billing address, shipping address, and payment method to complete your purchase.</Content>
</InlineAlert>
</div>
</Provider>
);
}
export default App;