Skip to content
This repository has been archived by the owner on Oct 1, 2021. It is now read-only.

Commit

Permalink
feat(style info): add Twitter share button
Browse files Browse the repository at this point in the history
  • Loading branch information
VChet committed Nov 22, 2020
1 parent 28a1032 commit 5640879
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions src/src/components/dialogs/StyleInfoDialog.vue
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,10 @@
</li>
</ul>

<div class="share">
<a class="twitter" :href="twitterLink" rel="noopener" target="_blank">Share on Twitter</a>
</div>

<div class="image">
<img
v-if="styleData.customPreview || styleData.preview"
Expand Down Expand Up @@ -147,6 +151,12 @@ export default {
const userOrgs = this.user.orgs.map((org) => org.name);
const isMember = userOrgs.includes(this.styleData.owner);
return isAdmin || isOwner || isMember;
},
twitterLink() {
const name = this.styleData.customName || this.styleData.name;
const link = `https://stylebase.cc/${this.styleData.owner}/${this.styleData.name}`;
const text = encodeURIComponent(`${name} by ${this.styleData.owner}.\n${link}`);
return `https://twitter.com/intent/tweet?text=${text}`;
}
},
methods: {
Expand Down Expand Up @@ -270,6 +280,17 @@ export default {
}
}
.share {
margin: 1rem 0;
a {
color: var(--color-main);
&:hover {
text-decoration: underline;
}
}
}
.image {
position: relative;
display: flex;
Expand Down

0 comments on commit 5640879

Please sign in to comment.