Skip to content
Merged
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
Binary file added app/assets/fonts/pirata-one-regular.ttf
Binary file not shown.
166 changes: 162 additions & 4 deletions app/assets/stylesheets/application.bootstrap.scss
Original file line number Diff line number Diff line change
Expand Up @@ -1140,22 +1140,180 @@ dialog {
transform: translateY(-3px);
}

@font-face {
font-family: "Pirata One Local";
src: url("/pirata-one-regular.ttf") format("truetype");
font-style: normal;
font-weight: 400;
font-display: swap;
}

.repair-partner-logo-link {
--repair-partner-title-color: #f3e2bf;
--repair-partner-shadow: rgba(18, 10, 3, 0.35);
width: 100%;
max-width: 190px;
max-width: 210px;
aspect-ratio: 1 / 1;
position: relative;
display: inline-flex;
align-items: center;
align-items: flex-end;
justify-content: center;
padding: 0.35rem;
padding: 0 1rem 1rem;
text-decoration: none;
perspective: 2500px;
isolation: isolate;
color: var(--repair-partner-title-color);
}

.repair-partner-logo-link:hover,
.repair-partner-logo-link:focus-visible {
color: var(--repair-partner-title-color);
text-decoration: none;
border-radius: 0.65rem;
}

.repair-partner-logo-link:focus-visible {
outline: 2px solid rgba(113, 28, 28, 0.55);
outline-offset: 0.35rem;
}

.repair-partner-logo-link__wrapper {
position: absolute;
inset: 0;
z-index: 0;
display: flex;
align-items: center;
justify-content: center;
padding: 0.2rem;
overflow: visible;
transition: transform 0.5s ease;
transform-origin: center;
}

.repair-partner-logo-link__wrapper::before,
.repair-partner-logo-link__wrapper::after {
content: "";
position: absolute;
inset-inline: 0;
pointer-events: none;
transition: opacity 0.5s ease, height 0.5s ease;
}

.repair-partner-logo-link__wrapper::before {
inset-block: 0;
opacity: 0;
background-image: linear-gradient(
to top,
transparent 42%,
rgba(18, 10, 3, 0.24) 70%,
rgba(18, 10, 3, 0.7) 100%
);
}

.repair-partner-logo-link__wrapper::after {
bottom: 0;
height: 88px;
opacity: 0.78;
background-image: linear-gradient(
to bottom,
transparent 18%,
rgba(18, 10, 3, 0.12) 60%,
rgba(18, 10, 3, 0.76) 100%
);
}

.repair-partner-logo-link:hover .repair-partner-logo-link__wrapper,
.repair-partner-logo-link:focus-visible .repair-partner-logo-link__wrapper {
transform: perspective(900px) translateY(-5%) rotateX(25deg);
}

.repair-partner-logo-link:hover .repair-partner-logo-link__wrapper::before,
.repair-partner-logo-link:focus-visible .repair-partner-logo-link__wrapper::before,
.repair-partner-logo-link:hover .repair-partner-logo-link__wrapper::after,
.repair-partner-logo-link:focus-visible .repair-partner-logo-link__wrapper::after {
opacity: 1;
}

.repair-partner-logo-link:hover .repair-partner-logo-link__wrapper::after,
.repair-partner-logo-link:focus-visible .repair-partner-logo-link__wrapper::after {
height: 128px;
}

.repair-partner-logo-link__image {
width: 100%;
height: 100%;
object-fit: contain;
filter: drop-shadow(0 16px 24px rgba(47, 20, 4, 0.15));
transition: transform 0.5s ease, filter 0.5s ease;
}

.repair-partner-logo-link:hover .repair-partner-logo-link__image,
.repair-partner-logo-link:focus-visible .repair-partner-logo-link__image {
transform: translateY(-0.4rem) scale(1.03);
filter:
drop-shadow(0 22px 32px rgba(18, 10, 3, 0.2))
drop-shadow(2px 35px 32px var(--repair-partner-shadow));
}

.repair-partner-logo-link__title {
position: relative;
z-index: 1;
display: block;
max-width: 85%;
margin-bottom: 0.1rem;
text-align: center;
font-family: "Pirata One Local", "Times New Roman", serif;
font-size: clamp(1.3rem, 1.05rem + 0.75vw, 1.85rem);
line-height: 0.95;
letter-spacing: 0.08em;
text-transform: uppercase;
text-shadow: 0 10px 18px rgba(0, 0, 0, 0.48);
opacity: 0;
transform: translate3d(0, 0.75rem, 70px) scale(0.92);
transform-origin: bottom center;
transition: transform 0.5s ease, opacity 0.35s ease;
pointer-events: none;
}

.repair-partner-logo-link:hover .repair-partner-logo-link__title,
.repair-partner-logo-link:focus-visible .repair-partner-logo-link__title {
opacity: 1;
transform: translate3d(0, -2.1rem, 100px) scale(1);
}

@media (hover: none) {
.repair-partner-logo-link {
padding: 0;
aspect-ratio: auto;
display: flex;
flex-direction: column;
gap: 0.75rem;
align-items: stretch;
}

.repair-partner-logo-link__wrapper {
position: relative;
inset: auto;
aspect-ratio: 1 / 1;
}

.repair-partner-logo-link__title {
max-width: none;
margin-bottom: 0;
opacity: 1;
color: #4c1f12;
text-shadow: none;
transform: none;
}
}

@media (prefers-reduced-motion: reduce) {
.repair-partner-logo-link__wrapper,
.repair-partner-logo-link__wrapper::before,
.repair-partner-logo-link__wrapper::after,
.repair-partner-logo-link__image,
.repair-partner-logo-link__title {
transition: none;
}
}

@media (max-width: 991.98px) {
Expand Down
2 changes: 1 addition & 1 deletion app/controllers/home_pages_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,6 @@ def set_home_page
# Only allow a list of trusted parameters through.
def home_page_params
params.expect(home_page: [ :title, :content, :position, :bloc_type, :target_id, :shop_scope, :image, :button_label,
:layout_background, :layout_text_tone, :layout_image_position ])
:layout_background, :layout_text_tone, :layout_image_position, :shop_products_limit ])
end
end
2 changes: 1 addition & 1 deletion app/mailers/application_mailer.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
class ApplicationMailer < ActionMailer::Base
default from: "from@example.com"
default from: ENV["GMAIL_LOGIN"]
layout "mailer"
end
33 changes: 18 additions & 15 deletions app/mailers/user_mailer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,20 +3,17 @@ class UserMailer < Devise::Mailer
layout "mailer"

def welcome_email(user)
# on récupère l'instance user pour ensuite pouvoir la passer à la view en @user
@user = user
@login_url = "#{app_host}/users/sign_in"
@home_url = app_host

# on définit une variable @url qu'on utilisera dans la view d’e-mail
@url = "http://monsite.fr/login"

# c'est cet appel à mail() qui permet d'envoyer l’e-mail en définissant destinataire et sujet.
mail(to: @user.email, subject: "Bienvenue Templier !")
mail(to: @user.email, subject: "Bienvenue sur l'atelier")
end

def order_email(order)
@order = order
@user = order.user
@url = "http://localhost:3000/orders/#{order.id}"
@order_url = "#{app_host}/orders/#{order.id}"

mail(to: @user.email, subject: "Confirmation de commande ##{order.id}")
end
Expand All @@ -25,18 +22,18 @@ def admin_order_email(order)
@admins = User.where(is_admin: true)
@order = order
@user = order.user
@url = "http://localhost:3000/orders/#{order.id}"
@order_url = "#{app_host}/orders/#{order.id}"

mail(
to: @admins.pluck(:email),
subject: "Nouvelle commande ##{@order.id} reçue !"
subject: "Nouvelle commande ##{@order.id}"
)
end

def order_status_update_email(order, previous_status:)
@order = order
@user = order.user
@url = "http://localhost:3000/orders/#{order.id}"
@order_url = "#{app_host}/orders/#{order.id}"
@current_status = order.status_label
if previous_status.present? && previous_status != order.status
@previous_status = order.status_label(previous_status)
Expand All @@ -51,19 +48,25 @@ def order_status_update_email(order, previous_status:)

def request_treatment_email(contact)
@contact = contact
@url = "http://localhost:3000/contacts/new"
mail(to: @contact.email, subject: "Demande en cours de traitement")
@contact_url = "#{app_host}/contacts/new"
@home_url = app_host
mail(to: @contact.email, subject: "Confirmation de réception de votre message")
end

def admin_contact_email(contact)
@admins = User.where(is_admin: true)
@contact = contact
@url = "http://localhost:3000/contacts/new"
@contact_url = "#{app_host}/contacts/new"

mail(
to: @admins.pluck(:email),
subject: "Nouvelle demande de contact !"
subject: "Nouvelle demande de contact"
)
end

private

def app_host
ENV["APP_HOST"].to_s.chomp("/")
end
end
16 changes: 12 additions & 4 deletions app/models/home_page.rb
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,12 @@ class HomePage < ApplicationRecord
has_one_attached :image

validates :button_url, length: { maximum: 1024 }, allow_blank: true
validates :shop_products_limit,
numericality: {
only_integer: true,
greater_than: 0,
message: "doit être un entier supérieur à 0"
}

def target_record
case bloc_type
Expand All @@ -47,18 +53,20 @@ def target_record
end
end

def shop_products(limit = 5)
def shop_products(limit = shop_products_limit)
safe_limit = [limit.to_i, 1].max

