Enhanced News UI.

Added a drop shadow so that the news no longer scrolls into nothing.
Tweaked several styles to make the UI look a lot better.
This commit is contained in:
Daniel Scalzi 2018-06-20 09:12:44 -04:00
parent e2e48f6444
commit 2d0c4c76eb
No known key found for this signature in database
GPG Key ID: 5CA2F145B63535F9
3 changed files with 73 additions and 23 deletions

View File

@ -1880,36 +1880,60 @@ input:checked + .toggleSwitchSlider:before {
/* News content container. */ /* News content container. */
#newsContent { #newsContent {
height: 82vh; height: 82vh;
width: 82vw; width: 100%;
display: flex; display: flex;
-webkit-user-select: initial; -webkit-user-select: initial;
position: relative;
}
/* Drop shadow displayed when content is scrolled out of view. */
#newsContent:before {
content: '';
background: linear-gradient(rgba(0, 0, 0, 0.25), transparent);
width: 100%;
height: 5px;
position: absolute;
opacity: 0;
transition: opacity 0.25s ease;
}
#newsContent[scrolled]:before {
opacity: 1;
} }
/* News article status container (left). */ /* News article status container (left). */
#newsStatusContainer { #newsStatusContainer {
width: 25%; width: calc(30% - 60px);
height: calc(100% - 30px); height: calc(100% - 30px);
padding: 15px; padding: 15px 15px 15px 45px;
display: flex; display: flex;
flex-direction: column; flex-direction: column;
justify-content: space-between; justify-content: space-between;
position: relative;
} }
/* News status content. */ /* News status content. */
#newsStatusContent { #newsStatusContent {
display: flex; display: flex;
flex-direction: column; flex-direction: column;
align-items: flex-end;
}
/* News title wrapper. */
#newsTitleContainer {
display: flex;
max-width: 90%;
} }
/* News article title styles. */ /* News article title styles. */
#newsArticleTitle { #newsArticleTitle {
font-size: 20px; font-size: 18px;
font-weight: bold; font-weight: bold;
font-family: 'Avenir Medium'; font-family: 'Avenir Medium';
color: white; color: white;
text-decoration: none; text-decoration: none;
transition: 0.25s ease; transition: 0.25s ease;
outline: none; outline: none;
text-align: right;
} }
#newsArticleTitle:hover, #newsArticleTitle:hover,
#newsArticleTitle:focus { #newsArticleTitle:focus {
@ -1926,6 +1950,13 @@ input:checked + .toggleSwitchSlider:before {
flex-direction: column; flex-direction: column;
} }
/* Date and author wrappers. */
#newsArticleDateWrapper,
#newsArticleAuthorWrapper {
display: flex;
justify-content: flex-end;
}
/* Date and author shared styles. */ /* Date and author shared styles. */
#newsArticleDate, #newsArticleDate,
#newsArticleAuthor { #newsArticleAuthor {
@ -1957,6 +1988,7 @@ input:checked + .toggleSwitchSlider:before {
text-decoration: none; text-decoration: none;
transition: 0.25s ease; transition: 0.25s ease;
outline: none; outline: none;
text-align: right;
} }
#newsArticleComments:focus, #newsArticleComments:focus,
#newsArticleComments:hover { #newsArticleComments:hover {
@ -1968,20 +2000,20 @@ input:checked + .toggleSwitchSlider:before {
/* Article content container (right). */ /* Article content container (right). */
#newsArticleContainer { #newsArticleContainer {
width: 75%; width: calc(100% - 25px);
height: 100%; height: 100%;
margin: 0px 0px 0px 25px;
} }
/* Article content styles. */ /* Article content styles. */
#newsArticleContentScrollable { #newsArticleContentScrollable {
font-size: 12px; font-size: 12px;
max-width: 80%;
margin: 25px 35px 0px 25px;
overflow-y: scroll; overflow-y: scroll;
height: calc(100% - 25px); height: 100%;
padding: 0px 15px 0px 15px; padding: 0px 15px 0px 15px;
} }
#newsArticleContentScrollable img { #newsArticleContentScrollable img,
#newsArticleContentScrollable iframe {
max-width: 95%; max-width: 95%;
display: block; display: block;
margin: 0 auto; margin: 0 auto;
@ -2009,8 +2041,16 @@ input:checked + .toggleSwitchSlider:before {
box-shadow: inset 0 0 10px rgba(255, 255, 255, 0.50); box-shadow: inset 0 0 10px rgba(255, 255, 255, 0.50);
} }
#newsArticleContentWrapper {
width: 80%;
}
.newsArticleSpacerTop {
height: 15px;
}
/* Div to add spacing at the end of a news article. */ /* Div to add spacing at the end of a news article. */
.newsArticleSpacer { .newsArticleSpacerBot {
height: 30px; height: 30px;
} }
@ -2021,6 +2061,9 @@ input:checked + .toggleSwitchSlider:before {
align-items: center; align-items: center;
margin-bottom: 10px; margin-bottom: 10px;
-webkit-user-select: none; -webkit-user-select: none;
position: absolute;
bottom: 15px;
right: 0px;
} }
/* Navigation status span. */ /* Navigation status span. */

View File

@ -21,17 +21,6 @@ const launch_details_text = document.getElementById('launch_details_text')
const server_selection_button = document.getElementById('server_selection_button') const server_selection_button = document.getElementById('server_selection_button')
const user_text = document.getElementById('user_text') const user_text = document.getElementById('user_text')
// News Elements
const newsContent = document.getElementById('newsContent')
const newsArticleTitle = document.getElementById('newsArticleTitle')
const newsArticleDate = document.getElementById('newsArticleDate')
const newsArticleAuthor = document.getElementById('newsArticleAuthor')
const newsArticleComments = document.getElementById('newsArticleComments')
const newsNavigationStatus = document.getElementById('newsNavigationStatus')
const newsArticleContent = document.getElementById('newsArticleContentScrollable')
const newsErrorContainer = document.getElementById('newsErrorContainer')
const nELoadSpan = document.getElementById('nELoadSpan')
/* Launch Progress Wrapper Functions */ /* Launch Progress Wrapper Functions */
/** /**
@ -722,6 +711,16 @@ function dlAsync(login = true){
* News Loading Functions * News Loading Functions
*/ */
// DOM Cache
const newsContent = document.getElementById('newsContent')
const newsArticleTitle = document.getElementById('newsArticleTitle')
const newsArticleDate = document.getElementById('newsArticleDate')
const newsArticleAuthor = document.getElementById('newsArticleAuthor')
const newsArticleComments = document.getElementById('newsArticleComments')
const newsNavigationStatus = document.getElementById('newsNavigationStatus')
const newsArticleContentScrollable = document.getElementById('newsArticleContentScrollable')
const nELoadSpan = document.getElementById('nELoadSpan')
// News slide caches. // News slide caches.
let newsActive = false let newsActive = false
let newsGlideCount = 0 let newsGlideCount = 0
@ -835,6 +834,14 @@ newsErrorRetry.onclick = () => {
}) })
} }
newsArticleContentScrollable.onscroll = (e) => {
if(e.target.scrollTop > Number.parseFloat($('.newsArticleSpacerTop').css('height'))){
newsContent.setAttribute('scrolled', '')
} else {
newsContent.removeAttribute('scrolled')
}
}
/** /**
* Reload the news without restarting. * Reload the news without restarting.
* *
@ -984,7 +991,7 @@ function displayArticle(articleObject, index){
newsArticleDate.innerHTML = articleObject.date newsArticleDate.innerHTML = articleObject.date
newsArticleComments.innerHTML = articleObject.comments newsArticleComments.innerHTML = articleObject.comments
newsArticleComments.href = articleObject.commentsLink newsArticleComments.href = articleObject.commentsLink
newsArticleContent.innerHTML = articleObject.content + '<div class="newsArticleSpacer"></div>' newsArticleContentScrollable.innerHTML = '<div id="newsArticleContentWrapper"><div class="newsArticleSpacerTop"></div>' + articleObject.content + '<div class="newsArticleSpacerBot"></div></div>'
newsNavigationStatus.innerHTML = index + ' of ' + newsArr.length newsNavigationStatus.innerHTML = index + ' of ' + newsArr.length
newsContent.setAttribute('article', index-1) newsContent.setAttribute('article', index-1)
} }

View File

@ -169,7 +169,7 @@
<div id="newsArticleDateWrapper"> <div id="newsArticleDateWrapper">
<span id="newsArticleDate">Mar 15, 44 BC, 9:14 AM</span> <span id="newsArticleDate">Mar 15, 44 BC, 9:14 AM</span>
</div> </div>
<div id="newsArticleTitleWrapper"> <div id="newsArticleAuthorWrapper">
<span id="newsArticleAuthor">by Cicero</span> <span id="newsArticleAuthor">by Cicero</span>
</div> </div>
<a href="#" id="newsArticleComments">0 Comments</a> <a href="#" id="newsArticleComments">0 Comments</a>