Skip to content

Commit

Permalink
Small fixes (#1266)
Browse files Browse the repository at this point in the history
* if logo does not meet validation error is thrown

* fix devise forms to be more uniform

* add logo to top navbar and fix its positioning relative to org name

* update form

* fix featured pets to have same image heights and handle collections of unadopted pets smaller than 4

* lint

* fix test
  • Loading branch information
kasugaijin authored Dec 17, 2024
1 parent 76d7acf commit 591588e
Show file tree
Hide file tree
Showing 8 changed files with 28 additions and 22 deletions.
2 changes: 1 addition & 1 deletion app/controllers/organizations/home_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ class Organizations::HomeController < Organizations::BaseController

def index
@pets = Pet.with_photo
.unadopted
.includes(images_attachments: :blob)
.where(organization: Current.organization)
.sample(4)
end
end
8 changes: 4 additions & 4 deletions app/views/devise/registrations/new.html.erb
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<section class="container d-flex flex-column">
<div class="row align-items-center justify-content-center g-0 min-vh-100">
<section class="container d-flex flex-column py-6">
<div class="row justify-content-center">
<div class="col-lg-5 col-md-8 py-8 py-xl-0">
<!-- Card -->
<div class="card shadow">
Expand All @@ -9,9 +9,9 @@
<div class='d-flex justify-content-center'>
<div class='d-flex flex-column align-items-center mb-3'>
<% if Current.organization.avatar.attached? %>
<%= image_tag Current.organization.avatar, alt: current_organization_name, title: current_organization_name, class: 'rounded', height: 100, width: 100 %>
<%= image_tag Current.organization.avatar, alt: current_organization_name, title: current_organization_name, height: 75 %>
<% end %>
<h1 class='text-muted'><%= Current.tenant.name %></h1>
<h1><%= Current.tenant.name %></h1>
</div>
</div>
<h1 class="mb-1 fw-bold">Sign up</h1>
Expand Down
10 changes: 6 additions & 4 deletions app/views/devise/sessions/new.html.erb
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<section class="container d-flex flex-column">
<div class="row align-items-center justify-content-center g-0 min-vh-100">
<section class="container d-flex flex-column py-6">
<div class="row justify-content-center">

<div class="col-lg-5 col-md-8 py-8 py-xl-0">
<!-- Card -->
Expand All @@ -9,8 +9,10 @@
<div class="mb-4">
<div class='d-flex justify-content-center'>
<div class='d-flex flex-column align-items-center mb-3'>
<%= image_tag 'brand/pet-rescue.png', class: 'mb-0', alt: 'logo-icon', height: 100, width: 100 %>
<h1 class='text-muted'><%= Current.tenant.name %></h1>
<% if Current.organization.avatar.attached? %>
<%= image_tag Current.organization.avatar, alt: current_organization_name, title: current_organization_name, height: 75 %>
<% end %>
<h1><%= Current.tenant.name %></h1>
</div>
</div>
<h1 class="mb-1 fw-bold">Log in</h1>
Expand Down
4 changes: 2 additions & 2 deletions app/views/layouts/dashboard/_sidebar.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
<!-- Brand logo -->
<p class="navbar-brand flex-column">
<%= link_to home_index_path, class: "nav-link" do %>
<% if Current.organization.avatar.attached? %>
<%= image_tag Current.organization.avatar, alt: current_organization_name, title: current_organization_name, class: 'rounded-1' %>
<% if Current.organization.avatar.attached? && Current.organization.avatar.persisted? %>
<%= image_tag Current.organization.avatar, alt: current_organization_name, title: current_organization_name %>
<% else %>
<%= current_organization_name %>
<% end %>
Expand Down
14 changes: 9 additions & 5 deletions app/views/layouts/shared/_navbar.html.erb
Original file line number Diff line number Diff line change
@@ -1,10 +1,14 @@
<nav class="navbar navbar-expand-lg bg-transparent shadow-none px-0 py-3">
<div class="container-fluid px-4">
<%= image_tag('png/logo.png', width: '40px', height: '35px', alt: 'Organization logo',
class: 'pe-2') %>
<%= link_to home_index_path, class: 'navbar-brand fw-bold text-black' do %>
<%= Current.organization.name %>
<% end %>
<div class="d-flex gap-2">
<% if Current.organization.avatar.attached? %>
<%= image_tag Current.organization.avatar, alt: current_organization_name, title: current_organization_name, height: 30 %>
<% end %>

<%= link_to home_index_path, class: 'navbar-brand fw-bold text-black' do %>
<%= Current.organization.name %>
<% end %>
</div>

<div class="d-flex align-items-center order-lg-3">
<div>
Expand Down
8 changes: 4 additions & 4 deletions app/views/organizations/home/index.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -32,21 +32,21 @@

<!--//? ADOPTION -->
<section class="pt-5 pb-5" id="adopt">
<div class="container mb-md-5 mt-md-5">
<div class="container mb-md-5 mt-md-5 d-flex flex-column align-items-center">

<!--//? section heading -->
<div class="text-center mb-5">
<div class="mb-5">
<h2 class="section-heading text-uppercase text-xl">
<%= t('.adopt')%>
</h2>
</div>
<!--//? bootstrap cards -->
<div class="row row-cols-1 row-cols-md-2 row-cols-lg-4 mt-4">
<div class="row row-cols-1 row-cols-md-2 row-cols-lg-4 mt-4 w-100 justify-content-center">
<% @pets.each do |pet| %>
<%= link_to adoptable_pet_path(pet) do %>
<div class="col">
<div class="card featured-pets h-100 mt-4 mt-lg-0">
<%= image_tag(pet.images.first, alt: pet.name) %>
<%= image_tag(pet.images.first, alt: pet.name, height: 275, style: "object-fit: cover;") %>
<div class="card-img-overlay p-0"></div>
<div class="card-footer">
<p class="card-text text-black">
Expand Down
2 changes: 1 addition & 1 deletion app/views/organizations/staff/organizations/_form.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@
<div class='form-group mt-3'>
<%= form.file_field :avatar,
class: "custom-attachments",
label: 'Attach picture' %>
label: 'Attach logo' %>
</div>
<% end %>
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ class Organization::EditTest < ActionDispatch::IntegrationTest
assert_select "label", text: "City/Town"
assert_select "input[name='organization[locations_attributes][0][city_town]'][type='text']"

assert_select "label", text: "Attach picture"
assert_select "label", text: "Attach logo"
assert_select "input[name='organization[avatar]']"

assert_select 'input[type="submit"][value="Save profile"]'
Expand Down

0 comments on commit 591588e

Please sign in to comment.