Skip to content

Commit

Permalink
removed margin
Browse files Browse the repository at this point in the history
  • Loading branch information
Nj221102 committed Feb 14, 2024
1 parent 7eb36b0 commit 3dce58f
Show file tree
Hide file tree
Showing 12 changed files with 46 additions and 30 deletions.
28 changes: 25 additions & 3 deletions lacci/lib/shoes/margin_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,19 @@ def margin_parse(kwargs)

if kwargs[:margin].is_a?(Numeric)

return kwargs
if !kwargs[:margin_top]
kwargs[:margin_top] = kwargs[:margin]
end
if !kwargs[:margin_bottom]
kwargs[:margin_bottom] = kwargs[:margin]
end
if !kwargs[:margin_left]
kwargs[:margin_left] = kwargs[:margin]
end
if !kwargs[:margin_right]
kwargs[:margin_right] = kwargs[:margin]
end

elsif kwargs[:margin].is_a?(Hash)

kwargs[:margin].each do |key,value|
Expand All @@ -17,8 +29,18 @@ def margin_parse(kwargs)
margin_props = kwargs[:margin].is_a?(String) ? kwargs[:margin].split(/\s+|\,|-/) : kwargs[:margin]
if margin_props.length == 1

kwargs[:margin] = margin_props[0]
return kwargs
if !kwargs[:margin_top]
kwargs[:margin_top] = margin_props[0]
end
if !kwargs[:margin_bottom]
kwargs[:margin_bottom] = margin_props[0]
end
if !kwargs[:margin_left]
kwargs[:margin_left] = margin_props[0]
end
if !kwargs[:margin_right]
kwargs[:margin_right] = margin_props[0]
end

elsif margin_props.length == 2

Expand Down
6 changes: 3 additions & 3 deletions lacci/test/test_margin_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ def test_one_Number_margin

kwargs = {:margin => 20}

assert_equal({:margin => 20},margin_parse(kwargs))
assert_equal({:margin => nil, :margin_left => 20, :margin_top => 20, :margin_right => 20, :margin_bottom => 20},margin_parse(kwargs))

end

Expand All @@ -26,7 +26,7 @@ def test_Array_one_margin

kwargs = {:margin => [20]}

assert_equal({:margin => 20},margin_parse(kwargs))
assert_equal({:margin => nil, :margin_left => 20, :margin_top => 20, :margin_right => 20, :margin_bottom => 20},margin_parse(kwargs))

end

Expand All @@ -43,7 +43,7 @@ def test_String_one_margin

kwargs = {:margin => "20"}

assert_equal({:margin => "20"},margin_parse(kwargs))
assert_equal({:margin => nil, :margin_left => "20", :margin_top => "20", :margin_right => "20", :margin_bottom => "20"},margin_parse(kwargs))

end

Expand Down
1 change: 0 additions & 1 deletion scarpe-components/lib/scarpe/components/calzini.rb
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,6 @@ def drawable_style(props)
styles[:left] = dimensions_length(props["left"]) if props["left"]
styles[:width] = dimensions_length(props["width"]) if props["width"]
styles[:height] = dimensions_length(props["height"]) if props["height"]
styles[:"margin"] = dimensions_length(props["margin"]) if props["margin"]
styles[:"margin-left"] = dimensions_length(props["margin_left"]) if props["margin_left"]
styles[:"margin-right"] = dimensions_length(props["margin_right"]) if props["margin_right"]
styles[:"margin-top"] = dimensions_length(props["margin_top"]) if props["margin_top"]
Expand Down
5 changes: 0 additions & 5 deletions test/test_stack.rb
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,6 @@ def test_it_accepts_a_height
assert_includes stack.to_html, "height:25px"
end

def test_it_accepts_margin
stack = Scarpe::Webview::Stack.new(@default_properties.merge("margin" => 25))

assert_includes stack.to_html, "margin:25px"
end


