Skip to content

Commit

Permalink
Add initial button component with stories
Browse files Browse the repository at this point in the history
  • Loading branch information
developius committed Aug 29, 2021
1 parent bc68b7c commit c0ddb06
Show file tree
Hide file tree
Showing 5 changed files with 37 additions and 0 deletions.
10 changes: 10 additions & 0 deletions app/components/button_component.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# frozen_string_literal: true

class ButtonComponent < ViewComponent::Base
attr_accessor :title

def initialize(title:)
@title = title
end

end
3 changes: 3 additions & 0 deletions app/components/button_component/button_component.html.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
<div data-controller="button-component--button-component">
<%= button_to title %>
</div>
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import { Controller } from "stimulus";

export default class extends Controller {
connect() {
console.log("Hello, Stimulus!", this.element);
}
}
10 changes: 10 additions & 0 deletions test/components/button_component_test.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
require "test_helper"

class ButtonComponentTest < ViewComponent::TestCase
def test_component_renders_something_useful
# assert_equal(
# %(<span>Hello, components!</span>),
# render_inline(ButtonComponent.new(message: "Hello, components!")).css("span").to_html
# )
end
end
7 changes: 7 additions & 0 deletions test/components/stories/button_component_stories.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
class ButtonComponentStories < ViewComponent::Storybook::Stories
story :default do
constructor(
title: text("Button title")
)
end
end

0 comments on commit c0ddb06

Please sign in to comment.