From 045cdb4ed045861f302471efa56b1525289f2d8b Mon Sep 17 00:00:00 2001 From: Aman Agrawal Date: Mon, 5 Oct 2020 19:39:25 +0530 Subject: [PATCH] login_to_access: Modal which blocks access for spectator. We will use this modal for any narrow / hash or other UI element that requires an actual account to use, to provide something reasonable to occur when a user clicks on those things. --- static/js/login_to_access.js | 31 +++++++++++++++++++++++++++ static/styles/app_components.css | 32 ++++++++++++++++++++++++++++ static/styles/night_mode.css | 11 ++++++++++ static/styles/zulip.css | 23 ++++++++++++++++++++ static/templates/login_to_access.hbs | 31 +++++++++++++++++++++++++++ templates/zerver/app/index.html | 1 + tools/test-js-with-node | 1 + 7 files changed, 130 insertions(+) create mode 100644 static/js/login_to_access.js create mode 100644 static/templates/login_to_access.hbs diff --git a/static/js/login_to_access.js b/static/js/login_to_access.js new file mode 100644 index 0000000000..7e3858580d --- /dev/null +++ b/static/js/login_to_access.js @@ -0,0 +1,31 @@ +// Module for displaying the modal asking spectators to login when +// attempting to do things that are not possible as a specatator (like +// add an emoji reaction, star a message, etc.). While in many cases, +// we will prefer to hide menu options that don't make sense for +// spectators, this modal is useful for everything that doesn't make +// sense to remove from a design perspective. + +import $ from "jquery"; + +import render_login_to_access_modal from "../templates/login_to_access.hbs"; + +import {page_params} from "./page_params"; + +export function show() { + // Hide all overlays, popover and go back to the previous hash if the + // hash has changed. + let login_link; + if (page_params.development_environment) { + login_link = "/devlogin"; + } else { + login_link = "/login"; + } + + $("#login-to-access-modal-holder").html( + render_login_to_access_modal({ + signup_link: "/register", + login_link, + }), + ); + $("#login_to_access_modal").modal("show"); +} diff --git a/static/styles/app_components.css b/static/styles/app_components.css index ec03416bda..d486563af1 100644 --- a/static/styles/app_components.css +++ b/static/styles/app_components.css @@ -592,3 +592,35 @@ div.overlay { outline: none; } } + +.color_animated_button { + display: flex; + justify-content: center; + background-color: hsl(0, 0%, 90%); + + span { + color: hsl(0, 0%, 0%); + } + + &:hover { + cursor: pointer; + background-color: hsl(228, 96%, 71%); + color: hsl(0, 0%, 100%); + + span { + color: hsl(0, 0%, 100%); + transition: all 0.2s ease; + } + + transition: all 0.2s ease; + } + + * { + padding: 6px 3px; + } + + .fa { + position: relative; + top: 3px; + } +} diff --git a/static/styles/night_mode.css b/static/styles/night_mode.css index 5f2ce7b3b1..6a4c1abfbd 100644 --- a/static/styles/night_mode.css +++ b/static/styles/night_mode.css @@ -1085,6 +1085,17 @@ body.night-mode { .animated-purple-button:focus { box-shadow: 0 1px 4px 0 hsl(0, 0%, 100%, 0.666); } + + .color_animated_button { + background-color: hsl(209, 32%, 5%); + * { + color: hsl(0, 0%, 100%); + } + + &:hover { + background-color: hsl(228, 96%, 71%); + } + } } @supports (-moz-appearance: none) { diff --git a/static/styles/zulip.css b/static/styles/zulip.css index 47bba548b0..7c7b6a4d9e 100644 --- a/static/styles/zulip.css +++ b/static/styles/zulip.css @@ -2988,3 +2988,26 @@ select.inline_select_topic_edit { top: 5%; } } + +#login_to_access_modal { + .go_back_button .fa { + position: fixed; + top: 11px; + left: 30px; + } + + .login_to_access_label { + font-size: 1.1rem; + font-weight: bold; + } + + .login_to_access_footer { + display: flex; + flex-direction: row; + justify-content: space-around; + + .color_animated_button { + width: 48%; + } + } +} diff --git a/static/templates/login_to_access.hbs b/static/templates/login_to_access.hbs new file mode 100644 index 0000000000..fd8b26976e --- /dev/null +++ b/static/templates/login_to_access.hbs @@ -0,0 +1,31 @@ + diff --git a/templates/zerver/app/index.html b/templates/zerver/app/index.html index ef6428ce00..c27f23ef14 100644 --- a/templates/zerver/app/index.html +++ b/templates/zerver/app/index.html @@ -208,5 +208,6 @@ +
{% endblock %} diff --git a/tools/test-js-with-node b/tools/test-js-with-node index f35da8f563..68ee59e1ca 100755 --- a/tools/test-js-with-node +++ b/tools/test-js-with-node @@ -84,6 +84,7 @@ EXEMPT_FILES = { "static/js/loading.ts", "static/js/local_message.js", "static/js/localstorage.js", + "static/js/login_to_access.js", "static/js/message_edit.js", "static/js/message_edit_history.js", "static/js/message_events.js",