Skip to content

OpenProject is the leading open source project management software for product, project and portfolio management. A powerful Jira alternative with agile planning, issue tracking, roadmaps, Gantt charts, time tracking, collaboration features, and more. Available on premises or in the cloud. ⭐ Star us on GitHub

Declare custom inputs for lookbook

Oliver Güntherd52e8ec2049d
diff --git a/app/views/lookbook/previews/inputs/_medium_octicon.html.erb b/app/views/lookbook/previews/inputs/_medium_octicon.html.erb
new file mode 100644
index 00000000000..18c4110cd7d
--- /dev/null
+++ b/app/views/lookbook/previews/inputs/_medium_octicon.html.erb
@@ -0,0 +1,5 @@
+<% octicons = Octicons::OCTICON_SYMBOLS.keys.select do |key| %>
+ <% Octicons::OCTICON_SYMBOLS[key]["heights"].include?("24") %>
+<% end %>
+
+<%= select_tag(name, options_for_select([:none, *octicons], value), **input_options, "x-model": "value") %>
diff --git a/config/initializers/lookbook.rb b/config/initializers/lookbook.rb
index d6d167b170b..29221f91719 100644
--- a/config/initializers/lookbook.rb
+++ b/config/initializers/lookbook.rb
@@ -22,4 +22,8 @@ Rails.application.configure do
# Show notes first, all other panels next
config.lookbook.preview_inspector.drawer_panels = [:notes, "*"]
config.lookbook.ui_theme = "blue"
+
+ # Add custom inputs
+ Lookbook.add_input_type(:octicon, "lookbook/previews/inputs/octicon")
+ Lookbook.add_input_type(:medium_octicon, "lookbook/previews/inputs/medium_octicon")
end