notification badges, navbar + admin navbar

This commit is contained in:
Luna D. 2024-06-11 01:01:02 +02:00
parent 13735e7d4e
commit 4e6665e2d6
No known key found for this signature in database
GPG key ID: 4B1C63448394F688
11 changed files with 142 additions and 25 deletions

View file

@ -1,3 +1,4 @@
$min-widescreen-width: 1500px;
$min-desktop-width: 1280px; $min-desktop-width: 1280px;
$max-phone-width: 700px; $max-phone-width: 700px;
$narrow-layout-width: 960px; $narrow-layout-width: 960px;
@ -22,7 +23,7 @@ $font-family-heading: $font-family-base;
/* Navbar */ /* Navbar */
--navbar-size: 4rem; --navbar-size: 4rem;
--navbar-secondary-size: 2.5rem; --navbar-secondary-size: 2.25rem;
--navbar-input-size: 2rem; --navbar-input-size: 2rem;
--navbar-input-width: 18vw; --navbar-input-width: 18vw;
--navbar-input-max-width: 22rem; --navbar-input-max-width: 22rem;
@ -76,11 +77,14 @@ $font-family-heading: $font-family-base;
--badge-normal-size: 2rem; --badge-normal-size: 2rem;
/* Counter badges (the "red notification badge") */ /* Counter badges (the "red notification badge") */
--number-badge-size: 0.6rem; --number-badge-size: 0.8rem;
--number-badge-padding: 0.1rem; --number-badge-padding: 0.1rem;
--number-badge-border: 2px; --number-badge-border: 2px;
--number-badge-lower-offset: 0.7rem; --number-badge-vote-vertical-offset: 0.7rem;
--number-badge-upper-offset: 0.7rem; --number-badge-header-vertical-offset: 1.2rem;
--number-badge-header-horizontal-offset: 0.6rem;
--number-badge-admin-vertical-offset: 0.6rem;
--number-badge-admin-horizontal-offset: 0.6rem;
/* Fonts */ /* Fonts */
--font-family: $font-family-base; --font-family: $font-family-base;
@ -91,6 +95,7 @@ $font-family-heading: $font-family-base;
--font-micro-size: 10px; --font-micro-size: 10px;
--font-header-size: 16px; --font-header-size: 16px;
--font-icon-size: 2rem; --font-icon-size: 2rem;
--font-small-icon-size: 0.9rem;
--font-h1-size: 1.75rem; --font-h1-size: 1.75rem;
--font-h2-size: 1.5rem; --font-h2-size: 1.5rem;
--font-h3-size: 1.35rem; --font-h3-size: 1.35rem;

View file

