Skip to content

Commit b1953cf

Browse files
authored
[feat] banner with extra release info (#2955)
- banner with extra info for 3.1 release - once minified, the user won't see the banner again during next sessions - can be disabled via application config Signed-off-by: Ihor Dykhta <dikhta.igor@gmail.com>
1 parent e95c4e5 commit b1953cf

File tree

7 files changed

+94
-11
lines changed

7 files changed

+94
-11
lines changed

examples/demo-app/package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,8 @@
5555
"redux-actions": "^2.2.1",
5656
"redux-logger": "^3.0.6",
5757
"redux-thunk": "^1.0.0",
58-
"styled-components": "6.1.8"
58+
"styled-components": "6.1.8",
59+
"usehooks-ts": "^3.1.0"
5960
},
6061
"resolutions": {
6162
"@luma.gl/core": "8.5.21",

examples/demo-app/src/components/map-control/map-control.js

Lines changed: 68 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,23 @@
11
// SPDX-License-Identifier: MIT
22
// Copyright contributors to the kepler.gl project
33

4-
import React, {useState} from 'react';
54
import classnames from 'classnames';
5+
import React, {useState} from 'react';
6+
import ReactMarkdown from 'react-markdown';
67
import styled from 'styled-components';
7-
import {Icons, IconRoundSmall, MapControlButton} from '@kepler.gl/components';
8+
import {useLocalStorage} from 'usehooks-ts';
89

9-
import ReactMarkdown from 'react-markdown';
10+
import {Icons, IconRoundSmall, MapControlButton} from '@kepler.gl/components';
11+
import {getApplicationConfig} from '@kepler.gl/utils';
1012

1113
const StyledFloatingPanel = styled.div`
1214
margin-right: 12px;
13-
margin-top: 20px;
15+
margin-top: 12px;
1416
`;
1517

1618
const StyledProjectPanel = styled.div`
1719
background: ${props => props.theme.panelBackground};
18-
padding: 16px 20px;
20+
padding: 16px 16px 16px 20px;
1921
width: 280px;
2022
box-shadow: ${props => props.theme.panelBoxShadow};
2123
@@ -25,6 +27,13 @@ const StyledProjectPanel = styled.div`
2527
font-weight: 500;
2628
display: flex;
2729
justify-content: space-between;
30+
31+
div {
32+
.release-icon {
33+
font-size: 20px;
34+
padding-left: 10px;
35+
}
36+
}
2837
}
2938
3039
.project-description {
@@ -39,7 +48,7 @@ const StyledProjectPanel = styled.div`
3948
}
4049
4150
.project-links {
42-
margin-top: 20px;
51+
margin-top: 16px;
4352
width: 100%;
4453
display: flex;
4554
align-items: center;
@@ -153,3 +162,56 @@ export function SampleMapPanel(props) {
153162
</StyledFloatingPanel>
154163
);
155164
}
165+
166+
export function BannerMapPanel() {
167+
const [isActive, setActive] = useState(true);
168+
// Once the banner is closed, the user won't see the banner during next sessions.
169+
const [showBanner, setShowBanner] = useLocalStorage(
170+
'show-duckdb-preview-banner',
171+
getApplicationConfig().showReleaseBanner
172+
);
173+
const [wasVisible] = useState(showBanner);
174+
175+
if (!showBanner && !wasVisible) {
176+
return null;
177+
}
178+
179+
return (
180+
<StyledFloatingPanel>
181+
{isActive ? (
182+
<StyledProjectPanel>
183+
<div className="project-title">
184+
<div>
185+
{'Kepler.gl 3.1 is here!'}
186+
<span className="release-icon">{'🚀'}</span>
187+
</div>
188+
189+
<CloseButton
190+
onClick={() => {
191+
setShowBanner(false);
192+
setActive(false);
193+
}}
194+
/>
195+
</div>
196+
<div className="project-description">
197+
<ReactMarkdown components={{a: LinkRenderer}}>
198+
{
199+
'Check out our new [DuckDB plugin preview](https://kepler-preview.foursquare.com) for data analysis, exploration and in-browser data processing in Kepler.gl.'
200+
}
201+
</ReactMarkdown>
202+
</div>
203+
</StyledProjectPanel>
204+
) : (
205+
<MapControlButton
206+
className={classnames('map-control-button', 'info-panel', {isActive})}
207+
onClick={e => {
208+
e.preventDefault();
209+
setActive(true);
210+
}}
211+
>
212+
<Icons.Docs height="18px" />
213+
</MapControlButton>
214+
)}
215+
</StyledFloatingPanel>
216+
);
217+
}

examples/demo-app/src/factories/map-control.js

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,16 @@
33

44
import React from 'react';
55
import styled from 'styled-components';
6+
7+
import {AiAssistantControlFactory, AiAssistantManagerFactory} from '@kepler.gl/ai-assistant';
68
import {
79
withState,
810
MapControlFactory,
911
EffectControlFactory,
1012
EffectManagerFactory
1113
} from '@kepler.gl/components';
12-
import {AiAssistantControlFactory, AiAssistantManagerFactory} from '@kepler.gl/ai-assistant';
13-
import {SampleMapPanel} from '../components/map-control/map-control';
14+
15+
import {BannerMapPanel, SampleMapPanel} from '../components/map-control/map-control';
1416
import SqlPanelControlFactory from '../components/map-control/sql-panel-control';
1517

1618
const StyledMapControlPanel = styled.div`
@@ -87,6 +89,7 @@ function CustomMapControlFactory(
8789
fullHeight={showAiAssistant}
8890
>
8991
<StyledMapControlPanel>
92+
{<BannerMapPanel {...props} />}
9093
{!props.isExport && props.currentSample ? <SampleMapPanel {...props} /> : null}
9194
<MapControl {...props} top={0} actionComponents={actionComponents} />
9295
</StyledMapControlPanel>

examples/demo-app/yarn.lock

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13045,6 +13045,7 @@ __metadata:
1304513045
redux-logger: "npm:^3.0.6"
1304613046
redux-thunk: "npm:^1.0.0"
1304713047
styled-components: "npm:6.1.8"
13048+
usehooks-ts: "npm:^3.1.0"
1304813049
languageName: unknown
1304913050
linkType: soft
1305013051

@@ -14225,6 +14226,17 @@ __metadata:
1422514226
languageName: node
1422614227
linkType: hard
1422714228

14229+
"usehooks-ts@npm:^3.1.0":
14230+
version: 3.1.0
14231+
resolution: "usehooks-ts@npm:3.1.0"
14232+
dependencies:
14233+
lodash.debounce: "npm:^4.0.8"
14234+
peerDependencies:
14235+
react: ^16.8.0 || ^17 || ^18
14236+
checksum: 10c0/2204d8c95109302bdaaa51a66bf216f3dba750f1d2795c20ecba75ba1c44a070a253935d537ef536514ab6e363bcc02ccc78b5ad63576ff8d880d577cf3fc48f
14237+
languageName: node
14238+
linkType: hard
14239+
1422814240
"util-deprecate@npm:^1.0.2":
1422914241
version: 1.0.2
1423014242
resolution: "util-deprecate@npm:1.0.2"

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -212,6 +212,7 @@
212212
"typedoc-plugin-markdown": "^3.0.11",
213213
"typescript": "4.7.2",
214214
"url-loader": "^4.1.1",
215+
"usehooks-ts": "^3.1.0",
215216
"watchify": "^3.6.1",
216217
"webpack": "^4.29.0",
217218
"webpack-bundle-analyzer": "^3.3.2",

src/utils/src/application-config.ts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,10 @@ export type KeplerApplicationConfig<Map> = {
3535
// TODO improve typing by exporting KeplerTable interface to @kepler.gl/types
3636
table?: any;
3737

38-
// disable progressive loading for arrow files
38+
// Disable progressive loading for arrow files
3939
useArrowProgressiveLoading?: boolean;
40+
// Show built-in banner associated with the current version of Kepler.gl
41+
showReleaseBanner?: boolean;
4042
};
4143

4244
const DEFAULT_APPLICATION_CONFIG: Required<KeplerApplicationConfig<mapboxgl.Map>> = {
@@ -70,7 +72,8 @@ const DEFAULT_APPLICATION_CONFIG: Required<KeplerApplicationConfig<mapboxgl.Map>
7072
// TODO include KeplerTable here when the circular dependency with @kepler.gl/table and @kepler.gl/utils are resolved.
7173
table: null,
7274

73-
useArrowProgressiveLoading: true
75+
useArrowProgressiveLoading: true,
76+
showReleaseBanner: false
7477
};
7578

7679
const applicationConfig: Required<KeplerApplicationConfig<mapboxgl.Map>> =

yarn.lock

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20543,6 +20543,7 @@ __metadata:
2054320543
typedoc-plugin-markdown: "npm:^3.0.11"
2054420544
typescript: "npm:4.7.2"
2054520545
url-loader: "npm:^4.1.1"
20546+
usehooks-ts: "npm:^3.1.0"
2054620547
watchify: "npm:^3.6.1"
2054720548
webpack: "npm:^4.29.0"
2054820549
webpack-bundle-analyzer: "npm:^3.3.2"

0 commit comments

Comments
 (0)