mirror of
https://github.com/ralsina/tartrazine.git
synced 2025-07-04 07:19:22 +00:00
Tweaks
This commit is contained in:
@ -1,6 +1,11 @@
|
||||
require "xml"
|
||||
|
||||
module Tartrazine
|
||||
def self.theme(name : String) : Theme
|
||||
path = File.join("styles", "#{name}.xml")
|
||||
Theme.from_xml(File.read(path))
|
||||
end
|
||||
|
||||
class Style
|
||||
# These properties are tri-state.
|
||||
# true means it's set
|
||||
@ -52,11 +57,7 @@ module Tartrazine
|
||||
return s if s.complete?
|
||||
|
||||
# Form the hierarchy of parent styles
|
||||
parents = ["Background"]
|
||||
parts = token.underscore.split("_").map(&.capitalize)
|
||||
parts.each_with_index do |_, i|
|
||||
parents << parts[..i].join("")
|
||||
end
|
||||
parents = style_parents(token)
|
||||
|
||||
s = parents.map do |parent|
|
||||
styles[parent]
|
||||
@ -68,6 +69,15 @@ module Tartrazine
|
||||
s
|
||||
end
|
||||
|
||||
def style_parents(token)
|
||||
parents = ["Background"]
|
||||
parts = token.underscore.split("_").map(&.capitalize)
|
||||
parts.each_with_index do |_, i|
|
||||
parents << parts[..i].join("")
|
||||
end
|
||||
parents
|
||||
end
|
||||
|
||||
# Load from a Chroma XML file
|
||||
def self.from_xml(xml : String) : Theme
|
||||
document = XML.parse(xml)
|
||||
@ -100,4 +110,4 @@ module Tartrazine
|
||||
theme
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
Reference in New Issue
Block a user