primer_view_components 0.0.5 → 0.0.6
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +23 -1
- data/README.md +13 -0
- data/app/components/primer/blankslate_component.rb +8 -0
- data/app/components/primer/button_component.rb +5 -5
- data/app/components/primer/counter_component.rb +7 -0
- data/app/components/primer/details_component.html.erb +5 -3
- data/app/components/primer/details_component.rb +37 -12
- data/lib/primer/classify.rb +1 -1
- data/lib/primer/view_components/version.rb +1 -1
- metadata +48 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: cc85888949a3628a056ecc2b0d6ee97267a5adb688498f2268dda1e54bcd72ce
|
4
|
+
data.tar.gz: 915dcfcbc1033baf6c0c635cbdd37e759045bee86fc92c3fbe7671f316b3cb7c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 47d296a7d90be6d0bf8794e68c3042a7ed5f1a70e0acabbef88a2f094e485a59910b96ee212e4ae77cf24695621f28ff149dfb2f444d839a4e5905e8e40d25d2
|
7
|
+
data.tar.gz: db4e16e23b4ef0c65e1ba0457e99b7acf8ac95b403187e7dcf36692e2a4e5d678f8733655e5b8fbadecb00755a3b395dc3cd7d7c6247ce32260de6f6ee3ee3ff
|
data/CHANGELOG.md
CHANGED
@@ -1,4 +1,26 @@
|
|
1
|
-
#
|
1
|
+
# 0.0.6
|
2
|
+
|
3
|
+
* Updated the invalid class name error message
|
4
|
+
|
5
|
+
*emplums*
|
6
|
+
|
7
|
+
* Updated README with testing instructions
|
8
|
+
|
9
|
+
*emplums*
|
10
|
+
|
11
|
+
* Add large and spacious option to BlankslateComponent
|
12
|
+
|
13
|
+
*simurai*
|
14
|
+
|
15
|
+
* Add option for `ButtonComponent` to render a `summary` tag
|
16
|
+
|
17
|
+
*Manuel Puyol*
|
18
|
+
|
19
|
+
## Breaking changes
|
20
|
+
|
21
|
+
* Changed `DetailsComponent` summary and body to be slots
|
22
|
+
|
23
|
+
*Manuel Puyol*
|
2
24
|
|
3
25
|
# 0.0.5
|
4
26
|
|
data/README.md
CHANGED
@@ -124,6 +124,15 @@ script/setup
|
|
124
124
|
|
125
125
|
to install all necessary dependencies
|
126
126
|
|
127
|
+
|
128
|
+
### Running tests
|
129
|
+
|
130
|
+
To run the full test suite:
|
131
|
+
|
132
|
+
```bash
|
133
|
+
bundle exec rake
|
134
|
+
```
|
135
|
+
|
127
136
|
### Storybook
|
128
137
|
|
129
138
|
*We recommend having [overmind](https://github.com/DarthSim/overmind) installed to run both rails and storybook, but it is not required.*
|
@@ -154,6 +163,10 @@ Remember that restarting the Rails server is necessary to see changes, as the ge
|
|
154
163
|
To minimize the number of restarts, we recommend checking the component in Storybook first, and then when it's in a good state,
|
155
164
|
you can check it in your app.
|
156
165
|
|
166
|
+
### Documentation
|
167
|
+
|
168
|
+
Document components with [YARD](https://yardoc.org/). Docs are published to [RubyDoc.info](https://rubydoc.info/github/primer/view_components).
|
169
|
+
|
157
170
|
## License
|
158
171
|
|
159
172
|
The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
|
@@ -98,6 +98,8 @@ module Primer
|
|
98
98
|
# There are a few variations of how the Blankslate appears:
|
99
99
|
#
|
100
100
|
# - `narrow` (`Boolean` optional). Adds a maximum width.
|
101
|
+
# - `large` (`Boolean` optional). Increaeses the font size.
|
102
|
+
# - `spacious` (`Boolean` optional). Adds extra padding.
|
101
103
|
#
|
102
104
|
# ```ruby
|
103
105
|
# <%= render Primer::BlankslateComponent.new(
|
@@ -106,6 +108,8 @@ module Primer
|
|
106
108
|
# description: "Wikis provide a place in your repository to lay out the roadmap of your project, show the current status, and document software better, together.",
|
107
109
|
#
|
108
110
|
# narrow: true,
|
111
|
+
# large: true,
|
112
|
+
# spacious: true,
|
109
113
|
# ) %>
|
110
114
|
# ```
|
111
115
|
class BlankslateComponent < Primer::Component
|
@@ -128,6 +132,8 @@ module Primer
|
|
128
132
|
|
129
133
|
#variations
|
130
134
|
narrow: false,
|
135
|
+
large: false,
|
136
|
+
spacious: false,
|
131
137
|
|
132
138
|
**kwargs
|
133
139
|
)
|
@@ -137,6 +143,8 @@ module Primer
|
|
137
143
|
@kwargs[:classes],
|
138
144
|
"blankslate",
|
139
145
|
"blankslate-narrow": narrow,
|
146
|
+
"blankslate-large": large,
|
147
|
+
"blankslate-spacious": spacious,
|
140
148
|
)
|
141
149
|
|
142
150
|
@title_tag = title_tag
|
@@ -20,7 +20,7 @@ module Primer
|
|
20
20
|
VARIANT_OPTIONS = VARIANT_MAPPINGS.keys
|
21
21
|
|
22
22
|
DEFAULT_TAG = :button
|
23
|
-
TAG_OPTIONS = [DEFAULT_TAG, :a].freeze
|
23
|
+
TAG_OPTIONS = [DEFAULT_TAG, :a, :summary].freeze
|
24
24
|
|
25
25
|
DEFAULT_TYPE = :button
|
26
26
|
TYPE_OPTIONS = [DEFAULT_TYPE, :reset, :submit].freeze
|
@@ -34,20 +34,20 @@ module Primer
|
|
34
34
|
**kwargs
|
35
35
|
)
|
36
36
|
@kwargs = kwargs
|
37
|
-
@kwargs[:tag] = fetch_or_fallback(TAG_OPTIONS, tag, DEFAULT_TAG)
|
37
|
+
@kwargs[:tag] = fetch_or_fallback(TAG_OPTIONS, tag.to_sym, DEFAULT_TAG)
|
38
38
|
|
39
39
|
if @kwargs[:tag] == :a
|
40
40
|
@kwargs[:role] = :button
|
41
41
|
else
|
42
|
-
@kwargs[:type] = type
|
42
|
+
@kwargs[:type] = type.to_sym
|
43
43
|
end
|
44
44
|
|
45
45
|
@kwargs[:classes] = class_names(
|
46
46
|
"btn",
|
47
47
|
kwargs[:classes],
|
48
48
|
BUTTON_TYPE_MAPPINGS[fetch_or_fallback(BUTTON_TYPE_OPTIONS, button_type.to_sym, DEFAULT_BUTTON_TYPE)],
|
49
|
-
VARIANT_MAPPINGS[fetch_or_fallback(VARIANT_OPTIONS, variant, DEFAULT_VARIANT)],
|
50
|
-
|
49
|
+
VARIANT_MAPPINGS[fetch_or_fallback(VARIANT_OPTIONS, variant.to_sym, DEFAULT_VARIANT)],
|
50
|
+
"BtnGroup-item" => group_item
|
51
51
|
)
|
52
52
|
end
|
53
53
|
|
@@ -9,6 +9,13 @@ module Primer
|
|
9
9
|
:light_gray => "Counter Counter--gray-light",
|
10
10
|
}.freeze
|
11
11
|
|
12
|
+
# @param count [Integer, Float::INFINITY, nil] The number to be displayed (e.x. # of issues, pull requests)
|
13
|
+
# @param scheme [Symbol] Color scheme. One of `SCHEME_MAPPINGS.keys`.
|
14
|
+
# @param limit [Integer] Maximum value to display. (e.x. if count == 6,000 and limit == 5000, counter will display "5,000+")
|
15
|
+
# @param hide_if_zero [Boolean] If true, a `hidden` attribute is added to the counter if `count` is zero.
|
16
|
+
# @param text [String] Text to display instead of count.
|
17
|
+
# @param round [Boolean] Whether to apply our standard rounding logic to value.
|
18
|
+
# @param kwargs [Hash] Style arguments to be passed to Primer::Classify
|
12
19
|
def initialize(
|
13
20
|
count: 0,
|
14
21
|
scheme: DEFAULT_SCHEME,
|
@@ -1,6 +1,8 @@
|
|
1
1
|
<%= render Primer::BaseComponent.new(**@kwargs) do %>
|
2
|
-
<%= render
|
3
|
-
<%= summary %>
|
2
|
+
<%= render summary.component do %>
|
3
|
+
<%= summary.content %>
|
4
|
+
<% end %>
|
5
|
+
<%= render body.component do %>
|
6
|
+
<%= body.content %>
|
4
7
|
<% end %>
|
5
|
-
<%= body %>
|
6
8
|
<% end %>
|
@@ -7,6 +7,8 @@ module Primer
|
|
7
7
|
# reset will remove all styles from the <summary> element.
|
8
8
|
#
|
9
9
|
class DetailsComponent < Primer::Component
|
10
|
+
include ViewComponent::Slotable
|
11
|
+
|
10
12
|
OVERLAY_DEFAULT = :none
|
11
13
|
OVERLAY_MAPPINGS = {
|
12
14
|
OVERLAY_DEFAULT => "",
|
@@ -14,25 +16,48 @@ module Primer
|
|
14
16
|
:dark => "details-overlay details-overlay-dark",
|
15
17
|
}.freeze
|
16
18
|
|
17
|
-
|
18
|
-
|
19
|
-
BUTTON_OPTIONS = [BUTTON_DEFAULT, BUTTON_RESET]
|
20
|
-
|
21
|
-
with_content_areas :summary, :body
|
22
|
-
|
23
|
-
def initialize(overlay: OVERLAY_DEFAULT, button: BUTTON_DEFAULT, **kwargs)
|
24
|
-
@button = fetch_or_fallback(BUTTON_OPTIONS, button, BUTTON_DEFAULT)
|
19
|
+
with_slot :body, class_name: "Body"
|
20
|
+
with_slot :summary, class_name: "Summary"
|
25
21
|
|
22
|
+
def initialize(overlay: OVERLAY_DEFAULT, reset: false, **kwargs)
|
26
23
|
@kwargs = kwargs
|
27
24
|
@kwargs[:tag] = :details
|
28
25
|
@kwargs[:classes] = class_names(
|
29
26
|
kwargs[:classes],
|
30
|
-
OVERLAY_MAPPINGS[fetch_or_fallback(OVERLAY_MAPPINGS.keys, overlay, OVERLAY_DEFAULT)],
|
31
|
-
"details-reset" =>
|
27
|
+
OVERLAY_MAPPINGS[fetch_or_fallback(OVERLAY_MAPPINGS.keys, overlay.to_sym, OVERLAY_DEFAULT)],
|
28
|
+
"details-reset" => reset
|
32
29
|
)
|
30
|
+
end
|
31
|
+
|
32
|
+
def render?
|
33
|
+
summary.present? && body.present?
|
34
|
+
end
|
35
|
+
|
36
|
+
class Summary < Primer::Slot
|
37
|
+
def initialize(button: true, **kwargs)
|
38
|
+
@button = button
|
39
|
+
|
40
|
+
@kwargs = kwargs
|
41
|
+
@kwargs[:tag] = :summary
|
42
|
+
@kwargs[:role] = "button"
|
43
|
+
end
|
44
|
+
|
45
|
+
def component
|
46
|
+
return Primer::BaseComponent.new(**@kwargs) unless @button
|
47
|
+
|
48
|
+
Primer::ButtonComponent.new(**@kwargs)
|
49
|
+
end
|
50
|
+
end
|
51
|
+
|
52
|
+
class Body < Primer::Slot
|
53
|
+
def initialize(**kwargs)
|
54
|
+
@kwargs = kwargs
|
55
|
+
@kwargs[:tag] ||= :div
|
56
|
+
end
|
33
57
|
|
34
|
-
|
35
|
-
|
58
|
+
def component
|
59
|
+
Primer::BaseComponent.new(**@kwargs)
|
60
|
+
end
|
36
61
|
end
|
37
62
|
end
|
38
63
|
end
|
data/lib/primer/classify.rb
CHANGED
@@ -131,7 +131,7 @@ module Primer
|
|
131
131
|
raise ArgumentError.new(
|
132
132
|
"Primer CSS class #{'name'.pluralize(invalid_class_names.length)} \
|
133
133
|
#{invalid_class_names.to_sentence} #{'is'.pluralize(invalid_class_names.length)} \
|
134
|
-
not allowed, use
|
134
|
+
not allowed, use style arguments instead (https://github.com/primer/view_components#built-in-styling-arguments). This warning will not be raised in production.",
|
135
135
|
)
|
136
136
|
end
|
137
137
|
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.
|
4
|
+
version: 0.0.6
|
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-08
|
11
|
+
date: 2020-09-08 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|
@@ -126,7 +126,49 @@ dependencies:
|
|
126
126
|
- - "~>"
|
127
127
|
- !ruby/object:Gem::Version
|
128
128
|
version: 0.13.0
|
129
|
-
|
129
|
+
- !ruby/object:Gem::Dependency
|
130
|
+
name: simplecov
|
131
|
+
requirement: !ruby/object:Gem::Requirement
|
132
|
+
requirements:
|
133
|
+
- - "~>"
|
134
|
+
- !ruby/object:Gem::Version
|
135
|
+
version: 0.18.0
|
136
|
+
type: :development
|
137
|
+
prerelease: false
|
138
|
+
version_requirements: !ruby/object:Gem::Requirement
|
139
|
+
requirements:
|
140
|
+
- - "~>"
|
141
|
+
- !ruby/object:Gem::Version
|
142
|
+
version: 0.18.0
|
143
|
+
- !ruby/object:Gem::Dependency
|
144
|
+
name: simplecov-console
|
145
|
+
requirement: !ruby/object:Gem::Requirement
|
146
|
+
requirements:
|
147
|
+
- - "~>"
|
148
|
+
- !ruby/object:Gem::Version
|
149
|
+
version: 0.7.2
|
150
|
+
type: :development
|
151
|
+
prerelease: false
|
152
|
+
version_requirements: !ruby/object:Gem::Requirement
|
153
|
+
requirements:
|
154
|
+
- - "~>"
|
155
|
+
- !ruby/object:Gem::Version
|
156
|
+
version: 0.7.2
|
157
|
+
- !ruby/object:Gem::Dependency
|
158
|
+
name: yard
|
159
|
+
requirement: !ruby/object:Gem::Requirement
|
160
|
+
requirements:
|
161
|
+
- - "~>"
|
162
|
+
- !ruby/object:Gem::Version
|
163
|
+
version: 0.9.25
|
164
|
+
type: :development
|
165
|
+
prerelease: false
|
166
|
+
version_requirements: !ruby/object:Gem::Requirement
|
167
|
+
requirements:
|
168
|
+
- - "~>"
|
169
|
+
- !ruby/object:Gem::Version
|
170
|
+
version: 0.9.25
|
171
|
+
description:
|
130
172
|
email:
|
131
173
|
- opensource+primer_view_components@github.com
|
132
174
|
executables: []
|
@@ -184,7 +226,7 @@ licenses:
|
|
184
226
|
- MIT
|
185
227
|
metadata:
|
186
228
|
allowed_push_host: https://rubygems.org
|
187
|
-
post_install_message:
|
229
|
+
post_install_message:
|
188
230
|
rdoc_options: []
|
189
231
|
require_paths:
|
190
232
|
- lib
|
@@ -200,7 +242,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
200
242
|
version: '0'
|
201
243
|
requirements: []
|
202
244
|
rubygems_version: 3.1.2
|
203
|
-
signing_key:
|
245
|
+
signing_key:
|
204
246
|
specification_version: 4
|
205
247
|
summary: ViewComponents for the Primer Design System
|
206
248
|
test_files: []
|