<GithubRibbon username="vuejs" project="vue" orientation="right" color="green"/>
Last active
November 23, 2018 09:04
-
-
Save nikibobi/9604285dd32be8f9945111fdcacc06ee to your computer and use it in GitHub Desktop.
Github ribbon vue.js component
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<template> | |
<a :href="link"> | |
<img :src="image" :style="{ [this.orientation]: 0 }" alt="Fork me on GitHub"> | |
</a> | |
</template> | |
<script lang="ts"> | |
import { Component, Prop, Vue } from 'vue-property-decorator'; | |
const palete = { | |
red: "aa0000", | |
green: "007200", | |
darkblue: "121621", | |
orange: "ff7600", | |
gray: "6d6d6d", | |
white: "ffffff" | |
} | |
// https://blog.github.com/2008-12-19-github-ribbons | |
@Component | |
export default class GitHubRibbon extends Vue { | |
@Prop() username!: string; | |
@Prop({ default: null }) project!: string; | |
@Prop({ default: "left" }) orientation!: "left" | "right"; | |
@Prop({ default: "red" }) color!: "red" | "green" | "darkblue" | "orange" | "gray" | "white"; | |
get link() { | |
let url = `https://github.com/${this.username}`; | |
if (this.project) { | |
url += `/${this.project}`; | |
} | |
return url; | |
} | |
get image() { | |
return `https://s3.amazonaws.com/github/ribbons/forkme_${this.orientation}_${this.color}_${palete[this.color]}.png`; | |
} | |
} | |
</script> | |
<style scoped> | |
img { | |
position: fixed; | |
top: 0; | |
border: 0; | |
} | |
</style> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment