-
Notifications
You must be signed in to change notification settings - Fork 29
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Add border as drawable * Add support for gradient and curve * Regenerate html fixtures
- Loading branch information
1 parent
f41a98a
commit c624654
Showing
13 changed files
with
128 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
Shoes.app(width: 300, height: 50) do | ||
stack height: 50 do | ||
para "Border is on top of text" | ||
border yellow, strokewidth: 4 | ||
end | ||
|
||
stack do | ||
para "This border is also on top of text" | ||
border blue, strokewidth: 4 | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
# frozen_string_literal: true | ||
|
||
class Shoes | ||
class Border < Shoes::Drawable | ||
# Shoes style with verification or value mapping: | ||
# shoes_style(:left) { |val| convert_to_integer(val, "left") } | ||
|
||
shoes_styles :stroke, :strokewidth # Write your shoes styles here | ||
|
||
shoes_style(:strokewidth) { |val| convert_to_integer(val, "strokewidth") } | ||
shoes_style(:curve) { |val| convert_to_integer(val, "curve") } | ||
|
||
Shoes::Drawable.drawable_default_styles[Shoes::Border][:stroke] = :black | ||
Shoes::Drawable.drawable_default_styles[Shoes::Border][:strokewidth] = 1 | ||
Shoes::Drawable.drawable_default_styles[Shoes::Border][:curve] = 0 | ||
|
||
opt_init_args :stroke, :strokewidth, :curve | ||
def initialize(*args, **kwargs) | ||
super | ||
@draw_context = Shoes::App.instance.current_draw_context | ||
|
||
create_display_drawable | ||
end | ||
|
||
private | ||
|
||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -37,7 +37,6 @@ | |
|
||
class Shoes::Widget < Shoes::Slot | ||
include Shoes::Background | ||
include Shoes::Border | ||
|
||
shoes_events | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
# frozen_string_literal: true | ||
|
||
module Scarpe::Webview | ||
class Border < Drawable | ||
|
||
def initialize(properties) | ||
super(properties) | ||
end | ||
|
||
# If the drawable is intended to be overridable, add element and style to Calzini instead | ||
def element | ||
render('border') | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
module Scarpe::Components::Calzini | ||
def border_element(props) | ||
HTML.render do |h| | ||
h.div(id: html_id, style: style(props)) | ||
end | ||
end | ||
|
||
private | ||
|
||
def style(props) | ||
styles = { | ||
height: :inherit, | ||
width: :inherit, | ||
position: :absolute, | ||
top: 0, | ||
left: 0, | ||
'box-sizing': 'border-box' | ||
} | ||
|
||
bc = props["stroke"] | ||
|
||
border_style_hash = case bc | ||
when Range | ||
{ "border-image": "linear-gradient(45deg, #{bc.first}, #{bc.last})" } | ||
when Array | ||
{ "border-color": "rgba(#{bc.join(", ")})" } | ||
else | ||
{ "border-color": bc } | ||
end | ||
styles = styles.merge( | ||
"border-style": "solid", | ||
"border-width": "#{props["strokewidth"]}px", | ||
"border-radius": "#{props["curve"]}px", | ||
).merge(border_style_hash) | ||
|
||
styles.compact | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
<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;height:50px"> | ||
<div style="height:100%;width:100%;position:relative"> | ||
<p id="4" style="font-size:12px">Border is on top of text</p> | ||
<div id="5" style="height:inherit;width:inherit;position:absolute;top:0;left:0;box-sizing:border-box;border-style:solid;border-width:4px;border-radius:0px;border-color:rgba(255, 255, 0, 255)"></div> | ||
</div> | ||
</div> | ||
<div id="6" style="display:flex;flex-direction:column;align-content:flex-start;justify-content:flex-start;align-items:flex-start"> | ||
<div style="height:100%;width:100%;position:relative"> | ||
<p id="7" style="font-size:12px">This border is also on top of text</p> | ||
<div id="8" style="height:inherit;width:inherit;position:absolute;top:0;left:0;box-sizing:border-box;border-style:solid;border-width:4px;border-radius:0px;border-color:rgba(0, 0, 255, 255)"></div> | ||
</div> | ||
</div> | ||
<div id="root-fonts"></div> | ||
<div id="root-alerts"> </div> | ||
</div> | ||
</div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters