gitoria

ident

All repositories: gitoria

ReadmeCodePull requestsReleasesTicketsSettings
Commiteee0b513eee0b513|||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.hlmreeee0b513/components/codestep.hl

2.5 KB

  1. // components/codestep.hl — THE CODE STEP of the sign-in (ident#40.2): the one-time-code form, placed by components/home.hl (the code page)
  2. // and components/embed.hl (the selector's frame). The host passes in WHO the code was sent to (sentTo) and the sentence's ending (tail);
  3. // this component owns the code field, the browser's time zone and the check against the server (face verifyCode, lib/login.hl
  4. // signInWithCode). What follows is the host's: it gets the answer through $parent.codeVerified(r) or $parent.codeFailed(text), and
  5. // "Other address" is $parent.back(). Markup, ids and look are those both pages had before (the CSS is components/styles.hl).
  6. import { signInWithCode } from '../lib/login.hl'
  7. import { leadLook } from './styles.hl'
  8. sentTo = ''
  9. tail = '.'
  10. code = ''
  11. Style {
  12. pLead = leadLook
  13. '#code' {
  14. fontSize = '1.4rem'
  15. letterSpacing = '.3em'
  16. fontVariantNumeric = 'tabular-nums'
  17. }
  18. }
  19. View {
  20. p { id = "sentto" Style.pLead "We sent a six-digit code to " strong { sentTo } tail }
  21. form { id = "codeform"
  22. on submit(e) {
  23. e.preventDefault()
  24. emit verify(e)
  25. }
  26. label { "One-time code"
  27. input { id = "code" name = "code" autocomplete = "one-time-code" inputmode = "numeric" pattern = "[0-9]{6}" maxlength = "6" required = "required" value = code on input(e) { emit setCode(e.target.value) } }
  28. }
  29. formButtons {
  30. button { id = "verify" type = "submit" "Sign in" }
  31. button { id = "back" type = "button" class = "quiet" "Other address" on click(e) { $parent.back() } }
  32. }
  33. }
  34. }
  35. on setCode(v) { code = v }
  36. // the browser's own time zone (IANA name) goes with the first login (`Intl` is a browser global of client code, hybriel#18)
  37. browserZone = () => { return Intl.DateTimeFormat().resolvedOptions().timeZone }
  38. on verify(e) {
  39. $parent.codeFailed('')
  40. r = emit server verifyCode(sentTo, code, browserZone())
  41. if (r == null) {
  42. $parent.codeFailed('the server did not answer — try again')
  43. return null
  44. }
  45. if (r.error != null) {
  46. $parent.codeFailed(r.error)
  47. return null
  48. }
  49. $parent.codeVerified(r)
  50. }
  51. // the right code signs the session in; the first one for an address creates the account, its default identity and stores the
  52. // browser's time zone
  53. on server verifyCode(email, code, timeZone, session) {
  54. if (session == null) { return { error = 'no session — reload the page' } }
  55. if (email == null || hlTypeName(email) != 'String' || code == null || hlTypeName(code) != 'String') { return { error = 'email and code must be strings' } }
  56. return signInWithCode(&session, email, code, timeZone)
  57. }

Branches

Latest commits

  • 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
  • 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