[deploy] Move first-nav-link from dynamic JS to erb (#7698)
This commit is contained in:
parent
06c8be370f
commit
82ab9f820b
2 changed files with 18 additions and 14 deletions
|
|
@ -1,15 +1,15 @@
|
|||
'use strict';
|
||||
|
||||
/* global filterXSS */
|
||||
|
||||
function initializeUserProfileContent(user) {
|
||||
document.getElementById('sidebar-profile--avatar').src = user.profile_image_90;
|
||||
document.getElementById('sidebar-profile--avatar').src =
|
||||
user.profile_image_90;
|
||||
document.getElementById('sidebar-profile--avatar').alt = user.username;
|
||||
|
||||
document.getElementById('sidebar-profile--name').innerHTML = filterXSS(
|
||||
user.name,
|
||||
);
|
||||
document.getElementById('sidebar-profile--username').innerHTML = '@' + user.username;
|
||||
document.getElementById('sidebar-profile--username').innerHTML =
|
||||
'@' + user.username;
|
||||
document.getElementById('sidebar-profile').href = '/' + user.username;
|
||||
}
|
||||
|
||||
|
|
@ -23,7 +23,7 @@ function initializeUserSidebar(user) {
|
|||
? 'Follow tags to improve your feed'
|
||||
: 'Other Popular Tags';
|
||||
|
||||
followedTags.forEach(tag => {
|
||||
followedTags.forEach((tag) => {
|
||||
const element = document.getElementById(
|
||||
'default-sidebar-element-' + tag.name,
|
||||
);
|
||||
|
|
@ -99,15 +99,12 @@ function addRelevantButtonsToComments(user) {
|
|||
|
||||
function initializeBaseUserData() {
|
||||
const user = userData();
|
||||
const userProfileLinkHTML =
|
||||
'<a href="/' + user.username + '" id="first-nav-link" class="crayons-link crayons-link--block"><div>' +
|
||||
'<span class="fw-medium block">' + user.name +'</span>' +
|
||||
'<small class="fs-s color-base-50">@' + user.username + '</small>' +
|
||||
'</div></a>';
|
||||
document.getElementById(
|
||||
'user-profile-link-placeholder',
|
||||
).innerHTML = userProfileLinkHTML;
|
||||
const userNavLink = document.getElementById('first-nav-link');
|
||||
userNavLink.href = `/${user.username}`;
|
||||
userNavLink.querySelector('span').textContent = user.name;
|
||||
userNavLink.querySelector('small').textContent = `@${user.username}`;
|
||||
document.getElementById('nav-profile-image').src = user.profile_image_90;
|
||||
|
||||
initializeUserSidebar(user);
|
||||
addRelevantButtonsToArticle(user);
|
||||
addRelevantButtonsToComments(user);
|
||||
|
|
|
|||
|
|
@ -1,6 +1,13 @@
|
|||
<div class="crayons-dropdown left-2 right-2 s:left-auto p-0 top-bar__menu__dropdown">
|
||||
<% if user_signed_in? %>
|
||||
<div id="user-profile-link-placeholder" class="border-0 border-b-1 border-solid border-base-20 p-1">...</div>
|
||||
<div id="user-profile-link-placeholder" class="border-0 border-b-1 border-solid border-base-20 p-1">
|
||||
<a id="first-nav-link" class="crayons-link crayons-link--block">
|
||||
<div>
|
||||
<span class="fw-medium block">...</span>
|
||||
<small class="fs-s color-base-50"></small>
|
||||
</div>
|
||||
</a>
|
||||
</div>
|
||||
|
||||
<div class="border-0 border-b-1 border-solid border-base-20 p-1">
|
||||
<a href="<%= dashboard_path %>" class="crayons-link crayons-link--block">Dashboard</a>
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue