Skip to content

Commit

Permalink
highlight instruction after first login
Browse files Browse the repository at this point in the history
  • Loading branch information
YaroslavPodorvanov committed Jan 2, 2024
1 parent 38440f4 commit 915c55b
Show file tree
Hide file tree
Showing 4 changed files with 55 additions and 20 deletions.
16 changes: 14 additions & 2 deletions client/src/instruction.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,21 @@ function initToggle() {
const $state = document.querySelector(".js-instruction-visibility-state");
const $instruction = document.querySelector(".js-instruction");

function toggle(state: boolean) {
localStorage.setItem("instruction", state.toString());

$instruction.classList.toggle("hide", state);
$state.classList.toggle("active", state);
}

let hidden = localStorage.getItem("instruction_hidden") === "true";

toggle(hidden);

$button.addEventListener("click", () => {
$instruction.classList.toggle("hide");
$state.classList.toggle("active");
hidden = !hidden;

toggle(hidden);
});
}

Expand Down
13 changes: 13 additions & 0 deletions internal/templates/v2/models.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,3 +32,16 @@ func (v ProfileView) GetName() string {

return v.Name
}

func showCharts(currentPageProfile ProfileView, sessionProfile ProfileView, stats ProfileViewsStats) bool {
if stats.TotalCount > 0 {
return true
}

// hide charts before first view tracked
if currentPageProfile.ID == sessionProfile.ID {
return false
}

return true
}
3 changes: 3 additions & 0 deletions internal/templates/v2/profile.qtpl
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,8 @@
</div>
</div>
</section>

{% if showCharts(currentPageProfile, sessionProfile, stats) %}
<section class="profile__statistics">
<div class="profile__header">
<h3 class="profile__title">Your GitHub profile views statistic</h3>
Expand Down Expand Up @@ -186,6 +188,7 @@
</button>
</section>
{% endif %}
{% endif %}

{%= instruction(currentPageProfile, sessionProfile, exampleProfile, instructionDone) %}
</div>
Expand Down
43 changes: 25 additions & 18 deletions internal/templates/v2/profile.qtpl.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 915c55b

Please sign in to comment.