gitoria

ident

All repositories: gitoria

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

Branches

Latest commits

  • 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
  • 47e516afident#33 ident#34: the identity form's avatar rules move into identityform.hl; the preview and Remove button are hidden with the hidden attribute instead of built class strings (avatarPreviewClass, avatarRemoveClass gone)mre
  • 5cb5cf0eident#33: the code field's look moves into codestep.hl's Stylemre
  • f421cd60ident#33: the shell's own rules (user menu address, offline note, network probe) move into main.hl's Stylemre
  • c512fb96Merge branch 'f4-homesplit' into mainIdent
  • 07d1717c|||PR ident#40 home.hl is split into components, one per area: email step, identity form, identity list, app identity choice, time zone; each moves its faces with it, the email step is shared with embed.hl (#40.3, rest of #40.2)mre
  • 59e8fcc1ident#40.3: the app's identity choice is one component (components/chooseidentity.hl); its face chooseIdentity moves with itmre
  • e23efdfcident#40.3: the identity list is one component (components/identitylist.hl); its delete and face dropIdentity move with itmre
  • e24b59a6ident#40.3: the time zone is one component (components/timezone.hl); its face changeTimeZone moves with itmre
  • 8cbc5717ident#40.3: the email step is one component (components/emailstep.hl) placed by home.hl and embed.hlmre
  • 6fad3bd2Merge branch 'f3-codestep' into mainIdent