The personal finance app for everyone
Currency select tweaks
Josh Pigfordfbe49bf4eae2
diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rbindex b13b5cb1..98c86602 100644--- a/app/helpers/application_helper.rb+++ b/app/helpers/application_helper.rb@@ -21,7 +21,7 @@ module ApplicationHelperdef currency_dropdown(f: nil, options: [])render partial: "shared/currency_dropdown", locals: { f: f, options: options }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" ]diff --git a/app/views/accounts/new.html.erb b/app/views/accounts/new.html.erbindex 1c673495..b8a2d4c1 100644--- a/app/views/accounts/new.html.erb+++ b/app/views/accounts/new.html.erb@@ -79,13 +79,10 @@<%= form_field_tag do %><%= f.label :original_balance, class: "form-field__label" %><%= f.number_field :original_balance, step: :any, placeholder: number_to_currency(0), in: 0.00..100000000.00, required: 'required', class: 'form-field__input max-w-[80%]' %>- <%= currency_dropdown(f: f, options: ['USD', 'EUR', 'JPY', 'GBP', 'AUD', 'CAD', 'CNY', 'BTC', 'ETH']) %>+ <%= currency_dropdown(f: f, options: Currency.all.order(:iso_code).pluck(:iso_code)) if Currency.count > 1 %><% end %></div>-- <%#= f.collection_select :original_currency, Currency.all, :iso_code, :iso_code, { prompt: "Choose a currency", selected: Current.family.currency }, { required: 'required', label: "Base Currency" } %>-<%= f.submit "Add #{@account.accountable.model_name.human.downcase}" %><% end %><% end %>diff --git a/app/views/shared/_currency_dropdown.html.erb b/app/views/shared/_currency_dropdown.html.erbindex 96ddfdc1..9d352f81 100644--- a/app/views/shared/_currency_dropdown.html.erb+++ b/app/views/shared/_currency_dropdown.html.erb@@ -1,14 +1,14 @@<div data-controller="currency-dropdown" class="absolute right-1 bottom-[10px] flex items-end">- <button type="button" class="flex justify-between items-center hover:bg-gray-100 focus:bg-gray-100 w-20 text-sm rounded-lg py-1 px-2" data-action="click->currency-dropdown#toggleMenu">- <div data-currency-dropdown-target="label"><%= f.object.currency %></div>+ <button type="button" class="flex items-center justify-between w-20 px-2 py-1 text-sm rounded-lg hover:bg-gray-100 focus:bg-gray-100" data-action="click->currency-dropdown#toggleMenu">+ <div data-currency-dropdown-target="label"><%= f.object.original_currency %></div><%# Example of how account currency value is updated %><%#= f.hidden_field :currency, data: {currency_dropdown_target: "input"} %><%= lucide_icon("chevron-down", class: "text-[#737373] w-5 h-5" ) %></button>- <ul data-currency-dropdown-target="menu" class="hidden fixed p-1 z-10 bg-white rounded-[10px] shadow min-w-[112px] z-50 translate-y-2 border border-[#141414]/8 shadow-[inset_0_-1px_0_0_rgba(0,0,0,0.1)]">+ <ul data-currency-dropdown-target="menu" class="hidden fixed p-1 bg-white rounded-[10px] min-w-[112px] z-50 translate-y-2 border border-[#141414]/8 shadow-[inset_0_-1px_0_0_rgba(0,0,0,0.1)]"><% options.each do |option| %>- <li data-action="click->currency-dropdown#selectOption" data-currency-dropdown-target="option" data-value="<%= option %>" class="flex justify-between items-center p-2 text-sm text-gray-700 hover:bg-gray-100 cursor-pointer rounded-lg <%= "bg-gray-100" if option === f.object.currency %>"><%= option %>- <%= inline_svg_tag('icn-check.svg', class: "text-gray-500 fill-current #{'hidden'if option != f.object.currency}") %>+ <li data-action="click->currency-dropdown#selectOption" data-currency-dropdown-target="option" data-value="<%= option %>" class="flex justify-between items-center p-2 text-sm text-gray-700 hover:bg-gray-100 cursor-pointer rounded-lg <%= "bg-gray-100" if option === f.object.original_currency %>"><%= option %>+ <%= inline_svg_tag('icn-check.svg', class: "text-gray-500 fill-current #{'hidden'if option != f.object.original_currency}") %></li><% end %></ul>