This repository has been archived by the owner on Jul 6, 2021. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 104
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
40 changed files
with
3,928 additions
and
2,976 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 |
---|---|---|
@@ -1,111 +1,49 @@ | ||
<style> | ||
body { | ||
font-family: Helvetica; | ||
margin: 0; | ||
} | ||
.header { | ||
height: 40px; | ||
line-height: 40px; | ||
background-color: #f0f0f0; | ||
padding: 0 20px; | ||
& select { | ||
margin-right: 10px; | ||
} | ||
} | ||
.people { | ||
margin-top: 20px; | ||
padding: 0 20px; | ||
} | ||
.person { | ||
font-size: 1.4rem; | ||
& .name { | ||
width: 150px; | ||
display: inline-block; | ||
} | ||
& .meta { | ||
display: inline-block; | ||
} | ||
} | ||
.timeago { | ||
color: #999; | ||
} | ||
</style> | ||
|
||
<template> | ||
<div class="app"> | ||
<header class="header"> | ||
Choose your language: | ||
<select @change="handleChange"> | ||
<option :value="lang" v-for="lang in langs" :selected="lang === currentLang"> | ||
{{ lang }} | ||
<div id="app"> | ||
<div class="header"> | ||
<select v-model="locale"> | ||
<option value="en">en</option> | ||
<option | ||
v-for="name of localeNames" | ||
:key="name" | ||
:value="name"> | ||
{{ name }} | ||
</option> | ||
</select> | ||
<input type="button" :value="autoUpdate ? 'Stop update' : 'Resume update'" @click="toggleUpdate"> | ||
</header> | ||
<div class="people"> | ||
<div class="person" v-for="person in people"> | ||
<span class="name">{{ person.name }}</span> | ||
<div class="meta"> | ||
was born at | ||
<timeago | ||
:auto-update="autoUpdate" | ||
:max-time="86400 * 365" | ||
:locale="currentLang" | ||
class="timeago" | ||
:since="person.birth"></timeago> | ||
</div> | ||
</div> | ||
</div> | ||
<div class="main"> | ||
<timeago :since="new Date('2011-02-12')" :locale="locale" /> | ||
<hr> | ||
<timeago :since="new Date()" :locale="locale" :autoUpdate="1" :includeSeconds="true" /> | ||
</div> | ||
</div> | ||
</template> | ||
|
||
<script> | ||
import qs from './qs' | ||
import locales from './locales' | ||
export default { | ||
props: ['localeNames'], | ||
const now = new Date().getTime() | ||
const people = [ | ||
{ | ||
name: 'egoist', | ||
birth: now - 60000 | ||
}, | ||
{ | ||
name: 'chelly', | ||
birth: now - 60000 * 22 | ||
}, | ||
{ | ||
name: 'aimer', | ||
birth: now - 60000 * 102 | ||
}, | ||
{ | ||
name: 'young boy', | ||
birth: now - 1000 | ||
}, | ||
{ | ||
name: 'old man', | ||
birth: new Date('2014-01-01') | ||
} | ||
] | ||
export default { | ||
data() { | ||
return { | ||
autoUpdate: 1, | ||
people, | ||
currentLang: qs().lang || 'en-US', | ||
langs: Object.keys(locales) | ||
} | ||
}, | ||
methods: { | ||
handleChange(e) { | ||
this.currentLang = e.target.value | ||
}, | ||
format(val) { | ||
return `` | ||
}, | ||
toggleUpdate() { | ||
this.autoUpdate = this.autoUpdate ? 0 : 1 | ||
} | ||
data() { | ||
return { | ||
locale: 'en' | ||
} | ||
} | ||
} | ||
</script> | ||
|
||
<style> | ||
body { | ||
margin: 0; | ||
} | ||
</style> | ||
|
||
<style scoped> | ||
.header { | ||
background: #f9f9f9; | ||
padding: 10px; | ||
} | ||
.main { | ||
padding: 10px; | ||
} | ||
</style> |
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 |
---|---|---|
@@ -1,16 +1,23 @@ | ||
import Vue from 'vue' | ||
import VueTimeago from '../src' | ||
import app from './app' | ||
import qs from './qs' | ||
import locales from './locales' | ||
import Timeago from '../src' | ||
import App from './App.vue' | ||
|
||
Vue.config.debug = true | ||
Vue.use(VueTimeago, { | ||
locale: 'en-US', | ||
const r = require.context('date-fns/locale', true, /^\.\/([\w\_]+)\/index\.js/) | ||
const locales = {} | ||
r.keys().forEach(v => { | ||
const [, name] = /^\.\/([\w\_]+)\/index\.js/.exec(v) | ||
locales[name] = r(v) | ||
}) | ||
|
||
Vue.use(Timeago, { | ||
locales | ||
}) | ||
|
||
new Vue({ | ||
el: '#app', | ||
render: h => h(app) | ||
render: h => h(App, { | ||
props: { | ||
localeNames: Object.keys(locales) | ||
} | ||
}) | ||
}) |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.