Skip to content

Commit f56ab1b

Browse files
authored
Merge pull request #5 from pantanal-labs/blog
Add Blog
2 parents bc6127a + f6e75b8 commit f56ab1b

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

45 files changed

+12460
-85
lines changed

assets/css/app.scss

+22-1
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,25 @@
22

33
@tailwind components;
44

5-
@tailwind utilities;
5+
@tailwind utilities;
6+
7+
@layer components {
8+
#menu-toggle:checked + #menu {
9+
display: block;
10+
}
11+
.post-body a {
12+
@apply border-b border-black;
13+
}
14+
15+
.post-body h2 {
16+
@apply text-2xl font-bold mt-6 mb-4;
17+
}
18+
19+
.post-body > :first-child {
20+
margin-top: 0;
21+
}
22+
23+
.post-body p {
24+
@apply mt-5 mb-5;
25+
}
26+
}

assets/js/app.js

+19-12
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
// We need to import the CSS so that webpack will load it.
22
// The MiniCssExtractPlugin is used to separate it out into
33
// its own CSS file.
4-
import "../css/app.scss"
4+
import "../css/app.scss";
55

66
// webpack automatically bundles all modules in your
77
// entry points. Those entry points can be configured
@@ -12,22 +12,29 @@ import "../css/app.scss"
1212
// import {Socket} from "phoenix"
1313
// import socket from "./socket"
1414
//
15-
import "phoenix_html"
16-
import {Socket} from "phoenix"
17-
import NProgress from "nprogress"
18-
import {LiveSocket} from "phoenix_live_view"
15+
import "phoenix_html";
16+
import { Socket } from "phoenix";
17+
// import NProgress from "nprogress";
18+
import { LiveSocket } from "phoenix_live_view";
19+
import Hooks from "./hooks";
1920

20-
let csrfToken = document.querySelector("meta[name='csrf-token']").getAttribute("content")
21-
let liveSocket = new LiveSocket("/live", Socket, {params: {_csrf_token: csrfToken}})
21+
let csrfToken = document
22+
.querySelector("meta[name='csrf-token']")
23+
.getAttribute("content");
24+
let liveSocket = new LiveSocket("/live", Socket, {
25+
params: { _csrf_token: csrfToken },
26+
hooks: Hooks,
27+
});
2228

2329
// Show progress bar on live navigation and form submits
24-
window.addEventListener("phx:page-loading-start", info => NProgress.start())
25-
window.addEventListener("phx:page-loading-stop", info => NProgress.done())
30+
// window.addEventListener("phx:page-loading-start", (info) => NProgress.start());
31+
// window.addEventListener("phx:page-loading-stop", (info) => NProgress.done());
2632

2733
// connect if there are any LiveViews on the page
28-
liveSocket.connect()
34+
liveSocket.connect();
2935

3036
// expose liveSocket on window for web console debug logs and latency simulation:
31-
// >> liveSocket.enableDebug()
37+
//liveSocket.enableDebug()
3238
// >> liveSocket.enableLatencySim(1000)
33-
window.liveSocket = liveSocket
39+
window.liveSocket = liveSocket;
40+

assets/js/hooks.js

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
import Editor from "./hooks/editor";
2+
import InfiniteScroll from "./hooks/infinitescroll";
3+
4+
const Hooks = {
5+
Editor: Editor,
6+
InfiniteScroll: InfiniteScroll,
7+
};
8+
9+
export default Hooks;

assets/js/hooks/editor.js

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
const Editor = {
2+
mounted() {},
3+
};
4+
5+
export default Editor;

assets/js/hooks/infinitescroll.js

+22
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
const InfiniteScroll = {
2+
mounted() {
3+
this.observer = new IntersectionObserver((entries) => {
4+
const entry = entries[0];
5+
if (entry.isIntersecting) {
6+
this.pushEvent("load-more");
7+
}
8+
});
9+
10+
this.observer.observe(this.el);
11+
},
12+
13+
updated() {
14+
const pageNumber = this.el.dataset.pageNumber;
15+
},
16+
17+
destroyed() {
18+
this.observer.disconnect();
19+
},
20+
};
21+
22+
export default InfiniteScroll;

0 commit comments

Comments
 (0)