Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Customisable opposite side text #11

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ Once the plugin is installed, you can use the component like this:
<template>
<!-- Latest update -->
<vue-timeline-update
:date="new Date('2017-02-26')"
:opposite="new Date('2017-02-26')"
title="v2.2.0 - Initial D"
description="Today I am thrilled to announce the release of Vue.js 2.2.0."
thumbnail="/images/vuetimeline/initial_d.jpg"
Expand All @@ -85,7 +85,7 @@ Once the plugin is installed, you can use the component like this:

<!-- Another update -->
<vue-timeline-update
:date="new Date('2016-11-22')"
:opposite="new Date('2016-11-22')"
title="v2.1.0 - Hunter X Hunter"
description="Today I am thrilled to announce the release of Vue.js 2.1.0."
thumbnail="/images/vuetimeline/hunter_x_hunter.jpg"
Expand All @@ -96,7 +96,7 @@ Once the plugin is installed, you can use the component like this:

<!-- Yet another update -->
<vue-timeline-update
:date="new Date('2016-09-30')"
opposite="Launch!"
title="v2.0.0 - Ghost in the Shell"
description="Today I am thrilled to announce the release of Vue.js 2.0.0"
thumbnail="/images/vuetimeline/ghost_in_the_shell.jpg"
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"private": false,
"name": "@growthbunker/vuetimeline",
"version": "0.1.16",
"version": "0.1.17",
"author": "Growth Bunker <[email protected]>",
"license": "MIT",
"description": "One easy-to-use component to build beautiful responsive timelines.",
Expand Down
22 changes: 14 additions & 8 deletions src/components/VueTimelineUpdate.vue
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ article(
]`
)
.gb-vue-timeline-update__left
span.gb-vue-timeline-update__ago {{ ago }}
span.gb-vue-timeline-update__ago {{ oppositeText }}

.gb-vue-timeline-update__center
base-number(
Expand Down Expand Up @@ -48,7 +48,7 @@ article(
size="small"
) {{ category }}

span.gb-vue-timeline-update__ago {{ ago }}
span.gb-vue-timeline-update__ago {{ oppositeText }}

h2(
v-html="title"
Expand Down Expand Up @@ -134,9 +134,9 @@ export default {
)
}
},
date: {
type: Date,
required: true
opposite: {
type: [String, Date],
default: ""
},
description: {
type: String,
Expand All @@ -161,9 +161,15 @@ export default {
},

computed: {
ago() {
return format(this.date)
}
oppositeText() {
if (typeof this.opposite == "object") {
// Must be date
return format(this.opposite)
}

// Otherwise just return string
return this.opposite
},
},

mounted() {
Expand Down