Initial commit - Fase 1: Setup Rails + Docker
This commit is contained in:
46
app/helpers/application_helper.rb
Normal file
46
app/helpers/application_helper.rb
Normal file
@@ -0,0 +1,46 @@
|
||||
# app/helpers/application_helper.rb
|
||||
module ApplicationHelper
|
||||
# Link de navegação com estado ativo
|
||||
def nav_link_to(label, path, **opts)
|
||||
active = current_page?(path)
|
||||
css = [
|
||||
"flex items-center gap-3 px-3 py-2.5 rounded-lg text-sm font-medium transition-all min-h-[44px]",
|
||||
active ? "bg-orange-500 text-black" : "text-gray-400 hover:bg-[#1a1a1a] hover:text-white"
|
||||
].join(" ")
|
||||
link_to label, path, class: css
|
||||
end
|
||||
|
||||
# Formata moeda BR
|
||||
def moeda(valor)
|
||||
"R$ #{"%.2f" % valor.to_f}".gsub('.', ',')
|
||||
end
|
||||
|
||||
# Badge de status de consolidação
|
||||
def badge_status(status)
|
||||
cfg = case status.to_s
|
||||
when 'rascunho' then { cor: 'bg-yellow-500 text-black', icone: '📝', label: 'Rascunho' }
|
||||
when 'finalizada' then { cor: 'bg-green-600 text-white', icone: '✅', label: 'Finalizada' }
|
||||
when 'arquivada' then { cor: 'bg-gray-700 text-gray-300', icone: '📁', label: 'Arquivada' }
|
||||
else { cor: 'bg-gray-800 text-gray-400', icone: '❓', label: status.humanize }
|
||||
end
|
||||
|
||||
tag.span class: "inline-flex items-center gap-1 px-2.5 py-1 rounded-full text-xs font-bold #{cfg[:cor]}" do
|
||||
"#{cfg[:icone]} #{cfg[:label]}"
|
||||
end
|
||||
end
|
||||
|
||||
# Barra de progresso laranja
|
||||
def progress_bar(percentual, label: nil)
|
||||
pct = percentual.to_i.clamp(0, 100)
|
||||
tag.div class: "w-full" do
|
||||
concat tag.div(class: "flex justify-between text-xs text-gray-400 mb-1") {
|
||||
concat tag.span(label || "#{pct}% classificado")
|
||||
concat tag.span("#{pct}%")
|
||||
}
|
||||
concat tag.div(class: "w-full bg-[#2a2a2a] rounded-full h-2") {
|
||||
tag.div style: "width: #{pct}%",
|
||||
class: "h-2 rounded-full bg-orange-500 transition-all duration-500"
|
||||
}
|
||||
end
|
||||
end
|
||||
end
|
||||
Reference in New Issue
Block a user