Skip to content

Commit

Permalink
Merge pull request #727 from michalv8/feature/github-star-button
Browse files Browse the repository at this point in the history
Added Github star button
  • Loading branch information
adam-boduch authored Sep 14, 2023
2 parents 1af18e7 + 36695ea commit 595a751
Show file tree
Hide file tree
Showing 4 changed files with 57 additions and 1 deletion.
1 change: 1 addition & 0 deletions resources/js/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import './libs/timeago.js';
import './components/vcard.js';
import './plugins/flags.ts';
import './plugins/sociale.js';
import './plugins/components.ts';
import '@popperjs/core'; // must be imported before bootstrap
import './bootstrap';
import './libs/axios-throttle.ts';
Expand Down
40 changes: 40 additions & 0 deletions resources/js/components/github-star.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
<template>
<iframe v-if="isLoaded"
src="https://ghbtns.com/github-btn.html?user=pradoslaw&repo=coyote&type=star&count=true&size=large"
frameborder="0"
scrolling="0"
width="120"
height="30"
title="GitHub"
></iframe>
</template>

<script lang="js">
export default {
data: () => ({
isLoaded: false,
isMounted: false,
}),
methods: {
handleLoad() {
this.isLoaded = true;
}
},
mounted() {
if (this.isMounted) {
return;
}
window.addEventListener('load', this.handleLoad)
this.isMounted = true;
},
unmounted() {
window.removeEventListener('load', this.handleLoad)
this.isMounted = false;
this.isLoaded = false;
}
}
</script>
9 changes: 9 additions & 0 deletions resources/js/plugins/components.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import Vue from "vue";
import VueGithubStar from "@/components/github-star.vue";

new Vue({
el: '#navbar',
components: {
'vue-github-star': VueGithubStar,
},
});
8 changes: 7 additions & 1 deletion resources/views/layout.twig
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@
{{ form_open({url: route('logout'), name: 'logout-form'}) }}
{{ form_close() }}

<nav class="navbar navbar-expand-lg {{ __dark_theme ? 'bg-dark navbar-dark' : 'bg-light navbar-light' }}">
<nav id="navbar" class="navbar navbar-expand-lg {{ __dark_theme ? 'bg-dark navbar-dark' : 'bg-light navbar-light' }}">
<div class="container-xxl d-flex w-100 flex-wrap">
<button class="navbar-toggler" type="button" data-bs-toggle="collapse" data-bs-target="#mobile-menu">
<span class="navbar-toggler-icon"></span>
Expand Down Expand Up @@ -87,12 +87,18 @@
{% endif %}
</li>
{% endfor %}
<li class="d-block d-md-none">
<vue-github-star></vue-github-star>
</li>
</ul>
</div>

<div id="js-searchbar" class="d-flex flex-grow-1 order-1">
<vue-searchbar value="{{ input_get('q') }}"></vue-searchbar>
</div>
<div class="d-none d-md-flex order-1 align-self-center">
<vue-github-star></vue-github-star>
</div>

{% if auth_check() %}
<ul id="nav-auth" class="nav-auth navbar-nav order-2"></ul>
Expand Down

0 comments on commit 595a751

Please sign in to comment.