mirror of
https://github.com/jlengrand/fuzzy-date.git
synced 2026-03-10 08:21:23 +00:00
42 lines
897 B
HTML
42 lines
897 B
HTML
<link rel="import" href="../polymer/polymer-element.html">
|
|
<script src="../moment/moment.js"></script>
|
|
|
|
<dom-module id="fuzzy-date">
|
|
<template>
|
|
<style>
|
|
:host {
|
|
display: block;
|
|
}
|
|
</style>
|
|
<span>[[_formatDate(date)]]</span>
|
|
</template>
|
|
|
|
<script>
|
|
/**
|
|
* `fuzzy-date`
|
|
* A simple element that shows dates in a format understood by humans
|
|
*
|
|
* @customElement
|
|
* @polymer
|
|
* @demo demo/index.html
|
|
*/
|
|
class FuzzyDate extends Polymer.Element {
|
|
static get is() { return 'fuzzy-date'; }
|
|
static get properties() {
|
|
return {
|
|
date: {
|
|
type: String,
|
|
reflectToAttribute: true
|
|
}
|
|
};
|
|
}
|
|
|
|
_formatDate(dateString){
|
|
return moment(dateString).fromNow();
|
|
}
|
|
}
|
|
|
|
window.customElements.define(FuzzyDate.is, FuzzyDate);
|
|
</script>
|
|
</dom-module>
|