-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Extract a SectionComponent from interests/new
- Loading branch information
Showing
5 changed files
with
60 additions
and
8 deletions.
There are no files selected for viewing
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
# frozen_string_literal: true | ||
|
||
class SectionComponent < ViewComponent::Base | ||
include ApplicationHelper | ||
|
||
def initialize(title:, link_text:, link_path:) | ||
@title = title | ||
@link_text = link_text | ||
@link_path = link_path | ||
|
||
super | ||
end | ||
end |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
<section class="mt-6 mb-12"> | ||
<h2 class="text-slate-400 mb-3 uppercase"><%= @title %></h2> | ||
|
||
<%= content %> | ||
|
||
<div class="flex justify-end"> | ||
<%= text_link_to @link_text, @link_path %> | ||
</div> | ||
</section> |
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
# frozen_string_literal: true | ||
|
||
class SectionComponentPreview < ViewComponent::Preview | ||
def default | ||
render( | ||
SectionComponent.new( | ||
title: 'Title', | ||
link_text: 'Link Text', | ||
link_path: 'http://example.com' | ||
) | ||
) do | ||
tag.div do | ||
content_tag(:span, 'Section content') | ||
end | ||
end | ||
end | ||
end |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
# frozen_string_literal: true | ||
|
||
require 'test_helper' | ||
|
||
class SectionComponentTest < ViewComponent::TestCase | ||
def test_component_renders_something_useful | ||
# assert_equal( | ||
# %(<span>Hello, components!</span>), | ||
# render_inline(SectionComponent.new(message: "Hello, components!")).css("span").to_html | ||
# ) | ||
end | ||
end |