Skip to content

Commit

Permalink
moved Dropzone's onDrop handler to AppToolbar
Browse files Browse the repository at this point in the history
  • Loading branch information
prusswan committed Jan 26, 2025
1 parent d606781 commit 29d78b2
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 5 deletions.
5 changes: 2 additions & 3 deletions src/components/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -884,8 +884,7 @@ export default class App extends React.Component<any, AppState> {
});
}

onFileSelected = (e: File[]) => {
const file = e[0];
setLocalPMTiles = (file: File) => {
const pmt = new PMTiles(new FileSource(file));
this.setState({
localPMTiles: pmt
Expand All @@ -906,7 +905,7 @@ export default class App extends React.Component<any, AppState> {
onStyleOpen={this.onStyleChanged}
onSetMapState={this.setMapState}
onToggleModal={this.toggleModal.bind(this)}
onFileSelected={this.onFileSelected}
setLocalPMTiles={this.setLocalPMTiles}
/>

const layerList = <LayerList
Expand Down
9 changes: 7 additions & 2 deletions src/components/AppToolbar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ type AppToolbarInternalProps = {
onSetMapState(mapState: MapState): unknown
mapState?: MapState
renderer?: string
onFileSelected(...args: unknown[]): unknown
setLocalPMTiles(file: File): unknown
} & WithTranslation;

class AppToolbarInternal extends React.Component<AppToolbarInternalProps> {
Expand Down Expand Up @@ -137,6 +137,11 @@ class AppToolbarInternal extends React.Component<AppToolbarInternalProps> {
}
}

onFileSelected = (e: File[]) => {
const file = e[0];
this.props.setLocalPMTiles(file);
}

render() {
const t = this.props.t;
const views = [
Expand Down Expand Up @@ -293,7 +298,7 @@ class AppToolbarInternal extends React.Component<AppToolbarInternalProps> {
<IconText>{t("Help")}</IconText>
</ToolbarLink>

<Dropzone onDrop={this.props.onFileSelected}>
<Dropzone onDrop={this.onFileSelected}>
{({getRootProps, getInputProps}) => (
<div {...getRootProps({className: 'dropzone maputnik-toolbar-link'})}>
<input {...getInputProps()} />
Expand Down

0 comments on commit 29d78b2

Please sign in to comment.