Skip to content

Commit

Permalink
use Color#normalize_hexcode to "unpack" short color hexcode
Browse files Browse the repository at this point in the history
  • Loading branch information
as-op committed Sep 25, 2023
1 parent 3e7b11e commit f3645e0
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions app/models/work_package/pdf_export/cover.rb
Original file line number Diff line number Diff line change
Expand Up @@ -67,14 +67,15 @@ def cover_text_color
def validate_cover_text_color
return nil if CustomStyle.current.blank?

color = CustomStyle.current.export_cover_text_color
return nil if color.blank?
hexcode = CustomStyle.current.export_cover_text_color
return nil if hexcode.blank?

color = Color.new({ hexcode: })
color.normalize_hexcode
return nil if color.hexcode.blank?

# pdf hex colors are defined without leading hash
color = color.sub('#', '')
# prawn does not support short notation like #000
color = color + color if color.size == 3
color
color.hexcode.sub('#', '')
end

def write_hero_title(top, width)
Expand Down

0 comments on commit f3645e0

Please sign in to comment.