diff options
Diffstat (limited to 'app/helpers/blame_helper.rb')
-rw-r--r-- | app/helpers/blame_helper.rb | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/app/helpers/blame_helper.rb b/app/helpers/blame_helper.rb index 82c74e2416d..5117f7c6d9c 100644 --- a/app/helpers/blame_helper.rb +++ b/app/helpers/blame_helper.rb @@ -1,6 +1,13 @@ # frozen_string_literal: true module BlameHelper + BODY_FONT_SIZE = "0.875rem" + COMMIT_LINE_HEIGHT = 3 # 150% * 2 lines of text + COMMIT_PADDING = "10px" # 5px from both top and bottom + COMMIT_BLOCK_HEIGHT_EXP = "(#{BODY_FONT_SIZE} * #{COMMIT_LINE_HEIGHT}) + #{COMMIT_PADDING}" + CODE_LINE_HEIGHT = 1.1875 + CODE_PADDING = "20px" # 10px from both top and bottom + def age_map_duration(blame_groups, project) now = Time.zone.now start_date = blame_groups.map { |blame_group| blame_group[:commit].committed_date } @@ -24,4 +31,12 @@ module BlameHelper "blame-commit-age-#{age_group}" end end + + def intrinsic_row_css(line_count) + # using rems here because the size of the row depends on the text size + # which can be customized via user agent styles and browser preferences + total_line_height_exp = "#{line_count * CODE_LINE_HEIGHT}rem + #{CODE_PADDING}" + row_height_exp = line_count == 1 ? COMMIT_BLOCK_HEIGHT_EXP : total_line_height_exp + "contain-intrinsic-size: 1px calc(#{row_height_exp})" + end end |