Skip to content

Commit 3f3cf14

Browse files
authored
Migrate the views to align with Phlex conventions (#172)
1 parent bb94c8c commit 3f3cf14

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

67 files changed

+157
-208
lines changed

app/controllers/docs_controller.rb

Lines changed: 49 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -5,200 +5,200 @@ class DocsController < ApplicationController
55

66
# GETTING STARTED
77
def introduction
8-
render Docs::GettingStarted::IntroductionView.new
8+
render Views::Docs::GettingStarted::IntroductionView.new
99
end
1010

1111
def installation
12-
render Docs::GettingStarted::InstallationView.new
12+
render Views::Docs::GettingStarted::InstallationView.new
1313
end
1414

1515
def theming
16-
render Docs::GettingStarted::ThemingView.new
16+
render Views::Docs::GettingStarted::ThemingView.new
1717
end
1818

1919
def dark_mode
20-
render Docs::GettingStarted::DarkModeView.new
20+
render Views::Docs::GettingStarted::DarkModeView.new
2121
end
2222

2323
def customizing_components
24-
render Docs::GettingStarted::CustomizingComponentsView.new
24+
render Views::Docs::GettingStarted::CustomizingComponentsView.new
2525
end
2626

2727
# INSTALLATION
2828
def installation_rails_bundler
29-
render Docs::Installation::RailsBundlerView.new
29+
render Views::Docs::Installation::RailsBundlerView.new
3030
end
3131

3232
def installation_rails_importmaps
33-
render Docs::Installation::RailsImportmapsView.new
33+
render Views::Docs::Installation::RailsImportmapsView.new
3434
end
3535

3636
# COMPONENTS
3737
def accordion
38-
render Docs::AccordionView.new
38+
render Views::Docs::AccordionView.new
3939
end
4040

4141
def alert_component # alert is a reserved word
42-
render Docs::AlertView.new
42+
render Views::Docs::AlertView.new
4343
end
4444

4545
def alert_dialog
46-
render Docs::AlertDialogView.new
46+
render Views::Docs::AlertDialogView.new
4747
end
4848

4949
def aspect_ratio
50-
render Docs::AspectRatioView.new
50+
render Views::Docs::AspectRatioView.new
5151
end
5252

5353
def avatar
54-
render Docs::AvatarView.new
54+
render Views::Docs::AvatarView.new
5555
end
5656

5757
def badge
58-
render Docs::BadgeView.new
58+
render Views::Docs::BadgeView.new
5959
end
6060

6161
def breadcrumb
62-
render Docs::BreadcrumbView.new
62+
render Views::Docs::BreadcrumbView.new
6363
end
6464

6565
def button
66-
render Docs::ButtonView.new
66+
render Views::Docs::ButtonView.new
6767
end
6868

6969
def card
70-
render Docs::CardView.new
70+
render Views::Docs::CardView.new
7171
end
7272

7373
def calendar
74-
render Docs::CalendarView.new
74+
render Views::Docs::CalendarView.new
7575
end
7676

7777
def chart
78-
render Docs::ChartView.new
78+
render Views::Docs::ChartView.new
7979
end
8080

8181
def checkbox
82-
render Docs::CheckboxView.new
82+
render Views::Docs::CheckboxView.new
8383
end
8484

8585
def checkbox_group
86-
render Docs::CheckboxGroupView.new
86+
render Views::Docs::CheckboxGroupView.new
8787
end
8888

8989
def clipboard
90-
render Docs::ClipboardView.new
90+
render Views::Docs::ClipboardView.new
9191
end
9292

9393
def codeblock
94-
render Docs::CodeblockView.new
94+
render Views::Docs::CodeblockView.new
9595
end
9696

9797
def collapsible
98-
render Docs::CollapsibleView.new
98+
render Views::Docs::CollapsibleView.new
9999
end
100100

101101
def combobox
102-
render Docs::ComboboxView.new
102+
render Views::Docs::ComboboxView.new
103103
end
104104

105105
def command
106-
render Docs::CommandView.new
106+
render Views::Docs::CommandView.new
107107
end
108108

109109
def context_menu
110-
render Docs::ContextMenuView.new
110+
render Views::Docs::ContextMenuView.new
111111
end
112112

113113
def date_picker
114-
render Docs::DatePickerView.new
114+
render Views::Docs::DatePickerView.new
115115
end
116116

117117
def dialog
118-
render Docs::DialogView.new
118+
render Views::Docs::DialogView.new
119119
end
120120

121121
def dropdown_menu
122-
render Docs::DropdownMenuView.new
122+
render Views::Docs::DropdownMenuView.new
123123
end
124124

125125
def form
126-
render Docs::FormView.new
126+
render Views::Docs::FormView.new
127127
end
128128

129129
def hover_card
130-
render Docs::HoverCardView.new
130+
render Views::Docs::HoverCardView.new
131131
end
132132

133133
def input
134-
render Docs::InputView.new
134+
render Views::Docs::InputView.new
135135
end
136136

137137
def link
138-
render Docs::LinkView.new
138+
render Views::Docs::LinkView.new
139139
end
140140

141141
def masked_input
142-
render Docs::MaskedInputView.new
142+
render Views::Docs::MaskedInputView.new
143143
end
144144

145145
def pagination
146-
render Docs::PaginationView.new
146+
render Views::Docs::PaginationView.new
147147
end
148148

149149
def popover
150-
render Docs::PopoverView.new
150+
render Views::Docs::PopoverView.new
151151
end
152152

153153
def progress
154-
render Docs::ProgressView.new
154+
render Views::Docs::ProgressView.new
155155
end
156156

157157
def radio_button
158-
render Docs::RadioButtonView.new
158+
render Views::Docs::RadioButtonView.new
159159
end
160160

161161
def select
162-
render Docs::SelectView.new
162+
render Views::Docs::SelectView.new
163163
end
164164

165165
def sheet
166-
render Docs::SheetView.new
166+
render Views::Docs::SheetView.new
167167
end
168168

169169
def shortcut_key
170-
render Docs::ShortcutKeyView.new
170+
render Views::Docs::ShortcutKeyView.new
171171
end
172172

173173
def skeleton
174-
render Docs::SkeletonView.new
174+
render Views::Docs::SkeletonView.new
175175
end
176176

177177
def switch
178-
render Docs::SwitchView.new
178+
render Views::Docs::SwitchView.new
179179
end
180180

181181
def table
182-
render Docs::TableView.new
182+
render Views::Docs::TableView.new
183183
end
184184

185185
def tabs
186-
render Docs::TabsView.new
186+
render Views::Docs::TabsView.new
187187
end
188188

189189
def textarea
190-
render Docs::TextareaView.new
190+
render Views::Docs::TextareaView.new
191191
end
192192

193193
def theme_toggle
194-
render Docs::ThemeToggleView.new
194+
render Views::Docs::ThemeToggleView.new
195195
end
196196

197197
def tooltip
198-
render Docs::TooltipView.new
198+
render Views::Docs::TooltipView.new
199199
end
200200

201201
def typography
202-
render Docs::TypographyView.new
202+
render Views::Docs::TypographyView.new
203203
end
204204
end

app/controllers/errors_controller.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,10 @@ class ErrorsController < ApplicationController
44
layout -> { ErrorsLayout }
55

66
def not_found
7-
render Errors::NotFoundView.new, status: :not_found
7+
render Views::Errors::NotFoundView.new, status: :not_found
88
end
99

1010
def internal_server_error
11-
render Errors::InternalServerErrorView.new, status: :internal_server_error
11+
render Views::Errors::InternalServerErrorView.new, status: :internal_server_error
1212
end
1313
end

app/controllers/pages_controller.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,6 @@ class PagesController < ApplicationController
44
layout -> { PagesLayout }
55

66
def home
7-
render Pages::HomeView.new
7+
render Views::Pages::HomeView.new
88
end
99
end

app/controllers/themes_controller.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,6 @@ class ThemesController < ApplicationController
55

66
# GET /themes/:theme
77
def show
8-
render Themes::ShowView.new(theme: params[:theme])
8+
render Views::Themes::ShowView.new(theme: params[:theme])
99
end
1010
end

app/views/application_view.rb

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

app/views/base.rb

Lines changed: 7 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -1,33 +1,11 @@
1-
class Base < Phlex::HTML
2-
include Components
3-
include RubyUI
1+
class Views::Base < Components::Base
2+
include ApplicationHelper
43

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
4+
GITHUB_REPO_URL = "https://github.com/ruby-ui/ruby_ui/"
5+
GITHUB_FILE_URL = "#{GITHUB_REPO_URL}blob/main/"
116

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-
{}
7+
def before_template
8+
Docs::VisualCodeExample.reset_collected_code
9+
super
3210
end
3311
end

app/views/docs/accordion_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::AccordionView < ApplicationView
3+
class Views::Docs::AccordionView < Views::Base
44
def view_template
55
div(class: "max-w-2xl mx-auto w-full py-10 space-y-10") do
66
component = "Accordion"

app/views/docs/alert_dialog_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::AlertDialogView < ApplicationView
3+
class Views::Docs::AlertDialogView < Views::Base
44
def view_template
55
component = "AlertDialog"
66
div(class: "max-w-2xl mx-auto w-full py-10 space-y-10") do

app/views/docs/alert_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::AlertView < ApplicationView
3+
class Views::Docs::AlertView < Views::Base
44
def view_template
55
component = "Alert"
66
div(class: "max-w-2xl mx-auto w-full py-10 space-y-10") do

app/views/docs/aspect_ratio_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::AspectRatioView < ApplicationView
3+
class Views::Docs::AspectRatioView < Views::Base
44
def view_template
55
component = "AspectRatio"
66
div(class: "max-w-2xl mx-auto w-full py-10 space-y-10") do

0 commit comments

Comments
 (0)