Class: QTimetrap::Styles::Theme
- Inherits:
-
Object
- Object
- QTimetrap::Styles::Theme
- Defined in:
- app/styles/theme.rb
Overview
Loads and composes QSS theme assets for the application.
Constant Summary collapse
- FILES =
%w[application project_sidebar tracker_controls entries_list].freeze
- DEFAULT =
'light'- SUPPORTED =
%w[light dark].freeze
Instance Attribute Summary collapse
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#root ⇒ Object
readonly
Returns the value of attribute root.
Instance Method Summary collapse
- #application_stylesheet ⇒ Object
-
#initialize(name:, root:) ⇒ Theme
constructor
A new instance of Theme.
- #snippet(snippet_name) ⇒ Object
- #stylesheet(file_name) ⇒ Object
- #with_name(next_name) ⇒ Object
Constructor Details
Instance Attribute Details
#name ⇒ Object (readonly)
Returns the value of attribute name.
17 18 19 |
# File 'app/styles/theme.rb', line 17 def name @name end |
#root ⇒ Object (readonly)
Returns the value of attribute root.
17 18 19 |
# File 'app/styles/theme.rb', line 17 def root @root end |
Instance Method Details
#application_stylesheet ⇒ Object
19 20 21 |
# File 'app/styles/theme.rb', line 19 def application_stylesheet FILES.map { |file| stylesheet(file) }.join("\n") end |
#snippet(snippet_name) ⇒ Object
27 28 29 |
# File 'app/styles/theme.rb', line 27 def snippet(snippet_name) File.read(path_for_snippet(snippet_name)) end |
#stylesheet(file_name) ⇒ Object
31 32 33 34 35 |
# File 'app/styles/theme.rb', line 31 def stylesheet(file_name) cache.fetch(file_name) do cache[file_name] = File.read(path_for(file_name)) end end |
#with_name(next_name) ⇒ Object
23 24 25 |
# File 'app/styles/theme.rb', line 23 def with_name(next_name) self.class.new(name: next_name, root: root) end |