primer_view_components 0.0.16 → 0.0.17

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: aa20e643699f825d7867ba90c89def4cb5a4718782a55e1c7f7442cf8544732c
4
- data.tar.gz: 4f01e3f6a5a2418b9318362820f08c37ad0dcc420aa62d55e12016f7e56b7e88
3
+ metadata.gz: 70daa13e7909487e01c01f4759a88740922070c985ac9604df738614d48c57a1
4
+ data.tar.gz: 257383c54d408d94c8aac723804a1db9b75dee88527f60ce101f70514259567c
5
5
  SHA512:
6
- metadata.gz: 02be1d647c02508fbc4fb7fd9339d221b7625a5fe047c2e14e5901d809e8c4edbffb1559f4c06dbbb95971e6697b76acd8b096f60087d14941dcddf20c58ff87
7
- data.tar.gz: 265ee51bd35a72bb183df848780a9d47b3203a06bb77ee53f7cfb606897785175bc347d48082bd7a0286081235155c4dae4c702fa752dc863342017a1a254d39
6
+ metadata.gz: 65bef1719944f20523e8670d382474fa15a49cd03eab6a39578ad3901933668c3d2bcfdff9da7e46ba9fdac8587447b92984a6e4c67028732f9ba2f18dc9cf52
7
+ data.tar.gz: b578660620dc448087463fd24361c652a8fd9ead88cd6693a658af94f497eb68361e3236cb43386da66f58666c72051d5728bb67b4be6c832ee815c54f59e4c8
@@ -2,6 +2,12 @@
2
2
 
3
3
  ## main
4
4
 
5
+ ## 0.0.17
6
+
7
+ * Ensure all components support inline styles.
8
+
9
+ *Joel Hawksley*
10
+
5
11
  ## 0.0.16
6
12
 
7
13
  * Adding a `spinner` slot to the `BlankslateComponent` that uses the `SpinnerComponent` added in `0.0.10`.
@@ -34,6 +34,7 @@ module Primer
34
34
  # | `data` | `Hash` | Data attributes: `data: { foo: :bar }` renders `data-foo='bar'`. |
35
35
  # | `aria` | `Hash` | Aria attributes: `aria: { label: "foo" }` renders `aria-label='foo'`. |
36
36
  # | `title` | `String` | The `title` attribute. |
37
+ # | `style` | `String` | Inline styles. |
37
38
  # | `hidden` | `Boolean` | Whether to assign the `hidden` attribute. |
38
39
  class BaseComponent < Primer::Component
39
40
  TEST_SELECTOR_TAG = :test_selector
@@ -6,5 +6,6 @@ module Primer
6
6
  include ClassNameHelper
7
7
  include FetchOrFallbackHelper
8
8
  include OcticonsHelper
9
+ include JoinStyleArgumentsHelper
9
10
  end
10
11
  end
@@ -57,9 +57,7 @@ module Primer
57
57
  @system_arguments[:mb] ||= spacious ? 4 : nil
58
58
  end
59
59
 
60
- class Actions < ViewComponent::Slot
61
- include ClassNameHelper
62
-
60
+ class Actions < Primer::Slot
63
61
  attr_reader :system_arguments
64
62
 
65
63
  # @param system_arguments [Hash] <%= link_to_system_arguments_docs %>
@@ -18,7 +18,7 @@ module Primer
18
18
  @system_arguments[:href] = href
19
19
  @system_arguments[:classes] = class_names(
20
20
  @system_arguments[:classes],
21
- "muted-link" => fetch_or_fallback([true, false], muted, false)
21
+ "muted-link" => fetch_or_fallback_boolean(muted, false)
22
22
  )
23
23
  end
24
24
 
@@ -57,7 +57,7 @@ module Primer
57
57
  body.present?
58
58
  end
59
59
 
60
- class Heading < ViewComponent::Slot
60
+ class Heading < Primer::Slot
61
61
  # @param system_arguments [Hash] <%= link_to_system_arguments_docs %>
62
62
  def initialize(**system_arguments)
63
63
  @system_arguments = system_arguments
@@ -55,8 +55,7 @@ module Primer
55
55
  items.any?
56
56
  end
57
57
 
58
- class Item < ViewComponent::Slot
59
- include ClassNameHelper
58
+ class Item < Primer::Slot
60
59
  attr_reader :system_arguments
