openproject-primer_view_components 0.33.2 → 0.34.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: f7bdcb326cadec091def40e2f0b6754806a5bc294786350ada58edfcf13bf0a3
4
- data.tar.gz: 1be6868946518c85f884343dc2c25913c4ebb232b261c417ba7690fe7d488bef
3
+ metadata.gz: e62a6eaac97e4ba2f5888dcfcd25da23ec74671931265ca171e803ebd88a2010
4
+ data.tar.gz: de34a286c13348d3c36db855c4ec280f5fa7e99ed3ac712c2ed583a9e92a9f3a
5
5
  SHA512:
6
- metadata.gz: 33170e4ddbfdf49d9c682778d2bc0d35183c2496772b6114615aa0a8d0b387e71faca70ff4a88e455498acb3e07b496068504fdd1b51d06ace5ac6c7398c42bf
7
- data.tar.gz: 7d706e71b1077a8aafb00636d3e24b523970e614285f4f2e47ae0d6572e88f97eea55c508e314b93ada5492542a8b462d5853cf96ee66446b9ad558d30eb93e9
6
+ metadata.gz: a72a263f1b73f434c20c5be7d18b23d2af4f2eb9297ecadd2fa4da8430a9cff8fd196742bfc3ab500b874b76f439e63f825bfb18c6aa1f8c1d857c095817d77f
7
+ data.tar.gz: 147d78e64ada459d540f42720c72da9d2b8651519d7f2ee3cb2daf8465b98dd245487b59f944bc0cdd0c24e1ad290e98ae9c73bfaf5cc8e3bd2c5921ad84e2d4
data/CHANGELOG.md CHANGED
@@ -1,5 +1,11 @@
1
1
  # CHANGELOG
2
2
 
3
+ ## 0.34.0
4
+
5
+ ### Minor Changes
6
+
7
+ - [#128](https://github.com/opf/primer_view_components/pull/128) [`7b7955d`](https://github.com/opf/primer_view_components/commit/7b7955d41b0f4b0dcdc6bb4176fce383c5beae6a) Thanks [@oliverguenther](https://github.com/oliverguenther)! - Allow segmented control action in page header
8
+
3
9
  ## 0.33.2
4
10
 
5
11
  ### Patch Changes
@@ -3,6 +3,9 @@
3
3
  <div class="PageHeader-contextBar">
4
4
  <%= @parent_link %>
5
5
  <%= breadcrumbs %>
6
+ <% if @mobile_segmented_control %>
7
+ <%= render(@mobile_segmented_control, &@mobile_segmented_control_block) %>
8
+ <% end %>
6
9
  <% if render_mobile_menu? %>
7
10
  <%= render(@mobile_action_menu) do |menu| %>
8
11
  <% menu.with_show_button(icon: :"kebab-horizontal", size: :small, "aria-label": @mobile_menu_label) %>
@@ -141,6 +141,21 @@ module Primer
141
141
  component.new(**system_arguments)
142
142
  },
143
143
  },
144
+ segmented_control: {
145
+ renders: lambda { |**system_arguments, &block|
146
+ deny_tag_argument(**system_arguments)
147
+
148
+ system_arguments = set_action_arguments(system_arguments, scheme: DEFAULT_ACTION_SCHEME)
149
+ mobile_args = system_arguments.delete(:mobile_system_arguments) || {}
150
+ @mobile_segmented_control = Primer::Alpha::SegmentedControl.new(**system_arguments,
151
+ **mobile_args,
152
+ mr: 2,
153
+ display: %i[flex none])
154
+ @mobile_segmented_control_block = block
155
+
156
+ Primer::Alpha::SegmentedControl.new(**system_arguments)
157
+ },
158
+ },
144
159
  }
145
160
 
146
161
  # Optional leading action prepend the title
@@ -252,7 +267,7 @@ module Primer
252
267
 
253
268
  def set_action_arguments(system_arguments, scheme: nil)
254
269
  system_arguments[:ml] ||= 2
255
- system_arguments[:display] = [:none, :flex]
270
+ system_arguments[:display] = %i[none flex]
256
271
  system_arguments[:size] = :medium
257
272
  system_arguments[:scheme] = scheme unless scheme.nil?
258
273
  system_arguments[:classes] = class_names(
@@ -5,8 +5,8 @@ module Primer
5
5
  module ViewComponents
6
6
  module VERSION
7
7
  MAJOR = 0
8
- MINOR = 33
9
- PATCH = 2
8
+ MINOR = 34
9
+ PATCH = 0
10
10
 
11
11
  STRING = [MAJOR, MINOR, PATCH].join(".")
12
12
  end
@@ -40,7 +40,7 @@ module Primer
40
40
  with_leading_action: with_leading_action,
41
41
  with_actions: with_actions,
42
42
  breadcrumb_items: breadcrumb_items,
43
- with_tab_nav: with_tab_nav})
43
+ with_tab_nav: with_tab_nav })
44
44
  end
45
45
 
46
46
  # @label Large title
@@ -71,8 +71,8 @@ module Primer
71
71
  component.with_breadcrumbs([{ href: "/foo", text: "Foo" }, { href: "/bar", text: "Bar" }, "Baz"])
72
72
 
73
73
  component.with_action_button(mobile_icon: "star", mobile_label: "Star") do |button|
74
- button.with_leading_visual_icon(icon: "star")
75
- "Star"
74
+ button.with_leading_visual_icon(icon: "star")
75
+ "Star"
76
76
  end
