Skip to content

Commit 5cc1f7d

Browse files
committed
wip: refine list ui
1 parent bda5008 commit 5cc1f7d

25 files changed

+297
-77
lines changed

β€Žs/auth/utils/validation.tsβ€Ž

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
2+
export function validName(name: string) {
3+
return (
4+
typeof name === "string" &&
5+
name.length >= 1 &&
6+
name.length <= 24 &&
7+
8+
// allowing all ordinary characters
9+
/^[\p{L}\p{N}\p{P}\p{S}\p{Zs}]+$/u.test(name) &&
10+
11+
// disallow control/invisible characters
12+
!/[\p{C}]/u.test(name) &&
13+
14+
// disallow leading/trailing whitespace
15+
!/^\s|\s$/u.test(name)
16+
)
17+
}
18+

β€Žs/dom/elements/app/element.tsβ€Ž

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import {Situation} from "../../situation.js"
77
import {Authcore} from "../../../auth/core.js"
88
import {Identity} from "../../../auth/types.js"
99
import {ListView} from "../../views/list/view.js"
10+
import {EditView} from "../../views/edit/view.js"
1011
import {CreateView} from "../../views/create/view.js"
1112
import {DeleteView} from "../../views/delete/view.js"
1213
import {syllabicName} from "../../../tools/random-names.js"
@@ -21,8 +22,8 @@ export const AuthApp = nexus.shadowComponent(use => {
2122
situationOp.load(async() => ({
2223
kind: "list",
2324
authcore,
25+
onEdit: gotoEdit,
2426
onCreate: gotoCreate,
25-
onDelete: gotoDelete,
2627
}))
2728
}
2829

@@ -40,6 +41,19 @@ export const AuthApp = nexus.shadowComponent(use => {
4041
}))
4142
}
4243

44+
function gotoEdit(identity: Identity) {
45+
situationOp.load(async() => ({
46+
kind: "edit",
47+
identity,
48+
onCancel: gotoList,
49+
onDelete: gotoDelete,
50+
onComplete: identity => {
51+
authcore.add(identity)
52+
gotoList()
53+
},
54+
}))
55+
}
56+
4357
function gotoDelete(identity: Identity) {
4458
situationOp.load(async() => ({
4559
kind: "delete",
@@ -57,6 +71,7 @@ export const AuthApp = nexus.shadowComponent(use => {
5771
return loading.braille(situationOp, situation => {switch (situation.kind) {
5872
case "list": return ListView([situation])
5973
case "create": return CreateView([situation])
74+
case "edit": return EditView([situation])
6075
case "delete": return DeleteView([situation])
6176
default: throw new Error("unknown situation")
6277
}})
File renamed without changes.
File renamed without changes.
File renamed without changes.

0 commit comments

Comments
Β (0)