add text_color helper methods

This commit is contained in:
Andrew Brown 2021-07-18 18:02:52 -07:00
parent cf999fbbe8
commit f56c8bc46b
39 changed files with 162 additions and 1 deletions

View File

@ -14,6 +14,10 @@ class ApplicationIntegration < ApplicationRecord
'orange'
end
def self.text_color
'orange-text'
end
def generate_new_access_token!
self.update(application_token: SecureRandom.hex(24))
end

View File

@ -32,10 +32,18 @@ class Document < ApplicationRecord
'teal'
end
def self.text_color
'teal-text'
end
def color
Document.color
end
def text_color
Document.text_color
end
def self.hex_color
'#009688'
end

View File

@ -10,6 +10,10 @@ class Folder < ApplicationRecord
'lighten-1 teal'
end
def self.text_color
'text-lighten-1 teal-text'
end
def self.icon
'folder'
end

View File

@ -74,6 +74,10 @@ class PageCollection < ApplicationRecord
'brown'
end
def self.text_color
'brown-text'
end
def self.hex_color
'#795548'
end

View File

@ -24,6 +24,10 @@ class AttributeCategory < ApplicationRecord
'amber'
end
def self.text_color
'amber-text'
end
def icon
icon_override || self.class.icon
end
@ -62,6 +66,7 @@ class AttributeCategory < ApplicationRecord
def backfill_fields_ordering!
sorted_fields = attribute_fields.select(&:persisted?).sort do |a, b|
# TODO: we shouldn't need this code anymore
a_value = case a.field_type
when 'name' then 0
when 'universe' then 1

View File

@ -31,6 +31,10 @@ class AttributeField < ApplicationRecord
'amber'
end
def self.text_color
'amber-text'
end
def self.icon
'text_fields'
end

View File

@ -26,6 +26,10 @@ class Building < ActiveRecord::Base
'blue-grey'
end
def self.text_color
'blue-grey-text'
end
def self.hex_color
'#607D8B'
end

View File

@ -52,6 +52,10 @@ class Character < ApplicationRecord
'red'
end
def self.text_color
'red-text'
end
def self.hex_color
'#F44336'
end

View File

@ -17,6 +17,10 @@ class Condition < ActiveRecord::Base
'text-darken-1 lime'
end
def self.text_color
'text-darken-1 lime-text'
end
def self.hex_color
'#CDDC39'
end

View File

@ -13,4 +13,8 @@ class ContentPage < ApplicationRecord
def color
self.page_type.constantize.color
end
def text_color
self.page_type.constantize.text_color
end
end

View File

@ -33,6 +33,10 @@ class Continent < ActiveRecord::Base
'lighten-1 text-lighten-1 green'
end
def self.text_color
'text-lighten-1 green-text'
end
def self.hex_color
'#66BB6A'
end

View File

@ -37,6 +37,10 @@ class Country < ApplicationRecord
'lighten-2 text-lighten-2 brown'
end
def self.text_color
'text-lighten-2 brown-text'
end
def self.hex_color
'#A1887F'
end

View File

@ -36,6 +36,10 @@ class Creature < ApplicationRecord
'brown'
end
def self.text_color
'brown-text'
end
def self.hex_color
'#795548'
end

View File

@ -37,6 +37,10 @@ class Deity < ApplicationRecord
'text-lighten-4 blue'
end
def self.text_color
'text-lighten-4 blue-text'
end
def self.hex_color
'#BBDEFB'
end

View File

@ -32,6 +32,10 @@ class Flora < ApplicationRecord
'text-lighten-2 lighten-2 teal'
end
def self.text_color
'text-lighten-2 teal-text'
end
def self.hex_color
'#4DB6AC'
end

View File

@ -17,6 +17,10 @@ class Food < ActiveRecord::Base
'red'
end
def self.text_color
'red-text'
end
def self.hex_color
'#F44336'
end

View File

@ -27,6 +27,10 @@ class Government < ApplicationRecord
'darken-2 green'
end
def self.text_color
'green-text'
end
def self.hex_color
'#388E3C'
end

View File

@ -40,6 +40,10 @@ class Group < ApplicationRecord
'cyan'
end
def self.text_color
'cyan-text'
end
def self.hex_color
'#00BCD4'
end

View File

@ -34,6 +34,10 @@ class Item < ApplicationRecord
'text-darken-2 amber'
end
def self.text_color
'text-darken-2 amber-text'
end
def self.hex_color
'#FFA000'
end

View File

@ -17,6 +17,10 @@ class Job < ActiveRecord::Base
'text-lighten-1 brown'
end
def self.text_color
'text-lighten-1 brown-text'
end
def self.hex_color
'#795548'
end

View File

@ -31,6 +31,10 @@ class Landmark < ApplicationRecord
'text-lighten-1 lighten-1 orange'
end
def self.text_color
'text-lighten-1 orange-text'
end
def self.hex_color
'#FFA726'
end

View File

@ -24,6 +24,10 @@ class Language < ApplicationRecord
'blue'
end
def self.text_color
'blue-text'
end
def self.hex_color
'#2196F3'
end

View File

@ -46,6 +46,10 @@ class Location < ApplicationRecord
'green'
end
def self.text_color
'green-text'
end
def self.hex_color
'#4CAF50'
end

View File

@ -47,6 +47,10 @@ class Lore < ActiveRecord::Base
'text-lighten-2 lighten-1 orange'
end
def self.text_color
'text-lighten-2 orange-text'
end
def self.hex_color
'#FFB74D'
end

View File

@ -25,6 +25,10 @@ class Magic < ApplicationRecord
'orange'
end
def self.text_color
'orange-text'
end
def self.hex_color
'#FF9800'
end

View File

@ -34,6 +34,10 @@ class Planet < ApplicationRecord
'text-lighten-2 blue'
end
def self.text_color
'text-lighten-2 blue-text'
end
def self.hex_color
'#64B5F6'
end

View File

@ -31,6 +31,10 @@ class Race < ApplicationRecord
'darken-2 light-green'
end
def self.text_color
'text-darken-2 light-green-text'
end
def self.hex_color
'#689F38'
end

View File

@ -38,6 +38,10 @@ class Religion < ApplicationRecord
'indigo'
end
def self.text_color
'indigo-text'
end
def self.hex_color
'#3f51b5'
end

View File

@ -30,6 +30,10 @@ class Scene < ApplicationRecord
'grey'
end
def self.text_color
'grey-text'
end
def self.hex_color
'#9E9E9E'
end

View File

@ -17,6 +17,10 @@ class School < ActiveRecord::Base
'cyan'
end
def self.text_color
'cyan-text'
end
def self.hex_color
'#00BCD4'
end

View File

@ -18,6 +18,10 @@ class Sport < ActiveRecord::Base
'orange'
end
def self.text_color
'orange-text'
end
def self.hex_color
'#FF9800'
end

View File

@ -31,6 +31,10 @@ class Technology < ApplicationRecord
'text-darken-2 red'
end
def self.text_color
'text-darken-2 red-text'
end
def self.hex_color
'#D32F2F'
end

View File

@ -34,6 +34,10 @@ class Town < ApplicationRecord
'text-lighten-3 lighten-3 purple'
end
def self.text_color
'text-lighten-3 purple-text'
end
def self.hex_color
'#CE93D8'
end

View File

@ -17,6 +17,10 @@ class Tradition < ActiveRecord::Base
'text-lighten-3 lighten-3 red'
end
def self.text_color
'text-lighten-3 red-text'
end
def self.hex_color
'#EF9A9A'
end

View File

@ -78,6 +78,10 @@ class Universe < ApplicationRecord
'purple'
end
def self.text_color
'purple-text'
end
def self.hex_color
'#9C27B0'
end

View File

@ -14,7 +14,11 @@ class Vehicle < ActiveRecord::Base
self.authorizer_name = 'ExtendedContentAuthorizer'
def self.color
'text-lighten-2 green'
'text-lighten-2 lighten-2 green'
end
def self.text_color
'text-lighten-2 green-text'
end
def self.hex_color

View File

@ -28,6 +28,10 @@ class ContentPageShare < ApplicationRecord
'text-lighten-3 purple'
end
def self.text_color
'text-lighten-3 purple-text'
end
def self.hex_color
'#CE93D8'
end

View File

@ -25,6 +25,10 @@ class Timeline < ApplicationRecord
'green'
end
def self.text_color
'green-text'
end
# Needed because we sometimes munge Timelines in with ContentPages :(
def color
Timeline.color

View File

@ -333,6 +333,10 @@ class User < ApplicationRecord
'green'
end
def self.text_color
'green-text'
end
def favorite_page_type_color
return User.color unless favorite_page_type? && Rails.application.config.content_types[:all].map(&:name).include?(favorite_page_type)