openproject-primer_view_components 0.62.0 → 0.63.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: 4929f92b5de2ff7680b004eda5619b18549a1205583b53e152d3ca1b53699238
4
- data.tar.gz: f41e2230548ff1bd6dfe7e1560a78b3470c082e36d295c648f993745956dfa9c
3
+ metadata.gz: 1a157780e81b4a84c0814e2b933b4f2e2fcf6ad74d549353b058fc8012b57fea
4
+ data.tar.gz: 3ab915e6a83249d059e8a95b6a21e3739c8ac6b73bf22486ae2601020e2971e3
5
5
  SHA512:
6
- metadata.gz: 9541c3e5adb821cb65525fd20ad425cedad0235f3aaeca2dd0ceb8fc77b1b890e10602b30aa9d7e91628376f52d5112421afc17e3ffb5b883380474e61675a8d
7
- data.tar.gz: 81d3002af641bd143d1decad9d0ca419fe5b83103102caa79d1dc407b5a5809886a29cc1bdf1ef9a05874876127645b1056611d07bd6aaa520b8ee1dad15ecdc
6
+ metadata.gz: a0b70e6823a3bc2d69de91864ccde36d0d8063fda209c829f041e8ba63105c1f3d97acfbed26bba8b8fd53c4e6ddf3f4486199a245653988d308bdceaca5f742
7
+ data.tar.gz: 026dbfd7490dfa3e53e43802e45947089ee1c5776d9db4e6eda22e20d914ae979cc7af3b0afb4a0a2266f5d2594d370265c1052072f997642c6a300672e8579a
data/CHANGELOG.md CHANGED
@@ -1,5 +1,15 @@
1
1
  # CHANGELOG
2
2
 
