Skip to content

Commit bb94c8c

Browse files
authored
Remove ApplicationComponent (#171)
1 parent 634ba80 commit bb94c8c

File tree

5 files changed

+35
-10
lines changed

5 files changed

+35
-10
lines changed

app/views/application_view.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ def visit_call_node(node)
1313
end
1414
end
1515

16-
class ApplicationView < ApplicationComponent
16+
class ApplicationView < Base
1717
include ApplicationHelper
1818
# The ApplicationView is an abstract class for all your views.
1919

app/views/base.rb

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
class Base < Phlex::HTML
2+
include Components
3+
include RubyUI
4+
5+
# Include any helpers you want to be available across all components
6+
include Phlex::Rails::Helpers::Routes
7+
include Phlex::Rails::Helpers::ImagePath
8+
include Phlex::Rails::Helpers::ImageURL
9+
include Phlex::Rails::Helpers::Flash
10+
include Phlex::Rails::Helpers::Request
11+
12+
TAILWIND_MERGER = ::TailwindMerge::Merger.new.freeze unless defined?(TAILWIND_MERGER)
13+
14+
attr_reader :attrs
15+
16+
def initialize(**user_attrs)
17+
@attrs = mix(default_attrs, user_attrs)
18+
@attrs[:class] = TAILWIND_MERGER.merge(@attrs[:class]) if @attrs[:class]
19+
end
20+
21+
if Rails.env.development?
22+
def before_template
23+
comment { "Before #{self.class.name}" }
24+
super
25+
end
26+
end
27+
28+
private
29+
30+
def default_attrs
31+
{}
32+
end
33+
end

app/views/component_view.rb

Lines changed: 0 additions & 4 deletions
This file was deleted.

app/views/components/application_component.rb

Lines changed: 0 additions & 4 deletions
This file was deleted.

app/views/docs/typography_view.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# frozen_string_literal: true
22

3-
class Docs::TypographyView < ComponentView
3+
class Docs::TypographyView < ApplicationView
44
def view_template
55
component = "Typography"
66

0 commit comments

Comments
 (0)