Skip to content

Commit 3e280a4

Browse files
committed
sorted admin-page, reworked notice/aletrt bar, add button for dark/light theme
1 parent e25a5db commit 3e280a4

File tree

15 files changed

+21473
-946
lines changed

15 files changed

+21473
-946
lines changed

app/.DS_Store

0 Bytes
Binary file not shown.

app/assets/.DS_Store

0 Bytes
Binary file not shown.

app/assets/js/.DS_Store

6 KB
Binary file not shown.

app/assets/stylesheets/.DS_Store

6 KB
Binary file not shown.

app/assets/stylesheets/application.scss

Lines changed: 54 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,59 @@
55

66

77

8-
9-
10-
11-
12-
body { background-color: Black; }
8+
@import url('https://fonts.googleapis.com/css?family=Josefin+Sans');
9+
10+
body {
11+
background-color: Black;
12+
font-family: 'Josefin Sans', sans-serif;
13+
}
14+
15+
16+
$dark-background-color-base : #0d1117;
17+
$dark-border-color: #21262d;
18+
19+
body {
20+
font-family: 'Josefin Sans', sans-serif;
21+
}
22+
23+
body.light {
24+
color: black;
25+
background-color: white;
26+
27+
#logo {
28+
color: black;
29+
}
30+
31+
#menu-links {
32+
a {
33+
color: black;
34+
}
35+
}
36+
}
37+
38+
body.dark {
39+
color: white;
40+
background-color: $dark-background-color-base;
41+
border-color: $dark-border-color !important;
42+
43+
#logo {
44+
color: white;
45+
}
46+
47+
header {
48+
background-color: $dark-background-color-base;
49+
border-color: $dark-border-color !important;
50+
}
51+
52+
#menu-links {
53+
a {
54+
color: white;
55+
}
56+
}
57+
58+
#user-dropdown-button {
59+
color: white;
60+
}
61+
}
1362

1463

app/controllers/application_controller.rb

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,16 @@
11
class ApplicationController < ActionController::Base
2+
before_action :set_theme
3+
4+
5+
def set_theme
6+
if params[:theme].present?
7+
theme = params[:theme].to_sym
8+
cookies[:theme] = theme
9+
redirect_to(request.referrer || home_path)
10+
end
11+
end
12+
13+
214
def about
315
render "/about"
416
end

app/javascript/.DS_Store

6 KB
Binary file not shown.

app/javascript/stylesheets/.DS_Store

6 KB
Binary file not shown.

app/views/articles/show.html.erb

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
1-
<% if user_signed_in? %>
2-
<% if @article.user.email == current_user.email || current_user.email == "atom-1121@mail.ru" %>
3-
<div class="btn-group container" role="group" aria-label="Basic mixed styles example">
4-
<a href="<%= edit_article_path(@article) %>" class="btn btn-outline-success" role="button">Edit task</a>
5-
<a class="btn btn-danger" <%= link_to "Delete task", article_path(@article),
6-
method: :delete,
7-
data: { confirm: "Are you sure?" } %></a></div>
8-
<% end %>
9-
<% end %>
1+
<% if user_signed_in? %>
2+
<% if @article.user.email == current_user.email || current_user.email == "atom-1121@mail.ru" %>
3+
<div class="btn-group container" role="group" aria-label="Basic mixed styles example">
4+
<a href="<%= edit_article_path(@article) %>" class="btn btn-outline-success" role="button">Edit task</a>
5+
<a class="btn btn-danger" <%= link_to "Delete task", article_path(@article),
6+
method: :delete,
7+
data: { confirm: "Are you sure?" } %></a></div>
8+
<% end %>
9+
<% end %>
1010
<br><br>
1111
<div class="container">
1212
<div class="row">
@@ -25,8 +25,8 @@
2525
<div class="col">
2626
<style>.raz {text-align: right;}</style>
2727
<div class = raz>
28-
<p class=text-muted>Created: <%= time_ago_in_words(@article.created_at) %> ago.<br>by <strong><%= link_to @article.user.username, @article.user %> </strong></p>
29-
</div>
28+
<p class=text-muted>Created: <%= time_ago_in_words(@article.created_at) %> ago.<br>by <strong><%= link_to @article.user.username, @article.user %> </strong></p>
29+
</div>
3030
</div>
3131
</div>
3232
</div>

app/views/layouts/_header.html.erb