3
+ ## 0.63.0
4
+
5
+ ### Minor Changes
6
+
7
+ - [#3428](https://github.com/primer/view_components/pull/3428) [`1ab1b06`](https://github.com/opf/primer_view_components/commit/1ab1b06509763ea60fc89770754edf06229b4f63) Thanks [@manuelpuyol](https://github.com/manuelpuyol)! - Create IncludeFragment component. Allow ConditionalWrapper to render components other than BaseComponent
8
+
9
+ ### Patch Changes
10
+
11
+ - [#3429](https://github.com/primer/view_components/pull/3429) [`6ea9fd5`](https://github.com/opf/primer_view_components/commit/6ea9fd5dc90c1964ab3882faf1733c6b49c80e21) Thanks [@manuelpuyol](https://github.com/manuelpuyol)! - Create IncludeFragment linter to migrate <include-fragment> uses
12
+
3
13
  ## 0.62.0
4
14
 
5
15
  ### Minor Changes
@@ -3,7 +3,7 @@
3
3
  <%= render(@overlay) do |overlay| %>
4
4
  <% overlay.with_body(padding: :none) do %>
5
5
  <% if @src.present? %>
6
- <include-fragment src="<%= @src %>" loading="<%= preload? ? "eager" : "lazy" %>" data-target="action-menu.includeFragment">
6
+ <%= render(Primer::Alpha::IncludeFragment.new(src: @src, loading: preload? ? :eager : :lazy, "data-target": "action-menu.includeFragment")) do %>
7
7
  <%= render(Primer::Alpha::ActionMenu::List.new(id: "#{@menu_id}-list", menu_id: @menu_id)) do |list| %>
8
8
  <% list.with_item(
9
9
  aria: { disabled: true },
@@ -18,7 +18,7 @@
18
18
  <%= render Primer::Beta::Spinner.new(aria: { label: "Loading content..." }) %>
19
19
  <% end %>
20
20
  <% end %>
21
- </include-fragment>
21
+ <% end %>
22
22
  <% else %>
23
23
  <%= render(@list) %>
24
24
  <% end %>
@@ -0,0 +1,26 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Primer
4
+ module Alpha
5
+ # Use `IncludeFragment` to load HTML elements from the server.
6
+ # Add additional usage considerations or best practices that may aid the user to use the component correctly.
7
+ # @accessibility Add any accessibility considerations
8
+ class IncludeFragment < Primer::Component
9
+ status :alpha
10
+
11
+ # @param src [String] The URL from which to retrieve an HTML element fragment.
12
+ # @param loading [Symbol] <%= one_of([:lazy, :eager]) %>
13
+ # @param system_arguments [Hash] <%= link_to_system_arguments_docs %>
14
+ def initialize(src: nil, loading: :eager, **system_arguments)
15
+ @system_arguments = system_arguments
16
+ @system_arguments[:tag] = "include-fragment"
17
+ @system_arguments[:loading] = loading
18
+ @system_arguments[:src] = src
19
+ end
20
+
21
+ def call
22
+ render(Primer::BaseComponent.new(**@system_arguments)) { content }
23
+ end
24
+ end
25
+ end
26
+ end
@@ -62,7 +62,7 @@
62
62
  )) do %>
63
63
  <div id="<%= @body_id %>">
64
64
  <% if @src.present? %>
65
- <%= render(Primer::ConditionalWrapper.new(condition: @fetch_strategy == :eventually_local, tag: "include-fragment", data: { target: "select-panel.includeFragment" }, src: @src, loading: preload? ? "eager" : "lazy", accept: "text/fragment+html")) do %>
65
+ <%= render(Primer::ConditionalWrapper.new(condition: @fetch_strategy == :eventually_local, component: Primer::Alpha::IncludeFragment, data: { target: "select-panel.includeFragment" }, src: @src, loading: preload? ? "eager" : "lazy", accept: "text/fragment+html")) do %>
66
66
  <%= render(Primer::BaseComponent.new(
67
67
  tag: :div,
68
68
  id: "#{@panel_id}-list",
@@ -1,14 +1,16 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Primer
4
- # Conditionally renders a `Primer::BaseComponent` around the given content. If the given condition
5
- # is true, a `Primer::BaseComponent` will render around the content. If the condition is false, only
4
+ # Conditionally renders a component around the given content. If the given condition
5
+ # is true, the component will render around the content. If the condition is false, only
6
6
  # the content is rendered.
7
7
  class ConditionalWrapper < Primer::Component
8
- # @param condition [Boolean] Whether or not to wrap the content in a `Primer::BaseComponent`.
9
- # @param base_component_arguments [Hash] The arguments to pass to `Primer::BaseComponent`.
10
- def initialize(condition:, **base_component_arguments)
8
+ # @param condition [Boolean] Whether or not to wrap the content in a component.
9
+ # @param component [Class] The component class to use as a wrapper, defaults to `Primer::BaseComponent`
10
+ # @param base_component_arguments [Hash] The arguments to pass to the component.
11
+ def initialize(condition:, component: Primer::BaseComponent, **base_component_arguments)
11
12
  @condition = condition
13
+ @component = component
12
14
  @base_component_arguments = base_component_arguments
13
15
  @trim = !!@base_component_arguments.delete(:trim)
14
16
  end
@@ -18,7 +20,7 @@ module Primer
18
20
  return @trim ? trimmed_content : content
19
21
  end
20
22
 
21
- BaseComponent.new(trim: @trim, **@base_component_arguments).render_in(self) { content }
23
+ @component.new(trim: @trim, **@base_component_arguments).render_in(self) { content }
22
24
  end
23
25
  end
24
26
  end
@@ -0,0 +1,21 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative "base"
4
+
5
+ module ERBLint
6
+ module Linters
7
+ module ArgumentMappers
8
+ # Maps attributes in the include-fragment element to arguments for the IncludeFragment component.
9
+ class IncludeFragment < Base
10
+ DEFAULT_TAG = "include-fragment"
11
+ ATTRIBUTES = %w[loading src accept role preload tabindex autofocus hidden].freeze
12
+
13
+ def attribute_to_args(attribute)
14
+ attr_name = attribute.name
15
+
16
+ { attr_name.to_sym => erb_helper.convert(attribute) }
17
+ end
18
+ end
19
+ end
20
+ end
21
+ end
@@ -0,0 +1,20 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative "base_linter"
4
+ require_relative "autocorrectable"
5
+ require_relative "argument_mappers/include_fragment"
6
+
7
+ module ERBLint
8
+ module Linters
9
+ # Counts the number of times a HTML include-fragment is used instead of the component.
10
+ class IncludeFragmentComponentMigrationCounter < BaseLinter
11
+ include Autocorrectable
12
+
13
+ TAGS = %w[include-fragment].freeze
14
+ REQUIRED_ARGUMENTS = [].freeze
15
+ MESSAGE = "We are migrating include-fragment to use [Primer::Alpha::IncludeFragment](https://primer.style/view-components/lookbook/inspect/primer/alpha/include_fragment/default), please try to use that instead of raw HTML."
16
+ ARGUMENT_MAPPER = ArgumentMappers::IncludeFragment
17
+ COMPONENT = "Primer::Alpha::IncludeFragment"
18
+ end
19
+ end
20
+ end
@@ -5,7 +5,7 @@ module Primer
5
5
  module ViewComponents
6
6
  module VERSION
7
7
  MAJOR = 0
8
- MINOR = 62
8
+ MINOR = 63
9
9
  PATCH = 0
10
10
 
11
11
  STRING = [MAJOR, MINOR, PATCH].join(".")
@@ -0,0 +1,22 @@
1
+ # frozen_string_literal: true
2
+
3
+ # Setup Playground to use all available component props
4
+ # Setup Features to use individual component props and combinations
5
+
6
+ module Primer
7
+ module Alpha
8
+ # @label IncludeFragment
9
+ class IncludeFragmentPreview < ViewComponent::Preview
10
+ # @label Playground
11
+ # @param loading select [eager, lazy]
12
+ def playground(loading: :eager)
13
+ render(Primer::Alpha::IncludeFragment.new(loading: loading, src: UrlHelpers.include_fragment_deferred_path)) { "Loading..." }
14
+ end
15
+
16
+ # @label Default options
17
+ def default
18
+ render(Primer::Alpha::IncludeFragment.new(loading: :eager, src: UrlHelpers.include_fragment_deferred_path)) { "Loading..." }
19
+ end
20
+ end
21
+ end
22
+ end
@@ -1357,6 +1357,34 @@
1357
1357
  }
1358
1358
  ]
1359
1359
  },
1360
+ {
1361
+ "component": "IncludeFragment",
1362
+ "status": "alpha",
1363
+ "a11y_reviewed": false,
1364
+ "short_name": "IncludeFragment",
1365
+ "source": "https://github.com/primer/view_components/tree/main/app/components/primer/alpha/include_fragment.rb",
1366
+ "lookbook": "https://primer.style/view-components/lookbook/inspect/primer/alpha/include_fragment/default/",
1367
+ "parameters": [
1368
+ {
1369
+ "name": "src",
1370
+ "type": "String",
1371
+ "default": "`nil`",
1372
+ "description": "The URL from which to retrieve an HTML element fragment."
1373
+ },
1374
+ {
1375
+ "name": "loading",
1376
+ "type": "Symbol",
1377
+ "default": "`:eager`",
1378
+ "description": "One of `:eager` or `:lazy`."
1379
+ },
1380
+ {
1381
+ "name": "system_arguments",
1382
+ "type": "Hash",
1383
+ "default": "N/A",
1384
+ "description": "[System arguments](/system-arguments)"
1385
+ }
1386
+ ]
1387
+ },
1360
1388
  {
1361
1389
  "component": "Layout",
1362
1390
  "status": "alpha",
@@ -4949,13 +4977,19 @@
4949
4977
  "name": "condition",
4950
4978
  "type": "Boolean",
4951
4979
  "default": "N/A",
4952
- "description": "Whether or not to wrap the content in a `Primer::BaseComponent`."
4980
+ "description": "Whether or not to wrap the content in a component."
4981
+ },
4982
+ {
4983
+ "name": "component",
4984
+ "type": "Class",
4985
+ "default": "`Primer::BaseComponent`",
4986
+ "description": "The component class to use as a wrapper, defaults to `Primer::BaseComponent`"
4953
4987
  },
4954
4988
  {
4955
4989
  "name": "base_component_arguments",
4956
4990
  "type": "Hash",
4957
4991
  "default": "N/A",
4958
- "description": "The arguments to pass to `Primer::BaseComponent`."
4992
+ "description": "The arguments to pass to the component."
4959
4993
  }
4960
4994
  ]
4961
4995
  },
@@ -30,6 +30,7 @@
30
30
  "Primer::Alpha::HellipButton": "",
31
31
  "Primer::Alpha::HiddenTextExpander": "",
32
32
  "Primer::Alpha::Image": "",
33
+ "Primer::Alpha::IncludeFragment": "",
33
34
  "Primer::Alpha::Layout": "",
34
35
  "Primer::Alpha::Layout::Main": "",
35
36
  "Primer::Alpha::Layout::Sidebar": "",
@@ -391,6 +391,9 @@
391
391
  "Primer::Alpha::Image": {
392
392
  "GeneratedSlotMethods": "Primer::Alpha::Image::GeneratedSlotMethods"
393
393
  },
394
+ "Primer::Alpha::IncludeFragment": {
395
+ "GeneratedSlotMethods": "Primer::Alpha::IncludeFragment::GeneratedSlotMethods"
396
+ },
394
397
  "Primer::Alpha::Layout": {
395
398
  "FIRST_IN_SOURCE_DEFAULT": "sidebar",
396
399
  "FIRST_IN_SOURCE_OPTIONS": [
@@ -4679,6 +4679,77 @@
4679
4679
 
4680
4680
  ]
4681
4681
  },
4682
+ {
4683
+ "fully_qualified_name": "Primer::Alpha::IncludeFragment",
4684
+ "description": "Use `IncludeFragment` to load HTML elements from the server.\nAdd additional usage considerations or best practices that may aid the user to use the component correctly.",
4685
+ "accessibility_docs": "Add any accessibility considerations",
4686
+ "is_form_component": false,
4687
+ "is_published": true,
4688
+ "requires_js": false,
4689
+ "component": "IncludeFragment",
4690
+ "status": "alpha",
4691
+ "a11y_reviewed": false,
4692
+ "short_name": "IncludeFragment",
4693
+ "source": "https://github.com/primer/view_components/tree/main/app/components/primer/alpha/include_fragment.rb",
4694
+ "lookbook": "https://primer.style/view-components/lookbook/inspect/primer/alpha/include_fragment/default/",
4695
+ "parameters": [
4696
+ {
4697
+ "name": "src",
4698
+ "type": "String",
4699
+ "default": "`nil`",
4700
+ "description": "The URL from which to retrieve an HTML element fragment."
4701
+ },
4702
+ {
4703
+ "name": "loading",
4704
+ "type": "Symbol",
4705
+ "default": "`:eager`",
4706
+ "description": "One of `:eager` or `:lazy`."
4707
+ },
4708
+ {
4709
+ "name": "system_arguments",
4710
+ "type": "Hash",
4711
+ "default": "N/A",
4712
+ "description": "{{link_to_system_arguments_docs}}"
4713
+ }
4714
+ ],
4715
+ "slots": [
4716
+
4717
+ ],
4718
+ "methods": [
4719
+
4720
+ ],
4721
+ "previews": [
4722
+ {
4723
+ "preview_path": "primer/alpha/include_fragment/playground",
4724
+ "name": "playground",
4725
+ "snapshot": "false",
4726
+ "skip_rules": {
4727
+ "wont_fix": [
4728
+ "region"
4729
+ ],
4730
+ "will_fix": [
4731
+ "color-contrast"
4732
+ ]
4733
+ }
4734
+ },
4735
+ {
4736
+ "preview_path": "primer/alpha/include_fragment/default",
4737
+ "name": "default",
4738
+ "snapshot": "false",
4739
+ "skip_rules": {
4740
+ "wont_fix": [
4741
+ "region"
4742
+ ],
4743
+ "will_fix": [
4744
+ "color-contrast"
4745
+ ]
4746
+ }
4747
+ }
4748
+ ],
4749
+ "subcomponents": [
4750
+
4751
+ ]
4752
+ },
4682
4753
  {
4683
4754
  "fully_qualified_name": "Primer::Alpha::Layout",
4684
4755
  "description": "`Layout` provides foundational patterns for responsive pages.\n`Layout` can be used for simple two-column pages, or it can be nested to provide flexible 3-column experiences.\n On smaller screens, `Layout` uses vertically stacked rows to display content.\n\n`Layout` flows as both column, when there's enough horizontal space to render both `Main` and `Sidebar`side-by-side (on a desktop of tablet device, per instance);\nor it flows as a row, when `Main` and `Sidebar` are stacked vertically (e.g. on a mobile device).\n`Layout` should always work in any screen size.",
@@ -17220,7 +17291,7 @@
17220
17291
  },
17221
17292
  {
17222
17293
  "fully_qualified_name": "Primer::ConditionalWrapper",
17223
- "description": "Conditionally renders a `Primer::BaseComponent` around the given content. If the given condition\nis true, a `Primer::BaseComponent` will render around the content. If the condition is false, only\nthe content is rendered.",
17294
+ "description": "Conditionally renders a component around the given content. If the given condition\nis true, the component will render around the content. If the condition is false, only\nthe content is rendered.",
17224
17295
  "accessibility_docs": null,
17225
17296
  "is_form_component": false,
17226
17297
  "is_published": true,
@@ -17236,13 +17307,19 @@
17236
17307
  "name": "condition",
17237
17308
  "type": "Boolean",
17238
17309
  "default": "N/A",
17239
- "description": "Whether or not to wrap the content in a `Primer::BaseComponent`."
17310
+ "description": "Whether or not to wrap the content in a component."
17311
+ },
17312
+ {
17313
+ "name": "component",
17314
+ "type": "Class",
17315
+ "default": "`Primer::BaseComponent`",
17316
+ "description": "The component class to use as a wrapper, defaults to `Primer::BaseComponent`"
17240
17317
  },
17241
17318
  {
17242
17319
  "name": "base_component_arguments",
17243
17320
  "type": "Hash",
17244
17321
  "default": "N/A",
17245
- "description": "The arguments to pass to `Primer::BaseComponent`."
17322
+ "description": "The arguments to pass to the component."
17246
17323
  }
17247
17324
  ],
17248
17325
  "slots": [
data/static/previews.json CHANGED
@@ -4682,6 +4682,40 @@
4682
4682
  }
4683
4683
  ]
4684
4684
  },
4685
+ {
4686
+ "name": "include_fragment",
4687
+ "component": "IncludeFragment",
4688
+ "status": "alpha",
4689
+ "lookup_path": "primer/alpha/include_fragment",
4690
+ "examples": [
4691
+ {
4692
+ "preview_path": "primer/alpha/include_fragment/playground",
4693
+ "name": "playground",
4694
+ "snapshot": "false",
4695
+ "skip_rules": {
4696
+ "wont_fix": [
4697
+ "region"
4698
+ ],
4699
+ "will_fix": [
4700
+ "color-contrast"
4701
+ ]
4702
+ }
4703
+ },
4704
+ {
4705
+ "preview_path": "primer/alpha/include_fragment/default",
4706
+ "name": "default",
4707
+ "snapshot": "false",
4708
+ "skip_rules": {
4709
+ "wont_fix": [
4710
+ "region"
4711
+ ],
4712
+ "will_fix": [
4713
+ "color-contrast"
4714
+ ]
4715
+ }
4716
+ }
4717
+ ]
4718
+ },
4685
4719
  {
4686
4720
  "name": "input_group",
4687
4721
  "component": "OpenProject::InputGroup",
data/static/statuses.json CHANGED
@@ -30,6 +30,7 @@
30
30
  "Primer::Alpha::HellipButton": "alpha",
31
31
  "Primer::Alpha::HiddenTextExpander": "alpha",
32
32
  "Primer::Alpha::Image": "alpha",
33
+ "Primer::Alpha::IncludeFragment": "alpha",
33
34
  "Primer::Alpha::Layout": "alpha",
34
35
  "Primer::Alpha::Layout::Main": "alpha",
35
36
  "Primer::Alpha::Layout::Sidebar": "alpha",
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.62.0
4
+ version: 0.63.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - GitHub Open Source
@@ -209,6 +209,7 @@ files:
209
209
  - app/components/primer/alpha/hellip_button.rb
210
210
  - app/components/primer/alpha/hidden_text_expander.rb
211
211
  - app/components/primer/alpha/image.rb
212
+ - app/components/primer/alpha/include_fragment.rb
212
213
  - app/components/primer/alpha/layout.css
213
214
  - app/components/primer/alpha/layout.css.json
214
215
  - app/components/primer/alpha/layout.css.map
@@ -789,6 +790,7 @@ files:
789
790
  - lib/primer/view_components/linters/argument_mappers/conversion_error.rb
790
791
  - lib/primer/view_components/linters/argument_mappers/flash.rb
791
792
  - lib/primer/view_components/linters/argument_mappers/helpers/erb_block.rb
793
+ - lib/primer/view_components/linters/argument_mappers/include_fragment.rb
792
794
  - lib/primer/view_components/linters/argument_mappers/label.rb
793
795
  - lib/primer/view_components/linters/argument_mappers/system_arguments.rb
794
796
  - lib/primer/view_components/linters/autocorrectable.rb
@@ -807,6 +809,7 @@ files:
807
809
  - lib/primer/view_components/linters/helpers/deprecated_components_helpers.rb
808
810
  - lib/primer/view_components/linters/helpers/rubocop_helpers.rb
809
811
  - lib/primer/view_components/linters/helpers/rule_helpers.rb
812
+ - lib/primer/view_components/linters/include_fragment_component_migration_counter.rb
810
813
  - lib/primer/view_components/linters/label_component_migration_counter.rb
811
814
  - lib/primer/view_components/linters/migrate_deprecated_flash_arguments.rb
812
815
  - lib/primer/view_components/linters/migrations/iconbutton_component.rb
@@ -894,6 +897,7 @@ files:
894
897
  - previews/primer/alpha/form_control_preview/playground.html.erb
895
898
  - previews/primer/alpha/hellip_button_preview.rb
896
899
  - previews/primer/alpha/hidden_text_expander_preview.rb
900
+ - previews/primer/alpha/include_fragment_preview.rb
897
901
  - previews/primer/alpha/layout_preview.rb
898
902
  - previews/primer/alpha/menu_preview.rb
899
903
  - previews/primer/alpha/menu_preview/default.html.erb