Skip to content

Commit

Permalink
Merge pull request #14 from qur2/master
Browse files Browse the repository at this point in the history
All prop defaults are factories.
  • Loading branch information
koddr authored Aug 17, 2018
2 parents 2eac657 + c2a6310 commit d948e92
Show file tree
Hide file tree
Showing 22 changed files with 2,977 additions and 746 deletions.
3,520 changes: 2,853 additions & 667 deletions package-lock.json

Large diffs are not rendered by default.

10 changes: 5 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,14 @@
"url": "git+https://github.com/koddr/vue-goodshare.git"
},
"dependencies": {
"vue": "^2.5.9"
"vue": "^2.5.17"
},
"devDependencies": {
"css-loader": "^0.28.7",
"css-loader": "^0.28.11",
"gitbook-cli": "^2.3.2",
"node-sass": "^4.7.2",
"sass-loader": "^6.0.6",
"vue-style-loader": "^3.0.3"
"node-sass": "^4.9.2",
"sass-loader": "^6.0.7",
"vue-style-loader": "^3.1.2"
},
"keywords": [
"social share buttons",
Expand Down
10 changes: 0 additions & 10 deletions src/helpers/defaultHref.js

This file was deleted.

7 changes: 7 additions & 0 deletions src/helpers/description.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
/**
* @return {String} description meta content
*/
export function metaDescription() {
const meta = document.querySelector('meta[name="description"]')
return meta ? meta.content : ''
}
16 changes: 16 additions & 0 deletions src/helpers/href.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
/**
* @return {String} document location href without hash
*/
export function documentHrefWithoutHash() {
return document.location.href.replace(
document.location.hash,
''
);
}

/**
* @return {String} document location
*/
export function documentHref() {
return document.location.href;
}
7 changes: 7 additions & 0 deletions src/helpers/icon.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
/**
* @return {String} apple-touch-icon link source
*/
export function linkAppleTouchIcon() {
const link = document.querySelector('link[rel="apple-touch-icon"]')
return link ? link.src : ''
}
6 changes: 6 additions & 0 deletions src/helpers/title.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
/**
* @return {String} document title
*/
export function documentTitle() {
return document.title;
}
6 changes: 3 additions & 3 deletions src/providers/Facebook.vue
Original file line number Diff line number Diff line change
Expand Up @@ -19,18 +19,18 @@
</template>

<script>
import defaultHref from '../helpers/defaultHref';
import {documentHrefWithoutHash} from '../helpers/href';
export default {
name: 'VueGoodshareFacebook',
props: {
page_url: {
type: String,
default: defaultHref
default: documentHrefWithoutHash
},
button_design: {
type: String,
default: 'flat'
default: () => 'flat'
},
title_social: String,
has_icon: Boolean,
Expand Down
6 changes: 4 additions & 2 deletions src/providers/GooglePlus.vue
Original file line number Diff line number Diff line change
Expand Up @@ -14,16 +14,18 @@
</template>

<script>
import {documentHref} from '../helpers/href';
export default {
name: 'VueGoodshareGooglePlus',
props: {
page_url: {
type: String,
default: document.location.href
default: documentHref
},
button_design: {
type: String,
default: 'flat'
default: () => 'flat'
},
title_social: String,
has_icon: Boolean,
Expand Down
6 changes: 4 additions & 2 deletions src/providers/Line.vue
Original file line number Diff line number Diff line change
Expand Up @@ -14,16 +14,18 @@
</template>

<script>
import {documentHref} from '../helpers/href';
export default {
name: 'VueGoodshareLine',
props: {
page_url: {
type: String,
default: document.location.href
default: documentHref
},
button_design: {
type: String,
default: 'flat'
default: () => 'flat'
},
title_social: String,
has_icon: Boolean,
Expand Down
13 changes: 7 additions & 6 deletions src/providers/LinkedIn.vue
Original file line number Diff line number Diff line change
Expand Up @@ -21,27 +21,28 @@
</template>

<script>
// Variables
const description = document.querySelector('meta[name="description"]')
import {documentHref} from '../helpers/href';
import {documentTitle} from '../helpers/title';
import {metaDescription} from '../helpers/description';
export default {
name: 'VueGoodshareLinkedIn',
props: {
page_url: {
type: String,
default: document.location.href
default: documentHref
},
page_title: {
type: String,
default: document.title
default: documentTitle
},
page_description: {
type: String,
default: (description) ? description.content : ''
default: metaDescription
},
button_design: {
type: String,
default: 'flat'
default: () => 'flat'
},
title_social: String,
has_icon: Boolean,
Expand Down
9 changes: 6 additions & 3 deletions src/providers/LiveJournal.vue
Original file line number Diff line number Diff line change
Expand Up @@ -15,20 +15,23 @@
</template>

<script>
import {documentHref} from '../helpers/href';
import {documentTitle} from '../helpers/title';
export default {
name: 'VueGoodshareLiveJournal',
props: {
page_url: {
type: String,
default: document.location.href
default: documentHref
},
page_title: {
type: String,
default: document.title
default: documentTitle
},
button_design: {
type: String,
default: 'flat'
default: () => 'flat'
},
title_social: String,
has_icon: Boolean,
Expand Down
17 changes: 9 additions & 8 deletions src/providers/MoiMir.vue
Original file line number Diff line number Diff line change
Expand Up @@ -22,32 +22,33 @@
</template>

<script>
// Variables
const description = document.querySelector('meta[name="description"]')
const image = document.querySelector('link[rel="apple-touch-icon"]')
import {documentHref} from '../helpers/href';
import {documentTitle} from '../helpers/title';
import {metaDescription} from '../helpers/description';
import {linkAppleTouchIcon} from '../helpers/icon';
export default {
name: 'VueGoodshareMoiMir',
props: {
page_url: {
type: String,
default: document.location.href
default: documentHref
},
page_title: {
type: String,
default: document.title
default: documentTitle
},
page_description: {
type: String,
default: (description) ? description.content : ''
default: metaDescription
},
page_image: {
type: String,
default: (image) ? image.src : ''
default: linkAppleTouchIcon
},
button_design: {
type: String,
default: 'flat'
default: () => 'flat'
},
title_social: String,
has_icon: Boolean,
Expand Down
9 changes: 5 additions & 4 deletions src/providers/Odnoklassniki.vue
Original file line number Diff line number Diff line change
Expand Up @@ -20,22 +20,23 @@
</template>

<script>
import defaultHref from '../helpers/defaultHref';
import {documentHrefWithoutHash} from '../helpers/href';
import {documentTitle} from '../helpers/title';
export default {
name: 'VueGoodshareOdnoklassniki',
props: {
page_url: {
type: String,
default: defaultHref
default: documentHrefWithoutHash
},
page_title: {
type: String,
default: document.title
default: documentTitle
},
button_design: {
type: String,
default: 'flat'
default: () => 'flat'
},
title_social: String,
has_icon: Boolean,
Expand Down
14 changes: 7 additions & 7 deletions src/providers/Pinterest.vue
Original file line number Diff line number Diff line change
Expand Up @@ -20,28 +20,28 @@
</template>

<script>
// Variables
const description = document.querySelector('meta[name="description"]')
const image = document.querySelector('link[rel="apple-touch-icon"]')
import {documentHref} from '../helpers/href';
import {metaDescription} from '../helpers/description';
import {linkAppleTouchIcon} from '../helpers/icon';
export default {
name: 'VueGoodsharePinterest',
props: {
page_url: {
type: String,
default: document.location.href
default: documentHref
},
page_description: {
type: String,
default: (description) ? description.content : ''
default: metaDescription
},
page_image: {
type: String,
default: (image) ? image.src : ''
default: linkAppleTouchIcon
},
button_design: {
type: String,
default: 'flat'
default: () => 'flat'
},
title_social: String,
has_icon: Boolean,
Expand Down
9 changes: 6 additions & 3 deletions src/providers/Reddit.vue
Original file line number Diff line number Diff line change
Expand Up @@ -20,20 +20,23 @@
</template>

<script>
import {documentHref} from '../helpers/href';
import {documentTitle} from '../helpers/title';
export default {
name: 'VueGoodshareReddit',
props: {
page_url: {
type: String,
default: document.location.href
default: documentHref
},
page_title: {
type: String,
default: document.title
default: documentTitle
},
button_design: {
type: String,
default: 'flat'
default: () => 'flat'
},
title_social: String,
has_icon: Boolean,
Expand Down
6 changes: 3 additions & 3 deletions src/providers/Telegram.vue
Original file line number Diff line number Diff line change
Expand Up @@ -14,18 +14,18 @@
</template>

<script>
import defaultHref from '../helpers/defaultHref';
import {documentHrefWithoutHash} from '../helpers/href';
export default {
name: 'VueGoodshareTelegram',
props: {
page_url: {
type: String,
default: defaultHref
default: documentHrefWithoutHash
},
button_design: {
type: String,
default: 'flat'
default: () => 'flat'
},
title_social: String,
has_icon: Boolean,
Expand Down
13 changes: 7 additions & 6 deletions src/providers/Tumblr.vue
Original file line number Diff line number Diff line change
Expand Up @@ -21,27 +21,28 @@
</template>

<script>
// Variables
const description = document.querySelector('meta[name="description"]')
import {documentHref} from '../helpers/href';
import {documentTitle} from '../helpers/title';
import {metaDescription} from '../helpers/description';
export default {
name: 'VueGoodshareTumblr',
props: {
page_url: {
type: String,
default: document.location.href
default: documentHref
},
page_title: {
type: String,
default: document.title
default: documentTitle
},
page_description: {
type: String,
default: (description) ? description.content : ''
default: metaDescription
},
button_design: {
type: String,
default: 'flat'
default: () => 'flat'
},
title_social: String,
has_icon: Boolean,
Expand Down
Loading

0 comments on commit d948e92

Please sign in to comment.