Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update to 1.4.2 #107

Merged
merged 6 commits into from
Dec 7, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion lib/inky.rb
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,8 @@ def initialize(options = {})
callout: 'callout',
spacer: 'spacer',
wrapper: 'wrapper',
menu_item: 'item'
menu_item: 'item',
h_line: 'h-line',
}.merge(::Inky.configuration.components).merge(options[:components] || {})

self.component_lookup = components.invert
Expand All @@ -41,6 +42,7 @@ def release_the_kraken(html_string)
transform_doc(html)
string = html.to_html
string.gsub!(INTERIM_TH_TAG_REGEX, 'th')
string.gsub!(' ', ' ') # Convert non-breaking spaces to explicit   entity
Inky::Core.re_inject_raws(string, raws)
end

Expand Down
23 changes: 15 additions & 8 deletions lib/inky/component_factory.rb
Original file line number Diff line number Diff line change
Expand Up @@ -45,21 +45,22 @@ def _target_attribute(elem)

def _transform_button(component, inner)
expand = _has_class(component, 'expand')
attributes = _pass_through_attributes(component)
if component.attr('href')
target = _target_attribute(component)
extra = ' align="center" class="float-center"' if expand
inner = %{<a href="#{component.attr('href')}"#{target}#{extra}>#{inner}</a>}
inner = %{<a #{attributes}href="#{component.attr('href')}"#{target}#{extra}>#{inner}</a>}
end
inner = "<center>#{inner}</center>" if expand

classes = _combine_classes(component, 'button')
expander = '<td class="expander"></td>' if expand
%{<table class="#{classes}"><tr><td><table><tr><td>#{inner}</td></tr></table></td>#{expander}</tr></table>}
%{<table class="#{classes}"><tbody><tr><td><table><tbody><tr><td>#{inner}</td></tr></tbody></table></td>#{expander}</tr></tbody></table>}
end

def _transform_menu(component, inner)
attributes = _combine_attributes(component, 'menu')
%{<table #{attributes}><tr><td><table><tr>#{inner}</tr></table></td></tr></table>}
%{<table #{attributes}><tbody><tr><td><table><tbody><tr>#{inner}</tr></tbody></table></td></tr></tbody></table>}
end

def _transform_menu_item(component, inner)
Expand Down Expand Up @@ -96,12 +97,12 @@ def _transform_columns(component, inner)
subrows = component.elements.css(".row").to_a.concat(component.elements.css("row").to_a)
expander = %{<th class="expander"></th>} if large_size.to_i == column_count && subrows.empty?

%{<#{INTERIM_TH_TAG} class="#{classes}" #{_pass_through_attributes(component)}><table><tr><th>#{inner}</th>#{expander}</tr></table></#{INTERIM_TH_TAG}>}
%{<#{INTERIM_TH_TAG} class="#{classes}" #{_pass_through_attributes(component)}><table><tbody><tr><th>#{inner}</th>#{expander}</tr></tbody></table></#{INTERIM_TH_TAG}>}
end

def _transform_block_grid(component, inner)
classes = _combine_classes(component, "block-grid up-#{component.attr('up')}")
%{<table class="#{classes}"><tr>#{inner}</tr></table>}
%{<table class="#{classes}"><tbody><tr>#{inner}</tr></tbody></table>}
end

def _transform_center(component, _inner)
Expand All @@ -121,12 +122,12 @@ def _transform_center(component, _inner)
def _transform_callout(component, inner)
classes = _combine_classes(component, 'callout-inner')
attributes = _pass_through_attributes(component)
%{<table #{attributes}class="callout"><tr><th class="#{classes}">#{inner}</th><th class="expander"></th></tr></table>}
%{<table #{attributes}class="callout"><tbody><tr><th class="#{classes}">#{inner}</th><th class="expander"></th></tr></tbody></table>}
end

def _transform_spacer(component, _inner)
classes = _combine_classes(component, 'spacer')
build_table = ->(size, extra) { %{<table class="#{classes} #{extra}"><tbody><tr><td height="#{size}" style="font-size:#{size}px;line-height:#{size}px;">&#xA0;</td></tr></tbody></table>} }
build_table = ->(size, extra) { %{<table class="#{classes} #{extra}"><tbody><tr><td height="#{size}" style="font-size:#{size}px;line-height:#{size}px;">&nbsp;</td></tr></tbody></table>} }
size = component.attr('size')
size_sm = component.attr('size-sm')
size_lg = component.attr('size-lg')
Expand All @@ -140,9 +141,15 @@ def _transform_spacer(component, _inner)
end
end

def _transform_h_line(component, _inner)
classes = _combine_classes(component, 'h-line')
attributes = _pass_through_attributes(component)
%{<table #{attributes}class="#{classes}"><tr><th>&nbsp;</th></tr></table>}
end

def _transform_wrapper(component, inner)
attributes = _combine_attributes(component, 'wrapper')
%{<table #{attributes} align="center"><tr><td class="wrapper-inner">#{inner}</td></tr></table>}
%{<table #{attributes} align="center"><tbody><tr><td class="wrapper-inner">#{inner}</td></tr></tbody></table>}
end
end
end
2 changes: 1 addition & 1 deletion lib/inky/rails/version.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module Inky
module Rails
VERSION = '1.3.8.0'.freeze
VERSION = '1.4.2.0'.freeze
end
NODE_VERSION, GEM_VERSION = Rails::VERSION.rpartition('.').map(&:freeze)
end
3 changes: 3 additions & 0 deletions spec/cases/button/with_extra_attr.inky
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
<button foo="bar">
A label
</button>
2 changes: 1 addition & 1 deletion spec/cases/button/with_link.inky
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
<button href="http://example.com" class="some classes" foo="bar">
<button href="http://example.com" class="some classes">
A label
</button>
3 changes: 3 additions & 0 deletions spec/cases/button/with_link_and_extra_attr.inky
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
<button href="http://example.com" foo="bar">
A label
</button>
1 change: 1 addition & 0 deletions spec/cases/h_line/basic.inky
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
<h-line/>
8 changes: 8 additions & 0 deletions spec/cases/h_line/multiple.inky
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<!-- pending https://github.com/foundation/inky/issues/137 --->
Hello
<h-line/>
World
<h-line foo="bar"/>
Bye
<h-line class="x" foo="bar"/>
Zzz
2 changes: 2 additions & 0 deletions spec/cases/h_line/with_attr.inky
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
<!-- pending https://github.com/foundation/inky/issues/137 --->
<h-line foo="bar"/>
6 changes: 6 additions & 0 deletions spec/cases/spacer/with_attr.inky
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<!-- pending https://github.com/foundation/inky/issues/135 --->
<div>
Stuff on top
<spacer foo="bar"/>
Stuff on bottom
</div>
2 changes: 1 addition & 1 deletion spec/cases/spacer/with_size.inky
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<div>
Stuff on top
<spacer class="some classes" foo="bar" size="42"/>
<spacer class="some classes" size="42"/>
Stuff on bottom
</div>
2 changes: 1 addition & 1 deletion spec/cases/spacer/with_size_lg.inky
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<div>
Stuff on top
<spacer class="some classes" foo="bar" size-lg="666"/>
<spacer class="some classes" size-lg="666"/>
<p>Stuff on bottom</p>
2 changes: 1 addition & 1 deletion spec/cases/spacer/with_size_sm.inky
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<div>
Stuff on top
<spacer class="some classes" foo="bar" size-sm="42"></spacer>
<spacer class="some classes" size-sm="42"></spacer>
Stuff on bottom
</div>
2 changes: 1 addition & 1 deletion spec/cases/spacer/with_size_sm_and_lg.inky
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<div>
Stuff on top
<spacer class="some classes" foo="bar" size-sm="42" size-lg="666"/>
<spacer class="some classes" size-sm="42" size-lg="666"/>
Stuff on bottom
</div>
6 changes: 6 additions & 0 deletions spec/cases/spacer/with_sizes_and_attr.inky
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<!-- pending https://github.com/foundation/inky/issues/135 --->
<div>
Stuff on top
<spacer class="some classes" foo="bar" size-sm="42" size-lg="666"/>
Stuff on bottom
</div>
Loading