mirror of
https://github.com/maybe-finance/maybe.git
synced 2025-07-27 17:19:39 +02:00
Remove styling configuration for account types out (#284)
* Remve styling configuration for account types out * No need to tailwind config for models
This commit is contained in:
parent
9b400c9c50
commit
a2b96db75d
12 changed files with 13 additions and 102 deletions
|
@ -3,12 +3,5 @@ class Account < ApplicationRecord
|
||||||
|
|
||||||
delegated_type :accountable, types: %w[ Account::Credit Account::Depository Account::Investment Account::Loan Account::OtherAsset Account::OtherLiability Account::Property Account::Vehicle], dependent: :destroy
|
delegated_type :accountable, types: %w[ Account::Credit Account::Depository Account::Investment Account::Loan Account::OtherAsset Account::OtherLiability Account::Property Account::Vehicle], dependent: :destroy
|
||||||
|
|
||||||
delegate :icon, :type_name, :color, to: :accountable
|
delegate :type_name, to: :accountable
|
||||||
|
|
||||||
# Class method to get a representative instance of each accountable type
|
|
||||||
def self.accountable_type_instances
|
|
||||||
accountable_types.map do |type|
|
|
||||||
type.constantize.new
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
|
@ -1,18 +1,7 @@
|
||||||
class Account::Credit < ApplicationRecord
|
class Account::Credit < ApplicationRecord
|
||||||
include Accountable
|
include Accountable
|
||||||
|
|
||||||
def icon
|
|
||||||
"icon-credit-card.svg"
|
|
||||||
end
|
|
||||||
|
|
||||||
def type_name
|
def type_name
|
||||||
"Credit Card"
|
"Credit Card"
|
||||||
end
|
end
|
||||||
|
|
||||||
def color
|
|
||||||
{
|
|
||||||
background: "bg-[#E6F6FA]",
|
|
||||||
text: "text-[#189FC7]"
|
|
||||||
}
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
|
@ -1,18 +1,7 @@
|
||||||
class Account::Depository < ApplicationRecord
|
class Account::Depository < ApplicationRecord
|
||||||
include Accountable
|
include Accountable
|
||||||
|
|
||||||
def icon
|
|
||||||
"icon-bank-accounts.svg"
|
|
||||||
end
|
|
||||||
|
|
||||||
def type_name
|
def type_name
|
||||||
"Bank Accounts"
|
"Bank Accounts"
|
||||||
end
|
end
|
||||||
|
|
||||||
def color
|
|
||||||
{
|
|
||||||
background: "bg-[#EAF4FF]",
|
|
||||||
text: "text-[#3492FB]"
|
|
||||||
}
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
|
@ -1,18 +1,7 @@
|
||||||
class Account::Investment < ApplicationRecord
|
class Account::Investment < ApplicationRecord
|
||||||
include Accountable
|
include Accountable
|
||||||
|
|
||||||
def icon
|
|
||||||
"icon-bank-accounts.svg"
|
|
||||||
end
|
|
||||||
|
|
||||||
def type_name
|
def type_name
|
||||||
"Investments"
|
"Investments"
|
||||||
end
|
end
|
||||||
|
|
||||||
def color
|
|
||||||
{
|
|
||||||
background: "bg-[#EDF7F4]",
|
|
||||||
text: "text-[#1BD5A1]"
|
|
||||||
}
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
|
@ -1,18 +1,7 @@
|
||||||
class Account::Loan < ApplicationRecord
|
class Account::Loan < ApplicationRecord
|
||||||
include Accountable
|
include Accountable
|
||||||
|
|
||||||
def icon
|
|
||||||
"icon-bank-accounts.svg"
|
|
||||||
end
|
|
||||||
|
|
||||||
def type_name
|
def type_name
|
||||||
"Loan"
|
"Loan"
|
||||||
end
|
end
|
||||||
|
|
||||||
def color
|
|
||||||
{
|
|
||||||
background: "bg-[#EDF7F4]",
|
|
||||||
text: "text-[#1BD5A1]"
|
|
||||||
}
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
|
@ -1,18 +1,7 @@
|
||||||
class Account::OtherAsset < ApplicationRecord
|
class Account::OtherAsset < ApplicationRecord
|
||||||
include Accountable
|
include Accountable
|
||||||
|
|
||||||
def icon
|
|
||||||
"icon-bank-accounts.svg"
|
|
||||||
end
|
|
||||||
|
|
||||||
def type_name
|
def type_name
|
||||||
"Other Asset"
|
"Other Asset"
|
||||||
end
|
end
|
||||||
|
|
||||||
def color
|
|
||||||
{
|
|
||||||
background: "bg-[#EDF7F4]",
|
|
||||||
text: "text-[#1BD5A1]"
|
|
||||||
}
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
|
@ -1,18 +1,7 @@
|
||||||
class Account::OtherLiability < ApplicationRecord
|
class Account::OtherLiability < ApplicationRecord
|
||||||
include Accountable
|
include Accountable
|
||||||
|
|
||||||
def icon
|
|
||||||
"icon-bank-accounts.svg"
|
|
||||||
end
|
|
||||||
|
|
||||||
def type_name
|
def type_name
|
||||||
"Other Liability"
|
"Other Liability"
|
||||||
end
|
end
|
||||||
|
|
||||||
def color
|
|
||||||
{
|
|
||||||
background: "bg-[#EDF7F4]",
|
|
||||||
text: "text-[#1BD5A1]"
|
|
||||||
}
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
|
@ -1,18 +1,7 @@
|
||||||
class Account::Property < ApplicationRecord
|
class Account::Property < ApplicationRecord
|
||||||
include Accountable
|
include Accountable
|
||||||
|
|
||||||
def icon
|
|
||||||
"icon-real-estate.svg"
|
|
||||||
end
|
|
||||||
|
|
||||||
def type_name
|
def type_name
|
||||||
"Real Estate"
|
"Real Estate"
|
||||||
end
|
end
|
||||||
|
|
||||||
def color
|
|
||||||
{
|
|
||||||
background: "bg-[#FEF0F7]",
|
|
||||||
text: "text-[#F03695]"
|
|
||||||
}
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
|
@ -1,18 +1,7 @@
|
||||||
class Account::Vehicle < ApplicationRecord
|
class Account::Vehicle < ApplicationRecord
|
||||||
include Accountable
|
include Accountable
|
||||||
|
|
||||||
def icon
|
|
||||||
"icon-bank-accounts.svg"
|
|
||||||
end
|
|
||||||
|
|
||||||
def type_name
|
def type_name
|
||||||
"Vehicle"
|
"Vehicle"
|
||||||
end
|
end
|
||||||
|
|
||||||
def color
|
|
||||||
{
|
|
||||||
background: "bg-[#EDF7F4]",
|
|
||||||
text: "text-[#1BD5A1]"
|
|
||||||
}
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
|
@ -1,9 +1,9 @@
|
||||||
<div class="relative flex-col items-center px-5 py-4 space-x-3 text-center bg-white border border-gray-100 shadow-sm rounded-xl hover:border-gray-200">
|
<div class="relative flex-col items-center px-5 py-4 space-x-3 text-center bg-white border border-gray-100 shadow-sm rounded-xl hover:border-gray-200">
|
||||||
<%= link_to new_account_path(type: account_type.class.name.demodulize), class: "flex flex-col items-center justify-center w-full text-center focus:outline-none" do %>
|
<%= link_to new_account_path(type: type.class.name.demodulize), class: "flex flex-col items-center justify-center w-full text-center focus:outline-none" do %>
|
||||||
<span class="absolute inset-0" aria-hidden="true"></span>
|
<span class="absolute inset-0" aria-hidden="true"></span>
|
||||||
<span class="flex w-10 h-10 shrink-0 grow-0 items-center justify-center rounded-xl <%= account_type.color[:background] %> mb-2">
|
<span class="flex w-10 h-10 shrink-0 grow-0 items-center justify-center rounded-xl <%= bg_color %> mb-2">
|
||||||
<%= inline_svg_tag(account_type.icon, class: "#{account_type.color[:text]} stroke-current") %>
|
<%= inline_svg_tag(icon, class: "#{text_color} stroke-current") %>
|
||||||
</span>
|
</span>
|
||||||
<%= account_type.type_name %>
|
<%= type.type_name %>
|
||||||
<% end %>
|
<% end %>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -2,7 +2,14 @@
|
||||||
|
|
||||||
<% if params[:type].blank? || Account.accountable_types.include?("Account::#{params[:type]}") == false %>
|
<% if params[:type].blank? || Account.accountable_types.include?("Account::#{params[:type]}") == false %>
|
||||||
<div class="grid grid-cols-2 gap-4 mt-8 text-sm sm:grid-cols-3 md:grid-cols-4">
|
<div class="grid grid-cols-2 gap-4 mt-8 text-sm sm:grid-cols-3 md:grid-cols-4">
|
||||||
<%= render partial: "account_type", collection: Account.accountable_type_instances %>
|
<%= render "account_type", type: Account::Credit.new, bg_color: "bg-[#E6F6FA]", text_color: "text-[#189FC7]", icon: "icon-credit-card.svg" %>
|
||||||
|
<%= render "account_type", type: Account::Depository.new, bg_color: "bg-[#EAF4FF]", text_color: "text-[#3492FB]", icon: "icon-bank-accounts.svg" %>
|
||||||
|
<%= render "account_type", type: Account::Investment.new, bg_color: "bg-[#EDF7F4]", text_color: "text-[#1BD5A1]", icon: "icon-bank-accounts.svg" %>
|
||||||
|
<%= render "account_type", type: Account::Loan.new, bg_color: "bg-[#EDF7F4]", text_color: "text-[#1BD5A1]", icon: "icon-bank-accounts.svg" %>
|
||||||
|
<%= render "account_type", type: Account::OtherAsset.new, bg_color: "bg-[#EDF7F4]", text_color: "text-[#1BD5A1]", icon: "icon-bank-accounts.svg" %>
|
||||||
|
<%= render "account_type", type: Account::OtherLiability.new, bg_color: "bg-[#EDF7F4]", text_color: "text-[#1BD5A1]", icon: "icon-bank-accounts.svg" %>
|
||||||
|
<%= render "account_type", type: Account::Property.new, bg_color: "bg-[#FEF0F7]", text_color: "text-[#F03695]", icon: "icon-real-estate.svg" %>
|
||||||
|
<%= render "account_type", type: Account::Vehicle.new, bg_color: "bg-[#EDF7F4]", text_color: "text-[#1BD5A1]", icon: "icon-bank-accounts.svg" %>
|
||||||
</div>
|
</div>
|
||||||
<% else %>
|
<% else %>
|
||||||
<div class="relative flex items-center mb-5 space-x-2">
|
<div class="relative flex items-center mb-5 space-x-2">
|
||||||
|
|
|
@ -4,7 +4,6 @@ module.exports = {
|
||||||
content: [
|
content: [
|
||||||
'./public/*.html',
|
'./public/*.html',
|
||||||
'./app/helpers/**/*.rb',
|
'./app/helpers/**/*.rb',
|
||||||
'./app/models/**/*.rb',
|
|
||||||
'./app/javascript/**/*.js',
|
'./app/javascript/**/*.js',
|
||||||
'./app/views/**/*.{erb,haml,html,slim}'
|
'./app/views/**/*.{erb,haml,html,slim}'
|
||||||
],
|
],
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue