-
Notifications
You must be signed in to change notification settings - Fork 4.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Map: add tooltip and popup templating (#4443)
- Loading branch information
1 parent
8cb4915
commit 944adb9
Showing
5 changed files
with
115 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,3 +7,8 @@ | |
z-index: 0; | ||
} | ||
} | ||
|
||
.leaflet-popup-content img { | ||
max-width: 100%; | ||
height: auto; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
import React from "react"; | ||
import { useDebouncedCallback } from "use-debounce"; | ||
import { Section, Input, Checkbox, TextArea, ContextHelp } from "@/components/visualizations/editor"; | ||
import { EditorPropTypes } from "@/visualizations"; | ||
|
||
function TemplateFormatHint() { | ||
// eslint-disable-line react/prop-types | ||
return ( | ||
<ContextHelp placement="topLeft" arrowPointAtCenter> | ||
<div className="p-b-5"> | ||
All query result columns can be referenced using <code>{"{{ column_name }}"}</code> syntax. | ||
</div> | ||
<div className="p-b-5">Leave this field empty to use default template.</div> | ||
</ContextHelp> | ||
); | ||
} | ||
|
||
export default function FormatSettings({ options, onOptionsChange }) { | ||
const [onOptionsChangeDebounced] = useDebouncedCallback(onOptionsChange, 200); | ||
|
||
const templateFormatHint = <TemplateFormatHint />; | ||
|
||
return ( | ||
<div className="map-visualization-editor-format-settings"> | ||
<Section> | ||
<Checkbox | ||
data-test="Map.Editor.TooltipEnabled" | ||
checked={options.tooltip.enabled} | ||
onChange={event => onOptionsChange({ tooltip: { enabled: event.target.checked } })}> | ||
Show tooltip | ||
</Checkbox> | ||
</Section> | ||
|
||
<Section> | ||
<Input | ||
label={<React.Fragment>Tooltip template {templateFormatHint}</React.Fragment>} | ||
className="w-100" | ||
data-test="Map.Editor.TooltipTemplate" | ||
disabled={!options.tooltip.enabled} | ||
placeholder="Default template" | ||
defaultValue={options.tooltip.template} | ||
onChange={event => onOptionsChangeDebounced({ tooltip: { template: event.target.value } })} | ||
/> | ||
</Section> | ||
|
||
<Section> | ||
<Checkbox | ||
data-test="Map.Editor.PopupEnabled" | ||
checked={options.popup.enabled} | ||
onChange={event => onOptionsChange({ popup: { enabled: event.target.checked } })}> | ||
Show popup | ||
</Checkbox> | ||
</Section> | ||
|
||
<Section> | ||
<TextArea | ||
label={<React.Fragment>Popup template {templateFormatHint}</React.Fragment>} | ||
className="w-100" | ||
data-test="Map.Editor.PopupTemplate" | ||
disabled={!options.popup.enabled} | ||
rows={4} | ||
placeholder="Default template" | ||
defaultValue={options.popup.template} | ||
onChange={event => onOptionsChangeDebounced({ popup: { template: event.target.value } })} | ||
/> | ||
</Section> | ||
</div> | ||
); | ||
} | ||
|
||
FormatSettings.propTypes = EditorPropTypes; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters