Skip to content

Commit

Permalink
fix: reenables scroll on sidebar click
Browse files Browse the repository at this point in the history
  • Loading branch information
ghivert committed Jun 29, 2024
1 parent 96c15f3 commit 774745d
Show file tree
Hide file tree
Showing 163 changed files with 15,764 additions and 72 deletions.
2 changes: 1 addition & 1 deletion apps/frontend/gleam.toml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ modem = ">= 1.1.0 and < 2.0.0"
plinth = ">= 0.2.0 and < 1.0.0"
sketch = ">= 2.2.2 and < 3.0.0"
tardis = ">= 0.1.0 and < 1.0.0"
lustre = ">= 4.3.0 and < 5.0.0"
lustre = { path = "../../packages/lustre" }

[dev-dependencies]
gleeunit = "~> 1.0"
15 changes: 8 additions & 7 deletions apps/frontend/manifest.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,20 +2,21 @@
# You typically do not need to edit this file

packages = [
{ name = "birl", version = "1.6.1", build_tools = ["gleam"], requirements = ["gleam_stdlib", "ranger"], otp_app = "birl", source = "hex", outer_checksum = "976CFF85D34D50F7775896615A71745FBE0C325E50399787088F941B539A0497" },
{ name = "birl", version = "1.7.1", build_tools = ["gleam"], requirements = ["gleam_stdlib", "ranger"], otp_app = "birl", source = "hex", outer_checksum = "5C66647D62BCB11FE327E7A6024907C4A17954EF22865FE0940B54A852446D01" },
{ name = "conversation", version = "1.4.3", build_tools = ["gleam"], requirements = ["gleam_http", "gleam_javascript", "gleam_stdlib"], otp_app = "conversation", source = "hex", outer_checksum = "908B46F60444442785A495197D482558AD8B849C3714A38FAA1940358CC8CCCD" },
{ name = "gleam_erlang", version = "0.25.0", build_tools = ["gleam"], requirements = ["gleam_stdlib"], otp_app = "gleam_erlang", source = "hex", outer_checksum = "054D571A7092D2A9727B3E5D183B7507DAB0DA41556EC9133606F09C15497373" },
{ name = "gleam_fetch", version = "0.4.0", build_tools = ["gleam"], requirements = ["gleam_http", "gleam_javascript", "gleam_stdlib"], otp_app = "gleam_fetch", source = "hex", outer_checksum = "7446410A44A1D1328F5BC1FF4FC9CBD1570479EA69349237B3F82E34521CCC10" },
{ name = "gleam_http", version = "3.6.0", build_tools = ["gleam"], requirements = ["gleam_stdlib"], otp_app = "gleam_http", source = "hex", outer_checksum = "8C07DF9DF8CC7F054C650839A51C30A7D3C26482AC241C899C1CEA86B22DBE51" },
{ name = "gleam_javascript", version = "0.8.0", build_tools = ["gleam"], requirements = ["gleam_stdlib"], otp_app = "gleam_javascript", source = "hex", outer_checksum = "14D5B7E1A70681E0776BF0A0357F575B822167960C844D3D3FA114D3A75F05A8" },
{ name = "gleam_javascript", version = "0.11.0", build_tools = ["gleam"], requirements = ["gleam_stdlib"], otp_app = "gleam_javascript", source = "hex", outer_checksum = "483631D3001FCE8EB12ADEAD5E1B808440038E96F93DA7A32D326C82F480C0B2" },
{ name = "gleam_json", version = "1.0.1", build_tools = ["gleam"], requirements = ["gleam_stdlib", "thoas"], otp_app = "gleam_json", source = "hex", outer_checksum = "9063D14D25406326C0255BDA0021541E797D8A7A12573D849462CAFED459F6EB" },
{ name = "gleam_otp", version = "0.10.0", build_tools = ["gleam"], requirements = ["gleam_erlang", "gleam_stdlib"], otp_app = "gleam_otp", source = "hex", outer_checksum = "0B04FE915ACECE539B317F9652CAADBBC0F000184D586AAAF2D94C100945D72B" },
{ name = "gleam_stdlib", version = "0.37.0", build_tools = ["gleam"], requirements = [], otp_app = "gleam_stdlib", source = "hex", outer_checksum = "5398BD6C2ABA17338F676F42F404B9B7BABE1C8DC7380031ACB05BBE1BCF3742" },
{ name = "gleeunit", version = "1.1.2", build_tools = ["gleam"], requirements = ["gleam_stdlib"], otp_app = "gleeunit", source = "hex", outer_checksum = "72CDC3D3F719478F26C4E2C5FED3E657AC81EC14A47D2D2DEBB8693CA3220C3B" },
{ name = "gleam_stdlib", version = "0.38.0", build_tools = ["gleam"], requirements = [], otp_app = "gleam_stdlib", source = "hex", outer_checksum = "663CF11861179AF415A625307447775C09404E752FF99A24E2057C835319F1BE" },
{ name = "gleeunit", version = "1.2.0", build_tools = ["gleam"], requirements = ["gleam_stdlib"], otp_app = "gleeunit", source = "hex", outer_checksum = "F7A7228925D3EE7D0813C922E062BFD6D7E9310F0BEE585D3A42F3307E3CFD13" },
{ name = "grille_pain", version = "1.0.1", build_tools = ["gleam"], requirements = ["birl", "gleam_stdlib", "lustre", "plinth", "sketch", "tardis"], otp_app = "grille_pain", source = "hex", outer_checksum = "F0CA9AA0BD4D03B8E190AB4CBB9429DE9389BC2152CF566C3410261F5729827C" },
{ name = "lustre", version = "4.3.0", build_tools = ["gleam"], requirements = ["gleam_erlang", "gleam_json", "gleam_otp", "gleam_stdlib"], otp_app = "lustre", source = "hex", outer_checksum = "43642C0602D3E2D6FEC3E24173D68A1F8E646969B53A2B0A5EB61238DDA739C4" },
{ name = "lustre", version = "4.3.0", build_tools = ["gleam"], requirements = ["gleam_erlang", "gleam_json", "gleam_otp", "gleam_stdlib"], source = "local", path = "../../packages/lustre" },
{ name = "lustre_http", version = "0.5.2", build_tools = ["gleam"], requirements = ["gleam_fetch", "gleam_http", "gleam_javascript", "gleam_json", "gleam_stdlib", "lustre"], otp_app = "lustre_http", source = "hex", outer_checksum = "FB0478CBFA6B16DBE8ECA326DAE2EC15645E04900595EF2C4F039ABFA0512ABA" },
{ name = "modem", version = "1.1.0", build_tools = ["gleam"], requirements = ["gleam_stdlib", "lustre"], otp_app = "modem", source = "hex", outer_checksum = "4C6E448089B09A57C179455D44526A717E4E217D4000B91201617FD2D9F18E68" },
{ name = "plinth", version = "0.2.0", build_tools = ["gleam"], requirements = ["gleam_javascript", "gleam_json", "gleam_stdlib"], otp_app = "plinth", source = "hex", outer_checksum = "83211E672D83F3CE14681D0ECD3AD883EE7588E423E7C9DDDB460014AD60AC24" },
{ name = "plinth", version = "0.4.7", build_tools = ["gleam"], requirements = ["conversation", "gleam_javascript", "gleam_json", "gleam_stdlib"], otp_app = "plinth", source = "hex", outer_checksum = "BBDD8F05368A1C9AB09A8BF50BBD98E5C23A6AA754DFF2E9B36C87988AC82D47" },
{ name = "ranger", version = "1.2.0", build_tools = ["gleam"], requirements = ["gleam_stdlib"], otp_app = "ranger", source = "hex", outer_checksum = "1566C272B1D141B3BBA38B25CB761EF56E312E79EC0E2DFD4D3C19FB0CC1F98C" },
{ name = "sketch", version = "2.2.2", build_tools = ["gleam"], requirements = ["gleam_erlang", "gleam_otp", "gleam_stdlib", "lustre", "plinth"], otp_app = "sketch", source = "hex", outer_checksum = "AE2FE447AB1C993CE4884D9EFE915D1971AEDED335904B77BE875B5BE3D7378B" },
{ name = "tardis", version = "0.1.0", build_tools = ["gleam"], requirements = ["gleam_stdlib", "lustre", "plinth", "sketch"], otp_app = "tardis", source = "hex", outer_checksum = "C8E7BAB95C59EF50332905A06B82BB35526B7BE2F191580F3CD8790903AA49F7" },
Expand All @@ -28,7 +29,7 @@ gleam_json = { version = ">= 1.0.1 and < 2.0.0" }
gleam_stdlib = { version = "~> 0.34 or ~> 1.0" }
gleeunit = { version = "~> 1.0" }
grille_pain = { version = ">= 1.0.0 and < 2.0.0" }
lustre = { version = ">= 4.3.0 and < 5.0.0"}
lustre = { path = "../../packages/lustre" }
lustre_http = { version = "~> 0.5" }
modem = { version = ">= 1.1.0 and < 2.0.0" }
plinth = { version = ">= 0.2.0 and < 1.0.0" }
Expand Down
3 changes: 2 additions & 1 deletion apps/frontend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,14 @@
"name": "frontend",
"version": "1.0.0",
"private": true,
"type": "module",
"scripts": {
"dev": "vite",
"build": "tsc && vite build",
"preview": "vite preview"
},
"dependencies": {
"@chouqueth/gleam": "^1.2.1",
"@gleam-lang/highlight.js-gleam": "^1.5.0",
"@sentry/browser": "^8.0.0",
"dompurify": "^3.1.4",
Expand All @@ -20,7 +22,6 @@
"@trivago/prettier-plugin-sort-imports": "^4.3.0",
"@types/dompurify": "^3.0.5",
"dotenv": "^16.4.5",
"gleam-lang": "^1.1.0",
"prettier": "^3.2.5",
"ts-gleam": "^1.0.1",
"typescript": "^5.4.2",
Expand Down
13 changes: 11 additions & 2 deletions apps/frontend/src/config.ffi.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,9 @@ export function is_dev() {
}

export function scrollTo(id) {
const elem = document.getElementById(id)
if (!elem) return
const cache = document.getElementsByTagName('cache-signatures')
if (!cache?.[0]) return
const elem = cache[0].shadowRoot.getElementById(id)
const elemRect = elem.getBoundingClientRect()
const navbarRect = document.getElementsByClassName('navbar')?.[0]?.getBoundingClientRect()
const bodyRect = document.body.getBoundingClientRect()
Expand All @@ -22,3 +23,11 @@ export function captureMessage(content) {
export function updateTitle(title) {
document.title = title
}

export function coerce(a) {
return a
}

export function coerce_event(a) {
return a.detail
}
1 change: 0 additions & 1 deletion apps/frontend/src/frontend.gleam
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import frontend/view/body/cache
import gleam/bool
import gleam/dict
import gleam/dynamic
import gleam/io
import gleam/list
import gleam/option.{None}
import gleam/result
Expand Down
7 changes: 7 additions & 0 deletions apps/frontend/src/frontend.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,13 @@ import plaintext from 'highlight.js/lib/languages/plaintext'
// @ts-ignore
import { main } from './frontend.gleam'

// @ts-ignore
Element.prototype._attachShadow = Element.prototype.attachShadow
Element.prototype.attachShadow = function () {
// @ts-ignore
return this._attachShadow({ mode: 'open' })
}

hljs.registerLanguage('gleam', gleamHljs)
hljs.registerLanguage('plaintext', plaintext)
document.addEventListener('DOMContentLoaded', main)
10 changes: 9 additions & 1 deletion apps/frontend/src/frontend/view/body/body.gleam
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import frontend/view/body/styles as s
import frontend/view/search_input/search_input
import gleam/dict
import gleam/int
import gleam/io
import gleam/list
import gleam/option.{None, Some}
import gleam/result
Expand Down Expand Up @@ -129,6 +130,13 @@ pub fn view_trending(model: Model) {
}
}

fn on_coerce(value: a) {
Ok(coerce_event(value))
}

@external(javascript, "../../../config.ffi.mjs", "coerce_event")
fn coerce_event(value: a) -> b

pub fn body(model: Model) {
s.main([], [
case model.route {
Expand Down Expand Up @@ -162,7 +170,7 @@ pub fn body(model: Model) {
|> result.map(fn(content) {
el.element(
"cache-signatures",
[a.property("content", content)],
[a.property("content", content), e.on("child", on_coerce)],
[],
)
})
Expand Down
17 changes: 10 additions & 7 deletions apps/frontend/src/frontend/view/body/cache.gleam
Original file line number Diff line number Diff line change
Expand Up @@ -144,21 +144,24 @@ pub fn cache_search_results(
])
}

pub type MsgComponent {
UpdateContent(el.Element(MsgComponent))
pub type MsgComponent(msg) {
UpdateContent(el.Element(msg))
Received(msg)
}

@external(javascript, "../../../config.ffi.mjs", "coerce")
fn coerce(value: a) -> b

pub fn component() {
lustre.component(
fn(_flags) { #(el.none(), eff.none()) },
fn(_model, msg) {
fn(model: el.Element(msg), msg: MsgComponent(msg)) {
case msg {
UpdateContent(c) -> #(c, eff.none())
Received(msg) -> #(model, e.emit("child", coerce(msg)))
}
},
fn(model) { model },
dict.from_list([
#("content", fn(dyn) { Ok(UpdateContent(dynamic.unsafe_coerce(dyn))) }),
]),
fn(model) { el.map(model, Received) |> io.debug },
dict.from_list([#("content", fn(dyn) { Ok(UpdateContent(coerce(dyn))) })]),
)
}
6 changes: 4 additions & 2 deletions apps/frontend/vite.config.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
import { sentryVitePlugin } from '@sentry/vite-plugin'
import 'dotenv/config'
import { defineConfig } from 'vite'
import gleam from 'vite-gleam'

export default {
export default defineConfig(({ mode }) => ({
plugins: [
gleam(),
sentryVitePlugin({
disable: mode === 'development',
org: process.env.SENTRY_ORG,
project: process.env.SENTRY_PROJECT,
authToken: process.env.SENTRY_AUTH_TOKEN,
Expand All @@ -19,4 +21,4 @@ export default {
interop: 'auto',
},
},
}
}))
72 changes: 22 additions & 50 deletions apps/frontend/yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -353,6 +353,18 @@ __metadata:
languageName: node
linkType: hard

"@chouqueth/gleam@npm:^1.2.1":
version: 1.2.1
resolution: "@chouqueth/gleam@npm:1.2.1"
dependencies:
cachedir: "npm:^2.4.0"
tar: "npm:^7.1.0"
bin:
gleam: bin/cli.mjs
checksum: 10c0/f9b7daaa24c9672ef5e6976f76a687cddb2df2a701670e7cbdf36231eb919d75a51e38ad8b69305e5559c2d2d589718b936bddf289b7a591934aa7d7f9be8a30
languageName: node
linkType: hard

"@esbuild/aix-ppc64@npm:0.19.12":
version: 0.19.12
resolution: "@esbuild/aix-ppc64@npm:0.19.12"
Expand Down Expand Up @@ -1690,14 +1702,14 @@ __metadata:
version: 0.0.0-use.local
resolution: "frontend@workspace:."
dependencies:
"@chouqueth/gleam": "npm:^1.2.1"
"@gleam-lang/highlight.js-gleam": "npm:^1.5.0"
"@sentry/browser": "npm:^8.0.0"
"@sentry/vite-plugin": "npm:^2.16.1"
"@trivago/prettier-plugin-sort-imports": "npm:^4.3.0"
"@types/dompurify": "npm:^3.0.5"
dompurify: "npm:^3.1.4"
dotenv: "npm:^16.4.5"
gleam-lang: "npm:^1.1.0"
highlight.js: "npm:^11.9.0"
marked: "npm:^12.0.2"
marked-highlight: "npm:^2.1.1"
Expand Down Expand Up @@ -1760,18 +1772,6 @@ __metadata:
languageName: node
linkType: hard

"gleam-lang@npm:^1.1.0":
version: 1.1.0
resolution: "gleam-lang@npm:1.1.0"
dependencies:
cachedir: "npm:^2.4.0"
tar: "npm:^7.1.0"
bin:
gleam: bin/cli.mjs
checksum: 10c0/851d41ce6e2e4969e611cb65ee33abc80d5efd579fa170e896534f8f91b5b79d996f41c6a96ae4ec7160d53dc8d94530ec8ff954187b0a30179705271851bef9
languageName: node
linkType: hard

"glob-parent@npm:~5.1.2":
version: 5.1.2
resolution: "glob-parent@npm:5.1.2"
Expand All @@ -1781,7 +1781,7 @@ __metadata:
languageName: node
linkType: hard

"glob@npm:^10.2.2, glob@npm:^10.3.10":
"glob@npm:^10.2.2, glob@npm:^10.3.10, glob@npm:^10.3.7":
version: 10.4.2
resolution: "glob@npm:10.4.2"
dependencies:
Expand All @@ -1797,21 +1797,6 @@ __metadata:
languageName: node
linkType: hard

"glob@npm:^10.3.7":
version: 10.3.15
resolution: "glob@npm:10.3.15"
dependencies:
foreground-child: "npm:^3.1.0"
jackspeak: "npm:^2.3.6"
minimatch: "npm:^9.0.1"
minipass: "npm:^7.0.4"
path-scurry: "npm:^1.11.0"
bin:
glob: dist/esm/bin.mjs
checksum: 10c0/cda748ddc181b31b3df9548c0991800406d5cc3b3f8110e37a8751ec1e39f37cdae7d7782d5422d7df92775121cdf00599992dff22f7ff1260344843af227c2b
languageName: node
linkType: hard

"glob@npm:^9.3.2":
version: 9.3.5
resolution: "glob@npm:9.3.5"
Expand Down Expand Up @@ -1982,19 +1967,6 @@ __metadata:
languageName: node
linkType: hard

"jackspeak@npm:^2.3.6":
version: 2.3.6
resolution: "jackspeak@npm:2.3.6"
dependencies:
"@isaacs/cliui": "npm:^8.0.2"
"@pkgjs/parseargs": "npm:^0.11.0"
dependenciesMeta:
"@pkgjs/parseargs":
optional: true
checksum: 10c0/f01d8f972d894cd7638bc338e9ef5ddb86f7b208ce177a36d718eac96ec86638a6efa17d0221b10073e64b45edc2ce15340db9380b1f5d5c5d000cbc517dc111
languageName: node
linkType: hard

"jackspeak@npm:^3.1.2":
version: 3.4.0
resolution: "jackspeak@npm:3.4.0"
Expand Down Expand Up @@ -2135,7 +2107,7 @@ __metadata:
languageName: node
linkType: hard

"minimatch@npm:^9.0.1, minimatch@npm:^9.0.4":
"minimatch@npm:^9.0.4":
version: 9.0.4
resolution: "minimatch@npm:9.0.4"
dependencies:
Expand Down Expand Up @@ -2218,14 +2190,14 @@ __metadata:
languageName: node
linkType: hard

"minipass@npm:^5.0.0 || ^6.0.2 || ^7.0.0, minipass@npm:^7.0.4, minipass@npm:^7.1.0":
"minipass@npm:^5.0.0 || ^6.0.2 || ^7.0.0":
version: 7.1.1
resolution: "minipass@npm:7.1.1"
checksum: 10c0/fdccc2f99c31083f45f881fd1e6971d798e333e078ab3c8988fb818c470fbd5e935388ad9adb286397eba50baebf46ef8ff487c8d3f455a69c6f3efc327bdff9
languageName: node
linkType: hard

"minipass@npm:^7.0.2, minipass@npm:^7.0.3, minipass@npm:^7.1.2":
"minipass@npm:^7.0.2, minipass@npm:^7.0.3, minipass@npm:^7.0.4, minipass@npm:^7.1.2":
version: 7.1.2
resolution: "minipass@npm:7.1.2"
checksum: 10c0/b0fd20bb9fb56e5fa9a8bfac539e8915ae07430a619e4b86ff71f5fc757ef3924b23b2c4230393af1eda647ed3d75739e4e0acb250a6b1eb277cf7f8fe449557
Expand Down Expand Up @@ -2400,7 +2372,7 @@ __metadata:
languageName: node
linkType: hard

"path-scurry@npm:^1.11.0, path-scurry@npm:^1.11.1, path-scurry@npm:^1.6.1":
"path-scurry@npm:^1.11.1, path-scurry@npm:^1.6.1":
version: 1.11.1
resolution: "path-scurry@npm:1.11.1"
dependencies:
Expand Down Expand Up @@ -2754,16 +2726,16 @@ __metadata:
linkType: hard

"tar@npm:^7.1.0":
version: 7.1.0
resolution: "tar@npm:7.1.0"
version: 7.4.0
resolution: "tar@npm:7.4.0"
dependencies:
"@isaacs/fs-minipass": "npm:^4.0.0"
chownr: "npm:^3.0.0"
minipass: "npm:^7.1.0"
minipass: "npm:^7.1.2"
minizlib: "npm:^3.0.1"
mkdirp: "npm:^3.0.1"
yallist: "npm:^5.0.0"
checksum: 10c0/08d85076820a2885855e581623c9c41e17a9ca47ca203e073e4612ccbcecc9e963134a48ff4a392a12d5d2184ebe5f7ed1e4a68d964193cbb52514aa858a0d2a
checksum: 10c0/f4bab85fd101585f2cececc41eb8706191052ab65cc33f1a798198e0c7905f41b06ae3d6731fb2b6084847c53bc1e2265b77e05a105c0c44afaf6cb7a08ddf14
languageName: node
linkType: hard

Expand Down
13 changes: 13 additions & 0 deletions packages/lustre/.github/FUNDING.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# These are supported funding model platforms

github: [hayleigh-dot-dev]
patreon: # Replace with a single Patreon username
open_collective: # Replace with a single Open Collective username
ko_fi: # Replace with a single Ko-fi username
tidelift: # Replace with a single Tidelift platform-name/package-name e.g., npm/babel
community_bridge: # Replace with a single Community Bridge project-name e.g., cloud-foundry
liberapay: # Replace with a single Liberapay username
issuehunt: # Replace with a single IssueHunt username
otechie: # Replace with a single Otechie username
lfx_crowdfunding: # Replace with a single LFX Crowdfunding project-name e.g., cloud-foundry
custom: # Replace with up to 4 custom sponsorship URLs e.g., ['link1', 'link2']
Loading

0 comments on commit 774745d

Please sign in to comment.