61
60
 
62
61
  # @param percentage [Integer] Percentage completion of item.
@@ -68,7 +67,8 @@ module Primer
68
67
 
69
68
  @system_arguments[:tag] = :span
70
69
  @system_arguments[:bg] = bg
71
- @system_arguments[:style] = "width: #{@percentage}%;"
70
+ @system_arguments[:style] =
71
+ join_style_arguments(@system_arguments[:style], "width: #{@percentage}%;")
72
72
  @system_arguments[:classes] = class_names("Progress-item", @system_arguments[:classes])
73
73
  end
74
74
  end
@@ -5,5 +5,6 @@ module Primer
5
5
  class Slot < ViewComponent::Slot
6
6
  include ClassNameHelper
7
7
  include FetchOrFallbackHelper
8
+ include JoinStyleArgumentsHelper
8
9
  end
9
10
  end
@@ -26,14 +26,14 @@ module Primer
26
26
  # <%= render(Primer::SpinnerComponent.new(size: :large)) %>
27
27
  #
28
28
  # @param size [Symbol] <%= one_of(Primer::SpinnerComponent::SIZE_MAPPINGS) %>
29
- def initialize(size: DEFAULT_SIZE, style: DEFAULT_STYLE, **system_arguments)
29
+ def initialize(size: DEFAULT_SIZE, **system_arguments)
30
30
  @system_arguments = system_arguments
31
31
  @system_arguments[:tag] = :svg
32
+ @system_arguments[:style] ||= DEFAULT_STYLE
32
33
  @system_arguments[:width] = SIZE_MAPPINGS[fetch_or_fallback(SIZE_OPTIONS, size, DEFAULT_SIZE)]
33
34
  @system_arguments[:height] = SIZE_MAPPINGS[fetch_or_fallback(SIZE_OPTIONS, size, DEFAULT_SIZE)]
34
35
  @system_arguments[:viewBox] = "0 0 16 16"
35
36
  @system_arguments[:fill] = :none
36
- @system_arguments[:style] = DEFAULT_STYLE unless style.nil?
37
37
  end
38
38
  end
39
39
  end
@@ -15,6 +15,7 @@ require "octicons_helper/helper"
15
15
  require "primer/class_name_helper"
16
16
  require "primer/classify"
17
17
  require "primer/fetch_or_fallback_helper"
18
+ require "primer/join_style_arguments_helper"
18
19
 
19
20
  # Base configurations
20
21
 
@@ -37,5 +37,13 @@ module Primer
37
37
  fallback
38
38
  end
39
39
  end
40
+
41
+ def fetch_or_fallback_boolean(given_value, fallback = false)
42
+ if [true, false].include?(given_value)
43
+ given_value
44
+ else
45
+ fallback
46
+ end
47
+ end
40
48
  end
41
49
  end
@@ -0,0 +1,13 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Primer
4
+ module JoinStyleArgumentsHelper
5
+ # Join two `style` arguments
6
+ #
7
+ # join_style_arguments("width: 100%", "height: 100%") =>
8
+ # "width: 100%;height: 100%"
9
+ def join_style_arguments(*args)
10
+ args.compact.join(";")
11
+ end
12
+ end
13
+ end
@@ -5,7 +5,7 @@ module Primer
5
5
  module VERSION
6
6
  MAJOR = 0
7
7
  MINOR = 0
8
- PATCH = 16
8
+ PATCH = 17
9
9
 
10
10
  STRING = [MAJOR, MINOR, PATCH].join(".")
11
11
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: primer_view_components
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.16
4
+ version: 0.0.17
5
5
  platform: ruby
6
6
  authors:
7
7
  - GitHub Open Source
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-11-25 00:00:00.000000000 Z
11
+ date: 2020-12-10 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
@@ -237,6 +237,7 @@ files:
237
237
  - lib/primer/class_name_helper.rb
238
238
  - lib/primer/classify.rb
239
239
  - lib/primer/fetch_or_fallback_helper.rb
240
+ - lib/primer/join_style_arguments_helper.rb
240
241
  - lib/primer/view_components.rb
241
242
  - lib/primer/view_components/engine.rb
242
243
  - lib/primer/view_components/version.rb