app/components/lookbook/code/component.rb in lookbook-1.3.1 vs app/components/lookbook/code/component.rb in lookbook-1.3.3

- old
+ new

@@ -7,11 +7,12 @@ language: :html, line_numbers: false, highlight_lines: [], start_line: 1, wrap: false, - theme: :github_light, + theme: nil, + dark: false, full_height: false, **html_attrs ) @source_code = source @highlight_opts = { @@ -21,10 +22,11 @@ start_line: start_line } @highlight_lines = highlight_lines @wrap = wrap @theme = theme + @dark = dark @full_height = full_height super(**html_attrs) end def theme_classname @@ -42,10 +44,19 @@ def focussed? @highlight_opts[:highlight_lines].any? end def full_height? - @full_height == true + @full_height + end + + def is_dark? + @dark + end + + def before_render + @theme ||= (config.highlighter_options && config.highlighter_options[:theme]&.to_sym) || :github + @dark ||= ActiveModel::Type::Boolean.new.cast((config.highlighter_options && config.highlighter_options[:dark]) || false) end protected def alpine_component