Skip to content

Commit

Permalink
focus on instructions
Browse files Browse the repository at this point in the history
  • Loading branch information
YaroslavPodorvanov committed Jan 2, 2024
1 parent 38440f4 commit a45e483
Show file tree
Hide file tree
Showing 4 changed files with 52 additions and 16 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_hidden", 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
14 changes: 14 additions & 0 deletions internal/templates/v2/models.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,3 +32,17 @@ 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
// focus on instructions
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 @@ -163,6 +165,7 @@
</div>
</div>
</section>
{% endif %}

{% if sessionProfile.ID == 0 %}
<section class="action">
Expand Down
35 changes: 21 additions & 14 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 a45e483

Please sign in to comment.