Skip to content

Commit 841577e

Browse files
committed
fix(docs): restore header theme and command search
1 parent 1a57f31 commit 841577e

4 files changed

Lines changed: 39 additions & 7 deletions

File tree

docs/app/assets/stylesheets/application.tailwind.css

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33
@plugin "@tailwindcss/forms";
44
@plugin "@tailwindcss/typography";
55

6+
/* Include classes from the local gem components rendered by the docs app. */
7+
@source "../../../../gem/lib/ruby_ui";
68

79
@import "tw-animate-css";
810

docs/app/components/shared/logo.rb

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,16 @@ def view_template
99
img(src: image_url("logo.svg"), class: "h-4 block dark:hidden")
1010
img(src: image_url("logo_dark.svg"), class: "h-4 hidden dark:block")
1111
span(class: "sr-only") { "RubyUI" }
12-
Badge(class: "ml-2 whitespace-nowrap bg-black text-white hover:bg-black/90 px-1.5 py-0.5 rounded-full text-xs font-semibold") { "1.0" }
12+
Badge(class: "ml-2 whitespace-nowrap bg-black text-white hover:bg-black/90 px-1.5 py-0.5 rounded-full text-xs font-semibold") { ruby_ui_version }
1313
}
1414
end
1515
end
16+
17+
private
18+
19+
def ruby_ui_version
20+
RubyUI::VERSION.split(".").first(2).join(".")
21+
end
1622
end
1723
end
1824
end

docs/app/javascript/controllers/ruby_ui/command_controller.js

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,18 +13,30 @@ export default class extends Controller {
1313
};
1414

1515
connect() {
16+
this.selectedIndex = -1;
17+
18+
if (!this.hasInputTarget) {
19+
return;
20+
}
21+
1622
this.inputTarget.focus();
1723
this.searchIndex = this.buildSearchIndex();
1824
this.toggleVisibility(this.emptyTargets, false);
19-
this.selectedIndex = -1;
2025

21-
if (this.openValue) {
26+
if (this.openValue && this.hasContentTarget) {
2227
this.open();
2328
}
2429
}
2530

2631
open(e) {
27-
e.preventDefault();
32+
if (e) {
33+
e.preventDefault();
34+
}
35+
36+
if (!this.hasContentTarget) {
37+
return;
38+
}
39+
2840
document.body.insertAdjacentHTML("beforeend", this.contentTarget.innerHTML);
2941
// prevent scroll on body
3042
document.body.classList.add("overflow-hidden");

gem/lib/ruby_ui/command/command_controller.js

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,18 +13,30 @@ export default class extends Controller {
1313
};
1414

1515
connect() {
16+
this.selectedIndex = -1;
17+
18+
if (!this.hasInputTarget) {
19+
return;
20+
}
21+
1622
this.inputTarget.focus();
1723
this.searchIndex = this.buildSearchIndex();
1824
this.toggleVisibility(this.emptyTargets, false);
19-
this.selectedIndex = -1;
2025

21-
if (this.openValue) {
26+
if (this.openValue && this.hasContentTarget) {
2227
this.open();
2328
}
2429
}
2530

2631
open(e) {
27-
e.preventDefault();
32+
if (e) {
33+
e.preventDefault();
34+
}
35+
36+
if (!this.hasContentTarget) {
37+
return;
38+
}
39+
2840
document.body.insertAdjacentHTML("beforeend", this.contentTarget.innerHTML);
2941
// prevent scroll on body
3042
document.body.classList.add("overflow-hidden");

0 commit comments

Comments
 (0)