-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
11 changed files
with
122 additions
and
18 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
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
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
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
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 |
---|---|---|
|
@@ -2,6 +2,6 @@ | |
|
||
module Phlex | ||
module Slotable | ||
VERSION = "0.4.0" | ||
VERSION = "0.5.0" | ||
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
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,63 @@ | ||
# frozen_string_literal: true | ||
|
||
require "test_helper" | ||
|
||
class Phlex::TestKitCompatibility < Minitest::Test | ||
class Headline < Phlex::HTML | ||
include Phlex::Slotable | ||
|
||
slot :icon | ||
slot :title | ||
|
||
def initialize(size:, bg_color:) | ||
@size = size | ||
@bg_color = bg_color | ||
end | ||
|
||
def view_template | ||
div class: "headline text-#{@size} bg-#{@bg_color}" do | ||
render icon_slot | ||
render title_slot | ||
end | ||
end | ||
end | ||
|
||
class Header < Phlex::HTML | ||
def view_template(&) | ||
h1(&) | ||
end | ||
end | ||
|
||
module Components | ||
extend Phlex::Kit | ||
|
||
Headline = Phlex::TestKitCompatibility::Headline | ||
Header = Phlex::TestKitCompatibility::Header | ||
end | ||
|
||
class Page < Phlex::HTML | ||
include Components | ||
|
||
def view_template | ||
Headline(size: :lg, bg_color: :red) do |h| | ||
h.with_icon { h.i(class: "star") } | ||
h.with_title do | ||
Header { "Hello World!" } | ||
end | ||
end | ||
end | ||
end | ||
|
||
def test_with_slots | ||
output = Page.new.call | ||
|
||
expected_html = <<~HTML.join_lines | ||
<div class="headline text-lg bg-red"> | ||
<i class="star"></i> | ||
<h1>Hello World!</h1> | ||
</div> | ||
HTML | ||
|
||
assert_equal expected_html, output | ||
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 @@ | ||
# frozen_string_literal: true | ||
|
||
require "test_helper" | ||
|
||
class Phlex::TestVersion < Minitest::Test | ||
def test_version | ||
refute_nil Phlex::Slotable::VERSION | ||
end | ||
end |