Skip to content

Commit 27e8fb7

Browse files
authored
Update manual instructions to install components (#179)
1 parent e6b2e5b commit 27e8fb7

File tree

7 files changed

+384
-84
lines changed

7 files changed

+384
-84
lines changed

app/assets/stylesheets/application.tailwind.css

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -49,11 +49,6 @@
4949
--warning-foreground: hsl(0 0% 100%);
5050
--success: hsl(87 100% 37%);
5151
--success-foreground: hsl(0 0% 100%);
52-
53-
/* Container settings */
54-
--container-center: true;
55-
--container-padding: hsl(2rem);
56-
--container-max-width-2xl: hsl(1400px);
5752
}
5853

5954
.dark {
@@ -142,6 +137,13 @@
142137
--color-success-foreground: var(--success-foreground);
143138
}
144139

140+
/* Container settings */
141+
@utility container {
142+
margin-inline: auto;
143+
padding-inline: 2rem;
144+
max-width: 1400px;
145+
}
146+
145147
@layer base {
146148
* {
147149
@apply border-border outline-ring/50;

app/components/component_setup/manual_steps.rb

Lines changed: 10 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,7 @@ def view_template
1515
Heading(level: 4, class: "pb-4 border-b") { "Manual installation" }
1616

1717
render Steps::Builder.new do |steps|
18-
main_component_step(steps)
19-
related_component_steps(steps)
18+
component_steps(steps)
2019
stimulus_controller_steps(steps)
2120
js_dependencies_steps(steps)
2221
ruby_dependencies_steps(steps)
@@ -25,47 +24,25 @@ def view_template
2524
end
2625
end
2726

28-
def main_component_step(steps)
29-
main_component_code = RubyUI::FileManager.main_component_code(component_name)
27+
def component_steps(steps)
28+
component_file_paths = RubyUI::FileManager.component_file_paths(component_name)
3029

31-
return if main_component_code.blank?
30+
component_file_paths.each do |component_path|
31+
component_class = component_path.split("/").last.delete_suffix(".rb").camelcase
32+
component_file_name = component_path.split("/").last
33+
component_code = RubyUI::FileManager.component_code(component_path)
3234

33-
steps.add_step do
34-
render Steps::Container do
35-
Text(size: "4", weight: "semibold") do
36-
plain "Add "
37-
InlineCode(class: "whitespace-nowrap") { "RubyUI::#{component_name.camelcase}" }
38-
plain " to "
39-
InlineCode(class: "whitespace-nowrap") { "app/components/ruby_ui/#{component_name.underscore}.rb" }
40-
end
41-
42-
div(class: "w-full") do
43-
Codeblock(main_component_code, syntax: :ruby)
44-
end
45-
end
46-
end
47-
end
48-
49-
def related_component_steps(steps)
50-
related_component_file_paths = RubyUI::FileManager.related_component_file_paths(component_name)
51-
52-
return if related_component_file_paths.empty?
53-
54-
related_component_file_paths.each do |component_path|
55-
related_component_class = component_path.split("/").last.delete_suffix(".rb").camelcase
56-
related_component_file_name = component_path.split("/").last
57-
related_component_code = RubyUI::FileManager.component_code(component_path)
5835
steps.add_step do
5936
render Steps::Container do
6037
Text(size: "4", weight: "semibold") do
6138
plain "Add "
62-
InlineCode(class: "whitespace-nowrap") { "RubyUI::#{related_component_class}" }
39+
InlineCode(class: "whitespace-nowrap") { "RubyUI::#{component_class}" }
6340
plain " to "
64-
InlineCode(class: "whitespace-nowrap") { "app/components/ruby_ui/#{component_name.underscore}/#{related_component_file_name}" }
41+
InlineCode(class: "whitespace-nowrap") { "app/components/ruby_ui/#{component_name.underscore}/#{component_file_name}" }
6542
end
6643

6744
div(class: "w-full") do
68-
Codeblock(related_component_code, syntax: :ruby)
45+
Codeblock(component_code, syntax: :ruby)
6946
end
7047
end
7148
end

app/lib/ruby_ui/file_manager.rb

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -10,13 +10,8 @@ def component_code(file_path)
1010
File.read(file_path) if File.exist?(file_path)
1111
end
1212

13-
def main_component_file_path(component_name)
14-
component_name = component_name.underscore
15-
File.join(component_folder(component_name), "#{component_name}.rb")
16-
end
17-
18-
def related_component_file_paths(component_name)
19-
Dir[File.join(component_folder(component_name), "*.rb")] - [main_component_file_path(component_name)]
13+
def component_file_paths(component_name)
14+
Dir[File.join(component_folder(component_name), "*.rb")]
2015
end
2116

2217
def stimulus_controller_file_paths(component_name)

app/views/docs/installation/rails_bundler.rb

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -277,11 +277,6 @@ def default_attrs
277277
--warning-foreground: hsl(0 0% 100%);
278278
--success: hsl(87 100% 37%);
279279
--success-foreground: hsl(0 0% 100%);
280-
281-
/* Container settings */
282-
--container-center: true;
283-
--container-padding: hsl(2rem);
284-
--container-max-width-2xl: hsl(1400px);
285280
}
286281
287282
.dark {
@@ -370,6 +365,14 @@ def default_attrs
370365
--color-success-foreground: var(--success-foreground);
371366
}
372367
368+
/* Container settings */
369+
@utility container {
370+
margin-inline: auto;
371+
padding-inline: 2rem;
372+
max-width: 1400px;
373+
}
374+
375+
373376
@layer base {
374377
* {
375378
@apply border-border outline-ring/50;

app/views/docs/installation/rails_importmaps.rb

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -278,11 +278,6 @@ def default_attrs
278278
--warning-foreground: hsl(0 0% 100%);
279279
--success: hsl(87 100% 37%);
280280
--success-foreground: hsl(0 0% 100%);
281-
282-
/* Container settings */
283-
--container-center: true;
284-
--container-padding: hsl(2rem);
285-
--container-max-width-2xl: hsl(1400px);
286281
}
287282
288283
.dark {
@@ -371,6 +366,13 @@ def default_attrs
371366
--color-success-foreground: var(--success-foreground);
372367
}
373368
369+
/* Container settings */
370+
@utility container {
371+
margin-inline: auto;
372+
padding-inline: 2rem;
373+
max-width: 1400px;
374+
}
375+
374376
@layer base {
375377
* {
376378
@apply border-border outline-ring/50;

package.json

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
"@floating-ui/dom": "^1.6.13",
66
"@hotwired/stimulus": "3.2.2",
77
"@hotwired/turbo-rails": "8.0.13",
8+
"@tailwindcss/cli": "4.0.14",
89
"@tailwindcss/forms": "^0.5.10",
910
"@tailwindcss/typography": "^0.5.16",
1011
"autoprefixer": "10.4.21",
@@ -17,9 +18,7 @@
1718
"maska": "^3.1.1",
1819
"motion": "^12.6.0",
1920
"mustache": "^4.2.0",
20-
"postcss": "8.5.3",
21-
"tailwindcss": "4.0.15",
22-
"tailwindcss-animate": "1.0.7",
21+
"tailwindcss": "4.0.14",
2322
"tippy.js": "^6.3.7",
2423
"tw-animate-css": "^1.2.4"
2524
},

0 commit comments

Comments
 (0)