@ -1,3 +1,9 @@
@define-mixin if-widescreen {
@media (min-width: calc($min-widescreen-width + 1px)) {
@mixin-content;
}
}
@define-mixin if-desktop { @define-mixin if-desktop {
@media (min-width: calc($min-desktop-width + 1px)) { @media (min-width: calc($min-desktop-width + 1px)) {
@mixin-content; @mixin-content;

View file

@ -1,3 +1,7 @@
.hidden--narrow-screen {
display: none;
}
/* Phones. */ /* Phones. */
@mixin if-phone { @mixin if-phone {
.hidden--phone { .hidden--phone {
@ -25,3 +29,14 @@
display: none !important; display: none !important;
} }
} }
/* Widescreens are larger than 1500px */
@mixin if-widescreen {
.hidden--widescreen {
display: none !important;
}
.hidden--narrow-screen {
display: inherit;
}
}

View file

@ -1,12 +1,37 @@
nav.header__staff {
display: flex;
line-height: var(--navbar-secondary-size);
border-radius: var(--border-radius-outer);
}
.header__counter__admin { .header__counter__admin {
position: absolute; display: inline-flex;
flex-flow: column;
background: var(--danger-color); background: var(--danger-color);
border: 1px solid var(--danger-border-color); border-radius: 100%;
border-radius: var(--border-radius-inner);
min-width: var(--number-badge-size); min-width: var(--number-badge-size);
line-height: var(--number-badge-size); line-height: var(--number-badge-size);
font-size: var(--number-badge-size); font-size: var(--number-badge-size);
font-weight: bold;
padding: var(--number-badge-padding); padding: var(--number-badge-padding);
top: var(--number-badge-lower-offset); text-align: center;
left: 0.25rem; }
.header--secondary__admin-links {
display: flex;
gap: var(--padding-large);
padding: 0 var(--padding-normal);
background: var(--danger-dark-color);
border-radius: var(--border-radius-outer);
}
@mixin if-mobile {
.header--secondary__admin-links {
justify-content: center;
flex: 1 0 auto;
}
nav.header__staff {
flex: 1 0 auto;
}
} }

View file

@ -9,6 +9,7 @@ header {
.header__link { .header__link {
@mixin animated-transition; @mixin animated-transition;
position: relative;
color: var(--text-color) !important; color: var(--text-color) !important;
} }
@ -42,6 +43,29 @@ header {
border: 0; border: 0;
} }
.header__counter {
position: absolute;
background: var(--danger-color);
border-radius: 100%;
min-width: var(--number-badge-size);
line-height: var(--number-badge-size);
font-size: var(--number-badge-size);
font-weight: bold;
padding: var(--number-badge-padding);
text-align: center;
top: var(--number-badge-header-vertical-offset);
left: var(--number-badge-header-horizontal-offset);
}
/* Old style counter */
.header__counter--simple {
display: inline-flex;
padding: 0 var(--padding-small);
line-height: inherit;
text-align: center;
background: var(--primary-muted-color);
}
.header__input { .header__input {
@mixin animated-transition; @mixin animated-transition;
height: var(--navbar-input-size); height: var(--navbar-input-size);
@ -72,9 +96,18 @@ header {
padding: 0 var(--padding-normal); padding: 0 var(--padding-normal);
} }
.nav-container {
display: flex;
gap: var(--padding-normal);
padding: 0 var(--padding-normal);
flex-wrap: wrap;
}
nav.header__secondary { nav.header__secondary {
display: flex; display: flex;
flex: 1 0 auto;
line-height: var(--navbar-secondary-size); line-height: var(--navbar-secondary-size);
border-radius: var(--border-radius-outer);
padding: 0 var(--padding-large); padding: 0 var(--padding-large);
font-size: var(--font-header-size); font-size: var(--font-header-size);
gap: var(--padding-large); gap: var(--padding-large);
@ -82,6 +115,16 @@ nav.header__secondary {
background: var(--primary-color); background: var(--primary-color);
} }
nav.header__secondary .fa,
nav.header__staff .fa {
display: inline-flex;
text-align: center;
font-size: var(--font-small-icon-size);
width: var(--font-small-icon-size);
height: var(--font-small-icon-size);
margin-right: var(--padding-tiny);
}
nav.header__secondary .header__link { nav.header__secondary .header__link {
color: var(--text-light-color) !important; color: var(--text-light-color) !important;
} }

View file

@ -27,7 +27,7 @@
padding: var(--number-badge-padding); padding: var(--number-badge-padding);
line-height: var(--number-badge-size); line-height: var(--number-badge-size);
min-width: var(--number-badge-size); min-width: var(--number-badge-size);
top: var(--number-badge-lower-offset); top: var(--number-badge-vote-vertical-offset);
} }
.interaction--comment:hover > .comments-count { .interaction--comment:hover > .comments-count {

View file

@ -5,6 +5,7 @@
import { fetchJson, handleError } from './utils/requests'; import { fetchJson, handleError } from './utils/requests';
import { $ } from './utils/dom'; import { $ } from './utils/dom';
import { delegate } from './utils/events'; import { delegate } from './utils/events';
import { assertNotNull } from './utils/assert';
import store from './utils/store'; import store from './utils/store';
const NOTIFICATION_INTERVAL = 600000, const NOTIFICATION_INTERVAL = 600000,
@ -39,7 +40,7 @@ function getNewNotifications() {
} }
function updateNotificationTicker(notificationCount) { function updateNotificationTicker(notificationCount) {
const ticker = $('.js-notification-ticker'); const ticker = assertNotNull($('.js-notification-ticker'));
const parsedNotificationCount = Number(notificationCount); const parsedNotificationCount = Number(notificationCount);
ticker.dataset.notificationCount = parsedNotificationCount; ticker.dataset.notificationCount = parsedNotificationCount;

View file

@ -60,7 +60,7 @@ function createTagDropdown(tag: HTMLSpanElement) {
const act = event.target.dataset.tagAction; const act = event.target.dataset.tagAction;
if (act && actions[act]) { if (act && actions[act]) {
actions[act]() actions[act]();
} }
}) as EventListener); }) as EventListener);
} }

View file

