Module: Playbook::TextAlign
- Included in:
- KitBase
- Defined in:
- lib/playbook/text_align.rb
Constant Summary collapse
- TEXT_ALIGN_VALUES =
%w[start end left right center justify justify-all match-parent].freeze
- SCREEN_SIZES =
%w[xs sm md lg xl].freeze
Class Method Summary collapse
Instance Method Summary collapse
Class Method Details
.included(base) ⇒ Object
5 6 7 |
# File 'lib/playbook/text_align.rb', line 5 def self.included(base) base.prop :text_align end |
Instance Method Details
#text_align_options ⇒ Object
28 29 30 |
# File 'lib/playbook/text_align.rb', line 28 def { text_align: "text_align" } end |
#text_align_props ⇒ Object
12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 |
# File 'lib/playbook/text_align.rb', line 12 def text_align_props value = text_align return nil unless value if value.is_a?(::Hash) css = +"" css << "text_align_#{value[:default].underscore} " if value.key?(:default) && TEXT_ALIGN_VALUES.include?(value[:default]) value.each do |media_size, flex_value| css << "text_align_#{media_size}_#{flex_value.underscore} " if SCREEN_SIZES.include?(media_size.to_s) && TEXT_ALIGN_VALUES.include?(flex_value) end css.strip unless css.empty? elsif TEXT_ALIGN_VALUES.include?(value) "text_align_#{value.underscore}" end end |
#text_align_values ⇒ Object
32 33 34 |
# File 'lib/playbook/text_align.rb', line 32 def text_align_values TEXT_ALIGN_VALUES end |