Created
March 1, 2016 04:56
-
-
Save jgaskins/439af129c2075f018f75 to your computer and use it in GitHub Desktop.
Composable styles in Clearwater
This file contains hidden or 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
class MasterDetailComponent | |
include Clearwater::Component | |
def initialize master, detail | |
@master = master | |
@detail = detail | |
end | |
def render | |
div([ | |
div({ key: 'master', style: Style.master }, @master), | |
div({ key: 'detail', style: Style.detail }, @detail), | |
]) | |
end | |
module Style | |
module_function | |
def master | |
side_by_side(width: '25%') | |
end | |
def detail | |
side_by_side(width: '75%') | |
end | |
def side_by_side(attributes={}) | |
{ | |
display: 'inline-block', | |
vertical_align: :top, | |
}.merge(attributes) | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment