Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Toggle comments theme when theme changed #11

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 7 additions & 5 deletions _includes/author.html
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
<div class="author">
<img
class="author-avatar"
src="{{ site.author.avatar }}"
alt="{{ site.author.username }}"
/>
<div class="author-avatar-wrapper">
<img
class="author-avatar"
src="{{ site.author.avatar }}"
alt="{{ site.author.username }}"
/>
</div>
<h2 class="author-name">{{ site.author.name }}</h2>
<p class="author-bio">{{ site.author.bio }}</p>
</div>
2 changes: 1 addition & 1 deletion _includes/comments.html
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
repo="username/reponame"
issue-term="pathname"
label="✨ comment ✨"
theme="github-light"
theme="github-dark"
crossorigin="anonymous"
async
></script>
19 changes: 18 additions & 1 deletion _sass/klise/_layout.scss
Original file line number Diff line number Diff line change
Expand Up @@ -184,12 +184,18 @@
margin-top: 6.3rem;
margin-bottom: 7.2rem;
text-align: center;
display: flex;
align-items: center;
flex-direction: column;

@include media-query($on-mobile) {
margin-bottom: 3em;
}

.author-avatar {
.author-avatar-wrapper {
border-style: solid;
border-width: 1px;
border-color:b6b6b6;
width: 70px;
height: 70px;
border-radius: 100%;
Expand All @@ -200,6 +206,17 @@
-webkit-animation: 0.5s ease-in forwards fadein;
animation: 0.5s ease-in forwards fadein;
opacity: 1;
overflow: hidden;
}

.author-avatar {
transition: 0.6s;
&:hover {
-ms-transform: scale(1.2);
-moz-transform: scale(1.2);
-webkit-transform: scale(1.2);
transform: scale(1.2);
}
}

.author-name {
Expand Down
9 changes: 9 additions & 0 deletions assets/js/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,21 @@
};

const toggleTheme = (state) => {
var utterances = document.querySelector('iframe');
if (state === "dark") {
localStorage.setItem("theme", "light");
body.removeAttribute("data-theme");
utterances.contentWindow.postMessage(
{type: 'set-theme',theme: 'github-light'},
'https://utteranc.es'
);
} else if (state === "light") {
localStorage.setItem("theme", "dark");
body.setAttribute("data-theme", "dark");
utterances.contentWindow.postMessage(
{type: 'set-theme',theme: 'github-dark'},
'https://utteranc.es'
);
} else {
initTheme(state);
}
Expand Down