Skip to content

Commit

Permalink
Adding share functionality
Browse files Browse the repository at this point in the history
  • Loading branch information
vishal30982 committed Dec 6, 2023
1 parent d13cd21 commit b5778e1
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 4 deletions.
2 changes: 1 addition & 1 deletion card.css
Original file line number Diff line number Diff line change
Expand Up @@ -220,4 +220,4 @@ html, body {
}
#share-area span.share-icon {
cursor: pointer;
}
}
4 changes: 2 additions & 2 deletions card.html
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@
<div id="main">
<div id="card">
<div id="share-area">
<span class="material-symbols-outlined share-icon">
<button><span class="material-symbols-outlined share-icon">
share
</span>
</span></button>
</div>
<div id="share-popup">
<div id="share">
Expand Down
10 changes: 9 additions & 1 deletion script.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,12 @@ function ChangeTheme (theme) {
let choosenTheme = localStorage.getItem('theme');
document.querySelector(':root').style.setProperty('--theme', choosenTheme);

let share_btn = document.querySelector('#share-area')
let share_btn = document.querySelector('#share-area button')
let share_link = location.href;
share_btn.addEventListener('click', async () => {
try {
await navigator.share(share_link)
} catch (error) {
alert('Something Went Wrong In Sharing!')
}
})

0 comments on commit b5778e1

Please sign in to comment.