diff --git a/__pycache__/dashboard.cpython-310.pyc b/__pycache__/dashboard.cpython-310.pyc new file mode 100644 index 0000000..883c995 Binary files /dev/null and b/__pycache__/dashboard.cpython-310.pyc differ diff --git a/dashboard.py b/dashboard.py index e832057..1478963 100644 --- a/dashboard.py +++ b/dashboard.py @@ -13,7 +13,7 @@ root_content_path = 'dashboard_static' # the action will be called with the context and the event @event('init') def setup(ctx, e): - start_offline_tweets('sports1.txt', event_name="tweet", time_factor=0.1) + start_offline_tweets('sports1.txt', event_name="tweet", time_factor=0.01) ctx.count = 0 # fire('sample', {'previous': 0.0}) diff --git a/dashboard_static/index.html b/dashboard_static/index.html index 757132f..9e26092 100644 --- a/dashboard_static/index.html +++ b/dashboard_static/index.html @@ -99,15 +99,17 @@
-
- Sort By arrow_drop_down +
+ Sort By
    +
  • Time
  • Time
  • Likes
  • Retweets
  • Replies
+ arrow_drop_down
arrow_downward diff --git a/dashboard_static/js/code.js b/dashboard_static/js/code.js index faa2d2a..f427f81 100644 --- a/dashboard_static/js/code.js +++ b/dashboard_static/js/code.js @@ -24,14 +24,19 @@ function showFeeds() { } function tweetCell(tweet) { + const date = new Date(tweet.created_at); + console.log(new Intl.DateTimeFormat('en-GB').format(date)); var cell = document.createElement("div"); cell.innerHTML = `
- ${tweet.user.name} - @${tweet.user.screen_name} + + ${date.getHours()}:${date.getMinutes()}
${tweet.text}
diff --git a/dashboard_static/js/events.js b/dashboard_static/js/events.js index 50d0ea4..24c1d53 100644 --- a/dashboard_static/js/events.js +++ b/dashboard_static/js/events.js @@ -38,15 +38,6 @@ $(window).on("load", function() { showFeeds() }) -$(".sortby").on("click", function() { - $(".sort-dropdown").toggle() - // $(".sort-btn").toggleClass("radius-bottom") -}) - -$(".sort-dropdown-list li").on("click", function() { - $(".sort-dropdown").toggle() -}) - let root = document.querySelector(":root") $(".logo").on("click", function() { @@ -89,6 +80,19 @@ $(window).on("filter", function() { } }) +$(".current-sort").on("click", function() { + $(".sort-dropdown-list li:not(:first-of-type)").toggle() +}) + +$(".sort-btn").on("click", function() { + $(".sort-dropdown-list li:not(:first-of-type)").toggle() +}) + +$(".sort-dropdown-list li:not(:first-of-type)").on("click", function() { + $(".sort-dropdown-list li:not(:first-of-type)").toggle() + $(".current-sort").html($(this).html()) +}) + $(".order-btn").on("click", function() { if($(this).html() == "arrow_downward") { // Descending to ascending diff --git a/dashboard_static/style/style.css b/dashboard_static/style/style.css index 9b27667..41c5f77 100644 --- a/dashboard_static/style/style.css +++ b/dashboard_static/style/style.css @@ -93,6 +93,7 @@ body { .tweet { display: flex; + gap: 10px; background-color: var(--tweet-color); border-radius: 16px; padding: 16px; @@ -108,6 +109,17 @@ body { .tweet-content { padding-left: 16px; + width: 100%; +} + +.tweet-name { + display: flex; + gap: 1.5%; + justify-content: space-between; +} + +.tweet-date { + align-self: flex-end; } .tweet-interactions { @@ -150,6 +162,13 @@ body { opacity: 0.8; } +.tweet-date { + color: var(--main-light); + text-decoration: none; + justify-self: flex-end; + opacity: 0.8; +} + .filters-search input { height: 28px; width: 100%; @@ -248,33 +267,57 @@ body { user-select: none; } -.sort-btn { +.sort-by { user-select: none; - position: relative; + display: flex; + padding: 8px; +} + +.sort-by-title { + font-size: 24px; + font-weight: 500; + margin-right: 8px; } .sort-dropdown { - display: none; + display: flex; + align-items: flex-start; + position: relative; } .sort-dropdown-list { /* position: absolute; */ - width: 100%; list-style-type: none; padding: 0; margin: 0; - margin-left: -8px; - background-color: var(--main-light); - border-radius: 0 0 16px 16px; + background-color: white; + width: 150px; + border-radius: 16px; +} + +.material-symbols-outlined.sort-btn { + position: absolute; + right: 0; + top: 5px; + color: black; + font-size: 26px; +} + +.sort-dropdown-list li:not(:first-of-type) { + display: none; +} + +.sort-dropdown-list li:not(:first-of-type):hover { + background-color: rgb(215, 215, 215); } .sort-dropdown-list li { + color: #1E1E1E; font-weight: 500; font-size: 22px; padding: 0 8px; } -.radius-bottom { - border-bottom-left-radius: 16px; - border-bottom-right-radius: 16px; -} \ No newline at end of file +.current-sort { + line-height: 36px; +}