1
1
mirror of https://github.com/namibia/awesome-cheatsheets.git synced 2024-12-23 02:28:55 +00:00
awesome-cheatsheets/components/BaseCheatsheet.vue

140 lines
3.1 KiB
Vue
Raw Normal View History

<!-- *************************************************************************
TEMPLATE
************************************************************************* -->
<template lang="pug">
.c-base-cheatsheet
a(
:href="link"
class="c-base-cheatsheet__link"
target="_blank"
)
img(
:src="baseUrl + '/images/components/BaseCheatsheet/' + thumbnail"
class="c-base-cheatsheet__thumbnail"
)
.c-base-cheatsheet__content
a(
:href="link"
class="c-base-cheatsheet__name"
target="_blank"
) The {{ name }} Cheatsheet
2018-09-09 18:07:59 +00:00
.c-base-cheatsheet__share
base-share(
2018-09-09 18:07:59 +00:00
v-for="network in networks"
@click="onShare"
:key="network"
:network="network"
class="c-base-cheatsheet__network"
2018-09-09 18:07:59 +00:00
)
</template>
<!-- *************************************************************************
SCRIPT
************************************************************************* -->
<script>
export default {
props: {
2018-09-09 18:07:59 +00:00
link: {
type: String,
required: true
},
name: {
type: String,
required: true
},
thumbnail: {
type: String,
required: true
}
2018-09-09 18:07:59 +00:00
},
data() {
return {
// --> STATE <--
baseUrl: process.env.baseUrl,
2018-09-09 18:07:59 +00:00
// --> COMPONENTS <--
2018-09-11 14:21:25 +00:00
networks: ["Facebook", "Twitter", "LinkedIn", "Telegram"]
2018-09-09 18:07:59 +00:00
};
},
methods: {
onShare(network) {
const link = this.link;
const socialNetwork = network.toLowerCase();
const technology = this.name;
let url = "";
let message = encodeURIComponent(
`Check this awesome cheatsheet about ${technology}: ${link} #${technology.toLowerCase()} #cheatsheet`
);
2018-09-10 12:24:08 +00:00
if (socialNetwork === "facebook") {
url = `https://www.facebook.com/sharer/sharer.php?u=${link}`;
} else if (socialNetwork === "telegram") {
url = `https://telegram.me/share/url?url=${link}&text=${message}`;
} else if (socialNetwork === "twitter") {
url = `https://twitter.com/intent/tweet?text=${message}`;
} else if (socialNetwork === "linkedin") {
url = `https://www.linkedin.com/shareArticle?mini=true&url=${link}&source=LinkedIn`;
}
window.open(url);
}
}
};
</script>
<!-- *************************************************************************
STYLE
************************************************************************* -->
<style lang="scss">
$c: ".c-base-cheatsheet";
#{$c} {
2018-09-09 18:07:59 +00:00
display: block;
padding: 10px;
2018-09-09 23:14:07 +00:00
border: 1px solid $oxford-blue;
border-radius: 6px;
2018-09-09 23:14:07 +00:00
background: $ebony-clay;
#{$c}__link {
#{$c}__thumbnail {
width: 100%;
height: 160px;
border-radius: 4px;
user-select: none;
}
}
#{$c}__content {
padding: 10px;
text-align: left;
#{$c}__name {
margin-bottom: 20px;
2018-09-09 23:14:07 +00:00
color: $white;
font-size: 18px;
}
#{$c}__share {
margin-top: 12px;
display: flex;
user-select: none;
#{$c}__network {
margin-right: 6px;
&:last-of-type {
margin-right: 0;
}
}
}
}
}
</style>