|
1 | 1 | // Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
2 | 2 | // SPDX-License-Identifier: Apache-2.0
|
| 3 | +import React, { useContext, useState } from 'react'; |
3 | 4 |
|
4 |
| -import React, { useContext } from 'react'; |
5 |
| - |
6 |
| -import { AppLayout, AppLayoutProps, Box, Header, Popover, SpaceBetween, SplitPanel, Toggle } from '~components'; |
| 5 | +import AppLayout, { AppLayoutProps } from '~components/app-layout'; |
| 6 | +import Header from '~components/header'; |
| 7 | +import Popover from '~components/popover'; |
| 8 | +import SpaceBetween from '~components/space-between'; |
| 9 | +import SplitPanel from '~components/split-panel'; |
| 10 | +import Toggle from '~components/toggle'; |
7 | 11 |
|
8 | 12 | import AppContext, { AppContextType } from '../app/app-context';
|
9 | 13 | import ScreenshotArea from '../utils/screenshot-area';
|
@@ -57,23 +61,37 @@ const DEMO_CONTENT = (
|
57 | 61 | pellentesque id. Porta lorem mollis aliquam ut porttitor leo a. Lectus quam id leo in vitae turpis massa sed.
|
58 | 62 | Pharetra pharetra massa massa ultricies mi.
|
59 | 63 | </p>
|
| 64 | + <p> |
| 65 | + Pharetra et ultrices neque ornare. Bibendum neque egestas congue quisque egestas diam in arcu cursus. Porttitor |
| 66 | + eget dolor morbi non arcu risus quis. Integer quis auctor elit sed vulputate mi sit. Mauris nunc congue nisi vitae |
| 67 | + suscipit tellus mauris a diam. Diam donec adipiscing tristique risus nec feugiat in. Arcu felis bibendum ut |
| 68 | + tristique et egestas quis. Nulla porttitor massa id neque aliquam vestibulum morbi blandit. In hac habitasse |
| 69 | + platea dictumst quisque sagittis. Sollicitudin tempor id eu nisl nunc mi ipsum. Ornare aenean euismod elementum |
| 70 | + nisi quis. Elementum curabitur vitae nunc sed velit dignissim sodales. Amet tellus cras adipiscing enim eu. Id |
| 71 | + interdum velit laoreet id donec ultrices tincidunt. Ullamcorper eget nulla facilisi etiam. Sodales neque sodales |
| 72 | + ut etiam sit amet nisl purus. Auctor urna nunc id cursus metus aliquam eleifend mi in. Urna condimentum mattis |
| 73 | + pellentesque id. Porta lorem mollis aliquam ut porttitor leo a. Lectus quam id leo in vitae turpis massa sed. |
| 74 | + Pharetra pharetra massa massa ultricies mi. |
| 75 | + </p> |
60 | 76 | </div>
|
61 | 77 | );
|
62 | 78 |
|
63 | 79 | export default function () {
|
64 |
| - const { |
65 |
| - urlParams: { splitPanelEnabled = true, toolsEnabled = true, splitPanelPosition }, |
66 |
| - setUrlParams, |
67 |
| - } = useContext(AppContext as SplitPanelDemoContext); |
| 80 | + const { urlParams, setUrlParams } = useContext(AppContext as SplitPanelDemoContext); |
| 81 | + const [splitPanelEnabled, setSplitPanelEnabled] = useState(urlParams.splitPanelEnabled ?? true); |
| 82 | + const [toolsPanelEnabled, setToolsPanelEnabled] = useState(urlParams.toolsEnabled ?? true); |
| 83 | + |
68 | 84 | return (
|
69 | 85 | <ScreenshotArea gutters={false}>
|
70 | 86 | <AppLayout
|
71 | 87 | ariaLabels={labels}
|
72 | 88 | breadcrumbs={<Breadcrumbs />}
|
73 | 89 | navigation={<Navigation />}
|
74 | 90 | tools={<Tools>{toolsContent.long}</Tools>}
|
75 |
| - toolsHide={!toolsEnabled} |
76 |
| - splitPanelPreferences={{ position: splitPanelPosition }} |
| 91 | + toolsHide={!toolsPanelEnabled} |
| 92 | + splitPanelPreferences={{ |
| 93 | + position: urlParams.splitPanelPosition, |
| 94 | + }} |
77 | 95 | onSplitPanelPreferencesChange={event => {
|
78 | 96 | const { position } = event.detail;
|
79 | 97 | setUrlParams({ splitPanelPosition: position === 'side' ? position : undefined });
|
@@ -106,28 +124,28 @@ export default function () {
|
106 | 124 | Demo page
|
107 | 125 | </Header>
|
108 | 126 | </div>
|
109 |
| - |
110 | 127 | <SpaceBetween size="l">
|
111 |
| - <SpaceBetween size="s" direction="horizontal"> |
112 |
| - <Toggle |
113 |
| - id="enable-split-panel" |
114 |
| - checked={splitPanelEnabled} |
115 |
| - onChange={e => setUrlParams({ splitPanelEnabled: e.detail.checked })} |
116 |
| - > |
117 |
| - Enable split panel |
118 |
| - </Toggle> |
119 |
| - <Toggle |
120 |
| - id="enable-tools-panel" |
121 |
| - checked={toolsEnabled} |
122 |
| - onChange={e => setUrlParams({ toolsEnabled: e.detail.checked })} |
123 |
| - > |
124 |
| - Enable tools panel |
125 |
| - </Toggle> |
126 |
| - </SpaceBetween> |
127 |
| - |
| 128 | + <Toggle |
| 129 | + id="enable-split-panel" |
| 130 | + checked={splitPanelEnabled} |
| 131 | + onChange={e => { |
| 132 | + setSplitPanelEnabled(e.detail.checked); |
| 133 | + setUrlParams({ splitPanelEnabled: e.detail.checked }); |
| 134 | + }} |
| 135 | + > |
| 136 | + Enable split panel |
| 137 | + </Toggle> |
| 138 | + <Toggle |
| 139 | + id="enable-tools-panel" |
| 140 | + checked={toolsPanelEnabled} |
| 141 | + onChange={e => { |
| 142 | + setToolsPanelEnabled(e.detail.checked); |
| 143 | + setUrlParams({ toolsEnabled: e.detail.checked }); |
| 144 | + }} |
| 145 | + > |
| 146 | + Enable tools panel |
| 147 | + </Toggle> |
128 | 148 | <Containers />
|
129 |
| - |
130 |
| - <Box>{DEMO_CONTENT}</Box> |
131 | 149 | </SpaceBetween>
|
132 | 150 | </>
|
133 | 151 | }
|
|
0 commit comments