@ -30,7 +30,7 @@ header
= if @current_user do = if @current_user do
a.header__link href="/notifications" title="Notifications" a.header__link href="/notifications" title="Notifications"
i.fas.fa-bell> i.fas.fa-bell>
/span.js-notification-ticker.fa__text.header__counter data-notification-count=@notification_count = @notification_count span.js-notification-ticker.fa__text.header__counter data-notification-count=@notification_count = @notification_count
a.header__link href="/conversations" title="Conversations" a.header__link href="/conversations" title="Conversations"
= if @conversation_count > 0 do = if @conversation_count > 0 do
@ -125,7 +125,11 @@ header
| Register | Register
a.header__link href=~p"/sessions/new" a.header__link href=~p"/sessions/new"
| Login | Login
nav.header__secondary
= render PhilomenaWeb.LayoutView, "_header_navigation.html", assigns .nav-container
nav.header__secondary
= render PhilomenaWeb.LayoutView, "_header_navigation.html", assigns
= if !is_nil(@current_user) and @current_user.role != "user" do = if !is_nil(@current_user) and @current_user.role != "user" do
/= render PhilomenaWeb.LayoutView, "_header_staff_links.html", assigns nav.header__staff
= render PhilomenaWeb.LayoutView, "_header_navigation_staff.html", assigns

View file

@ -45,7 +45,7 @@ a.header__link href="/tags"
a.header__link href="/channels" a.header__link href="/channels"
i.fa.fa-stream> i.fa.fa-stream>
' Live ' Live
span.header__counter span.header__counter--simple
= @conn.assigns.live_channels = @conn.assigns.live_channels
a.header__link href="/galleries" a.header__link href="/galleries"

View file

@ -1,8 +1,8 @@
.flex.flex--centered.header--secondary__admin-links.stretched-mobile-links.js-staff-action .header--secondary__admin-links.js-staff-action
= if manages_users?(@conn) do = if manages_users?(@conn) do
.dropdown.hidden--mobile .dropdown.hidden--mobile
a.header__link title="Admin" a.header__link title="Admin"
' A i.fa.fa-bars>
i.fa.fa-caret-down i.fa.fa-caret-down
.dropdown__content.js-burger-links .dropdown__content.js-burger-links
@ -64,38 +64,56 @@
= if @pending_approval_count do = if @pending_approval_count do
= link to: ~p"/admin/approvals", class: "header__link", title: "Approval Queue" do = link to: ~p"/admin/approvals", class: "header__link", title: "Approval Queue" do
' Q i.fa.fa-stamp>
span
| A
span.hidden--narrow-screen> pprovals
span.header__counter__admin span.header__counter__admin
= @pending_approval_count = @pending_approval_count
= if @duplicate_report_count do = if @duplicate_report_count do
= link to: ~p"/duplicate_reports", class: "header__link", title: "Duplicates" do = link to: ~p"/duplicate_reports", class: "header__link", title: "Duplicates" do
' D i.fa.fa-copy>
span
| D
span.hidden--narrow-screen> upes
span.header__counter__admin span.header__counter__admin
= @duplicate_report_count = @duplicate_report_count
= if @report_count do = if @report_count do
= link to: ~p"/admin/reports", class: "header__link", title: "Reports" do = link to: ~p"/admin/reports", class: "header__link", title: "Reports" do
' R i.fa.fa-flag>
span
| R
span.hidden--narrow-screen> eports
span.header__counter__admin span.header__counter__admin
= @report_count = @report_count
= if @artist_link_count do = if @artist_link_count do
= link to: ~p"/admin/artist_links", class: "header__link", title: "Artist Links" do = link to: ~p"/admin/artist_links", class: "header__link", title: "Artist Links" do
' L i.fa.fa-link>
span
| L
span.hidden--narrow-screen> inks
span.header__counter__admin span.header__counter__admin
= @artist_link_count = @artist_link_count
= if @dnp_entry_count do = if @dnp_entry_count do
= link to: ~p"/admin/dnp_entries", class: "header__link", title: "DNP Requests" do = link to: ~p"/admin/dnp_entries", class: "header__link", title: "DNP Requests" do
' S i.fa.fa-circle-minus>
span
span.hidden--narrow-screen> DNPs
span.hidden--widescreen> S
span.header__counter__admin span.header__counter__admin
= @dnp_entry_count = @dnp_entry_count
= if manages_bans?(@conn) do = if manages_bans?(@conn) do
.dropdown.hidden--mobile .dropdown.hidden--mobile
a.header__link title="Bans" a.header__link title="Bans"
' B i.fa.fa-gavel>
span
| B
span.hidden--narrow-screen> ans
i.fa.fa-caret-down i.fa.fa-caret-down
.dropdown__content.dropdown__content--right.js-burger-links .dropdown__content.dropdown__content--right.js-burger-links