Skip to content

Commit

Permalink
🐛 Fix Click to Load
Browse files Browse the repository at this point in the history
  • Loading branch information
mcnaveen committed Apr 14, 2022
1 parent 8ca258d commit 3f786e6
Show file tree
Hide file tree
Showing 6 changed files with 15 additions and 15 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -102,10 +102,10 @@ yarn build
- Example: `mysupacomments.com`
```html
<div id="comments" data-url="yoursite.com" loadmore="false"></div>
<div id="comments" data-url="yoursite.com" clickToLoad="false"></div>
```
- Optionally, You can set the `loadmore` attribute to `true` to disable autoloading of comments, the User has to click Load Comments button. (Default is `false`)
- Optionally, You can set the `clickToLoad` attribute to `true` to disable autoloading of comments, the User has to click Load Comments button. (Default is `false`)
Now, If you open your static website or blog, you will see the comments section like below.
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "SupaComments",
"version": "0.0.3",
"version": "0.0.4",
"private": true,
"scripts": {
"watch:tailwind": "postcss public/tailwind.css -o public/build/comments.css -w",
Expand Down
2 changes: 1 addition & 1 deletion public/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
</head>

<body>
<div id="comments" data-url="yoursite.com" loadmore="true"></div>
<div id="comments" data-url="yoursite.com" clickToLoad="true"></div>
</body>


Expand Down
4 changes: 2 additions & 2 deletions src/App.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,12 @@
const postPath = window.location.pathname;
const hostURL = window.location.host;
export let appUrl;
export let loadMore;
export let clickToLoad;
const Props = {
hostURL,
postPath,
loadMore,
clickToLoad,
};
</script>

Expand Down
14 changes: 7 additions & 7 deletions src/components/AllComments.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@
import { generateFromString } from "generate-avatar";
export let postPath;
let loading = true;
export let loadMore;
let enableLoadMore;
export let clickToLoad;
let enableclickToLoad;
export const comments = async () => {
enableLoadMore = false;
enableclickToLoad = false;
const { data, error } = await supabase
.from("comments")
.select()
Expand All @@ -27,10 +27,10 @@
}
};
if (loadMore) {
enableLoadMore = true;
if (clickToLoad) {
enableclickToLoad = true;
} else {
enableLoadMore = false;
enableclickToLoad = false;
comments();
}
</script>
Expand All @@ -42,7 +42,7 @@
<div class="w-full p-3">
<h3 class="text-gray-700 text-2xl font-bold">User Comments</h3>
</div>
{#if enableLoadMore}
{#if enableclickToLoad}
<div class="w-full p-3">
<button
class="bg-blue-500 hover:bg-blue-700 text-white font-bold py-2 px-4 rounded"
Expand Down
4 changes: 2 additions & 2 deletions src/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@ import App from "./App.svelte";

let comments = document.getElementById("comments");
let appUrl = comments.getAttribute("data-url") || "localhost:8080";
let loadMore = comments.getAttribute("loadmore") || false;
let clickToLoad = comments.getAttribute("clickToLoad") || false;

const app = new App({
target: comments,
props: {
appUrl: appUrl,
loadMore: loadMore,
clickToLoad: clickToLoad,
},
});

Expand Down

0 comments on commit 3f786e6

Please sign in to comment.