Skip to content

Instantly share code, notes, and snippets.

@efimweb
Last active December 22, 2019 17:24
Show Gist options
  • Save efimweb/1ce42c15cadd2aab2771d50aeac85717 to your computer and use it in GitHub Desktop.
Save efimweb/1ce42c15cadd2aab2771d50aeac85717 to your computer and use it in GitHub Desktop.

Brief description:

  • JS implementation of MTProto
  • CSS code is inlined to index.html. So user can view login page instantly, without additional network requests.
  • Login page is implemented with static html+js for good First Meaningful Paint/First Contentful Paint
  • Chat app is implemented with Web Components (Custom Elements (V1) without Shadow DOM), because JS for its rendering is already loaded during login or cached during previous session.
  • Pixel-perfect layout of most elements (a few margins between them may be wrong)

To go through signup flow, open app in test mode with empty localStorage(without data from previous session) and use test phone number. To open app in production mode (after test mode), you should clear localStorage too.


Details that may be unnoticed at first glance:

  1. Determination of the country by phone number and using appropriate phone mask.
    phone_mask
    (gif speed: 2x)

  2. Case-insensitive search with scrolling of the center of menu to the found country. If the user didn't fill the full name of country and blurred the select field, the last suggested country selecting automatically. When combobox becomes focused, its value becomes selected (lightblue highlighting). User can start searching without deleting old value manually.
    select_search

  3. The select placeholder changes to the name of the hovered country. When the user selects a country, phone input becomes focused.
    select_placecholder

  4. Smooth animation of monkey when changing steps, entering code, changing password visibility. Input autofocus.
    progress of the gif at the bottom
    step_animaition

  5. Editing masked phone in any part without jumping of cater to the end of input.
    mask_editing

  6. "+" sign at the beginning of the phone input is persistent. User can't delete it.
    plus_sign

  7. Fields validation. Focusing on invalid input.
    validation

  8. Custom font with large dots in password input and blue input caret in all inputs.
    password_font

  9. Avatar cropping.
    to open this page without registering a new user, execute window.showPage.fullname() in console
    crop

  10. Hash router. Saving current chat ID in URL.
    router

  11. Keyboard navigation with Tab, Shift+Tab (outline style activates only when interacting with keyboard).
    keyboard_1 keyboard_2 keyboard_3

  12. Different size of line breaks of message, depending on the width of the date, the read icon, and the type of message (forward, replay, plain).
    linebreak_1 linebreak_2

  13. Borders in dialog lists and chats that appears on scroll.
    scroll_line_1 scroll_line_2

  14. Different styles of messages, depending on position and author.
    15

  15. Ripples appear on mousedown and disappear on mouseup - it keeps on mouse hold (like in Telegram Desktop).
    ripple_1 ripple_2

  16. Custom scroll.
    scroll
    (gif speed: 2x)

  17. Audio component(but without playing)
    audio

  18. Offline indicator.
    network_status

  19. Typing and online indicator (but with z-index bug of online indicator).
    typing

  20. Logout at termination other sessions on other device.
    terminate

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment