Module: ThousandIsland::StyleSheet

Included in:
Template
Defined in:
lib/thousand_island/style_sheet.rb

Overview

The StyleSheet is designed to be a mixin to the Template class. It may also be included into other modules to define custom StyleSheets.

Methods should return a StyleHash object rather than a vanilla Hash, as it has some customisation to help it work with Prawn. The default_style is used as the starting point for all other styles. For instance, the default_style[:size] value is multiplied in the heading styles, so changing the default style size value will have a cascading effect. Check the source for the default values and override as preferred.

An example of a custom StyleSheet:

module MyStyleSheet
  include ThousandIsland::StyleSheet

  def default_style
    super.merge({
      size: 12,
      color: '222222'
    })
  end

  def h1_style
    super.merge({ align: :center })
  end

end

Instance Method Summary collapse

Instance Method Details

#body_styleObject



43
44
45
# File 'lib/thousand_island/style_sheet.rb', line 43

def body_style
  default_style
end

#default_styleObject



32
33
34
35
36
37
38
39
40
41
# File 'lib/thousand_island/style_sheet.rb', line 32

def default_style
  StyleHash.new({
      size: 10,
      style: :normal,
      align: :left,
      leading: 1,
      inline_format: true,
      color: '000000',
  })
end


94
95
96
97
98
99
100
# File 'lib/thousand_island/style_sheet.rb', line 94

def footer_style
  default_style.merge({
     size: default_style[:size] * 0.8,
     color: '666666',
     align: :center,
  })
end

#h1_styleObject



47
48
49
50
51
52
53
# File 'lib/thousand_island/style_sheet.rb', line 47

def h1_style
  default_style.merge({
      size: default_style[:size] * 1.8,
      style: :bold,
      leading: 8,
  })
end

#h2_styleObject



55
56
57
58
59
60
61
# File 'lib/thousand_island/style_sheet.rb', line 55

def h2_style
  default_style.merge({
      size: default_style[:size] * 1.5,
      style: :bold,
      leading: 4,
  })
end

#h3_styleObject



63
64
65
66
67
68
69
# File 'lib/thousand_island/style_sheet.rb', line 63

def h3_style
  default_style.merge({
      size: default_style[:size] * 1.4,
      style: :bold,
      leading: 4,
  })
end

#h4_styleObject



71
72
73
74
75
76
77
# File 'lib/thousand_island/style_sheet.rb', line 71

def h4_style
  default_style.merge({
      size: default_style[:size] * 1.1,
      style: :bold_italic,
      leading: 4,
  })
end

#h5_styleObject



79
80
81
82
83
84
# File 'lib/thousand_island/style_sheet.rb', line 79

def h5_style
  default_style.merge({
      size: default_style[:size] * 1,
      leading: 4,
  })
end

#h6_styleObject



86
87
88
89
90
91
92
# File 'lib/thousand_island/style_sheet.rb', line 86

def h6_style
  default_style.merge({
      size: default_style[:size] * 0.85,
      style: :italic,
      leading: 4,
  })
end