Skip to content

Commit c0ddb06

Browse files
committed
Add initial button component with stories
1 parent bc68b7c commit c0ddb06

File tree

5 files changed

+37
-0
lines changed

5 files changed

+37
-0
lines changed

app/components/button_component.rb

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
# frozen_string_literal: true
2+
3+
class ButtonComponent < ViewComponent::Base
4+
attr_accessor :title
5+
6+
def initialize(title:)
7+
@title = title
8+
end
9+
10+
end
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
<div data-controller="button-component--button-component">
2+
<%= button_to title %>
3+
</div>
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
import { Controller } from "stimulus";
2+
3+
export default class extends Controller {
4+
connect() {
5+
console.log("Hello, Stimulus!", this.element);
6+
}
7+
}
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
require "test_helper"
2+
3+
class ButtonComponentTest < ViewComponent::TestCase
4+
def test_component_renders_something_useful
5+
# assert_equal(
6+
# %(<span>Hello, components!</span>),
7+
# render_inline(ButtonComponent.new(message: "Hello, components!")).css("span").to_html
8+
# )
9+
end
10+
end
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
class ButtonComponentStories < ViewComponent::Storybook::Stories
2+
story :default do
3+
constructor(
4+
title: text("Button title")
5+
)
6+
end
7+
end

0 commit comments

Comments
 (0)