gitoria

ident

All repositories: gitoria

ReadmeCodePull requestsReleasesTicketsSettings
Commit24dd414e24dd414eident#34: the shared lead, message and notice looks are statics in components/styles.hl, imported by the components (lib/looks.hl gone)mre24dd414e/components/identitylist.hl

3.7 KB

  1. // components/identitylist.hl — THE ACCOUNT'S IDENTITIES (ident#40.3), placed by components/home.hl on `/`: the list with "Used in…", Edit
  2. // and Delete, and the New identity button. The host passes in the rows (identities, lib/identities.hl identityRows). This component owns
  3. // the delete (face dropIdentity); the form is the host's other component (identityform.hl), so New and Edit go up:
  4. // $parent.openNew() and $parent.openEdit(id). The host shows the messages: $parent.status(message, notice), and takes the new rows with
  5. // $parent.identitiesDeleted(rows, id).
  6. import { accountOfSession } from '../lib/accounts.hl'
  7. import { identityRows, deleteIdentity } from '../lib/identities.hl'
  8. identities = []
  9. // 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)
  10. Style {
  11. identityMain {
  12. flex = '1 1 12rem'
  13. display = 'flex'
  14. flexWrap = 'wrap'
  15. alignItems = 'baseline'
  16. gap = '.2rem .5rem'
  17. minWidth = '0'
  18. }
  19. identityLabel {
  20. fontWeight = '700'
  21. color = 'var(--color-text-strong)'
  22. overflowWrap = 'anywhere'
  23. }
  24. identityShortId {
  25. fontFamily = 'ui-monospace, monospace'
  26. fontSize = '.875rem'
  27. color = 'var(--color-text-muted)'
  28. letterSpacing = '.08em'
  29. userSelect = 'all'
  30. }
  31. defaultBadge {
  32. padding = '0 .5rem'
  33. fontSize = '.875rem'
  34. fontWeight = '700'
  35. color = 'var(--color-accent-text)'
  36. background = 'var(--color-accent)'
  37. borderRadius = 'var(--radius-small)'
  38. }
  39. identityDetails {
  40. flexBasis = '100%'
  41. color = 'var(--color-text-muted)'
  42. fontSize = '.875rem'
  43. overflowWrap = 'anywhere'
  44. }
  45. identityActions {
  46. display = 'flex'
  47. flexWrap = 'wrap'
  48. gap = '.4rem'
  49. }
  50. // the avatar is a class the data chooses (a row has one only with a picture): quoted
  51. '#identities img.avatar, #chooselist img.avatar' {
  52. flex = '0 0 auto'
  53. width = '32px'
  54. height = '32px'
  55. objectFit = 'cover'
  56. borderRadius = '50%'
  57. background = 'var(--color-background-sunken)'
  58. }
  59. }
  60. View {
  61. section { id = "identitiessection"
  62. sectionHead {
  63. h1 { "Your identities" }
  64. button { id = "newidentity" type = "button" class = "small" "New identity" on click(e) { $parent.openNew() } }
  65. }
  66. ul { id = "identities"
  67. for (row of identities) {
  68. li {
  69. if (row.hasAvatar) { img { class = "avatar" src = row.avatar alt = "" width = "32" height = "32" } }
  70. identityMain {
  71. identityLabel { row.label }
  72. identityShortId { row.shortId }
  73. if (row.isDefault) { defaultBadge { "default" } }
  74. identityDetails { row.details }
  75. }
  76. identityActions {
  77. a { class = "used" href = row.usedHref "Used in…" }
  78. button { type = "button" class = "quiet small" name = "edit" value = row.id "Edit" on click(e) { $parent.openEdit(e.target.value) } }
  79. if (row.canDelete) { button { type = "button" class = "quiet small danger" name = "delete" value = row.id "Delete" on click(e) { emit remove(e.target.value) } } }
  80. }
  81. }
  82. }
  83. }
  84. }
  85. }
  86. rowOf = (id) => {
  87. for (row of identities) { if ('' + row.id == '' + id) { return row } }
  88. return null
  89. }
  90. on remove(id) {
  91. $parent.status('', '')
  92. row = rowOf(id)
  93. if (row == null) { return null }
  94. if (!confirm('Delete the identity “' + row.label + '”?')) { return null }
  95. r = emit server dropIdentity('' + id)
  96. if (r == null) {
  97. $parent.status('the server did not answer — try again', '')
  98. return null
  99. }
  100. if (r.error != null) {
  101. $parent.status(r.error, '')
  102. return null
  103. }
  104. $parent.identitiesDeleted(r.identities, '' + id)
  105. }
  106. on server dropIdentity(id, session) {
  107. let me = accountOfSession(&session)
  108. if (me == null) { return { error = 'you are not signed in' } }
  109. r = deleteIdentity(me.id, id)
  110. if (r.error != null) { return r }
  111. return { deleted = r.deleted identities = identityRows(me.id) }
  112. }

Branches

Latest commits

  • 24dd414eident#34: the shared lead, message and notice looks are statics in components/styles.hl, imported by the components (lib/looks.hl gone)mre
  • 03ed26c7ident#34: access.hl: the remaining lead classes droppedmre
  • 1d066c42ident#34: access.hl drops its unstyled lead class (the shared lead rule would otherwise mute it)mre
  • 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