Skip to content

Instantly share code, notes, and snippets.

@jgaskins
Created March 1, 2016 04:56
Show Gist options
  • Save jgaskins/439af129c2075f018f75 to your computer and use it in GitHub Desktop.
Save jgaskins/439af129c2075f018f75 to your computer and use it in GitHub Desktop.
Composable styles in Clearwater
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