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
Ruby agile-developmentangularbcfboardsbug-trackerganttgantt-chartifcissue-trackerjira-alternativekanbanopenprojectproduct-managementproject-managementproject-planningroadmaprubyscrumtimelineworkflows
First draft for the docs on the collapsibleSection
Henriette Darge8e7f8636cda4
diff --git a/lookbook/docs/components/collapsible-section.md.erb b/lookbook/docs/components/collapsible-section.md.erbnew file mode 100644index 00000000000..b487913b781--- /dev/null+++ b/lookbook/docs/components/collapsible-section.md.erb@@ -0,0 +1,33 @@+The <strong>CollapsibleSection</strong> is awesome :)++<%= embed Patterns::CollapsibleSectionPreview, :default %>++## Anatomy++The CollapsibleSection consists of two basic parts: the title and the content that shall be collapsed. However, for the title there are some additional options available:++- The title+ - A caption (optional): Text, shown next to the title in a subtle colour+ - Additional information (optional): Free content, shown at the end of the title row+- The collapsible content area++## Best practices++**Do**++**Don't**++- Don't use the CollapsibleSection if you want to collapse the content of a BorderBox. Use the [BorderBox::CollapsibleHeader](./tables/border-box-table.md.erb) instead.+- Don't use too complex elements for the `additional_information` slot. It is designed for small texts or an individual button.++## Used in++* The time report overview++## Technical notes++<%= embed Patterns::CollapsibleSectionPreview, :full_example, panels: %i[source] %>++## Examples++For detailed examples have a look at the other [preview examples](/lookbook/inspect/primer/open_project/collapsible_section/default) of the component.diff --git a/lookbook/previews/patterns/collapsible_section_preview.rb b/lookbook/previews/patterns/collapsible_section_preview.rbnew file mode 100644index 00000000000..21129259b74--- /dev/null+++ b/lookbook/previews/patterns/collapsible_section_preview.rb@@ -0,0 +1,16 @@+# frozen_string_literal: true++module Patterns+ # @hidden+ class CollapsibleSectionPreview < ViewComponent::Preview+ # @display min_height 300px+ def default+ render_with_template+ end++ # @display min_height 300px+ def full_example+ render_with_template+ end+ end+enddiff --git a/lookbook/previews/patterns/collapsible_section_preview/default.html.erb b/lookbook/previews/patterns/collapsible_section_preview/default.html.erbnew file mode 100644index 00000000000..2bc7d637738--- /dev/null+++ b/lookbook/previews/patterns/collapsible_section_preview/default.html.erb@@ -0,0 +1,36 @@+<%+ default_form = Class.new(ApplicationForm) do+ form do |f|+ f.text_field(+ name: :ultimate_answer,+ label: "Ultimate answer",+ required: true,+ caption: "The answer to life, the universe, and everything",+ input_width: :medium+ )++ f.select_list(+ name: "cities",+ label: "Cool cities",+ caption: "Select your favorite!",+ include_blank: true,+ input_width: :small+ ) do |city_list|+ city_list.option(label: "Lopez Island", value: "lopez_island")+ city_list.option(label: "Bellevue", value: "bellevue")+ city_list.option(label: "Seattle", value: "seattle")+ end+ end+ end+%>++<%=+ render(Primer::OpenProject::CollapsibleSection.new) do |component|+ component.with_title { "A collapsible form" }+ component.with_collapsible_content do+ primer_form_with(url: "/foo") do |f|+ render(default_form.new(f))+ end+ end+ end+%>diff --git a/lookbook/previews/patterns/collapsible_section_preview/full_example.html.erb b/lookbook/previews/patterns/collapsible_section_preview/full_example.html.erbnew file mode 100644index 00000000000..20f5a715130--- /dev/null+++ b/lookbook/previews/patterns/collapsible_section_preview/full_example.html.erb@@ -0,0 +1,45 @@+<%+ default_form = Class.new(ApplicationForm) do+ form do |f|+ f.text_field(+ name: :ultimate_answer,+ label: "Ultimate answer",+ required: true,+ caption: "The answer to life, the universe, and everything",+ input_width: :medium+ )++ f.select_list(+ name: "cities",+ label: "Cool cities",+ caption: "Select your favorite!",+ include_blank: true,+ input_width: :small+ ) do |city_list|+ city_list.option(label: "Lopez Island", value: "lopez_island")+ city_list.option(label: "Bellevue", value: "bellevue")+ city_list.option(label: "Seattle", value: "seattle")+ end+ end+ end+%>++<%= render(Primer::OpenProject::CollapsibleSection.new) do |component| %>+ <% component.with_title { "A collapsible form" } %>+ <% component.with_caption { "(click me)" } %>+ <% component.with_additional_information do %>+ <%= render(Primer::Alpha::ActionMenu.new) do |menu|+ menu.with_show_button(icon: "kebab-horizontal", "aria-label": "More", scheme: :invisible)+ menu.with_item(tag: :a, label: "Foo", href: "/foo") do |item|+ item.with_leading_visual_icon(icon: :pencil)+ "foo"+ end+ end %>+ <% end %>+ <% component.with_collapsible_content do %>+ <%= render(Primer::Alpha::Banner.new(mb: 3)) { "The collapsible section can contain everything you want" } %>+ <%= primer_form_with(url: "/foo") do |f| %>+ <% render(default_form.new(f)) %>+ <% end %>+ <% end %>+<% end %>