openproject-primer_view_components 0.93.0 → 0.94.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 7e48940c0021996de6eb9ad0b8f1e44489e89e3056140c3e4f2a5be78432c073
4
- data.tar.gz: 95c12fdeb352cb1d407960cfbfe4035d4a1128c8b946443fa182e70bccba87b4
3
+ metadata.gz: 1926304244eb14ceecf9e3adaec9f5fca51e1d190c8469e88af44405f195a17f
4
+ data.tar.gz: eeeffe1a4a340e60e10f34f913437021f1ad9a1c88071697b32ab6623f810c8d
5
5
  SHA512:
6
- metadata.gz: 381f5e7266e0f430811a6b287fdcbbce26729ad669c081155d74fefc9213a5c4b97b6d71115541a8a153e0ecc95d8c01b52d7cef829bc1a12388ef519a608749
7
- data.tar.gz: a923bfd97e866e1e927ea4c5750f44fec63e709651452be1f36a11d580d7de106d73fee7f29ba832b35c5bf9f0ed9216b3db795b15a968a903ed2fc95e79b378
6
+ metadata.gz: '080f8e8920edf48c4c3b553743b9e86f4f7a52f94f4c174acbe39df14affc19da9b8a1cc99d240984cdf128814a3967d02516bb09c5f78dd52850c2e42ff7730'
7
+ data.tar.gz: 13de414fb9e160638c51530e62ffe70e0c4152ed0ae8af5941dd617ed7d8b565c29a5649f46c7a06e64a6f618363da84a6d7561ee9dfdba3fa5c4bfb2bae5707
data/CHANGELOG.md CHANGED
@@ -1,5 +1,11 @@
1
1
  # CHANGELOG
2
2
 
3
+ ## 0.94.0
4
+
5
+ ### Minor Changes
6
+
7
+ - [#539](https://github.com/opf/primer_view_components/pull/539) [`3ddf0b2`](https://github.com/opf/primer_view_components/commit/3ddf0b2a460603fafa413e0cba303c3c81c4348b) Thanks [@mrmir](https://github.com/mrmir)! - Add a `:locked` state to the `collapsed` argument of `Primer::OpenProject::CollapsibleSection` to lock the section permanently open and disable the toggle
8
+
3
9
  ## 0.93.0
4
10
 
5
11
  ### Minor Changes
@@ -1,8 +1,6 @@
1
1
  <%= render(Primer::BaseComponent.new(**@system_arguments)) do %>
2
2
  <%= render(Primer::OpenProject::FlexLayout.new) do |flex| %>
3
- <%= flex.with_row(classes: "CollapsibleSection--triggerArea",
4
- id: @title_id,
5
- data: { action: "click:collapsible-section#toggle" }) do %>
3
+ <%= flex.with_row(**trigger_arguments) do %>
6
4
  <%= render(Primer::OpenProject::FlexLayout.new(display: :flex, align_items: :center)) do |header| %>
7
5
  <%= header.with_column(id: @heading_id) do %>
8
6
  <%= title %>
@@ -10,10 +8,12 @@
10
8
  <%= header.with_column do %>
11
9
  <%= caption %>
12
10
  <% end %>
13
- <%= header.with_column do %>
14
- <%= render(Primer::Beta::Button.new(**@toggle_button_arguments)) do %>
15
- <%= render(Primer::Beta::Octicon.new(icon: "chevron-up", hidden: @collapsed, data: { target: "collapsible-section.arrowUp" })) %>
16
- <%= render(Primer::Beta::Octicon.new(icon: "chevron-down", hidden: !@collapsed, data: { target: "collapsible-section.arrowDown" })) %>
11
+ <% if @collapsible %>
12
+ <%= header.with_column do %>
13
+ <%= render(Primer::Beta::Button.new(**@toggle_button_arguments)) do %>
14
+ <%= render(Primer::Beta::Octicon.new(icon: "chevron-up", hidden: @collapsed, data: { target: "collapsible-section.arrowUp" })) %>
15
+ <%= render(Primer::Beta::Octicon.new(icon: "chevron-down", hidden: !@collapsed, data: { target: "collapsible-section.arrowDown" })) %>
16
+ <% end %>
17
17
  <% end %>
18
18
  <% end %>
19
19
  <%= header.with_column(flex: 1, text_align: :right) do %>
@@ -47,14 +47,19 @@ module Primer
47
47
  Primer::BaseComponent.new(tag: :div, **system_arguments)
48
48
  }
