Skip to content

Commit

Permalink
Merge pull request #90 from PhlexUI/ch/migrate-typography
Browse files Browse the repository at this point in the history
Migrate typography
  • Loading branch information
cirdes authored Aug 25, 2024
2 parents 2bfac72 + 3f1798d commit e85541e
Show file tree
Hide file tree
Showing 18 changed files with 139 additions and 26 deletions.
6 changes: 0 additions & 6 deletions lib/phlex_ui/typography.rb

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# frozen_string_literal: true

module PhlexUI
module RBUI
class TypographyBlockquote < Base
def view_template(&)
blockquote(**attrs, &)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# frozen_string_literal: true

module PhlexUI
module RBUI
class TypographyH1 < Base
def view_template(&)
h1(**attrs, &)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# frozen_string_literal: true

module PhlexUI
module RBUI
class TypographyH2 < Base
def view_template(&)
h2(**attrs, &)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# frozen_string_literal: true

module PhlexUI
module RBUI
class TypographyH3 < Base
def view_template(&)
h3(**attrs, &)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# frozen_string_literal: true

module PhlexUI
module RBUI
class TypographyH4 < Base
def view_template(&)
h4(**attrs, &)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# frozen_string_literal: true

module PhlexUI
module RBUI
class TypographyInlineCode < Base
def view_template(&)
code(**attrs, &)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# frozen_string_literal: true

module PhlexUI
module RBUI
class TypographyInlineLink < Base
def initialize(href:, **attrs)
super(**attrs)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# frozen_string_literal: true

module PhlexUI
module RBUI
class TypographyLarge < Base
def view_template(&)
div(**attrs, &)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# frozen_string_literal: true

module PhlexUI
module RBUI
class TypographyLead < Base
def view_template(&)
p(**attrs, &)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# frozen_string_literal: true

module PhlexUI
module RBUI
class TypographyList < Base
def initialize(items: [], numbered: false, **attrs)
@items = items
Expand All @@ -14,7 +14,7 @@ def view_template(&)
else
list(**attrs) do
@items.each do |item|
PhlexUI.TypographyListItem { item }
TypographyListItem { item }
end
end
end
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# frozen_string_literal: true

module PhlexUI
module RBUI
class TypographyListItem < Base
def view_template(&)
li(**attrs, &)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# frozen_string_literal: true

module PhlexUI
module RBUI
class TypographyMuted < Base
def view_template(&)
p(**attrs, &)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# frozen_string_literal: true

module PhlexUI
module RBUI
class TypographyP < Base
def view_template(&)
p(**attrs, &)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# frozen_string_literal: true

module PhlexUI
module RBUI
class TypographySmall < Base
def view_template(&)
small(**attrs, &)
Expand Down
8 changes: 4 additions & 4 deletions test/phlex_ui/tabs_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,12 @@ def test_render_with_all_items
PhlexUI.TabsTrigger(value: "password") { "Password" }
end
PhlexUI.TabsContent(value: "account") do
PhlexUI.TypographyLarge { "Account" }
PhlexUI.TypographyMuted { "Update your account details." }
RBUI.TypographyLarge { "Account" }
RBUI.TypographyMuted { "Update your account details." }
end
PhlexUI.TabsContent(value: "password") do
PhlexUI.TypographyLarge { "Password" }
PhlexUI.TypographyMuted { "Change your password here. After saving, you'll be logged out." }
RBUI.TypographyLarge { "Password" }
RBUI.TypographyMuted { "Change your password here. After saving, you'll be logged out." }
end
end
end
Expand Down
2 changes: 1 addition & 1 deletion test/rbui/tooltip_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ def test_render_with_all_items
PhlexUI.Button(variant: :outline, icon: true) { "?" }
end
RBUI.TooltipContent do
PhlexUI.TypographyP { "Add to library" }
RBUI.TypographyP { "Add to library" }
end
end
end
Expand Down
119 changes: 119 additions & 0 deletions test/rbui/typography_test.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,119 @@
# frozen_string_literal: true

require "test_helper"

class RBUI::TypographyTest < Minitest::Test
include Phlex::Testing::ViewHelper

def test_h1
output = phlex_context do
RBUI.TypographyH1 { "This is an H1 title" }
end

assert_match("This is an H1 title", output)
end

def test_h2
output = phlex_context do
RBUI.TypographyH2 { "This is an H2 title" }
end

assert_match("This is an H2 title", output)
end

def test_h3
output = phlex_context do
RBUI.TypographyH3 { "This is an H3 title" }
end

assert_match("This is an H3 title", output)
end

def test_h4
output = phlex_context do
RBUI.TypographyH4 { "This is an H4 title" }
end

assert_match("This is an H4 title", output)
end

def test_p
output = phlex_context do
RBUI.TypographyP { "This is an P tag" }
end

assert_match("This is an P tag", output)
end

def test_inline_link
output = phlex_context do
RBUI.TypographyInlineLink(href: "#") { "installation instructions" }
end

assert_match("installation instructions", output)
end

def test_list
output = phlex_context do
RBUI.TypographyList(items: [
"Phlex is fast",
"Phlex is easy to use",
"Phlex is awesome"
])
end

assert_match("Phlex is fast", output)
end

def test_numbered_list
output = phlex_context do
RBUI.TypographyList(items: [
"Copy",
"Paste",
"Customize"
], numbered: true)
end

assert_match("Copy", output)
end

def test_inline_code
output = phlex_context do
RBUI.TypographyInlineCode { "This is an inline code block" }
end

assert_match("This is an inline code block", output)
end

def test_lead
output = phlex_context do
RBUI.TypographyLead { "A modal dialog that interrupts the user with important content and expects a response." }
end

assert_match("A modal dialog that interrupts", output)
end

def test_large
output = phlex_context do
RBUI.TypographyLarge { "Are you sure absolutely sure?" }
end

assert_match("Are you sure absolutely sure?", output)
end

def test_small
output = phlex_context do
RBUI.TypographySmall { "Email address" }
end

assert_match("Email address", output)
end

def test_muted
output = phlex_context do
RBUI.TypographyMuted { "Enter your email address." }
end

assert_match("Enter your email address.", output)
end
end

0 comments on commit e85541e

Please sign in to comment.