case shop_scope
when "last"
Product.order(created_at: :desc).limit(limit)
Product.order(created_at: :desc).limit(safe_limit)
when "top_sellers"
Product.left_joins(:order_products)
.select("products.*, COALESCE(SUM(order_products.quantity), 0) AS total_sold")
.group("products.id")
.order(Arel.sql("total_sold DESC"))
.limit(limit)
.limit(safe_limit)
else
Product.order(created_at: :asc).limit(limit)
Product.order(created_at: :asc).limit(safe_limit)
end
end

Expand Down
6 changes: 3 additions & 3 deletions app/views/devise/mailer/confirmation_instructions.html.erb
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<p>Welcome <%= @email %>!</p>
<p>Bonjour <%= @email %>,</p>

<p>You can confirm your account email through the link below:</p>
<p>Vous pouvez confirmer votre adresse e-mail via le lien ci-dessous :</p>

<p><%= link_to 'Confirm my account', confirmation_url(@resource, confirmation_token: @token) %></p>
<p><%= link_to "Confirmer mon compte", confirmation_url(@resource, confirmation_token: @token) %></p>
6 changes: 3 additions & 3 deletions app/views/devise/mailer/email_changed.html.erb
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<p>Hello <%= @email %>!</p>
<p>Bonjour <%= @email %>,</p>

<% if @resource.try(:unconfirmed_email?) %>
<p>We're contacting you to notify you that your email is being changed to <%= @resource.unconfirmed_email %>.</p>
<p>Nous vous informons que votre adresse e-mail est en cours de modification vers <%= @resource.unconfirmed_email %>.</p>
<% else %>
<p>We're contacting you to notify you that your email has been changed to <%= @resource.email %>.</p>
<p>Nous vous informons que votre adresse e-mail a bien été modifiée en <%= @resource.email %>.</p>
<% end %>
4 changes: 2 additions & 2 deletions app/views/devise/mailer/password_change.html.erb
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
<p>Hello <%= @resource.email %>!</p>
<p>Bonjour <%= @resource.email %>,</p>

<p>We're contacting you to notify you that your password has been changed.</p>
<p>Nous vous confirmons que votre mot de passe a bien été modifié.</p>
10 changes: 5 additions & 5 deletions app/views/devise/mailer/reset_password_instructions.html.erb
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
<p>Hello <%= @resource.email %>!</p>
<p>Bonjour <%= @resource.email %>,</p>

<p>Someone has requested a link to change your password. You can do this through the link below.</p>
<p>Une demande de réinitialisation de mot de passe a été effectuée pour votre compte.</p>

<p><%= link_to 'Change my password', edit_password_url(@resource, reset_password_token: @token) %></p>
<p><%= link_to "Changer mon mot de passe", edit_password_url(@resource, reset_password_token: @token) %></p>

<p>If you didn't request this, please ignore this email.</p>
<p>Your password won't change until you access the link above and create a new one.</p>
<p>Si vous n'êtes pas à l'origine de cette demande, vous pouvez ignorer cet e-mail.</p>
<p>Votre mot de passe ne changera pas tant que vous n'aurez pas ouvert le lien ci-dessus et défini un nouveau mot de passe.</p>
8 changes: 4 additions & 4 deletions app/views/devise/mailer/unlock_instructions.html.erb
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<p>Hello <%= @resource.email %>!</p>
<p>Bonjour <%= @resource.email %>,</p>

<p>Your account has been locked due to an excessive number of unsuccessful sign in attempts.</p>
<p>Votre compte a été verrouillé après un trop grand nombre de tentatives de connexion échouées.</p>

<p>Click the link below to unlock your account:</p>
<p>Vous pouvez le déverrouiller via le lien ci-dessous :</p>

<p><%= link_to 'Unlock my account', unlock_url(@resource, unlock_token: @token) %></p>
<p><%= link_to "Déverrouiller mon compte", unlock_url(@resource, unlock_token: @token) %></p>
11 changes: 8 additions & 3 deletions app/views/home_pages/_form.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -91,12 +91,17 @@
<div class="mb-3" data-home-block-form-target="shopSection">
<%= form.label :shop_scope, "Sélection boutique", class: "form-label" %>
<%= form.select :shop_scope,
[["5 premiers", "first"],
["5 derniers", "last"],
["5 plus achetés", "top_sellers"]],
[["Premiers produits", "first"],
["Derniers produits", "last"],
["Produits les plus achetés", "top_sellers"]],
{},
class: "form-select" %>
<div class="form-text">Utilisé si le type est “Bloc boutique”.</div>
<div class="mt-3">
<%= form.label :shop_products_limit, "Nombre d’articles à afficher", class: "form-label" %>
<%= form.number_field :shop_products_limit, class: "form-control", min: 1, step: 1 %>
<div class="form-text">Minimum 1. L’affichage s’adapte automatiquement.</div>
</div>
</div>

<div class="mb-3" data-home-block-form-target="contentSection">
Expand Down
Loading
Loading