primer_view_components 0.0.7 → 0.0.8

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: 8e2de200019cce82f6ab8da4f177fffa54cf62f703bca353b05376c9c7cb62ab
4
- data.tar.gz: 9166cc8d3208cbaee4e9c0ae12cca3c5b53faa56d081fd4baa28f79b0d48f1fa
3
+ metadata.gz: 25626f31190d4622e822db5eb8f435f103c0a77668cb78c1db16eec60ac4dfb9
4
+ data.tar.gz: e551785879e69a0bd7c2ae62a97a39f311dc3dbc415bc5dade637d97fa297910
5
5
  SHA512:
6
- metadata.gz: deb5e962d169066fe55d7c28f9c81f7d5e59f5e13ee57dd33dfc80b0f37422c60feabb850ec4c6c02253ad3cace554a0146f74ed1287e075560ee39453e2f1f3
7
- data.tar.gz: e15db34d645de8e42bb29136d95c2caf87c61e4c2c84f09bbbe9a4f11ed48a99478c1f06b0fc7bf165806a74b30e6ff15fcaf1439b3bebee290765759cd3f0b5
6
+ metadata.gz: 6a77219748e0c7018f789df844cd6f6e83159b2fef82a5b81985c277d0427d85442e4e14c6f9934e387afc3f1d2291f31a3d88c9630c8f4910bae992d39a0188
7
+ data.tar.gz: 15b0b2a9faa1603f57d263a2a6b18f2eb4e1aa325d8c261bfce9f803571ae9a5075b1d51f8a5f3bf31bc7f12662dbe914f7380f71518fe6896b947f2d000757b
@@ -1,3 +1,21 @@
1
+ # main
2
+
3
+ # 0.0.8
4
+
5
+ * Add support for border margins, such as: `border_top: 0`.
6
+
7
+ *Natasha Umer*
8
+
9
+ * Add FlashComponent and OcticonComponent.
10
+
11
+ *Joel Hawksley*
12
+
13
+ ## Breaking changes
14
+
15
+ * BlankslateComponent accepts `icon_size` instead of `icon_height`.
16
+
17
+ *Joel Hawksley*
18
+
1
19
  # 0.0.7
2
20
 
3
21
  * Use `octicons_helper` v11.0.0.
data/README.md CHANGED
@@ -77,6 +77,10 @@ Some components have their own specific arguments, but they can all be styled wi
77
77
  | `font_weight` | `text-<value>` | `font_weight: :bold` → `.text-bold` |
78
78
  | `border` | `border-<value>` | `border: :bottom` → `.border-bottom` |
79
79
  | `border_color` | `border-<value>` | `border: :green` → `.border-green` |
80
+ | `border_top` | `border-top-<value>` | `border_top: 0` → `.border-top-0` |
81
+ | `border_bottom` | `border-bottom-<value>` | `border_bottom: 0` → `.border-bottom-0` |
82
+ | `border_left` | `border-left-<value>` | `border_left: 0` → `.border-left-0` |
83
+ | `border_right` | `border-right-<value>` | `border_right: 0` → `.border-right-0` |
80
84
  | `word_break` | `wb-<value>` | `word_break: :break_all` → `.wb-break-all` |
81
85
  | `direction` | `flex-<value>` | `direction: :row` → `.flex-row` |
82
86
  | `justify_content` | `flex-justify-<value>` | `justify_content: :center` → `.flex-justify-center` |
@@ -23,9 +23,7 @@ module Primer
23
23
  end
24
24
 
25
25
  def call
26
- tag.public_send(
27
- @tag, content, **@content_tag_args.merge(@result)
28
- )
26
+ content_tag(@tag, content, **@content_tag_args.merge(@result))
29
27
  end
30
28
 
31
29
  private
@@ -1,13 +1,19 @@
1
1
  <%= render Primer::BaseComponent.new(**@kwargs) do %>
2
2
  <% if @icon.present? %>
3
- <%= octicon @icon, height: @icon_height, class: "blankslate-icon" %>
3
+ <%= render(Primer::OcticonComponent.new(
4
+ icon: @icon,
5
+ size: @icon_size,
6
+ class: "blankslate-icon"
7
+ )) %>
4
8
  <% end %>
5
9
 
6
10
  <% if @image_src.present? && @image_alt.present? %>
7
11
  <%= image_tag "#{@image_src}", class: "mb-3", size: "56x56", alt: "#{@image_alt}" %>
8
12
  <% end %>
9
13
 
10
- <<%= @title_tag %> class="mb-1"><%= @title %></<%= @title_tag %>>
14
+ <% if @title.present? %>
15
+ <%= render Primer::BaseComponent.new(tag: @title_tag, mb: 1) do %><%= @title %><% end %>
16
+ <% end %>
11
17
 