49
49
 
50
+ COLLAPSED_OPTIONS = [false, true, :locked].freeze
51
+
50
52
  # @param id [String] The unique ID of the collapsible section.
51
- # @param collapsed [Boolean] Whether the section is collapsed on initial render.
53
+ # @param collapsed [Boolean, Symbol] The initial state of the section. `false` renders it open and toggleable, `true` renders it collapsed and toggleable, and `:locked` keeps it permanently open with the toggle disabled.
52
54
  # @param system_arguments [Hash] <%= link_to_system_arguments_docs %>
53
55
  def initialize(id: self.class.generate_id, collapsed: false, **system_arguments)
56
+ collapsed = fetch_or_fallback(COLLAPSED_OPTIONS, collapsed, false)
57
+
54
58
  @title_id = "#{id}-title"
55
59
  @content_id = "#{id}-content"
56
60
  @heading_id = "#{id}-heading"
57
- @collapsed = collapsed
61
+ @collapsible = collapsed != :locked
62
+ @collapsed = collapsed == true
58
63
 
59
64
  @system_arguments = deny_tag_argument(**system_arguments)
60
65
  @system_arguments[:tag] = "collapsible-section"
@@ -78,6 +83,16 @@ module Primer
78
83
 
79
84
  private
80
85
 
86
+ def trigger_arguments
87
+ return { id: @title_id } unless @collapsible
88
+
89
+ {
90
+ classes: "CollapsibleSection--triggerArea",
91
+ id: @title_id,
92
+ data: { action: "click:collapsible-section#toggle" }
93
+ }
94
+ end
95
+
81
96
  def render?
82
97
  raise ArgumentError, "Title must be present" unless title.present?
83
98
  raise ArgumentError, "Collapsible content must be present" unless collapsible_content.present?
@@ -5,7 +5,7 @@ module Primer
5
5
  module ViewComponents
6
6
  module VERSION
7
7
  MAJOR = 0
8
- MINOR = 93
8
+ MINOR = 94
9
9
  PATCH = 0
10
10
 
11
11
  STRING = [MAJOR, MINOR, PATCH].join(".")
@@ -0,0 +1,10 @@
1
+ <%= render(Primer::OpenProject::CollapsibleSection.new(collapsed: :locked)) do |section| %>
2
+ <% section.with_title { "Feedback" } %>
3
+ <% section.with_collapsible_content do %>
4
+ <%= render(Primer::Alpha::Banner.new(mb: 3)) { "Please take one minute time to answer this question" } %>
5
+ <%= primer_form_with(url: "/foo") do |f| %>
6
+ <%= render(RadioButtonGroupForm.new(f)) %>
7
+ <% end %>
8
+
9
+ <% end %>
10
+ <% end %>
@@ -1,4 +1,4 @@
1
- <%= render(Primer::OpenProject::CollapsibleSection.new) do |section| %>
1
+ <%= render(Primer::OpenProject::CollapsibleSection.new(collapsed: collapsed)) do |section| %>
2
2
  <% section.with_title { "Advanced settings" } %>
3
3
 
4
4
  <% if caption.present? %>
@@ -10,10 +10,12 @@ module Primer
10
10
  # @label Playground
11
11
  # @param caption [String] text
12
12
  # @param show_additional_information [Boolean] toggle
13
- def playground(caption: "(optional)", show_additional_information: false)
13
+ # @param collapsed [String] select ["false", "true", "locked"]
14
+ def playground(caption: "(optional)", show_additional_information: false, collapsed: "false")
15
+ collapsed = { "false" => false, "true" => true, "locked" => :locked }.fetch(collapsed)
14
16
  render_with_template(
15
17
  template: "primer/open_project/collapsible_section_preview/playground",
16
- locals: { caption: caption, show_additional_information: show_additional_information}
18
+ locals: { caption: caption, show_additional_information: show_additional_information, collapsed: collapsed }
17
19
  )
18
20
  end
19
21
 
@@ -53,6 +55,15 @@ module Primer
53
55
  )
54
56
  end
55
57
 
