|
2 | 2 | // SPDX-License-Identifier: MIT
|
3 | 3 | // Copyright (c) vis.gl contributors
|
4 | 4 |
|
5 |
| -import React, {useState, useEffect, useCallback} from 'react'; |
| 5 | +import React, {useState, useEffect, useCallback, Children, isValidElement, cloneElement} from 'react'; |
6 | 6 | import styled from 'styled-components';
|
7 | 7 | import InfoPanel from '../info-panel';
|
8 | 8 | import {loadData, joinPath} from '../../utils/data-utils';
|
9 | 9 | import {normalizeParam} from '../../utils/format-utils';
|
10 | 10 | import {MAPBOX_STYLES} from '../../constants/defaults';
|
11 | 11 | import useBaseUrl from '@docusaurus/useBaseUrl';
|
| 12 | +import { DeviceTabs } from '../device-tabs'; |
| 13 | +import { useStore } from '../../store/device-store'; |
12 | 14 |
|
13 | 15 | const DemoContainer = styled.div`
|
14 | 16 | height: 100%;
|
| 17 | + position: relative; |
| 18 | +
|
15 | 19 | .tooltip,
|
16 | 20 | .deck-tooltip {
|
17 | 21 | position: absolute;
|
@@ -52,6 +56,7 @@ export default function makeExample(DemoComponent, {isInteractive = true, style}
|
52 | 56 | const [data, setData] = useState(defaultData);
|
53 | 57 | const [params, setParams] = useState(defaultParams);
|
54 | 58 | const [meta, setMeta] = useState({});
|
| 59 | + const device = useStore(state => state.device) |
55 | 60 | const baseUrl = useBaseUrl('/');
|
56 | 61 |
|
57 | 62 | const useParam = useCallback(newParameters => {
|
@@ -112,28 +117,32 @@ export default function makeExample(DemoComponent, {isInteractive = true, style}
|
112 | 117 | };
|
113 | 118 |
|
114 | 119 | return (
|
115 |
| - <DemoContainer style={style}> |
116 |
| - <DemoComponent |
117 |
| - data={data} |
118 |
| - mapStyle={mapStyle || MAPBOX_STYLES.BLANK} |
119 |
| - params={params} |
120 |
| - useParam={useParam} |
121 |
| - onStateChange={updateMeta} |
122 |
| - /> |
123 |
| - {isInteractive && ( |
124 |
| - <InfoPanel |
125 |
| - title={DemoComponent.title} |
| 120 | + <> |
| 121 | + {DemoComponent.hasDeviceTabs && <DeviceTabs />} |
| 122 | + <DemoContainer style={style}> |
| 123 | + <DemoComponent |
| 124 | + device={device} |
| 125 | + data={data} |
| 126 | + mapStyle={mapStyle || MAPBOX_STYLES.BLANK} |
126 | 127 | params={params}
|
127 |
| - meta={meta} |
128 |
| - updateParam={updateParam} |
129 |
| - sourceLink={DemoComponent.code} |
130 |
| - > |
131 |
| - {DemoComponent.renderInfo(meta)} |
132 |
| - </InfoPanel> |
133 |
| - )} |
134 |
| - |
135 |
| - {isInteractive && mapStyle && <MapTip>Hold down shift to rotate</MapTip>} |
136 |
| - </DemoContainer> |
| 128 | + useParam={useParam} |
| 129 | + onStateChange={updateMeta} |
| 130 | + /> |
| 131 | + {isInteractive && ( |
| 132 | + <InfoPanel |
| 133 | + title={DemoComponent.title} |
| 134 | + params={params} |
| 135 | + meta={meta} |
| 136 | + updateParam={updateParam} |
| 137 | + sourceLink={DemoComponent.code} |
| 138 | + > |
| 139 | + {DemoComponent.renderInfo(meta)} |
| 140 | + </InfoPanel> |
| 141 | + )} |
| 142 | + |
| 143 | + {isInteractive && mapStyle && <MapTip>Hold down shift to rotate</MapTip>} |
| 144 | + </DemoContainer> |
| 145 | + </> |
137 | 146 | );
|
138 | 147 | };
|
139 | 148 | }
|
0 commit comments