-
Notifications
You must be signed in to change notification settings - Fork 25
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1315 from simon-leech/type-key-button
entry type:key to return layer display toggle
- Loading branch information
Showing
5 changed files
with
101 additions
and
44 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
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,45 @@ | ||
/** | ||
@function key | ||
@description | ||
mapp.ui.locations.entries.key(entry) | ||
The entry method returns a button HTML element which will toggle the location.layer display. | ||
The button classList reflects whether the layer is displayed or not. | ||
@example | ||
```json | ||
{ | ||
"type":"key" | ||
} | ||
``` | ||
@param {Object} entry | ||
@param {Object} entry.location.layer The Mapp location layer object. | ||
@return {HTMLElement} | ||
The button key element, with an onclick event to toggle the visibility of the layer. | ||
*/ | ||
|
||
export default function key(entry) { | ||
|
||
const classList = `layer-key ${entry.location.layer.display ? 'active' : ''}` | ||
|
||
const node = mapp.utils.html.node`<div> | ||
<button | ||
class=${classList} | ||
title="${mapp.dictionary.layer_visibility}" | ||
onclick="${e => { | ||
if (e.target.classList.toggle('active')) { | ||
entry.location.layer.show(); | ||
} else { | ||
entry.location.layer.hide(); | ||
} | ||
}}">${entry.location.layer.name}`; | ||
|
||
return node; | ||
} |
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,36 @@ | ||
/** | ||
mapp.ui.locations.entries.title(entry) | ||
The method returns just the title of the entry. | ||
You can provide a tooltip (shown when hovering over the title). | ||
You can provide a css style for the title (to style the title in a specific way). | ||
@example | ||
```json | ||
{ | ||
"title": "This is a title", | ||
"type":"title", | ||
"tooltip": "This is a tooltip", | ||
"css_title": "font-weight: 800" | ||
} | ||
``` | ||
@function title | ||
@param {Object} entry | ||
@param {string} entry.title The title of the entry. | ||
@param {string} entry.tooltip The tooltip of the entry. | ||
@param {string} entry.css_title The css of the title. | ||
@return {HTMLElement} The title element. | ||
*/ | ||
|
||
export default function title(entry) { | ||
|
||
const tooltipSpan = entry.tooltip && mapp.utils.html` | ||
<span | ||
class="tooltip mask-icon question-mark">${entry.tooltip}` | ||
|
||
return mapp.utils.html.node` | ||
<div | ||
class="label" | ||
style=${entry.css_title} | ||
title=${entry.tooltip}>${entry.title} | ||
${tooltipSpan}`; | ||
} |
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