Skip to content

Instantly share code, notes, and snippets.

@paulcsmith
Created August 17, 2020 17:20
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save paulcsmith/6cb93d695d150f7ee6bd0e8c92b341cc to your computer and use it in GitHub Desktop.
Save paulcsmith/6cb93d695d150f7ee6bd0e8c92b341cc to your computer and use it in GitHub Desktop.
class Button < BaseComponent
enum Size
Small
Medium
Large
end
needs size : Size = Medium
def render
with_defaults class: "my button classes #{size_classes}" do |button_builder|
yield button_builder
end
end
def size_classes
case size
when Small
"px-2 py-1"
# etc.
end
end
end
m Button, size: :large, &.link("foo", Foo::Index)
@stephendolan
Copy link

@paulcsmith
Copy link
Author

Nice! Thanks @stephendolan

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment