Skip to content

Commit

Permalink
add CSS
Browse files Browse the repository at this point in the history
  • Loading branch information
quentinkhoo committed Nov 29, 2023
1 parent 71723aa commit 7134bfe
Show file tree
Hide file tree
Showing 9 changed files with 160 additions and 12 deletions.
126 changes: 126 additions & 0 deletions app/assets/stylesheets/application.css
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,129 @@
*= require_tree .
*= require_self
*/

nav {
background-color: #fab3ad;
}

nav ul {
list-style-type: none;
margin: 0;
padding: 0;
overflow: hidden;
font-weight: bold;
}

nav li {
float: left;
font-weight: bold;
}

nav li a {
display: block;
color: #2c2827;
text-align: center;
padding: 14px 16px;
text-decoration: none;
}

nav li a:hover {
background-color: #8da99b;
}

nav::after {
content: "";
display: table;
clear: both;
}

li.right {
float: right;
}

.form-container {
width: 300px;
padding: 16px;
background-color: white;
margin: 0 auto;
margin-top: 100px;
border: 1px solid black;
border-radius: 4px;
}

form {
display: flex;
flex-direction: column;
}

label {
font-weight: bold;
margin-top: 10px;
}

input[type="text"], input[type="password"], input[type="email"] {
padding: 10px;
margin-top: 5px;
border-radius: 4px;
border: 1px solid grey;
}

input[type="submit"] {
margin-top: 10px;
padding: 10px;
border-radius: 4px;
background-color: #4CAF50;
color: white;
border: none;
cursor: pointer;
}

input[type="submit"]:hover {
background-color: #45a049;
}

.styled-image {
width: 50%;
height: auto;
border: 1px solid #ddd;
border-radius: 4px;
padding: 5px;
}

.styled-image:hover {
box-shadow: 0 0 2px 1px rgba(0, 140, 186, 0.5);
}

.styled-paragraph {
color: #333;
font-size: 18px;
line-height: 1.6;
text-align: justify;
padding: 10px;
background-color: #f8f8f8;
border: 1px solid #ddd;
border-radius: 4px;
}

.alert {
padding: 20px;
margin-bottom: 20px;
border: 1px solid transparent;
border-radius: 4px;
}

.alert-notice {
color: #3c763d;
background-color: #dff0d8;
border-color: #d6e9c6;
}

.alert-alert {
color: #a94442;
background-color: #f2dede;
border-color: #ebccd1;
}

* {
font-family: Arial, sans-serif;
}
7 changes: 7 additions & 0 deletions app/helpers/application_helper.rb
Original file line number Diff line number Diff line change
@@ -1,2 +1,9 @@
module ApplicationHelper
def flash_class(level)
case level
when :notice then "alert-notice"
when :alert then "alert-alert"
else "alert"
end
end
end
13 changes: 13 additions & 0 deletions app/views/layouts/_header.html.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<nav>
<ul>
<li><a href="/">Home</a></li>
<li><a href="/pages/anya">Secret Page</a></li>
<% if current_user %>
<li class='right'><%= link_to 'Log out', user_session_path(current_user), data: {turbo_method: :delete} %></li>
<% else %>
<li class='right'><%= link_to 'Login', new_user_session_path %></li>
<li class='right'><%= link_to 'Register', new_user_path %></li>
<% end %>
</ul>
</nav>
<br>
3 changes: 2 additions & 1 deletion app/views/layouts/application.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,12 @@

<body>
<% flash.each do |type, msg| %>
<div>
<div class="alert-<%= flash_class(type) %>">
<%= msg %>
</div>
<% end %>

<%= render "layouts/header" %>
<%= yield %>
</body>
</html>
2 changes: 1 addition & 1 deletion app/views/pages/anya.html.erb
Original file line number Diff line number Diff line change
@@ -1 +1 @@
<h1>This is the secret page</h1>
<h1>Secret: Anya like Peanuts</h1>
15 changes: 8 additions & 7 deletions app/views/pages/index.html.erb
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
<%= image_tag "data:image/png;base64,#{@img}", style: "width:30%; height:30%" %>

<% if current_user %>
<h1>Ohayaimasu, <%= current_user.name %></h1>
<%= image_tag "data:image/png;base64,#{@img}", class: "styled-image" %>
<p class="styled-paragraph">
<% @anyas.each do |anya| %>
<p><%= anya %></p><br>
<%= anya %>
<br>
<% end %>
<%= link_to 'Log out', user_session_path(current_user), data: {turbo_method: :delete} %><br>
</p><br>
<% else %>
<h1>Yororosu onegaisurumasu - Anya</h1>
<%= link_to 'Login', new_user_session_path %><br>
<%= link_to 'Register', new_user_path %><br>
<% end %>
<%= link_to 'Secret page', '/pages/anya' %>
<%= image_tag "data:image/png;base64,#{@img}", class: "styled-image" %>
<% end %>
2 changes: 1 addition & 1 deletion app/views/user_sessions/new.html.erb
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<h1>Login page</h1>
<h1>Login</h1>
<%= form_with model: @user, url: user_sessions_path do |f| %>
<div>
<%= f.label :name %><br>
Expand Down
2 changes: 1 addition & 1 deletion app/views/users/index.html.erb
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<h1>Users#index</h1>
<h1>Users</h1>

<%= link_to 'New User', new_user_path %>

Expand Down
2 changes: 1 addition & 1 deletion app/views/users/new.html.erb
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<h1>Users#new</h1>
<h1>Registration</h1>
<%= form_with model: @user do |f| %>
<% if @user.errors.any? %>
<div>
Expand Down

0 comments on commit 7134bfe

Please sign in to comment.