Skip to content

Commit

Permalink
cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
walsh9 committed Dec 4, 2024
1 parent ef7f112 commit 692e31e
Showing 1 changed file with 10 additions and 16 deletions.
26 changes: 10 additions & 16 deletions v2/src/components/VShareToolsItem.vue
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,10 @@
import { computed } from 'vue'
import AudioIcon from '../assets/icons/AudioIcon.vue'
// eslint-disable-next-line import/no-duplicates
import EmailIcon from '../assets/icons/EmailIcon.vue'
import FacebookIcon from '../assets/icons/FacebookIcon.vue'
import InstagramIcon from '../assets/icons/InstagramIcon.vue'
import LinkedinIcon from '../assets/icons/LinkedinIcon.vue'
// eslint-disable-next-line import/no-duplicates
import NewsletterIcon from '../assets/icons/EmailIcon.vue'
import PhoneIcon from '../assets/icons/PhoneIcon.vue'
import RedditIcon from '../assets/icons/RedditIcon.vue'
import SiteIcon from '../assets/icons/SiteIcon.vue'
Expand Down Expand Up @@ -77,7 +74,7 @@ const icons = {
homepage: LinkIcon,
}
const URL_PLACEHOLDER_PATTERN = new RegExp('%URL%', 'g')
const URL_PLACEHOLDER_PATTERN = /%URL%/g
const SOCIAL_SERVICE_MAP = {
spotify: {
profileBase: 'https://open.spotify.com/playlist/',
Expand Down Expand Up @@ -140,20 +137,16 @@ const shareBase = computed(() => {
})
const shareUrl = computed(() => {
const utmParams = Object.entries(props.utmParameters).map(([key, value]) => {
return 'utm_' + key + '=' + encodeURIComponent(value)
return `utm_${key}=${encodeURIComponent(value)}`
})
let url = props.url
if (utmParams.length > 0) {
url = url + '?' + utmParams.join('&')
url = `${url}?${utmParams.join('&')}`
}
const shareParams = Object.entries(props.shareParameters).map(
([key, value]) => {
return (
key +
'=' +
encodeURIComponent(value.replace(URL_PLACEHOLDER_PATTERN, url))
)
return `${key}=${encodeURIComponent(value.replace(URL_PLACEHOLDER_PATTERN, url))}`
}
)
Expand All @@ -162,23 +155,24 @@ const shareUrl = computed(() => {
const shouldOmitUrl = SOCIAL_SERVICE_MAP[props.service]?.omitUrl
if (!shouldOmitUrl) {
const urlKey = SOCIAL_SERVICE_MAP[props.service]?.urlKey || 'url'
const urlParam = urlKey + '=' + encodeURIComponent(url)
const urlParam = `${urlKey}=${encodeURIComponent(url)}`
params = [urlParam, ...params]
}
return shareBase.value + '?' + params.join('&')
return `${shareBase.value}?${params.join('&')}`
})
const ariaLabel = computed(() => {
if (props.label) {
return props.label
} else if (props.action === 'follow') {
return 'Follow us on ' + props.service
return `Follow us on ${props.service}`
} else if (props.action === 'share') {
return 'Share on ' + props.service
return `Share on ${props.service}`
}
return ''
})
// create share popup
const share = () => {
if (!props.service) {
return
Expand All @@ -200,7 +194,7 @@ const share = () => {
const left = windowWidth / 2 - 600 / 2 + screenLeft
const top = windowheight / 2 - 600 / 2 + screenTop
return { left: left, top: top }
return { left, top }
}
// get the position of the window
Expand Down

0 comments on commit 692e31e

Please sign in to comment.