Lines changed: 38 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,28 @@
1212
<% end %>
1313
<% end %>
1414
</ul>
15+
16+
<% if cookies[:theme] == "light" %>
17+
<%= link_to home_path(theme: "dark"), class: 'navbar-brand mb-0 h1' do %>
18+
<button type="button" class="btn btn-outline-light">
19+
<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="currentColor" class="bi bi-moon" viewBox="0 0 16 16">
20+
<path d="M6 .278a.768.768 0 0 1 .08.858 7.208 7.208 0 0 0-.878 3.46c0 4.021 3.278 7.277 7.318 7.277.527 0 1.04-.055 1.533-.16a.787.787 0 0 1 .81.316.733.733 0 0 1-.031.893A8.349 8.349 0 0 1 8.344 16C3.734 16 0 12.286 0 7.71 0 4.266 2.114 1.312 5.124.06A.752.752 0 0 1 6 .278zM4.858 1.311A7.269 7.269 0 0 0 1.025 7.71c0 4.02 3.279 7.276 7.319 7.276a7.316 7.316 0 0 0 5.205-2.162c-.337.042-.68.063-1.029.063-4.61 0-8.343-3.714-8.343-8.29 0-1.167.242-2.278.681-3.286z"/>
21+
</svg>
22+
</button>
23+
<% end %>
24+
<% else %>
25+
<%= link_to home_path(theme: "light"), class: 'navbar-brand mb-0 h1' do %>
26+
<button type="button" class="btn btn-outline-light">
27+
<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="currentColor" class="bi bi-brightness-high-fill" viewBox="0 0 16 16">
28+
<path d="M12 8a4 4 0 1 1-8 0 4 4 0 0 1 8 0zM8 0a.5.5 0 0 1 .5.5v2a.5.5 0 0 1-1 0v-2A.5.5 0 0 1 8 0zm0 13a.5.5 0 0 1 .5.5v2a.5.5 0 0 1-1 0v-2A.5.5 0 0 1 8 13zm8-5a.5.5 0 0 1-.5.5h-2a.5.5 0 0 1 0-1h2a.5.5 0 0 1 .5.5zM3 8a.5.5 0 0 1-.5.5h-2a.5.5 0 0 1 0-1h2A.5.5 0 0 1 3 8zm10.657-5.657a.5.5 0 0 1 0 .707l-1.414 1.415a.5.5 0 1 1-.707-.708l1.414-1.414a.5.5 0 0 1 .707 0zm-9.193 9.193a.5.5 0 0 1 0 .707L3.05 13.657a.5.5 0 0 1-.707-.707l1.414-1.414a.5.5 0 0 1 .707 0zm9.193 2.121a.5.5 0 0 1-.707 0l-1.414-1.414a.5.5 0 0 1 .707-.707l1.414 1.414a.5.5 0 0 1 0 .707zM4.464 4.465a.5.5 0 0 1-.707 0L2.343 3.05a.5.5 0 1 1 .707-.707l1.414 1.414a.5.5 0 0 1 0 .708z"/>
29+
</svg>
30+
</button>
31+
<% end %>
32+
<% end %>
33+
34+
35+
36+
</ul>
1537
<form class="d-flex" action="/search">
1638
<input class="form-control me-2" name="q" type="search" placeholder="Search" aria-label="Search" >
1739
<button class="btn btn-outline-primary me-2" type="submit">Search</button>
@@ -34,4 +56,19 @@
3456
<a href="/users/sign_up" class="btn btn-primary" role="button" aria-pressed="true">Sign-up</a>
3557
<% end %>
3658
</header>
37-
<div class="alert" role="alert" ><center><%= notice %><%= alert %></center></div>
59+
60+
<% if notice %>
61+
<div class="alert alert-success alert-dismissible fade show" role="alert">
62+
<center><%= notice %></center>
63+
<button type="button" class="btn-close" data-bs-dismiss="alert" aria-label="Close"></button>
64+
</div>
65+
<% elsif alert %>
66+
<div class="alert alert-danger "><center><%= alert %></center></div>
67+
<% else %>
68+
<% flash.each do |message_type, message| %>
69+
<div class="alert alert-<%= message_type %> alert-dismissible fade show" role="alert">
70+
<center><%= message %></center>
71+
<button type="button" class="btn-close" data-bs-dismiss="alert" aria-label="Close"></button>
72+
</div>
73+
<% end %>
74+
<% end %>

0 commit comments

Comments
 (0)