12
18
  <% if @description.present? %>
13
19
  <p><%= @description %></p>
@@ -7,7 +7,7 @@ module Primer
7
7
  #
8
8
  # The `Primer::BlankslateComponent` supports the following arguments to add a basic blankslate:
9
9
  #
10
- # 1. `title` (`String` required). Text that appears in a larger bold font.
10
+ # 1. `title` (`String` optional). Text that appears in a larger bold font.
11
11
  # 2. `description` (`String` optional). Text that appears below the title. Typically a whole sentence.
12
12
  #
13
13
  # ```ruby
@@ -114,13 +114,10 @@ module Primer
114
114
  # ```
115
115
  class BlankslateComponent < Primer::Component
116
116
  def initialize(
117
- # required
118
- title:,
119
-
120
- # optional
117
+ title: "",
121
118
  title_tag: :h3,
122
119
  icon: "",
123
- icon_height: 32,
120
+ icon_size: :medium,
124
121
  image_src: "",
125
122
  image_alt: " ",
126
123
  description: "",
@@ -138,7 +135,7 @@ module Primer
138
135
  **kwargs
139
136
  )
140
137
  @kwargs = kwargs
141
- @kwargs[:tag] = :div
138
+ @kwargs[:tag] ||= :div
142
139
  @kwargs[:classes] = class_names(
143
140
  @kwargs[:classes],
144
141
  "blankslate",
@@ -149,7 +146,7 @@ module Primer
149
146
 
150
147
  @title_tag = title_tag
151
148
  @icon = icon
152
- @icon_height = icon_height
149
+ @icon_size = icon_size
153
150
  @image_src = image_src
154
151
  @image_alt = image_alt
155
152
  @title = title
@@ -0,0 +1,14 @@
1
+ <%= render Primer::BaseComponent.new(**@kwargs) do %>
2
+ <%= render(Primer::OcticonComponent.new(icon: @icon)) if @icon %>
3
+ <%= content %>
4
+ <% if @dismissible %>
5
+ <button class="flash-close js-flash-close" type="button" aria-label="Close">
6
+ <%= render(Primer::OcticonComponent.new(icon: "x")) %>
7
+ </button>
8
+ <% end %>
9
+ <% if actions.present? %>
10
+ <%= render Primer::BaseComponent.new(**actions.kwargs) do %>
11
+ <%= actions.content %>
12
+ <% end %>
13
+ <% end %>
14
+ <% end %>
@@ -0,0 +1,43 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Primer
4
+ class FlashComponent < Primer::Component
5
+ include ViewComponent::Slotable
6
+
7
+ with_slot :actions, class_name: "Actions"
8
+
9
+ DEFAULT_VARIANT = :default
10
+ VARIANT_MAPPINGS = {
11
+ DEFAULT_VARIANT => "",
12
+ :warning => "flash-warn",
13
+ :danger => "flash-error",
14
+ :success => "flash-success"
15
+ }.freeze
16
+
17
+ def initialize(full: false, spacious: false, dismissible: false, icon: nil, variant: DEFAULT_VARIANT, **kwargs)
18
+ @icon = icon
19
+ @dismissible = dismissible
20
+ @kwargs = kwargs
21
+ @kwargs[:tag] = :div
22
+ @kwargs[:classes] = class_names(
23
+ @kwargs[:classes],
24
+ "flash",
25
+ VARIANT_MAPPINGS[fetch_or_fallback(VARIANT_MAPPINGS.keys, variant.to_sym, DEFAULT_VARIANT)],
26
+ "flash-full": full
27
+ )
28
+ @kwargs[:mb] ||= spacious ? 4 : nil
29
+ end
30
+
31
+ class Actions < ViewComponent::Slot
32
+ include ClassNameHelper
33
+
34
+ attr_reader :kwargs
35
+
36
+ def initialize(**kwargs)
37
+ @kwargs = kwargs
38
+ @kwargs[:tag] = :div
39
+ @kwargs[:classes] = class_names(@kwargs[:classes], "flash-action")
40
+ end
41
+ end
42
+ end
43
+ end
@@ -0,0 +1,27 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Primer
4
+ class OcticonComponent < Primer::Component
5
+ include Primer::ClassNameHelper
6
+ include OcticonsHelper
7
+
8
+ SIZE_DEFAULT = :small
9
+ SIZE_MAPPINGS = {
10
+ SIZE_DEFAULT => 16,
11
+ :medium => 32,
12
+ :large => 64,
13
+ }.freeze
14
+ SIZE_OPTIONS = SIZE_MAPPINGS.keys
15
+
16
+ def initialize(icon:, size: SIZE_DEFAULT, **kwargs)
17
+ @icon, @kwargs = icon, kwargs
18
+
19
+ @kwargs[:height] = SIZE_MAPPINGS[size.to_sym]
20
+ @kwargs[:class] = class_names(@kwargs[:class], Primer::Classify.call(**@kwargs)[:class])
21
+ end
22
+
23
+ def call
24
+ octicon(@icon, **@kwargs)
25
+ end
26
+ end
27
+ end
@@ -33,12 +33,14 @@ require_relative "button_component"
33
33
  require_relative "counter_component"
34
34
  require_relative "details_component"
35
35
  require_relative "dropdown_menu_component"
36
+ require_relative "flash_component"
36
37
  require_relative "flex_component"
37
38
  require_relative "flex_item_component"
38
39
  require_relative "heading_component"
39
40
  require_relative "label_component"
40
41
  require_relative "layout_component"
41
42
  require_relative "link_component"
43
+ require_relative "octicon_component"
42
44
  require_relative "popover_component"
43
45
  require_relative "progress_bar_component"
44
46
  require_relative "state_component"
@@ -78,11 +78,13 @@ module Primer
78
78
  }
