forked from gramps-project/gramps-web
-
Notifications
You must be signed in to change notification settings - Fork 0
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 #1 from DavidMStraub/map_time_slider
Add simple time slider to map view
- Loading branch information
Showing
4 changed files
with
227 additions
and
2 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,88 @@ | ||
import {html, css, LitElement} from 'lit' | ||
import '@material/web/slider/slider.js' | ||
|
||
import {sharedStyles} from '../SharedStyles.js' | ||
import {GrampsjsTranslateMixin} from '../mixins/GrampsjsTranslateMixin.js' | ||
import {fireEvent} from '../util.js' | ||
|
||
class GrampsjsMapTimeSlider extends GrampsjsTranslateMixin(LitElement) { | ||
static get styles() { | ||
return [ | ||
sharedStyles, | ||
css` | ||
#container { | ||
z-index: 999; | ||
background-color: #ffffff; | ||
border-radius: 14px; | ||
width: calc(100% - 150px); | ||
position: absolute; | ||
bottom: 25px; | ||
height: 28px; | ||
left: 50%; | ||
transform: translateX(-50%); | ||
display: flex; | ||
justify-content: center; | ||
align-items: center; | ||
} | ||
md-slider { | ||
width: 100%; | ||
} | ||
div.date { | ||
display: inline-block; | ||
font-size: 13px; | ||
font-weight: 500; | ||
color: rgba(0, 0, 0, 0.6); | ||
white-space: nowrap; | ||
margin-left: 4px; | ||
margin-right: 14px; | ||
line-height: 22px; | ||
height: 22px; | ||
} | ||
.date .year { | ||
font-weight: 600; | ||
} | ||
`, | ||
] | ||
} | ||
|
||
static get properties() { | ||
return { | ||
value: {type: Number}, | ||
} | ||
} | ||
|
||
constructor() { | ||
super() | ||
this.value = new Date().getFullYear() - 100 | ||
} | ||
|
||
render() { | ||
return html` | ||
<div id="container"> | ||
<md-slider | ||
@input="${this._handleInput}" | ||
labeled | ||
min="1500" | ||
max="${new Date().getFullYear()}" | ||
value="${this.value}" | ||
></md-slider> | ||
<div class="date"> | ||
<span class="year">${this.value}</span> ± | ||
<span class="tolerance">10</span> | ||
</div> | ||
</div> | ||
` | ||
} | ||
|
||
_handleInput() { | ||
const slider = this.renderRoot.querySelector('md-slider') | ||
const detail = {value: slider.value} | ||
this.value = slider.value | ||
fireEvent(this, 'timeslider:change', detail) | ||
} | ||
} | ||
|
||
window.customElements.define('grampsjs-map-time-slider', GrampsjsMapTimeSlider) |
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