Skip to content

Instantly share code, notes, and snippets.

@nikibobi
Last active November 23, 2018 09:04
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save nikibobi/9604285dd32be8f9945111fdcacc06ee to your computer and use it in GitHub Desktop.
Save nikibobi/9604285dd32be8f9945111fdcacc06ee to your computer and use it in GitHub Desktop.
Github ribbon vue.js component

Example

<GithubRibbon username="vuejs" project="vue" orientation="right" color="green"/>
<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