79
79
  }.freeze
80
80
  BORDER_KEYS = [:border, :border_color].freeze
81
+ BORDER_MARGIN_KEYS = [:border_top, :border_bottom, :border_left, :border_right].freeze
81
82
  TYPOGRAPHY_KEYS = [:font_size].freeze
82
83
  VALID_KEYS = (
83
84
  CONCAT_KEYS +
84
85
  BOOLEAN_MAPPINGS.keys +
85
86
  BORDER_KEYS +
87
+ BORDER_MARGIN_KEYS +
86
88
  TYPOGRAPHY_KEYS +
87
89
  TEXT_KEYS +
88
90
  [
@@ -196,6 +198,8 @@ module Primer
196
198
  memo[:classes] << "wb-#{dasherized_val}"
197
199
  elsif BORDER_KEYS.include?(key)
198
200
  memo[:classes] << "border-#{dasherized_val}"
201
+ elsif BORDER_MARGIN_KEYS.include?(key)
202
+ memo[:classes] << "#{key.to_s.dasherize}-#{val}"
199
203
  elsif key == DIRECTION_KEY
200
204
  memo[:classes] << "flex#{breakpoint}-#{dasherized_val}"
201
205
  elsif key == JUSTIFY_CONTENT_KEY
@@ -5,7 +5,7 @@ module Primer
5
5
  module VERSION
6
6
  MAJOR = 0
7
7
  MINOR = 0
8
- PATCH = 7
8
+ PATCH = 8
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.7
4
+ version: 0.0.8
5
5
  platform: ruby
6
6
  authors:
7
7
  - GitHub Open Source
8
- autorequire:
8
+ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-09-09 00:00:00.000000000 Z
11
+ date: 2020-09-14 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
@@ -168,7 +168,7 @@ dependencies:
168
168
  - - "~>"
169
169
  - !ruby/object:Gem::Version
170
170
  version: 0.9.25
171
- description:
171
+ description:
172
172
  email:
173
173
  - opensource+primer_view_components@github.com
174
174
  executables: []
@@ -194,6 +194,8 @@ files:
194
194
  - app/components/primer/details_component.rb
195
195
  - app/components/primer/dropdown_menu_component.html.erb
196
196
  - app/components/primer/dropdown_menu_component.rb
197
+ - app/components/primer/flash_component.html.erb
198
+ - app/components/primer/flash_component.rb
197
199
  - app/components/primer/flex_component.rb
198
200
  - app/components/primer/flex_item_component.rb
199
201
  - app/components/primer/heading_component.rb
@@ -201,6 +203,7 @@ files:
201
203
  - app/components/primer/layout_component.html.erb
202
204
  - app/components/primer/layout_component.rb
203
205
  - app/components/primer/link_component.rb
206
+ - app/components/primer/octicon_component.rb
204
207
  - app/components/primer/popover_component.html.erb
205
208
  - app/components/primer/popover_component.rb
206
209
  - app/components/primer/progress_bar_component.html.erb
@@ -226,7 +229,7 @@ licenses:
226
229
  - MIT
227
230
  metadata:
228
231
  allowed_push_host: https://rubygems.org
229
- post_install_message:
232
+ post_install_message:
230
233
  rdoc_options: []
231
234
  require_paths:
232
235
  - lib
@@ -242,7 +245,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
242
245
  version: '0'
243
246
  requirements: []
244
247
  rubygems_version: 3.1.2
245
- signing_key:
248
+ signing_key:
246
249
  specification_version: 4
247
250
  summary: ViewComponents for the Primer Design System
248
251
  test_files: []