Skip to content

Commit

Permalink
Implement <h-line> [Fixes #106]
Browse files Browse the repository at this point in the history
Note: original inky's implementation seems completely broken
foundation/inky#137
foundation/inky#136
  • Loading branch information
marcandre committed Dec 7, 2021
1 parent ccf22b4 commit 2d60a50
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 1 deletion.
3 changes: 2 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 Down
6 changes: 6 additions & 0 deletions lib/inky/component_factory.rb
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,12 @@ 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"><tbody><tr><td class="wrapper-inner">#{inner}</td></tr></tbody></table>}
Expand Down
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"/>

0 comments on commit 2d60a50

Please sign in to comment.