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
- f9d405c8comments: reactions row half as far from its comment (creator 2026-10-24: 'half this distance please'); the 44 px tap targets staymre
- 4922f9cfsessions last 99 years (creator 2026-10-23: logins never expire; only sign out ends them)mre
- 0355975areports/MC-mobile.md, LOG, STATUS (MC)mre
- 3f0a7229Month view, date picker, range picker: names follow the page language (English by default, not the browser's), weekday/month names formatted in UTC (a UTC+12 zone showed Tue first), 44 px day cells and buttons, Send row air; gate checks at 390 px for every page, popup and dialog (MC)mre
- 29eb07eaPhone: 44 px targets on the site (brand, home links, buttons), comments, modal and pagination; the header is the brand alone on a phone; comments demo: labelled 'You are' group with the chosen user pressed (MC)mre
- d1cc83e2reports/E2-toolbar.mdmre
- 214c3183MdEditor on a phone: toolbar as two even rows of 44 px targets (no clipped icon, no swipe), 'Markdown source' label 15 px, table head 16 px; gate checks (E2)mre
- 9215bbaareports/F5-empty.mdmre
- 134b4e3eMdEditor: an editor the framework puts into the page is built at once (page observer), a surface put in anew under a built editor is redrawn; gates for both (hybriel#211)mre
- 0dce2899reports/K1-bubble.mdmre
- 6b0936a0comments: 'edited' foldable also drops the theme's border, margin and radius (display: contents alone left them computed)mre
- 8d79ff79comments bubble hugs its content: a readonly md-editor surface gets no inline min-height (it beat the stylesheet's min-height 0); 'edited' is a quiet label beside the time, versions unframed; gate checksmre
- ef253fecreports/F4-icons.mdmre
- ba96735ficons: README, md-editor README note, gate checks for the single focus ring and toolbar iconsmre
- 96c97691icons: shared Icon component; md-editor toolbar and files-upload remove use it; no inner focus ring in md-editormre
- 0d6863d6reports/F3-mdvalue.mdmre
- d58ed98bMdEditor: an older text of the editor handed back is not an outside change (kept surface, written back); gate for itmre
- c2d0de59MdEditor: show a value that changes from outside (data-value observer), demo button and gatemre
- c4272fa3re-vendor Hybriel 5406d146 (hl:web batches 9+10: #72 emits while the socket is closed delivered after reconnect, browser boot linear, faster list appends; contains int 6–14 + m406)mre
- 2e22618etests: cdp-blank/md-bg/md-keys-run Chrome range and base port from env (MDK_CHROME, MDK_PORT), defaults unchangedmre