gitoria

ident

All repositories: gitoria

ReadmeCodePull requestsReleasesTicketsSettings
Commit8caec7718caec771|||PR ident#34 restore .choose hookmre8caec771/components/timezone.hl

2.5 KB

  1. // components/timezone.hl — THE TIME ZONE of the signed-in account (ident#40.3), placed by components/home.hl on `/`. The host passes in
  2. // the account's current zone (timeZone); this component owns the input, the browser's zone and the save (face changeTimeZone, which
  3. // asks lib/accounts.hl setTimeZone). The host shows the messages: $parent.status(message, notice) and, after a save, $parent.zoneSaved(zone).
  4. import { accountOfSession, setTimeZone } from '../lib/accounts.hl'
  5. import { leadLook } from './styles.hl'
  6. timeZone = ''
  7. tzInput = timeZone
  8. Style {
  9. pLead = leadLook
  10. '#timezonesection' {
  11. marginTop = '.6rem'
  12. }
  13. }
  14. View {
  15. section { id = "timezonesection"
  16. h2 { "Time zone" }
  17. p { Style.pLead "Taken from your browser at your first login. Currently " strong { id = "timezone" timeZone } "." }
  18. p { id = "digestnote" Style.pLead "Your daily mail of notifications comes at 17:00 in this time zone." }
  19. form { id = "tzform"
  20. on submit(e) {
  21. e.preventDefault()
  22. emit saveZone(e)
  23. }
  24. label { "Time zone (IANA name, e.g. Europe/Vienna)"
  25. input { id = "tzinput" name = "timeZone" autocomplete = "off" maxlength = "64" required = "required" value = tzInput on input(e) { emit setTz(e.target.value) } }
  26. }
  27. formButtons {
  28. button { id = "savetz" type = "submit" "Save time zone" }
  29. button { id = "browsertz" type = "button" class = "quiet" "Use this browser's" on click(e) { emit useBrowserZone(e) } }
  30. }
  31. }
  32. }
  33. }
  34. on setTz(v) { tzInput = v }
  35. // the browser's own time zone (IANA name) and whether a name is one it knows (`Intl` is a
  36. // browser global of client code, hybriel#18)
  37. browserZone = () => { return Intl.DateTimeFormat().resolvedOptions().timeZone }
  38. knownZone = (v) => { return v == 'UTC' || Intl.supportedValuesOf('timeZone').includes(v) }
  39. on useBrowserZone(e) { tzInput = browserZone() }
  40. on saveZone(e) {
  41. $parent.status('', '')
  42. v = tzInput.trim()
  43. if (!knownZone(v)) {
  44. $parent.status('this browser does not know the time zone “' + v + '”', '')
  45. return null
  46. }
  47. r = emit server changeTimeZone(v)
  48. if (r == null) {
  49. $parent.status('the server did not answer — try again', '')
  50. return null
  51. }
  52. if (r.error != null) {
  53. $parent.status(r.error, '')
  54. return null
  55. }
  56. tzInput = r.timeZone
  57. $parent.zoneSaved(r.timeZone)
  58. }
  59. // A face runs on a BLANK instance (its arguments and its imports only); the account comes from the session.
  60. on server changeTimeZone(tz, session) {
  61. let me = accountOfSession(&session)
  62. if (me == null) { return { error = 'you are not signed in' } }
  63. r = setTimeZone(me.id, tz)
  64. if (r.error != null) { return r }
  65. return { timeZone = r.account.timeZone }
  66. }

Branches

Latest commits

  • 8caec771|||PR ident#34 restore .choose hookmre
  • 0dbff960Merge branch 'f8-shared' into mainIdent
  • 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