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

Create current topic #374

Merged
merged 11 commits into from
Sep 19, 2020
Merged
14 changes: 12 additions & 2 deletions app/assets/stylesheets/application.css
Original file line number Diff line number Diff line change
Expand Up @@ -126,12 +126,18 @@
}

.active-topic {
background-color: #e4e9f0;
background-color: #F3F2F1;
padding: 20px 0;
font-size: 1rem;
}

.active-topic p {
.active-topic p ,
.active-topic h1,
.active-topic h2,
.active-topic h3,
.active-topic h4,
.active-topic h5,
.active-topic h6 {
margin: 10px 0;
font-size: 1rem;
}
Expand All @@ -148,3 +154,7 @@
display: grid;
grid-template-columns: 1fr 100px;
}

.active-topic__hidden {
display: none;
}
2 changes: 1 addition & 1 deletion app/models/current_topic.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
class CurrentTopic < ApplicationRecord

def key
updated_at.to_s
Digest::MD5.hexdigest updated_at.to_s
end

def self.active
Expand Down
10 changes: 9 additions & 1 deletion app/views/components/_active_topic.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,16 @@
<%= @active_current_topic.body.html_safe %>
</div>
<div>
<a href="#" data-key="<%= @active_current_topic.key %>">Skryť správu</a>
<a href="#" class="js__active-topic-close">Skryť správu</a>
</div>
</div>
</div>
</div>
<script src="https://cdn.jsdelivr.net/npm/js-cookie@rc/dist/js.cookie.min.js"></script>
jsuchal marked this conversation as resolved.
Show resolved Hide resolved
<script>
document.querySelector('.js__active-topic-close').addEventListener('click', function(e) {
jsuchal marked this conversation as resolved.
Show resolved Hide resolved
e.preventDefault()
Cookies.set('current_topic', '<%= @active_current_topic.key %>', { expires: 365 });
document.querySelector('.active-topic').classList.add('active-topic__hidden');
});
</script>