ident
All repositories: gitoria
3.7 KB
// components/identitylist.hl — THE ACCOUNT'S IDENTITIES (ident#40.3), placed by components/home.hl on `/`: the list with "Used in…", Edit// and Delete, and the New identity button. The host passes in the rows (identities, lib/identities.hl identityRows). This component owns// the delete (face dropIdentity); the form is the host's other component (identityform.hl), so New and Edit go up:// $parent.openNew() and $parent.openEdit(id). The host shows the messages: $parent.status(message, notice), and takes the new rows with// $parent.identitiesDeleted(rows, id).import { accountOfSession } from '../lib/accounts.hl'import { identityRows, deleteIdentity } from '../lib/identities.hl'identities = []// the identity row's parts: also used by the app's identity choice (chooseidentity.hl, embed.hl), the identity page (identity.hl) and, for identityActions, the apps list (apps.hl)Style {identityMain {flex = '1 1 12rem'display = 'flex'flexWrap = 'wrap'alignItems = 'baseline'gap = '.2rem .5rem'minWidth = '0'}identityLabel {fontWeight = '700'color = 'var(--color-text-strong)'overflowWrap = 'anywhere'}identityShortId {fontFamily = 'ui-monospace, monospace'fontSize = '.875rem'color = 'var(--color-text-muted)'letterSpacing = '.08em'userSelect = 'all'}defaultBadge {padding = '0 .5rem'fontSize = '.875rem'fontWeight = '700'color = 'var(--color-accent-text)'background = 'var(--color-accent)'borderRadius = 'var(--radius-small)'}identityDetails {flexBasis = '100%'color = 'var(--color-text-muted)'fontSize = '.875rem'overflowWrap = 'anywhere'}identityActions {display = 'flex'flexWrap = 'wrap'gap = '.4rem'}// the avatar is a class the data chooses (a row has one only with a picture): quoted'#identities img.avatar, #chooselist img.avatar' {flex = '0 0 auto'width = '32px'height = '32px'objectFit = 'cover'borderRadius = '50%'background = 'var(--color-background-sunken)'}}View {section { id = "identitiessection"sectionHead {h1 { "Your identities" }button { id = "newidentity" type = "button" class = "small" "New identity" on click(e) { $parent.openNew() } }}ul { id = "identities"for (row of identities) {li {if (row.hasAvatar) { img { class = "avatar" src = row.avatar alt = "" width = "32" height = "32" } }identityMain {identityLabel { row.label }identityShortId { row.shortId }if (row.isDefault) { defaultBadge { "default" } }identityDetails { row.details }}identityActions {a { class = "used" href = row.usedHref "Used in…" }button { type = "button" class = "quiet small" name = "edit" value = row.id "Edit" on click(e) { $parent.openEdit(e.target.value) } }if (row.canDelete) { button { type = "button" class = "quiet small danger" name = "delete" value = row.id "Delete" on click(e) { emit remove(e.target.value) } } }}}}}}}rowOf = (id) => {for (row of identities) { if ('' + row.id == '' + id) { return row } }return null}on remove(id) {$parent.status('', '')row = rowOf(id)if (row == null) { return null }if (!confirm('Delete the identity “' + row.label + '”?')) { return null }r = emit server dropIdentity('' + id)if (r == null) {$parent.status('the server did not answer — try again', '')return null}if (r.error != null) {$parent.status(r.error, '')return null}$parent.identitiesDeleted(r.identities, '' + id)}on server dropIdentity(id, session) {let me = accountOfSession(&session)if (me == null) { return { error = 'you are not signed in' } }r = deleteIdentity(me.id, id)if (r.error != null) { return r }return { deleted = r.deleted identities = identityRows(me.id) }}
Branches
Latest commits
- 1e1dd7b4ident#34: the access page keeps its lead class string (the page has no ident-card, so its lead line was never muted; a shared rule would change the look)mre
- 89ac6553ident#34: the lead, message and notice lines are named with Style.pLead / pMessage / pNotice (shared bodies in lib/looks.hl) instead of class stringsmre
- e84be3deident#34: browser gate lists the Edit/Delete buttons by namemre
- fb7111faident#34: access page: unstyled test-hook classes (idrow, never, who, whoname, appname, neverrevoke) dropped; the tests use element/name selectorsmre
- 9f2ad803ident#34: notification switches: push/email by name=..., locked by aria-disabled, the switch look is the role=switch button (no switch/push/email/locked classes)mre
- e0f0ddaaident#34: inbox: the Mark read/unread button is styled as the button of its note-foot, the icon is found as the row's img (no toggle/icon classes)mre
- 16b49756ident#34: unused row classes (choice, usedrow, kind, shortid) droppedmre
- f9d6fb38ident#34: apps and identity rows: the Edit/New secret/Delete buttons carry name=..., the API key is found by its element; unused row classes (app, identity, shortid) droppedmre
- b323265aMerge branch 'f5-styles' into mainIdent
- 9ced53c3|||PR ident#33 ident#35 every component's styles live in its own Style block; styles.hl keeps the page-wide rest; the account bar is phone first (min-width: 60rem block); the avatar preview is hidden with the hidden attribute (ident#34 in part)mre
- f28333e4ident#33 ident#35: styles.hl keeps only the accent, the page column and the shared patterns; the account bar is written phone first (base rule + one min-width: 60rem block) instead of a max-width overridemre
- 5b4541fcident#33: the selector sign-in frame's rules move into embed.hl's Stylemre
- 00235f21ident#33: the per-app notification switches move into appsettings.hl's Stylemre
- 2249945cident#33: the inbox and connection list rules move into inbox.hl's Stylemre
- f2d9f79fident#33: the apps list and the secret box move into apps.hl's Stylemre
- 8370b748ident#33: the app request box moves into home.hl's Stylemre
- 40bf3b97ident#33: the 404 page's home link rule moves into notfound.hlmre
- 40627a89ident#33: the time zone section's spacing moves into timezone.hlmre
- d389db08ident#33: the identity page's rules and the Notif. chip move into identity.hl's Stylemre
- ddda0b5bident#33: the identity row's parts move into identitylist.hl's Stylemre