-
-
Save 1gor/975093e6d0e6a013fc8fdf09f44c99d5 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