77
77
  component.with_action_menu(menu_arguments: { anchor_align: :end },
78
78
  button_arguments: { button_block: callback }) do |menu|
@@ -123,7 +123,6 @@ module Primer
123
123
  end
124
124
  end
125
125
 
126
-
127
126
  # @label With a single action
128
127
  # The single action will not be transformed into a menu on mobile, but remains in a smaller variant
129
128
  def single_action
@@ -180,13 +179,62 @@ module Primer
180
179
  header.with_description { "Last updated 5 minutes ago by XYZ." }
181
180
  header.with_tab_nav(label: "label") do |nav|
182
181
  Array.new(3) do |i|
183
- nav.with_tab(selected: i.zero? , href: "#") do |tab|
182
+ nav.with_tab(selected: i.zero?, href: "#") do |tab|
184
183
  tab.with_text { "Tab #{i + 1}" }
185
184
  end
186
185
  end
187
186
  end
188
187
  end
189
188
  end
189
+
190
+ # @label With a SegmentedControl
191
+ def segmented_control
192
+ render(Primer::OpenProject::PageHeader.new) do |component|
193
+ component.with_title { "Here's a segmented control" }
194
+ component.with_breadcrumbs(["Baz"])
195
+
196
+ component.with_action_segmented_control("aria-label": "Segmented control") do |control|
197
+ control.with_item(label: "Preview", icon: :eye, selected: true)
198
+ control.with_item(label: "Raw", icon: :"file-code")
199
+ end
200
+
201
+ component.with_action_button(mobile_icon: "star", mobile_label: "Star") do |button|
202
+ button.with_leading_visual_icon(icon: "star")
203
+ "Star"
204
+ end
205
+
206
+ callback = lambda do |button|
207
+ button.with_leading_visual_icon(icon: :gear)
208
+ "Settings"
209
+ end
210
+
211
+ component.with_action_menu(menu_arguments: { anchor_align: :end },
212
+ button_arguments: { button_block: callback }) do |menu|
213
+ menu.with_item(label: "Subitem 1") do |item|
214
+ item.with_leading_visual_icon(icon: :paste)
215
+ end
216
+ menu.with_item(label: "Subitem 2") do |item|
217
+ item.with_leading_visual_icon(icon: :log)
218
+ end
219
+ end
220
+ end
221
+ end
222
+
223
+ # @label With mobile icons-only SegmentedControl
224
+ def segmented_control_mobile_icons
225
+ render(Primer::OpenProject::PageHeader.new) do |component|
226
+ component.with_title { "Here's a segmented control" }
227
+ component.with_breadcrumbs(["Baz"])
228
+
229
+ component.with_action_segmented_control(
230
+ "aria-label": "Segmented control",
231
+ mobile_system_arguments: { hide_labels: true }
232
+ ) do |control|
233
+ control.with_item(label: "Preview", icon: :eye, selected: true)
234
+ control.with_item(label: "Raw", icon: :"file-code")
235
+ end
236
+ end
237
+ end
190
238
  end
191
239
  end
192
240
  end
@@ -16891,6 +16891,32 @@
16891
16891
  "color-contrast"
16892
16892
  ]
16893
16893
  }
16894
+ },
16895
+ {
16896
+ "preview_path": "primer/open_project/page_header/segmented_control",
16897
+ "name": "segmented_control",
16898
+ "snapshot": "false",
16899
+ "skip_rules": {
16900
+ "wont_fix": [
16901
+ "region"
16902
+ ],
16903
+ "will_fix": [
16904
+ "color-contrast"
16905
+ ]
16906
+ }
16907
+ },
16908
+ {
16909
+ "preview_path": "primer/open_project/page_header/segmented_control_mobile_icons",
16910
+ "name": "segmented_control_mobile_icons",
16911
+ "snapshot": "false",
16912
+ "skip_rules": {
16913
+ "wont_fix": [
16914
+ "region"
16915
+ ],
16916
+ "will_fix": [
16917
+ "color-contrast"
16918
+ ]
16919
+ }
16894
16920
  }
16895
16921
  ],
16896
16922
  "subcomponents": [
data/static/previews.json CHANGED
@@ -5429,6 +5429,32 @@
5429
5429
  "color-contrast"
5430
5430
  ]
5431
5431
  }
5432
+ },
5433
+ {
5434
+ "preview_path": "primer/open_project/page_header/segmented_control",
5435
+ "name": "segmented_control",
5436
+ "snapshot": "false",
5437
+ "skip_rules": {
5438
+ "wont_fix": [
5439
+ "region"
5440
+ ],
5441
+ "will_fix": [
5442
+ "color-contrast"
5443
+ ]
5444
+ }
5445
+ },
5446
+ {
5447
+ "preview_path": "primer/open_project/page_header/segmented_control_mobile_icons",
5448
+ "name": "segmented_control_mobile_icons",
5449
+ "snapshot": "false",
5450
+ "skip_rules": {
5451
+ "wont_fix": [
5452
+ "region"
5453
+ ],
5454
+ "will_fix": [
5455
+ "color-contrast"
5456
+ ]
5457
+ }
5432
5458
  }
5433
5459
  ]
5434
5460
  },
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.33.2
4
+ version: 0.34.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - GitHub Open Source
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2024-06-07 00:00:00.000000000 Z
12
+ date: 2024-06-13 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: actionview