mirror of
https://github.com/maybe-finance/maybe.git
synced 2025-07-19 13:19:39 +02:00
Add sidebar link helper (#435)
* Add helper for sidebar nav links * Allow options to be passed down to sidebar link
This commit is contained in:
parent
aef15c9371
commit
e37ed2c988
2 changed files with 21 additions and 12 deletions
|
@ -18,6 +18,24 @@ module ApplicationHelper
|
||||||
render partial: "shared/modal", locals: { content: content }
|
render partial: "shared/modal", locals: { content: content }
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def sidebar_link_to(name, path, options = {})
|
||||||
|
base_class_names = "block border border-transparent rounded-xl -ml-2 p-2 text-sm font-medium text-gray-500 flex items-center"
|
||||||
|
hover_class_names = "hover:bg-white hover:border-[#141414]/[0.07] hover:text-gray-900 hover:shadow-xs"
|
||||||
|
current_page_class_names = "bg-white border-[#141414]/[0.07] text-gray-900 shadow-xs"
|
||||||
|
|
||||||
|
link_class_names = class_names(
|
||||||
|
base_class_names,
|
||||||
|
hover_class_names,
|
||||||
|
current_page_class_names => current_page?(path)
|
||||||
|
)
|
||||||
|
|
||||||
|
merged_options = options.reverse_merge(class: link_class_names).except(:icon)
|
||||||
|
|
||||||
|
link_to path, merged_options do
|
||||||
|
lucide_icon(options[:icon], class: "w-5 h-5 mr-2") + name
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
def format_currency(number, options = {})
|
def format_currency(number, options = {})
|
||||||
user_currency_preference = Current.family.try(:currency) || "USD"
|
user_currency_preference = Current.family.try(:currency) || "USD"
|
||||||
|
|
||||||
|
|
|
@ -47,22 +47,13 @@
|
||||||
<nav>
|
<nav>
|
||||||
<ul class="mt-6 space-y">
|
<ul class="mt-6 space-y">
|
||||||
<li>
|
<li>
|
||||||
<%= link_to root_path, class: 'block hover:bg-white border border-transparent hover:border-[#141414]/[0.07] rounded-xl hover:text-gray-900 hover:shadow-xs -ml-2 p-2 text-sm font-medium text-gray-500 flex items-center' do %>
|
<%= sidebar_link_to t('.dashboard'), root_path, icon: 'layout-grid' %>
|
||||||
<%= lucide_icon('layout-grid', class: 'w-5 h-5 mr-2') %>
|
|
||||||
<%= t('.dashboard') %>
|
|
||||||
<% end %>
|
|
||||||
</li>
|
</li>
|
||||||
<li>
|
<li>
|
||||||
<%= link_to accounts_path, class: 'block hover:bg-white border border-transparent hover:border-[#141414]/[0.07] rounded-xl hover:text-gray-900 hover:shadow-xs -ml-2 p-2 text-sm font-medium text-gray-500 flex items-center' do %>
|
<%= sidebar_link_to t('.accounts'), accounts_path, icon: 'layers' %>
|
||||||
<%= lucide_icon('layers', class: 'w-5 h-5 mr-2') %>
|
|
||||||
<%= t('.accounts') %>
|
|
||||||
<% end %>
|
|
||||||
</li>
|
</li>
|
||||||
<li>
|
<li>
|
||||||
<%= link_to "#", class: 'block hover:bg-white border border-transparent hover:border-[#141414]/[0.07] rounded-xl hover:text-gray-900 hover:shadow-xs -ml-2 p-2 text-sm font-medium text-gray-500 flex items-center' do %>
|
<%= sidebar_link_to t('.transactions'), "#", icon: 'credit-card' %>
|
||||||
<%= lucide_icon('credit-card', class: 'w-5 h-5 mr-2') %>
|
|
||||||
<%= t('.transactions') %>
|
|
||||||
<% end %>
|
|
||||||
</li>
|
</li>
|
||||||
</ul>
|
</ul>
|
||||||
</nav>
|
</nav>
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue