components
All repositories: gitoria
3.9 KB
// demo.hl — `/comments`: the comments block on a page with the mock thread of lib/comments.hl. WHAT IS STORED IS THE APP'S DECISION:// the block tells this page (post, edit, delete, like) through the four functions it is handed; the page makes a new list and hands it// back. "You are" switches the current user, so Edit / Delete show only on that user's comments; "nobody" reads only.// ATTACHMENTS (attach = "true", mission 009): files dropped, chosen or pasted into the form go with the post — the page's face stores// them (one day, lib/uploads.hl) and the new comment shows them: pictures as thumbnails, other files as rows. Up to 2 MB per file.parent '../main.hl'import Comments from './comments.hl'import { demoComments, withNew, withEdit, without, withLike, attachedOf } from '../../lib/comments.hl'import { storeMdFiles } from '../../lib/uploads.hl'__title = 'Comments · Hybriel components'Hybrid thread = demoCommentsString me = 'alice'// who is chosen: its button is filled and pressed, the others quiet (a View attribute cannot hold an expression, so each is a member)String aliceClass = ''String bobClass = 'quiet'String nobodyClass = 'quiet'String alicePressed = 'true'String bobPressed = 'false'String nobodyPressed = 'false'String meText = 'now alice'String told = 'nothing yet'Number seq = 0posted = (text, files) => {let stored = []if (files.length > 0) {stored = emit server demoAttach(files)if (stored == null) {told = 'post refused'return false}}seq = seq + 1thread = withNew(thread, me, text, seq, stored)told = files.length > 0 ? 'post with ' + files.length + ' files' : 'post'}edited = (id, text) => {thread = withEdit(thread, id, text)told = 'edit ' + id}deleted = (id) => {thread = without(thread, id)told = 'delete ' + id}// what a push from elsewhere does in an app (another user edits): the page gets a new list, nobody pressed anything in this blockon demoElsewhere(e) { thread = withEdit(thread, 'c2', 'Changed **elsewhere**: bob edited it in another tab.') }liked = (id) => {thread = withLike(thread, id)told = 'like ' + id}View {commentsDemo {h1 { "Comments" }p { class = "muted" "A thread: avatar, name, time, “edited” with the earlier versions, the text as Markdown, a like, and Edit / Delete on your own comments. Type a new one below in the Markdown editor." }p { class = "comments-who" role = "group" 'aria-label' = "Act as" "You are:"button { type = "button" id = "as-alice" class = aliceClass 'aria-pressed' = alicePressed "alice" on click(e) { emit demoAs('alice') } }button { type = "button" id = "as-bob" class = bobClass 'aria-pressed' = bobPressed "bob" on click(e) { emit demoAs('bob') } }button { type = "button" id = "as-nobody" class = nobodyClass 'aria-pressed' = nobodyPressed "nobody" on click(e) { emit demoAs('') } }output { id = "comments-me" class = "muted" meText }}p { button { type = "button" id = "elsewhere" "bob edits his comment elsewhere (a push)" on click(e) { emit demoElsewhere(e) } } }Comments { comments = thread user = me onPost = posted onEdit = edited onDelete = deleted onLike = liked signInText = "Choose a user above to comment." attach = "true" maxFileSize = 2097152 }p { class = "muted" "The page was told: " output { id = "comments-told" told } }p { a { id = "readme" href = "/comments/README.md" "README (how to use it)" } }}}on demoAs(who) {me = whoaliceClass = who == 'alice' ? '' : 'quiet'bobClass = who == 'bob' ? '' : 'quiet'nobodyClass = who == '' ? '' : 'quiet'alicePressed = who == 'alice' ? 'true' : 'false'bobPressed = who == 'bob' ? 'true' : 'false'nobodyPressed = who == '' ? 'true' : 'false'meText = 'now ' + (who == '' ? 'nobody' : who)}// the files of a new comment: stored for a day, what the block shows of each back (the demo's decision: lib/uploads.hl)on server demoAttach(files) { return attachedOf(files, storeMdFiles(files)) }
Branches
Latest commits
- c9861533Record B44 component proof and browser gate blockermre
- 1b7413beIgnore detached media events and space demo option outputsmre
- ca3b4959Re-vendor complete Hybriel plugins and runtime to day44mre
- df9e7df9Last-item checks run in the browser gate (components#26 fixed on day41); media-player loop is a plain Booleanmre
- 895a5afcRe-vendor complete Hybriel plugins and runtime to day41mre
- 16006bb3Backup tar: --hard-dereference, so mpackdb sidecars are never stored as hard links (Tracker's finding)mre
- 88397fc3Re-vendor complete Hybriel plugins and runtime to day39mre
- 9b872cedRecord IC28 deployment and live icon verificationmre
- 46fefaa7Count the icons entry in the offline home-page checkmre
- c7e14cabRecord IC28 rerun and unchanged-main baseline comparisonmre
- 5e090ffdRecord IC28 review evidence and gate resultsmre
- adfe2c4dAdd shuffle, repeat and repeatOne shared iconsmre
- c96709c8media-player: skip = false and repeat = 'one' options (jukebox#19)mre
- bd4aa808Record VL24 deployment and live verificationmre
- e5b98ecfRun virtual-list gate before deploymentmre
- 2e9b4a8evirtual-list: into main, with centerId and scrollTop/onScroll (jukebox#20)mre
- 69954249Align all plugin sources with Hybriel day38bmre
- f740f666Re-vendor components to Hybriel set day38bmre
- 8176eb14Record CS23b deployment and live verificationmre
- 84e3ddaaRemove blank line before pagination Style closing bracemre