-
Notifications
You must be signed in to change notification settings - Fork 3
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 #14 from puraku/timeline-polish
Timeline 更多細節
- Loading branch information
Showing
8 changed files
with
219 additions
and
121 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
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,44 @@ | ||
<template> | ||
<div class="plurks-container"> | ||
<time-baseline /> | ||
<plurk-card v-for="plurk in taggedPlurks" :plurk="plurk" :userList="userList" /> | ||
</div> | ||
</template> | ||
|
||
<script> | ||
import PlurkCard from '../components/PlurkCard.vue'; | ||
import TimeBaseline from '../components/TimeBaseline.vue'; | ||
import { postedDateTagger } from '../helpers/plurkHelper'; | ||
export default { | ||
name: 'PlurksContainer', | ||
props: [ | ||
'plurks', | ||
'userList' | ||
], | ||
components: { | ||
PlurkCard, | ||
TimeBaseline | ||
}, | ||
computed: { | ||
taggedPlurks() { | ||
return postedDateTagger(this.plurks); | ||
} | ||
} | ||
} | ||
</script> | ||
|
||
<style scoped> | ||
.plurks-container { | ||
padding: 0em 1.5em 1em 0.5em; | ||
overflow-y: scroll; | ||
height: 100%; | ||
background-color: #f5ede8; | ||
} | ||
</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
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,22 @@ | ||
import moment from 'moment'; | ||
|
||
export function postedDateTagger(plurks) { | ||
return plurks.map((plurk, index) => { | ||
const previousPlurk = plurks[index - 1]; | ||
|
||
return { | ||
...plurk, | ||
showPostedDate: !(previousPlurk && (formatDate(previousPlurk) === formatDate(plurk))) | ||
}; | ||
}); | ||
} | ||
|
||
export function formatDate(plurk) { | ||
const formatedDate = moment.parseZone(plurk.posted).format('YYYY-MM-DD'); | ||
|
||
if (moment().format('YYYY-MM-DD') === formatedDate) { | ||
return 'Today'; | ||
} else { | ||
return formatedDate; | ||
} | ||
} |
Oops, something went wrong.