58
+ # @label Non-collapsible
59
+ # @snapshot
60
+ def non_collapsible
61
+ render_with_template(
62
+ template: "primer/open_project/collapsible_section_preview/non_collapsible",
63
+ locals: { }
64
+ )
65
+ end
66
+
56
67
  # @label With link in title
57
68
  # @hidden
58
69
  def with_link_in_title
@@ -5961,9 +5961,9 @@
5961
5961
  },
5962
5962
  {
5963
5963
  "name": "collapsed",
5964
- "type": "Boolean",
5964
+ "type": "Boolean, Symbol",
5965
5965
  "default": "`false`",
5966
- "description": "Whether the section is collapsed on initial render."
5966
+ "description": "The initial state of the section. `false` renders it open and toggleable, `true` renders it collapsed and toggleable, and `:locked` keeps it permanently open with the toggle disabled."
5967
5967
  },
5968
5968
  {
5969
5969
  "name": "system_arguments",
@@ -1747,6 +1747,11 @@
1747
1747
  "GeneratedSlotMethods": "Primer::OpenProject::BorderGrid::Cell::GeneratedSlotMethods"
1748
1748
  },
1749
1749
  "Primer::OpenProject::CollapsibleSection": {
1750
+ "COLLAPSED_OPTIONS": [
1751
+ false,
1752
+ true,
1753
+ "locked"
1754
+ ],
1750
1755
  "GeneratedSlotMethods": "Primer::OpenProject::CollapsibleSection::GeneratedSlotMethods",
1751
1756
  "TITLE_TAG_FALLBACK": "h2",
1752
1757
  "TITLE_TAG_OPTIONS": [
@@ -19614,9 +19614,9 @@
19614
19614
  },
19615
19615
  {
19616
19616
  "name": "collapsed",
19617
- "type": "Boolean",
19617
+ "type": "Boolean, Symbol",
19618
19618
  "default": "`false`",
19619
- "description": "Whether the section is collapsed on initial render."
19619
+ "description": "The initial state of the section. `false` renders it open and toggleable, `true` renders it collapsed and toggleable, and `:locked` keeps it permanently open with the toggle disabled."
19620
19620
  },
19621
19621
  {
19622
19622
  "name": "system_arguments",
@@ -19748,6 +19748,19 @@
19748
19748
  ]
19749
19749
  }
19750
19750
  },
19751
+ {
19752
+ "preview_path": "primer/open_project/collapsible_section/non_collapsible",
19753
+ "name": "non_collapsible",
19754
+ "snapshot": "true",
19755
+ "skip_rules": {
19756
+ "wont_fix": [
19757
+ "region"
19758
+ ],
19759
+ "will_fix": [
19760
+ "color-contrast"
19761
+ ]
19762
+ }
19763
+ },
19751
19764
  {
19752
19765
  "preview_path": "primer/open_project/collapsible_section/with_link_in_title",
19753
19766
  "name": "with_link_in_title",
data/static/previews.json CHANGED
@@ -8824,6 +8824,19 @@
8824
8824
  ]
8825
8825
  }
8826
8826
  },
8827
+ {
8828
+ "preview_path": "primer/open_project/collapsible_section/non_collapsible",
8829
+ "name": "non_collapsible",
8830
+ "snapshot": "true",
8831
+ "skip_rules": {
8832
+ "wont_fix": [
8833
+ "region"
8834
+ ],
8835
+ "will_fix": [
8836
+ "color-contrast"
8837
+ ]
8838
+ }
8839
+ },
8827
8840
  {
8828
8841
  "preview_path": "primer/open_project/collapsible_section/with_link_in_title",
8829
8842
  "name": "with_link_in_title",
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: openproject-primer_view_components
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.93.0
4
+ version: 0.94.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - GitHub Open Source
@@ -1228,6 +1228,7 @@ files:
1228
1228
  - previews/primer/open_project/collapsible_section_preview.rb
1229
1229
  - previews/primer/open_project/collapsible_section_preview/collapsed.html.erb
1230
1230
  - previews/primer/open_project/collapsible_section_preview/default.html.erb
1231
+ - previews/primer/open_project/collapsible_section_preview/non_collapsible.html.erb
1231
1232
  - previews/primer/open_project/collapsible_section_preview/playground.html.erb
1232
1233
  - previews/primer/open_project/collapsible_section_preview/with_additional_information.html.erb
1233
1234
  - previews/primer/open_project/collapsible_section_preview/with_caption.html.erb