gitoria

ident

All repositories: gitoria

ReadmeCodePull requestsReleasesTicketsSettings
Commitd69665f6d69665f6|||PR ident#34 part 3: shared look classes (wide, avatar, chip/used, conn, choose, who, inboxlink) moved to statics or droppedmred69665f6/components/embed.hl

6.0 KB

  1. // components/embed.hl — `/embed/signin?key=<api key>&return=<url>` (ident#31): THE SELECTOR'S SIGN-IN, shown inside the selector's
  2. // panel on an app's page (an iframe; lib/api.hl embedSignin checks key + return, parks the request like the login button and allows
  3. // framing only by the app's registered origins). Signed out of ident: email → code → the identity list, all in this frame, with one
  4. // note that this signs the user in to ident. Choosing an identity (the identity row itself, no extra Continue click), and the way on for a NEW address, are plain links with
  5. // target="_top": the whole app page then goes to `<return>?ident_code=<code>` (lib/api.hl embedGo), the flow every app handles.
  6. // A new address (the account is created by the first right code) is sent on to ident in the same tab (`/signin/<rid>/welcome`)
  7. // to name its identity and pick it; ident then sends the browser back to the page it came from.
  8. parent './embedshell.hl'
  9. import { accountOfSession } from '../lib/accounts.hl'
  10. import EmailStep from './emailstep.hl'
  11. import CodeStep from './codestep.hl'
  12. import { identityRows } from '../lib/identities.hl'
  13. import { requestOf } from '../lib/apps.hl'
  14. import { leadLook, messageLook } from './styles.hl'
  15. session = null
  16. rid = null
  17. me = accountOfSession(&session)
  18. request = rid != null ? requestOf(rid) : null
  19. appName = request != null ? request.app.name : ''
  20. identities = me != null ? identityRows(me.id) : []
  21. // the steps (a View's `if` takes a member): email → code → choose (or `fresh` for a new address)
  22. askEmail = me == null
  23. askCode = false
  24. choose = me != null
  25. fresh = false
  26. sentTo = ''
  27. message = ''
  28. rowsOf = (list) => {
  29. out = []
  30. for (row of list) { out.push({ label = row.label shortId = row.shortId href = '/embed/go?rid=' + rid + '&identity=' + row.id }) }
  31. return out
  32. }
  33. choices = rowsOf(identities)
  34. newHref = '/signin/' + rid + '/welcome'
  35. // the selector's sign-in frame (ident#31): inside the selector's panel (same surface colour), the same fields and buttons
  36. Style {
  37. pLead = leadLook
  38. pMessage = messageLook
  39. 'html:has(embed-card), body:has(embed-card)' {
  40. background = 'var(--color-surface)'
  41. }
  42. fitMark {
  43. position = 'absolute'
  44. width = '0'
  45. height = '0'
  46. overflow = 'hidden'
  47. animation = 'ident-frame-fit 1s infinite'
  48. }
  49. '@keyframes ident-frame-fit' = {
  50. 'from' = { opacity = '1' }
  51. to = { opacity = '0.99' }
  52. }
  53. embedCard {
  54. display = 'grid'
  55. gap = '.8rem'
  56. padding = '.5rem'
  57. }
  58. 'embed-card p' {
  59. margin = '0'
  60. overflowWrap = 'anywhere'
  61. }
  62. 'embed-card, embed-card form, embed-card label, embed-card input, embed-card li' {
  63. minWidth = '0'
  64. }
  65. 'embed-card input' {
  66. width = '100%'
  67. maxWidth = '100%'
  68. boxSizing = 'border-box'
  69. }
  70. 'embed-card #code' {
  71. fontSize = '1.2rem'
  72. letterSpacing = '.15em'
  73. }
  74. 'embed-card form' {
  75. display = 'grid'
  76. gap = '.8rem'
  77. }
  78. 'embed-card label' {
  79. display = 'grid'
  80. gap = '.25rem'
  81. marginBottom = '0'
  82. }
  83. 'embed-card .message:empty' {
  84. display = 'none'
  85. }
  86. 'embed-card .lead' {
  87. color = 'var(--color-text-muted)'
  88. }
  89. 'embed-card #chooselist' {
  90. listStyle = 'none'
  91. margin = '0'
  92. padding = '0'
  93. display = 'grid'
  94. gap = '.5rem'
  95. }
  96. 'embed-card #chooselist li' {
  97. background = 'var(--color-background-sunken)'
  98. flexWrap = 'nowrap'
  99. }
  100. 'embed-card identity-main' {
  101. flex = '1 1 auto'
  102. }
  103. 'embed-card #chooselist a' {
  104. display = 'flex'
  105. flex = '1 1 auto'
  106. alignItems = 'center'
  107. minHeight = 'var(--layout-tap)'
  108. color = 'inherit'
  109. textDecoration = 'none'
  110. }
  111. 'embed-card a.button' {
  112. display = 'inline-flex'
  113. alignItems = 'center'
  114. justifyContent = 'center'
  115. minHeight = 'var(--layout-tap)'
  116. textDecoration = 'none'
  117. }
  118. }
  119. View {
  120. embedCard {
  121. if (askEmail) {
  122. fitMark { on animationstart(e) { emit fit(e) } on animationiteration(e) { emit fit(e) } }
  123. p { id = "embednote" Style.pLead "This signs you in to ident. We mail you a one-time code." }
  124. EmailStep {}
  125. }
  126. if (askCode) {
  127. fitMark { on animationstart(e) { emit fit(e) } on animationiteration(e) { emit fit(e) } }
  128. CodeStep { sentTo = sentTo tail = '.' }
  129. }
  130. if (choose) {
  131. fitMark { on animationstart(e) { emit fit(e) } on animationiteration(e) { emit fit(e) } }
  132. p { Style.pLead "You are signed in to ident. Choose the identity to log in to " strong { appName } " with." }
  133. ul { id = "chooselist"
  134. for (row of choices) {
  135. li {
  136. a { target = "_top" href = row.href
  137. identityMain { identityLabel { row.label } identityShortId { row.shortId } }
  138. }
  139. }
  140. }
  141. }
  142. }
  143. if (fresh) {
  144. fitMark { on animationstart(e) { emit fit(e) } on animationiteration(e) { emit fit(e) } }
  145. p { id = "freshnote" Style.pLead "This address is new to ident, so it has an account now. Create your identity on ident: it takes you there and brings you back to this page." }
  146. a { id = "gonew" class = "button" target = "_top" href = newHref "Create my identity" }
  147. }
  148. p { id = "message" Style.pMessage message }
  149. }
  150. }
  151. // THE FRAME'S HEIGHT: the selector (selector.js) cannot read this page's height across origins, so the page tells it. Every step has a
  152. // fitMark whose CSS animation starts when the step appears (and repeats each second for a resize or a message): then the page's content
  153. // height goes to the parent window. No JavaScript of ours; selector.js accepts it from ident's origin only.
  154. on fit(e) {
  155. // the card's bottom edge, not the document's height (the document is as tall as the frame, so it could never shrink)
  156. card = document.querySelector('embed-card')
  157. if (card != null) { window.parent.postMessage({ identFrameHeight = Math.ceil(card.getBoundingClientRect().bottom + window.scrollY) }, '*') }
  158. }
  159. // the email step (components/emailstep.hl) asked for a code (the plain POST to /api/code): the frame goes on to the code step
  160. emailSent = (String address) => {
  161. sentTo = address
  162. askEmail = false
  163. askCode = true
  164. }
  165. // the code step (components/codestep.hl) checked the code: the answer, or why not
  166. codeFailed = (String text) => { message = text }
  167. codeVerified = (r) => {
  168. askCode = false
  169. identities = r.identities
  170. choices = rowsOf(r.identities)
  171. if (r.created) {
  172. fresh = true
  173. } else {
  174. choose = true
  175. }
  176. }
  177. back = () => {
  178. message = ''
  179. askCode = false
  180. askEmail = true
  181. }

