Improve subscribed user profile pictures and nav pane selection

- Add yellow halo around subscribed user profile
- Fix highlighting current page in header nav pane
This commit is contained in:
Debanjum Singh Solanky 2023-11-09 00:57:05 -08:00
parent 605058c72a
commit 391db80499
6 changed files with 39 additions and 6 deletions

View file

@ -147,7 +147,7 @@ img.khoj-logo {
} }
.circle { .circle {
border-radius: 50%; border-radius: 50%;
border: 3px solid var(--primary-hover); border: 3px dotted var(--main-text-color);
width: 40px; width: 40px;
height: 40px; height: 40px;
padding: 3px; padding: 3px;
@ -164,6 +164,11 @@ img.khoj-logo {
align-items: center; align-items: center;
font-size: 20px; font-size: 20px;
box-sizing: unset; box-sizing: unset;
width: 40px;
height: 40px;
}
.subscribed {
border: 3px solid var(--primary-hover);
} }
@media screen and (max-width: 700px) { @media screen and (max-width: 700px) {

View file

@ -24,6 +24,12 @@
{% endblock %} {% endblock %}
</div> </div>
</body> </body>
<script>
document.getElementById("settings-nav").classList.add("khoj-nav-selected");
{% if is_active %}
document.getElementById("profile-picture").classList.add("subscribed");
{% endif %}
</script>
<style> <style>
html, body { html, body {
width: 100%; width: 100%;

View file

@ -374,7 +374,12 @@
<textarea id="chat-input" class="option" oninput="onChatInput()" onkeydown=incrementalChat(event) autofocus="autofocus" placeholder="Type / to see a list of commands, or just type your questions and hit enter."></textarea> <textarea id="chat-input" class="option" oninput="onChatInput()" onkeydown=incrementalChat(event) autofocus="autofocus" placeholder="Type / to see a list of commands, or just type your questions and hit enter."></textarea>
</div> </div>
</body> </body>
<script>
document.getElementById("chat-nav").classList.add("khoj-nav-selected");
{% if is_active %}
document.getElementById("profile-picture").classList.add("subscribed");
{% endif %}
</script>
<style> <style>
html, body { html, body {
height: 100%; height: 100%;

View file

@ -285,6 +285,12 @@
<!-- Section to Render Results --> <!-- Section to Render Results -->
<div id="results"></div> <div id="results"></div>
</body> </body>
<script>
document.getElementById("search-nav").classList.add("khoj-nav-selected");
{% if is_active %}
document.getElementById("profile-picture").classList.add("subscribed");
{% endif %}
</script>
<style> <style>
@media only screen and (max-width: 700px) { @media only screen and (max-width: 700px) {

View file

@ -4,18 +4,22 @@
<img class="khoj-logo" src="/static/assets/icons/khoj-logo-sideways-500.png" alt="Khoj"></img> <img class="khoj-logo" src="/static/assets/icons/khoj-logo-sideways-500.png" alt="Khoj"></img>
</a> </a>
<nav class="khoj-nav"> <nav class="khoj-nav">
<a class="khoj-nav" href="/chat">💬 Chat</a> <a id="chat-nav" class="khoj-nav" href="/chat">💬 Chat</a>
<a class="khoj-nav" href="/search">🔎 Search</a> <a id="search-nav" class="khoj-nav" href="/search">🔎 Search</a>
<!-- Dropdown Menu --> <!-- Dropdown Menu -->
<div id="khoj-nav-menu-container" class="khoj-nav dropdown"> <div id="khoj-nav-menu-container" class="khoj-nav dropdown">
{% if user_photo and user_photo != "None" %} {% if user_photo and user_photo != "None" %}
<img class="circle" src="{{ user_photo }}" alt="{{ username[0].upper() }}" onclick="toggleMenu()" referrerpolicy="no-referrer"> {% if is_active %}
<img id="profile-picture" class="circle subscribed" src="{{ user_photo }}" alt="{{ username[0].upper() }}" onclick="toggleMenu()" referrerpolicy="no-referrer">
{% else %}
<img id="profile-picture" class="circle" src="{{ user_photo }}" alt="{{ username[0].upper() }}" onclick="toggleMenu()" referrerpolicy="no-referrer">
{% endif %}
{% else %} {% else %}
<div class="circle user-initial" alt="{{ username[0].upper() }}" onclick="toggleMenu()">{{ username[0].upper() }}</div> <div class="circle user-initial" alt="{{ username[0].upper() }}" onclick="toggleMenu()">{{ username[0].upper() }}</div>
{% endif %} {% endif %}
<div id="khoj-nav-menu" class="khoj-nav-dropdown-content"> <div id="khoj-nav-menu" class="khoj-nav-dropdown-content">
<div class="khoj-nav-username"> {{ username }} </div> <div class="khoj-nav-username"> {{ username }} </div>
<a class="khoj-nav khoj-nav-selected" href="/config">⚙️ Settings</a> <a id="settings-nav" class="khoj-nav" href="/config">⚙️ Settings</a>
<a class="khoj-nav" href="/auth/logout">🔑 Logout</a> <a class="khoj-nav" href="/auth/logout">🔑 Logout</a>
</div> </div>
</div> </div>

View file

@ -69,6 +69,8 @@ def index_post(request: Request):
def search_page(request: Request): def search_page(request: Request):
user = request.user.object user = request.user.object
user_picture = request.session.get("user", {}).get("picture") user_picture = request.session.get("user", {}).get("picture")
user_subscription = adapters.get_user_subscription(user.email)
user_subscription_state = get_user_subscription_state(user_subscription)
return templates.TemplateResponse( return templates.TemplateResponse(
"search.html", "search.html",
@ -76,6 +78,7 @@ def search_page(request: Request):
"request": request, "request": request,
"username": user.username, "username": user.username,
"user_photo": user_picture, "user_photo": user_picture,
"is_active": user_subscription_state == "subscribed" or user_subscription_state == "unsubscribed",
}, },
) )
@ -85,6 +88,8 @@ def search_page(request: Request):
def chat_page(request: Request): def chat_page(request: Request):
user = request.user.object user = request.user.object
user_picture = request.session.get("user", {}).get("picture") user_picture = request.session.get("user", {}).get("picture")
user_subscription = adapters.get_user_subscription(user.email)
user_subscription_state = get_user_subscription_state(user_subscription)
return templates.TemplateResponse( return templates.TemplateResponse(
"chat.html", "chat.html",
@ -92,6 +97,7 @@ def chat_page(request: Request):
"request": request, "request": request,
"username": user.username, "username": user.username,
"user_photo": user_picture, "user_photo": user_picture,
"is_active": user_subscription_state == "subscribed" or user_subscription_state == "unsubscribed",
}, },
) )
@ -154,6 +160,7 @@ def config_page(request: Request):
"subscription_state": user_subscription_state, "subscription_state": user_subscription_state,
"subscription_renewal_date": subscription_renewal_date, "subscription_renewal_date": subscription_renewal_date,
"khoj_cloud_subscription_url": os.getenv("KHOJ_CLOUD_SUBSCRIPTION_URL"), "khoj_cloud_subscription_url": os.getenv("KHOJ_CLOUD_SUBSCRIPTION_URL"),
"is_active": user_subscription_state == "subscribed" or user_subscription_state == "unsubscribed",
}, },
) )