Skip to content

Commit

Permalink
feat: add 'Copy Link' button to each page
Browse files Browse the repository at this point in the history
  • Loading branch information
motorcityadam committed Mar 18, 2024
1 parent 0146f60 commit ddc0bea
Show file tree
Hide file tree
Showing 8 changed files with 49 additions and 3 deletions.
2 changes: 2 additions & 0 deletions layouts/page/about.html
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

{{ partial "site_logo.html" . }}

{{ partial "share.html" . }}

<section>
<div class="about-content">

Expand Down
10 changes: 9 additions & 1 deletion themes/kaigi/assets/app.css
Original file line number Diff line number Diff line change
Expand Up @@ -599,6 +599,14 @@
}

.about-content img {
width: 100%;
@apply w-full;
}

.btn-share::before {
@apply mb-1 mr-3 inline-block h-6 w-6 bg-white align-middle;

content: '';
mask: url('./icons/link.svg') no-repeat 50% 50%;
mask-size: cover;
}
}
6 changes: 4 additions & 2 deletions themes/kaigi/layouts/events/single.html.html
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,9 @@
<article>
{{ partial "site_logo.html" . }}

{{ partial "event_rsvp_live_stream" . }}
{{ partial "share.html" . }}

{{ partial "event_rsvp_live_stream.html" . }}

<header class="my-8">
<div>
Expand Down Expand Up @@ -37,7 +39,7 @@ <h2>{{ i18n "description" }}</h2>
{{ .Content }}

<div class="mt-8">
{{ partial "event_rsvp_live_stream" . }}
{{ partial "event_rsvp_live_stream.html" . }}
</div>

{{ partial "giscus_section.html" . }}
Expand Down
26 changes: 26 additions & 0 deletions themes/kaigi/layouts/partials/footer.html
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,10 @@
</div>

<script>
////////////////
// Theme
////////////////

// base
const htmlClass = document.documentElement.classList;
setTimeout(() => {
Expand Down Expand Up @@ -76,5 +80,27 @@
btnDark.addEventListener('click', () => {
setDark(sessionStorage.getItem('dark') !== 'true');
});

////////////////
// Share
////////////////
if (navigator && navigator.clipboard) {
var button = document.getElementById("share-btn");

button.addEventListener('click', function () {
navigator.clipboard.writeText(window.location.href).then(function () {
button.blur();

var oldInnerText = button.innerText;
button.innerText = 'Copied!';

setTimeout(function () {
button.innerText = oldInnerText;
}, 2000);
}, function (err) {
console.log(err);
});
});
}
</script>
</footer>
7 changes: 7 additions & 0 deletions themes/kaigi/layouts/partials/share.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<div>
<div class="mt-4">
<button id="share-btn" class="btn-primary btn-share">
<span>Copy Link</span>
</button>
</div>
</div>
1 change: 1 addition & 0 deletions themes/kaigi/static/icons/link.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
File renamed without changes
File renamed without changes

0 comments on commit ddc0bea

Please sign in to comment.