#def test_it_can_have_a_background
Expand Down
2 changes: 1 addition & 1 deletion test/wv/html_fixtures/highlander.html
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<div id="2" style="display:flex;flex-direction:row;flex-wrap:wrap;align-content:flex-start;justify-content:flex-start;align-items:flex-start;width:100%;height:100%">
<div style="height:100%;width:100%;position:relative">
<div id="3" style="display:flex;flex-direction:column;align-content:flex-start;justify-content:flex-start;align-items:flex-start;margin:40px">
<div id="3" style="display:flex;flex-direction:column;align-content:flex-start;justify-content:flex-start;align-items:flex-start;margin-left:40px;margin-right:40px;margin-top:40px;margin-bottom:40px">
<div style="height:100%;width:100%;position:relative">
<p id="4" style="font-size:12px">Found 0 likely duplicates.</p>
<select id="5" onchange="scarpeHandler('5-change', this.options[this.selectedIndex].value)"></select><button id="6" onclick="scarpeHandler('6-click')" onmouseover="scarpeHandler('6-hover')">Refresh the list!</button>
Expand Down
4 changes: 2 additions & 2 deletions test/wv/html_fixtures/list_box.html
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
<div id="2" style="display:flex;flex-direction:row;flex-wrap:wrap;align-content:flex-start;justify-content:flex-start;align-items:flex-start;width:100%;height:100%">
<div style="height:100%;width:100%;position:relative">
<div id="3" style="display:flex;flex-direction:column;align-content:flex-start;justify-content:flex-start;align-items:flex-start;margin:40px">
<div id="3" style="display:flex;flex-direction:column;align-content:flex-start;justify-content:flex-start;align-items:flex-start;margin-left:40px;margin-right:40px;margin-top:40px;margin-bottom:40px">
<div style="height:100%;width:100%;position:relative">
<div id="4" style="display:flex;flex-direction:column;align-content:flex-start;justify-content:flex-start;align-items:flex-start;margin:10px">
<div id="4" style="display:flex;flex-direction:column;align-content:flex-start;justify-content:flex-start;align-items:flex-start;margin-left:10px;margin-right:10px;margin-top:10px;margin-bottom:10px">
<div style="height:100%;width:100%;position:relative">
<p id="5" style="font-size:12px">Name</p>
<select id="6" onchange="scarpeHandler('6-change', this.options[this.selectedIndex].value)"><option value="Phyllis">Phyllis</option><option value="Ronald">Ronald</option><option value="Wyatt">Wyatt</option></select></div>
Expand Down
2 changes: 1 addition & 1 deletion test/wv/html_fixtures/margin.html
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<div style="height:100%;width:100%;position:relative">
<p id="3" style="margin-left:60px;margin-right:80px;margin-top:30px;margin-bottom:40px;font-size:12px">All margins with array input</p>
<p id="4" style="margin-left:30;margin-right:10;margin-top:20;margin-bottom:20;font-size:12px">All margins with string input</p>
<p id="5" style="margin:20px;font-size:12px">One Number to set all margins</p>
<p id="5" style="margin-left:20px;margin-right:20px;margin-top:20px;margin-bottom:20px;font-size:12px">One Number to set all margins</p>
<p id="6" style="margin-left:20px;margin-right:20px;margin-top:100px;margin-bottom:30px;font-size:12px">Specific property can overwrite shorthand</p>
<p id="7" style="margin-left:20px;margin-right:20px;margin-top:100px;margin-bottom:10px;font-size:12px">margins using a hash input</p>
<div id="root-fonts"></div>
Expand Down
2 changes: 1 addition & 1 deletion test/wv/html_fixtures/margin_check.html
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<div style="height:100%;width:100%;position:relative"><button id="6" onclick="scarpeHandler('6-click')" onmouseover="scarpeHandler('6-hover')" style="margin-left:10px;margin-right:5px;margin-top:25px;margin-bottom:10px">Hash margin</button></div>
</div>
<div id="7" style="display:flex;flex-direction:column;align-content:flex-start;justify-content:flex-start;align-items:flex-start;width:100px;height:100px;background:rgba(255, 255, 0, 255)">
<div style="height:100%;width:100%;position:relative"><button id="8" onclick="scarpeHandler('8-click')" onmouseover="scarpeHandler('8-hover')" style="margin:5px;margin-top:30px">Middle Button</button></div>
<div style="height:100%;width:100%;position:relative"><button id="8" onclick="scarpeHandler('8-click')" onmouseover="scarpeHandler('8-hover')" style="margin-left:5px;margin-right:5px;margin-top:30px;margin-bottom:5px">Middle Button</button></div>
</div>
<div id="9" style="display:flex;flex-direction:column;align-content:flex-start;justify-content:flex-start;align-items:flex-start;width:100px;height:100px;background:rgba(0, 128, 0, 255)">
<div style="height:100%;width:100%;position:relative"><button id="10" onclick="scarpeHandler('10-click')" onmouseover="scarpeHandler('10-hover')">OK 2</button></div>
Expand Down
6 changes: 3 additions & 3 deletions test/wv/html_fixtures/ruby_racer.html
Original file line number Diff line number Diff line change
Expand Up @@ -2,21 +2,21 @@
<div style="height:100%;width:100%;position:relative">
<div id="3" style="display:flex;flex-direction:row;flex-wrap:wrap;align-content:flex-start;justify-content:flex-start;align-items:flex-start;width:100%">
<div style="height:100%;width:100%;position:relative">
<div id="4" style="display:flex;flex-direction:column;align-content:flex-start;justify-content:flex-start;align-items:flex-start;width:45.0%;margin:5px">
<div id="4" style="display:flex;flex-direction:column;align-content:flex-start;justify-content:flex-start;align-items:flex-start;width:45.0%;margin-left:5px;margin-right:5px;margin-top:5px;margin-bottom:5px">
<div style="height:100%;width:100%;position:relative">
<p id="5" style="font-size:14px">Racer 1</p>
<textarea id="6" oninput="scarpeHandler('6-change', this.value)" onmouseover="scarpeHandler('6-hover')" style="width:100%;height:100px">for i in 1..10n a = "1"nendn</textarea>
</div>
</div>
<div id="7" style="display:flex;flex-direction:column;align-content:flex-start;justify-content:flex-start;align-items:flex-start;width:45.0%;margin:5px">
<div id="7" style="display:flex;flex-direction:column;align-content:flex-start;justify-content:flex-start;align-items:flex-start;width:45.0%;margin-left:5px;margin-right:5px;margin-top:5px;margin-bottom:5px">
<div style="height:100%;width:100%;position:relative">
<p id="8" style="font-size:14px">Racer 2</p>
<textarea id="9" oninput="scarpeHandler('9-change', this.value)" onmouseover="scarpeHandler('9-hover')" style="width:100%;height:100px">10.times don a = "1"nendn</textarea>
</div>
</div>
</div>
</div>
<div id="10" style="display:flex;flex-direction:column;align-content:flex-start;justify-content:flex-start;align-items:flex-start;margin:10px">
<div id="10" style="display:flex;flex-direction:column;align-content:flex-start;justify-content:flex-start;align-items:flex-start;margin-left:10px;margin-right:10px;margin-top:10px;margin-bottom:10px">
<div style="height:100%;width:100%;position:relative"><button id="11" onclick="scarpeHandler('11-click')" onmouseover="scarpeHandler('11-hover')">Race!</button>
<p id="12" style="font-size:12px"></p>
</div>
Expand Down
16 changes: 8 additions & 8 deletions test/wv/html_fixtures/simpler-menu.html
Original file line number Diff line number Diff line change
@@ -1,30 +1,30 @@
<div id="2" style="display:flex;flex-direction:row;flex-wrap:wrap;align-content:flex-start;justify-content:flex-start;align-items:flex-start;width:100%;height:100%">
<div style="height:100%;width:100%;position:relative">
<div id="3" style="display:flex;flex-direction:row;flex-wrap:wrap;align-content:flex-start;justify-content:flex-start;align-items:flex-start;width:175px;height:120px;margin:4px;background:rgba(0, 128, 0, 255)">
<div id="3" style="display:flex;flex-direction:row;flex-wrap:wrap;align-content:flex-start;justify-content:flex-start;align-items:flex-start;width:175px;height:120px;margin-left:4px;margin-right:4px;margin-top:4px;margin-bottom:4px;background:rgba(0, 128, 0, 255)">
<div style="height:100%;width:100%;position:relative">
<div id="4" style="text-align:center;width:100%">
<p style="margin:18px;font-size:20px">Box 1</p>
<p style="margin-left:18px;margin-right:18px;margin-top:18px;margin-bottom:18px;font-size:20px">Box 1</p>
</div>
</div>
</div>
<div id="5" style="display:flex;flex-direction:row;flex-wrap:wrap;align-content:flex-start;justify-content:flex-start;align-items:flex-start;width:140px;height:120px;margin:4px;background:rgba(0, 0, 255, 255)">
<div id="5" style="display:flex;flex-direction:row;flex-wrap:wrap;align-content:flex-start;justify-content:flex-start;align-items:flex-start;width:140px;height:120px;margin-left:4px;margin-right:4px;margin-top:4px;margin-bottom:4px;background:rgba(0, 0, 255, 255)">
<div style="height:100%;width:100%;position:relative">
<div id="6" style="text-align:center;width:100%">
<p style="margin:18px;font-size:20px">Box 2</p>
<p style="margin-left:18px;margin-right:18px;margin-top:18px;margin-bottom:18px;font-size:20px">Box 2</p>
</div>
</div>
</div>
<div id="7" style="display:flex;flex-direction:row;flex-wrap:wrap;align-content:flex-start;justify-content:flex-start;align-items:flex-start;width:135px;height:120px;margin:4px;background:rgba(255, 0, 0, 255)">
<div id="7" style="display:flex;flex-direction:row;flex-wrap:wrap;align-content:flex-start;justify-content:flex-start;align-items:flex-start;width:135px;height:120px;margin-left:4px;margin-right:4px;margin-top:4px;margin-bottom:4px;background:rgba(255, 0, 0, 255)">
<div style="height:100%;width:100%;position:relative">
<div id="8" style="text-align:center;width:100%">
<p style="margin:18px;font-size:20px">Box 3</p>
<p style="margin-left:18px;margin-right:18px;margin-top:18px;margin-bottom:18px;font-size:20px">Box 3</p>
</div>
</div>
</div>
<div id="9" style="display:flex;flex-direction:row;flex-wrap:wrap;align-content:flex-start;justify-content:flex-start;align-items:flex-start;width:125px;height:120px;margin:4px;background:rgba(128, 0, 128, 255)">
<div id="9" style="display:flex;flex-direction:row;flex-wrap:wrap;align-content:flex-start;justify-content:flex-start;align-items:flex-start;width:125px;height:120px;margin-left:4px;margin-right:4px;margin-top:4px;margin-bottom:4px;background:rgba(128, 0, 128, 255)">
<div style="height:100%;width:100%;position:relative">
<div id="10" style="text-align:center;width:100%">
<p style="margin:18px;font-size:20px">Box 4</p>
<p style="margin-left:18px;margin-right:18px;margin-top:18px;margin-bottom:18px;font-size:20px">Box 4</p>
</div>
</div>
</div>
Expand Down
2 changes: 1 addition & 1 deletion test/wv/html_fixtures/spacing.html
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<div id="2" style="display:flex;flex-direction:row;flex-wrap:wrap;align-content:flex-start;justify-content:flex-start;align-items:flex-start;width:100%;height:100%">
<div style="height:100%;width:100%;position:relative">
<div id="3" style="display:flex;flex-direction:column;align-content:flex-start;justify-content:flex-start;align-items:flex-start;margin:50px;background:purple">
<div id="3" style="display:flex;flex-direction:column;align-content:flex-start;justify-content:flex-start;align-items:flex-start;margin-left:50px;margin-right:50px;margin-top:50px;margin-bottom:50px;background:purple">
<div style="height:100%;width:100%;position:relative">
<p id="4" style="color:#FFFFFF;font-size:12px">with 50px margin</p>
</div>
Expand Down
2 changes: 1 addition & 1 deletion test/wv/html_fixtures/span.html
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<div id="2" style="display:flex;flex-direction:row;flex-wrap:wrap;align-content:flex-start;justify-content:flex-start;align-items:flex-start;width:100%;height:100%">
<div style="height:100%;width:100%;position:relative">
<div id="3" style="display:flex;flex-direction:column;align-content:flex-start;justify-content:flex-start;align-items:flex-start;margin:10px">
<div id="3" style="display:flex;flex-direction:column;align-content:flex-start;justify-content:flex-start;align-items:flex-start;margin-left:10px;margin-right:10px;margin-top:10px;margin-bottom:10px">
<div style="height:100%;width:100%;position:relative">
<p id="5" style="color:#FF0000;font-size:12px"><span class="id_4" style="color:#0000FF;background-color:#008000">TEXT EDITOR</span> * USE ALT-Q TO QUIT</p>
</div>
Expand Down

0 comments on commit 3dce58f

Please sign in to comment.