-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
ef83fd7
commit 1fb6d2b
Showing
20 changed files
with
294 additions
and
38 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
[tools] | ||
erlang = "27.1.2" | ||
rebar = "3.24.0" | ||
gleam = "1.5.1" | ||
gleam = "latest" | ||
erlang = "latest" | ||
rebar = "latest" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,18 @@ | ||
{ | ||
"name": "okane", | ||
"type": "module", | ||
"devDependencies": { | ||
"daisyui": "^4.12.14", | ||
"@preact/signals-core": "^1.8.0", | ||
"@types/bun": "latest", | ||
"@types/toastify-js": "^1.12.3", | ||
"daisyui": "^4.12.14", | ||
"tailwindcss": "^3.4.14" | ||
}, | ||
"peerDependencies": { | ||
"typescript": "^5.0.0" | ||
}, | ||
"type": "module", | ||
"dependencies": { | ||
"tinydate": "^1.3.0", | ||
"toastify-js": "^1.12.0" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
/** | ||
* | ||
* @param {string|URL|globalThis.Request} url | ||
* @param {RequestInit} init | ||
*/ | ||
export async function $fetch(url, { headers = {}, ...rest } = {}) { | ||
return fetch(url, { | ||
...rest, | ||
headers: { | ||
"Content-Type": "application/json", | ||
...headers, | ||
}, | ||
}); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
import { html } from "htm"; | ||
|
||
export function GroupCreateForm() { | ||
return html` <form>some</form> `; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
import { html } from "htm"; | ||
import { $fetch } from "../client.js"; | ||
import { $groups, set_partial } from "../store.js"; | ||
import tinydate from "tinydate"; | ||
|
||
async function load_groups() { | ||
set_partial($groups, { state: "loading" }); | ||
|
||
const resp = await $fetch("/auth/groups"); | ||
|
||
if (resp.status === 200) { | ||
const body = await resp.json(); | ||
|
||
$groups.value = { | ||
state: "idle", | ||
data: body.data, | ||
}; | ||
} | ||
} | ||
|
||
load_groups(); | ||
|
||
export function GroupsList() { | ||
return html` | ||
${$groups.value.state === "loading" | ||
? html`<span>Loading groups</span>` | ||
: html`<div class="flex flex-col gap-3"> | ||
<div>Groups you're part of</div> | ||
<ul class="flex flex-col gap-2"> | ||
${$groups.value.data.map((group) => { | ||
return html`<li | ||
key=${group.id} | ||
class="rounded flex flex-col gap-0.5 px-1.5 py-1 shadow-sm bg-base-200" | ||
> | ||
<div class="text-sm">${group.id}: ${group.name}</div> | ||
<div class="text-xs"> | ||
created: | ||
${tinydate("{MMMM} {DD} {YYYY}", { | ||
MMMM: (d) => d.toLocaleString("default", { month: "long" }), | ||
})(new Date(group.created_at))} | ||
</div> | ||
</li>`; | ||
})} | ||
</ul> | ||
</div>`} | ||
`; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
import "toastify-js/src/toastify.css"; | ||
import toastify from "toastify-js/src/toastify-es.js"; | ||
|
||
export { toastify }; |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,19 @@ | ||
import { $auth_state } from "../store.js"; | ||
import { html } from "htm"; | ||
import { GroupsList } from "../components/groups_list.js"; | ||
import { GroupCreateForm } from "../components/group_create_form.js"; | ||
|
||
export function home() { | ||
return html`<div>Hello ${$auth_state.value.name}! Welcome to Okane.</div>`; | ||
return html`<div class="flex flex-col gap-4"> | ||
<div | ||
class="pb-2 flex justify-between gap-2 items-center border-b border-secondary" | ||
> | ||
<div>Okane</div> | ||
<div>${$auth_state.value.name}</div> | ||
</div> | ||
<${GroupsList} /> | ||
<${GroupCreateForm} /> | ||
</div>`; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,11 @@ | ||
@tailwind base; | ||
@tailwind components; | ||
@tailwind utilities; | ||
|
||
.app-toast { | ||
@apply alert p-1; | ||
} | ||
|
||
.app-toast--error { | ||
@apply alert-error; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.