Branches

Latest commits

  • d69665f6|||PR ident#34 part 3: shared look classes (wide, avatar, chip/used, conn, choose, who, inboxlink) moved to statics or droppedmre
  • 3a64dc48ident#34: chipLook: radius as the same var() string (a bare token name in a static does not compile); selector gate selectormre
  • eb039073ident#34: tests: signin and migration find the choice without the classmre
  • 4b94a594ident#34: tests: fix selector of the identity choicemre
  • bebc88e4ident#34: main.hl drops the unstyled classes inboxlink and whomre
  • b4e7ad04ident#34: the identity choice link/button has no class (rule on #chooselist a)mre
  • 3c33d6eaident#34: the connection link in inbox has no class (rule on #conns a)mre
  • dc97ec0dident#34: the Notif. chip and the Used in link share chipLook (Style.pChip) instead of the classes chip/used/notifmre
  • 378bd432ident#34: the identity picture look is a static in styles.hl (Style.pAvatar); sizes stay with each listmre
  • 1cf79e7eident#34: the wide page column is a static in styles.hl (Style.pWide), not the class "wide"mre
  • ddc7d135Merge branch 'f7-hooks' into mainIdent
  • eee0b513|||PR ident#34 part: test-hook classes replaced by name/element/attribute selectors (tests adjusted), the shared lead/message/notice looks are statics in styles.hlmre
  • ccd6d0c4ident#34: browser gate: rowButton finds the row's button by namemre
  • 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