primer_view_components 0.0.9 → 0.0.10
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +6 -0
- data/app/components/primer/avatar_component.rb +11 -0
- data/app/components/primer/base_component.rb +6 -9
- data/app/components/primer/blankslate_component.rb +66 -111
- data/app/components/primer/counter_component.rb +4 -0
- data/app/components/primer/spinner_component.html.erb +6 -0
- data/app/components/primer/spinner_component.rb +38 -0
- data/app/components/primer/view_components.rb +1 -0
- data/lib/primer/view_components/version.rb +1 -1
- metadata +5 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f4ccf1dd55332ea7b350841d78e04a0f56a0f036749638c30041582500cc561c
|
4
|
+
data.tar.gz: f948087b2dba1cd217296a08260db95a8973cf8e58d4e1240a2c45295ef17e24
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2359e308fa78d78b5cb0f4e76791bfcd6a9714b7295320d04f293f0b7e0351c4fbad90a13743c61e9401de9c69c1269ee791167638715e7fafc594a47b8a242b
|
7
|
+
data.tar.gz: 2089d76d7cdef40b4bce9871d2b0ade0f492751ba057dc99e6fabc4654390656e0cdef57004931d66b1ea75f6189581dbf840bedbb7b89ee6d0fbfdb31d13136
|
data/CHANGELOG.md
CHANGED
@@ -1,9 +1,20 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
module Primer
|
4
|
+
# Avatars are images used to represent users and organizations on GitHub.
|
5
|
+
# Use the default round avatar for users, and the `square` argument
|
6
|
+
# for organizations or any other non-human avatars.
|
4
7
|
class AvatarComponent < Primer::Component
|
5
8
|
SMALL_THRESHOLD = 24
|
6
9
|
|
10
|
+
#
|
11
|
+
# @example 34|Default
|
12
|
+
# <%= render(Primer::AvatarComponent.new(src: "http://placekitten.com/200/200", alt: "@kittenuser")) %>
|
13
|
+
#
|
14
|
+
# @param src [String] The source url of the avatar image
|
15
|
+
# @param alt [String] Passed through to alt on img tag
|
16
|
+
# @param size [Integer] Adds the avatar-small class if less than 24
|
17
|
+
# @param square [Boolean] Used to create a square avatar.
|
7
18
|
def initialize(src:, alt:, size: 20, square: false, **kwargs)
|
8
19
|
@kwargs = kwargs
|
9
20
|
@kwargs[:tag] = :img
|
@@ -2,18 +2,15 @@
|
|
2
2
|
|
3
3
|
module Primer
|
4
4
|
# Base component used by other Primer components.
|
5
|
-
#
|
6
|
-
# tag(symbol): HTML tag name to be passed to tag.send(tag)
|
7
|
-
# class_names(string): CSS class name value to be concatenated with generated Primer CSS classes
|
8
|
-
# args(hash): Combination of arguments for classes_from_hash and content_tag
|
9
|
-
#
|
10
|
-
# Example usage:
|
11
|
-
# <%= render Primer::BaseComponent, tag: :a, href: "http://www.google.com", mt: 4 do %>Link<% end %>
|
12
|
-
# generates:
|
13
|
-
# <a href="http://www.google.com" class="mt-4">Link</a>
|
14
5
|
class BaseComponent < Primer::Component
|
15
6
|
TEST_SELECTOR_TAG = :test_selector
|
16
7
|
|
8
|
+
#
|
9
|
+
# @example 34|Default
|
10
|
+
# <%= render(Primer::BaseComponent.new(tag: :a, href: "http://www.google.com", mt: 4)) { "Link" } %>
|
11
|
+
#
|
12
|
+
# @param tag [Symbol] HTML tag name to be passed to tag.send(tag)
|
13
|
+
# @param classes [String] CSS class name value to be concatenated with generated Primer CSS classes
|
17
14
|
def initialize(tag:, classes: nil, **args)
|
18
15
|
@tag = tag
|
19
16
|
@result = Primer::Classify.call(**args.merge(classes: classes))
|
@@ -1,118 +1,73 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
module Primer
|
4
|
-
#
|
5
|
-
#
|
6
|
-
# ## Basic example
|
7
|
-
#
|
8
|
-
# The `Primer::BlankslateComponent` supports the following arguments to add a basic blankslate:
|
9
|
-
#
|
10
|
-
# 1. `title` (`String` optional). Text that appears in a larger bold font.
|
11
|
-
# 2. `description` (`String` optional). Text that appears below the title. Typically a whole sentence.
|
12
|
-
#
|
13
|
-
# ```ruby
|
14
|
-
# <%= render Primer::BlankslateComponent.new(
|
15
|
-
# title: "Title",
|
16
|
-
# description: "Description",
|
17
|
-
# ) %>
|
18
|
-
# ```
|
19
|
-
#
|
20
|
-
# ## Icon or graphic (optional)
|
21
|
-
#
|
22
|
-
# Add an `icon` to give additional context. Please refer to the [Octicons](https://primer.style/octicons/) documentation to choose an icon.
|
23
|
-
#
|
24
|
-
# ```ruby
|
25
|
-
# <%= render Primer::BlankslateComponent.new(
|
26
|
-
# icon: "octoface",
|
27
|
-
# title: "Title",
|
28
|
-
# description: "Description",
|
29
|
-
# ) %>
|
30
|
-
# ```
|
31
|
-
#
|
32
|
-
# Alternatively you can also add a graphic by providing a path (`image_src`) to an image instead.Also, make sure to add an alternative description (`image_alt`). It will be used for the `alt` tag.
|
33
|
-
#
|
34
|
-
# ```ruby
|
35
|
-
# <%= render Primer::BlankslateComponent.new(
|
36
|
-
# image_src: "file.svg",
|
37
|
-
# image_alt: "Description of the image",
|
38
|
-
# title: "Title",
|
39
|
-
# description: "Description",
|
40
|
-
# ) %>
|
41
|
-
# ```
|
42
|
-
#
|
43
|
-
# Both icon and graphic will appear above the title.
|
44
|
-
#
|
45
|
-
#
|
46
|
-
# ## Custom content (optional)
|
47
|
-
#
|
48
|
-
# You can add any custom content that typically is used instead of the description:
|
49
|
-
#
|
50
|
-
# ```ruby
|
51
|
-
# <%= render Primer::BlankslateComponent.new(
|
52
|
-
# icon: "octoface",
|
53
|
-
# title: "Title",
|
54
|
-
# ) do %>
|
55
|
-
# <p>Your custom content here</p>
|
56
|
-
# <% end %>
|
57
|
-
# ```
|
58
|
-
#
|
59
|
-
# ## Action button (optional)
|
60
|
-
#
|
61
|
-
# You can provide an action button to help users replace the blankslate. The button will appear below the description and custom content. It takes the following arguments:
|
62
|
-
#
|
63
|
-
# - `button_text` (`String` optional). The text of the button.
|
64
|
-
# - `button_url` (`String` optional). The URL where the user will be taken after clicking the button.
|
65
|
-
#
|
66
|
-
# ```ruby
|
67
|
-
# <%= render Primer::BlankslateComponent.new(
|
68
|
-
# icon: "book",
|
69
|
-
# title: "Welcome to the mona wiki!",
|
70
|
-
# 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.",
|
71
|
-
#
|
72
|
-
# button_text: "Create the first page",
|
73
|
-
# button_url: "https://github.com/monalisa/mona/wiki/_new",
|
74
|
-
# ) %>
|
75
|
-
# ```
|
76
|
-
#
|
77
|
-
# ## Link (optional)
|
78
|
-
#
|
79
|
-
# Add an additional link to help users learn more about a feature. The link will be shown at the very bottom:
|
80
|
-
#
|
81
|
-
# - `link_text` (`String` optional). The text of the link.
|
82
|
-
# - `link_url` (`String` optional). The URL where the user will be taken after clicking the link.
|
83
|
-
#
|
84
|
-
# ```ruby
|
85
|
-
# <%= render Primer::BlankslateComponent.new(
|
86
|
-
# icon: "book",
|
87
|
-
# title: "Welcome to the mona wiki!",
|
88
|
-
# 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.",
|
89
|
-
# button_text: "Create the first page",
|
90
|
-
# button_url: "https://github.com/monalisa/mona/wiki/_new",
|
91
|
-
# link_text: "Learn more about wikis",
|
92
|
-
# link_url: "https://docs.github.com/en/github/building-a-strong-community/about-wikis",
|
93
|
-
# ) %>
|
94
|
-
# ```
|
95
|
-
#
|
96
|
-
# ## Variations (optional)
|
97
|
-
#
|
98
|
-
# There are a few variations of how the Blankslate appears:
|
99
|
-
#
|
100
|
-
# - `narrow` (`Boolean` optional). Adds a maximum width.
|
101
|
-
# - `large` (`Boolean` optional). Increaeses the font size.
|
102
|
-
# - `spacious` (`Boolean` optional). Adds extra padding.
|
103
|
-
#
|
104
|
-
# ```ruby
|
105
|
-
# <%= render Primer::BlankslateComponent.new(
|
106
|
-
# icon: "book",
|
107
|
-
# title: "Welcome to the mona wiki!",
|
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.",
|
109
|
-
#
|
110
|
-
# narrow: true,
|
111
|
-
# large: true,
|
112
|
-
# spacious: true,
|
113
|
-
# ) %>
|
114
|
-
# ```
|
4
|
+
# Use Primer::BlankslateComponent when there is a lack of content within a page or section. Use as placeholder to tell users why something isn't there.
|
115
5
|
class BlankslateComponent < Primer::Component
|
6
|
+
#
|
7
|
+
# @example 150|Basic
|
8
|
+
# <%= render Primer::BlankslateComponent.new(
|
9
|
+
# title: "Title",
|
10
|
+
# description: "Description",
|
11
|
+
# ) %>
|
12
|
+
#
|
13
|
+
# @example 190|Icon|Add an `icon` to give additional context. Refer to the [Octicons](https://primer.style/octicons/) documentation to choose an icon.
|
14
|
+
# <%= render Primer::BlankslateComponent.new(
|
15
|
+
# icon: "octoface",
|
16
|
+
# title: "Title",
|
17
|
+
# description: "Description",
|
18
|
+
# ) %>
|
19
|
+
#
|
20
|
+
# @example 150|Custom content|Pass custom content as a block in place of `description`.
|
21
|
+
# <%= render Primer::BlankslateComponent.new(
|
22
|
+
# title: "Title",
|
23
|
+
# ) do %>
|
24
|
+
# <em>Your custom content here</em>
|
25
|
+
# <% end %>
|
26
|
+
#
|
27
|
+
# @example 270|Action button|Provide a button to guide users to take action from the blankslate. The button appears below the description and custom content.
|
28
|
+
# <%= render Primer::BlankslateComponent.new(
|
29
|
+
# icon: "book",
|
30
|
+
# title: "Welcome to the mona wiki!",
|
31
|
+
# 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.",
|
32
|
+
#
|
33
|
+
# button_text: "Create the first page",
|
34
|
+
# button_url: "https://github.com/monalisa/mona/wiki/_new",
|
35
|
+
# ) %>
|
36
|
+
#
|
37
|
+
# @example 225|Link|Add an additional link to help users learn more about a feature. The link will be shown at the very bottom:
|
38
|
+
# <%= render Primer::BlankslateComponent.new(
|
39
|
+
# icon: "book",
|
40
|
+
# title: "Welcome to the mona wiki!",
|
41
|
+
# 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.",
|
42
|
+
# link_text: "Learn more about wikis",
|
43
|
+
# link_url: "https://docs.github.com/en/github/building-a-strong-community/about-wikis",
|
44
|
+
# ) %>
|
45
|
+
#
|
46
|
+
# @example 340|Variations|There are a few variations of how the Blankslate appears: `narrow` adds a maximum width, `large` increases the font size, and `spacious` adds extra padding.
|
47
|
+
# <%= render Primer::BlankslateComponent.new(
|
48
|
+
# icon: "book",
|
49
|
+
# title: "Welcome to the mona wiki!",
|
50
|
+
# 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.",
|
51
|
+
# narrow: true,
|
52
|
+
# large: true,
|
53
|
+
# spacious: true,
|
54
|
+
# ) %>
|
55
|
+
#
|
56
|
+
# @param title [String] Text that appears in a larger bold font.
|
57
|
+
# @param title_tag [Symbol] HTML tag to use for title.
|
58
|
+
# @param icon [String] Octicon icon to use at top of component.
|
59
|
+
# @param icon_size [Symbol] One of <%= Primer::OcticonComponent::SIZE_MAPPINGS.keys.map { |k| "`:#{k}`" }.to_sentence %>
|
60
|
+
# @param image_src [String] Image to display.
|
61
|
+
# @param image_alt [String] Alt text for image.
|
62
|
+
# @param description [String] Text that appears below the title. Typically a whole sentence.
|
63
|
+
# @param button_text [String] The text of the button.
|
64
|
+
# @param button_url [String] The URL where the user will be taken after clicking the button.
|
65
|
+
# @param button_classes [String] Classes to apply to action button
|
66
|
+
# @param link_text [String] The text of the link.
|
67
|
+
# @param link_url [String] The URL where the user will be taken after clicking the link.
|
68
|
+
# @param narrow [Boolean] Adds a maximum width.
|
69
|
+
# @param large [Boolean] Increases the font size.
|
70
|
+
# @param spacious [Boolean] Adds extra padding.
|
116
71
|
def initialize(
|
117
72
|
title: "",
|
118
73
|
title_tag: :h3,
|
@@ -10,6 +10,10 @@ module Primer
|
|
10
10
|
:light_gray => "Counter Counter--gray-light",
|
11
11
|
}.freeze
|
12
12
|
|
13
|
+
#
|
14
|
+
# @example 34|Default
|
15
|
+
# <%= render(Primer::CounterComponent.new(count: 25)) %>
|
16
|
+
#
|
13
17
|
# @param count [Integer, Float::INFINITY, nil] The number to be displayed (e.x. # of issues, pull requests)
|
14
18
|
# @param scheme [Symbol] Color scheme. One of `SCHEME_MAPPINGS.keys`.
|
15
19
|
# @param limit [Integer] Maximum value to display. (e.x. if count == 6,000 and limit == 5000, counter will display "5,000+")
|
@@ -0,0 +1,6 @@
|
|
1
|
+
<%= render Primer::BaseComponent.new(**@kwargs) do %>
|
2
|
+
<circle cx="8" cy="8" r="7" stroke="currentColor" stroke-opacity="0.25" stroke-width="2" vector-effect="non-scaling-stroke" />
|
3
|
+
<path d="M15 8a7.002 7.002 0 00-7-7" stroke="currentColor" stroke-width="2" stroke-linecap="round" vector-effect="non-scaling-stroke">
|
4
|
+
<animateTransform attributeName="transform" type="rotate" from="0 8 8" to="360 8 8" dur="1s" repeatCount="indefinite" />
|
5
|
+
</path>
|
6
|
+
<% end %>
|
@@ -0,0 +1,38 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Primer
|
4
|
+
# Use Primer::SpinnerComponent to let users know that content is being loaded.
|
5
|
+
class SpinnerComponent < Primer::Component
|
6
|
+
|
7
|
+
DEFAULT_SIZE = :medium
|
8
|
+
SIZE_MAPPINGS = {
|
9
|
+
:small => 16,
|
10
|
+
DEFAULT_SIZE => 32,
|
11
|
+
:large => 64,
|
12
|
+
}.freeze
|
13
|
+
SIZE_OPTIONS = SIZE_MAPPINGS.keys
|
14
|
+
|
15
|
+
#
|
16
|
+
# @example 48|Default
|
17
|
+
# <%= render(Primer::SpinnerComponent.new) %>
|
18
|
+
#
|
19
|
+
# @example 32|Small
|
20
|
+
# <%= render(Primer::SpinnerComponent.new(size: :small)) %>
|
21
|
+
#
|
22
|
+
# @example 80|Large
|
23
|
+
# <%= render(Primer::SpinnerComponent.new(size: :large)) %>
|
24
|
+
#
|
25
|
+
# @param size [Symbol] One of <%= Primer::SpinnerComponent::SIZE_OPTIONS.map { |k| "`:#{k}`" }.to_sentence(last_word_connector: ', or ') %>
|
26
|
+
def initialize(size: DEFAULT_SIZE, **kwargs)
|
27
|
+
@kwargs = kwargs
|
28
|
+
@kwargs[:tag] = :svg
|
29
|
+
@kwargs[:width] = SIZE_MAPPINGS[fetch_or_fallback(SIZE_OPTIONS, size, DEFAULT_SIZE)]
|
30
|
+
@kwargs[:height] = SIZE_MAPPINGS[fetch_or_fallback(SIZE_OPTIONS, size, DEFAULT_SIZE)]
|
31
|
+
@kwargs[:viewBox] = "0 0 16 16"
|
32
|
+
@kwargs[:fill] = :none
|
33
|
+
# Setting `box-sizing: content-box` allows consumers to add padding
|
34
|
+
# to the spinner without shrinking the icon
|
35
|
+
@kwargs[:style] = "box-sizing: content-box; color: var(--color-icon-primary);"
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
@@ -43,6 +43,7 @@ require_relative "link_component"
|
|
43
43
|
require_relative "octicon_component"
|
44
44
|
require_relative "popover_component"
|
45
45
|
require_relative "progress_bar_component"
|
46
|
+
require_relative "spinner_component"
|
46
47
|
require_relative "state_component"
|
47
48
|
require_relative "subhead_component"
|
48
49
|
require_relative "text_component"
|
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.10
|
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-10-
|
11
|
+
date: 2020-10-19 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|
@@ -223,6 +223,8 @@ files:
|
|
223
223
|
- app/components/primer/progress_bar_component.html.erb
|
224
224
|
- app/components/primer/progress_bar_component.rb
|
225
225
|
- app/components/primer/slot.rb
|
226
|
+
- app/components/primer/spinner_component.html.erb
|
227
|
+
- app/components/primer/spinner_component.rb
|
226
228
|
- app/components/primer/state_component.rb
|
227
229
|
- app/components/primer/subhead_component.html.erb
|
228
230
|
- app/components/primer/subhead_component.rb
|
@@ -258,7 +260,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
258
260
|
- !ruby/object:Gem::Version
|
259
261
|
version: '0'
|
260
262
|
requirements: []
|
261
|
-
rubygems_version: 3.
|
263
|
+
rubygems_version: 3.0.3
|
262
264
|
signing_key:
|
263
265
|
specification_version: 4
|
264
266
|
summary: ViewComponents for the Primer Design System
|