Skip to content

Commit

Permalink
Add alert and button preview
Browse files Browse the repository at this point in the history
  • Loading branch information
martinemde committed Nov 20, 2024
1 parent 33c2eb5 commit 980cf5e
Show file tree
Hide file tree
Showing 2 changed files with 72 additions and 0 deletions.
12 changes: 12 additions & 0 deletions test/components/previews/alert_component_preview.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
class AlertComponentPreview < Lookbook::Preview
layout "hammy_component_preview"

# @param content text "content"
# @param style select "style", { choices: [notice, alert, error, success, primary, neutral] }
# @param closeable toggle "closeable"
def default(content = "Example content", style: :notice, closeable: false)
render AlertComponent.new(style:, closeable:) do
content
end
end
end
60 changes: 60 additions & 0 deletions test/components/previews/button_component_preview.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
class ButtonComponentPreview < Lookbook::Preview
layout "hammy_component_preview"

# @param text text "text"
# @param url url "link"
# @param type select "type", { choices: [button, link, submit] }
# @param color select "color", { choices: [primary, secondary, red, orange, hammy, yellow, green, blue, neutral] }
# @param size select "size", { choices: [small, large] }
# @param style select "style", { choices: [fill, outline, plain] }
# @param disabled toggle "disabled"
def default(text: "Button", url: "", type: :button, color: :primary, size: :large, style: :fill, disabled: false) # rubocop:disable Metrics/ParameterLists
args = [text, url].compact_blank
render ButtonComponent.new(
*args,
type: type,
color: color,
size: size,
style: style,
disabled: disabled
)
end

# @param text text "text"
# @param url url "link"
# @param type select "type", { choices: [button, link, submit] }
# @param color select "color", { choices: [primary, secondary, red, orange, hammy, yellow, green, blue, neutral] }
# @param size select "size", { choices: [small, large] }
# @param style select "style", { choices: [fill, outline, plain] }
# @param disabled toggle "disabled"
def outline(text: "Button", url: "", type: :button, color: :primary, size: :large, style: :outline, disabled: false) # rubocop:disable Metrics/ParameterLists
args = [text, url].compact_blank
render ButtonComponent.new(
*args,
type: type,
color: color,
size: size,
style: style,
disabled: disabled
)
end

# @param text text "text"
# @param url url "link"
# @param type select "type", { choices: [button, link, submit] }
# @param color select "color", { choices: [primary, secondary, red, orange, hammy, yellow, green, blue, neutral] }
# @param size select "size", { choices: [small, large] }
# @param style select "style", { choices: [fill, outline, plain] }
# @param disabled toggle "disabled"
def plain(text: "Button", url: "", type: :button, color: :primary, size: :large, style: :plain, disabled: false) # rubocop:disable Metrics/ParameterLists
args = [text, url].compact_blank
render ButtonComponent.new(
*args,
type: type,
color: color,
size: size,
style: style,
disabled: disabled
)
end
end

0 comments on commit 980cf5e

Please sign in to comment.