primer_view_components 0.0.10 → 0.0.11
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 +4 -4
- data/CHANGELOG.md +6 -0
- data/README.md +1 -176
- data/app/components/primer/blankslate_component.rb +1 -1
- data/app/components/primer/border_box_component.rb +16 -4
- data/app/components/primer/box_component.rb +2 -0
- data/app/components/primer/breadcrumb_component.rb +13 -20
- data/app/components/primer/button_component.rb +17 -0
- data/app/components/primer/component.rb +1 -0
- data/app/components/primer/details_component.rb +4 -4
- data/app/components/primer/flash_component.rb +31 -1
- data/app/components/primer/label_component.rb +17 -0
- data/app/components/primer/layout_component.rb +17 -0
- data/app/components/primer/link_component.rb +10 -0
- data/app/components/primer/octicon_component.rb +13 -0
- data/app/components/primer/popover_component.rb +38 -0
- data/app/components/primer/progress_bar_component.rb +29 -19
- data/app/components/primer/slot.rb +1 -0
- data/app/components/primer/spinner_component.rb +1 -1
- data/app/components/primer/state_component.rb +19 -7
- data/app/components/primer/subhead_component.rb +45 -20
- data/app/components/primer/text_component.rb +6 -0
- data/app/components/primer/timeline_item_component.rb +24 -0
- data/lib/primer/view_components/version.rb +1 -1
- metadata +7 -7
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: befa90070fd7a8cd5a5668c8ac39697fb4baf39d11ebc50f938f72eb1805543a
|
4
|
+
data.tar.gz: c9b3abe81ae870566a2a2decf6135b8f13158842c43fd46b40346aba6fcc6e45
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 16cbb49509d19431d5dba889847c350c5720b471452a62d5452de2ce454376826edc37628b5b65711255dbe4bd50357f7b7c0d158b2c595b15685db974e11607
|
7
|
+
data.tar.gz: aea1f3880d89157176c509eba04c7a79d9fd443e9f8ca8d5e3f40960e27ed94e100c69bfde39c86bba76471e76d6afca4f6ed7919d398e35b076a4ef5f659309
|
data/CHANGELOG.md
CHANGED
data/README.md
CHANGED
@@ -8,182 +8,7 @@
|
|
8
8
|
|
9
9
|
_Note: This library is in pre-release development and should not be considered stable._
|
10
10
|
|
11
|
-
|
12
|
-
|
13
|
-
Primer ViewComponents aims to mimic the API of [Primer Components](https://github.com/primer/components), while using [Primer CSS](https://github.com/primer/css) under the hood.
|
14
|
-
|
15
|
-
## Installation
|
16
|
-
|
17
|
-
In `Gemfile`, add:
|
18
|
-
|
19
|
-
```ruby
|
20
|
-
gem "primer_view_components"
|
21
|
-
```
|
22
|
-
|
23
|
-
In `config/application.rb`, add **after the application definition**
|
24
|
-
|
25
|
-
```ruby
|
26
|
-
require "primer/view_components/engine"
|
27
|
-
```
|
28
|
-
|
29
|
-
## Usage
|
30
|
-
|
31
|
-
### Built-in styling arguments
|
32
|
-
|
33
|
-
Primer components should be styled using the built-in arguments when possible. Most Primer utility classes for spacing, alignment, display, and colors have equivalent component arguments.
|
34
|
-
|
35
|
-
Example label built with Primer CSS:
|
36
|
-
|
37
|
-
```html
|
38
|
-
<span title="Label: Suggested" class="Label Label--outline Label--outline-green ml-2 v-align-middle">Suggested</span>
|
39
|
-
```
|
40
|
-
|
41
|
-
The same label using `Primer::LabelComponent`:
|
42
|
-
|
43
|
-
```erb
|
44
|
-
<%= render Primer::LabelComponent.new(ml: 2, vertical_align: :middle, scheme: :green, title: "Label: Suggested") do %>
|
45
|
-
Suggested
|
46
|
-
<% end %>
|
47
|
-
```
|
48
|
-
|
49
|
-
Some components have their own specific arguments, but they can all be styled with the following arguments.
|
50
|
-
|
51
|
-
| Component argument | Primer class | Example |
|
52
|
-
| --------------- | --------------- | -------- |
|
53
|
-
| `m` | `m-<value>` | `m: 4` → `.m-4` |
|
54
|
-
| `my` | `my-<value>` | `my: 4` → `.my-4` |
|
55
|
-
| `mx` | `my-<value>` | `mx: 4` → `.mx-4` |
|
56
|
-
| `mt` | `mt-<value>` | `mt: 4` → `.mt-4` |
|
57
|
-
| `mb` | `mb-<value>` | `mb: 4` → `.mb-4` |
|
58
|
-
| `ml` | `ml-<value>` | `ml: 4` → `.ml-4` |
|
59
|
-
| `mr` | `mr-<value>` | `mr: 4` → `.mr-4` |
|
60
|
-
| `p` | `p-<value>` | `p: 4` → `.p-4` |
|
61
|
-
| `py` | `py-<value>` | `py: 4` → `.py-4` |
|
62
|
-
| `px` | `py-<value>` | `px: 4` → `.px-4` |
|
63
|
-
| `pt` | `pt-<value>` | `pt: 4` → `.pt-4` |
|
64
|
-
| `pb` | `pb-<value>` | `pb: 4` → `.pb-4` |
|
65
|
-
| `pl` | `pl-<value>` | `pl: 4` → `.pl-4` |
|
66
|
-
| `pr` | `pr-<value>` | `pr: 4` → `.pr-4` |
|
67
|
-
| `pr` | `pr-<value>` | `pr: 4` → `.pr-4` |
|
68
|
-
| `f` | `f-<value>` | `f: 4` → `.f-4` |
|
69
|
-
| `color` | `color-<value>` | `color: :red_500` → `.color-red-500` |
|
70
|
-
| `text` | `text-<value>` | `text: :green` → `.text-green` |
|
71
|
-
| `bg` | `bg-<value>` | `bg: :blue_light` → `.bg-blue-light` |
|
72
|
-
| `display` | `d-<value>` | `display: :none` → `.d-none` |
|
73
|
-
| `float` | `float-<value>` | `float: :right` → `.float-right` |
|
74
|
-
| `vertical_align` | `v-align-<value>` | `vertical_align: :baseline` → `.v-align-baseline` |
|
75
|
-
| `text_align` | `text-<value>` | `text_align: :right` → `.text-right` |
|
76
|
-
| `font_size` | `f<value>` | `font_size: 4` → `.f4` |
|
77
|
-
| `font_weight` | `text-<value>` | `font_weight: :bold` → `.text-bold` |
|
78
|
-
| `border` | `border-<value>` | `border: :bottom` → `.border-bottom` |
|
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` |
|
84
|
-
| `word_break` | `wb-<value>` | `word_break: :break_all` → `.wb-break-all` |
|
85
|
-
| `direction` | `flex-<value>` | `direction: :row` → `.flex-row` |
|
86
|
-
| `justify_content` | `flex-justify-<value>` | `justify_content: :center` → `.flex-justify-center` |
|
87
|
-
| `align_items` | `flex-items-<value>` | `align_items: :baseline` → `.flex-items-baseline` |
|
88
|
-
| `box_shadow` | `box-shadow-<value>` | `box_shadow: :medium` → `.box-shadow-medium` |
|
89
|
-
|
90
|
-
#### Boolean arguments
|
91
|
-
|
92
|
-
| Component arguments | True | False |
|
93
|
-
| -------------- | ------- | ------ |
|
94
|
-
| `underline` | `underline: true` → `.text-underline` | `underline: false` → `.no-underline` |
|
95
|
-
| `top` | n/a | `top: false` → `.top-0` |
|
96
|
-
| `bottom` | n/a | `bottom: false` → `.bottom-0` |
|
97
|
-
| `left` | n/a | `left: false` → `.left-0` |
|
98
|
-
| `right` | n/a | `right: false` → `.right-0` |
|
99
|
-
|
100
|
-
#### Responsive arguments
|
101
|
-
|
102
|
-
Different classes can be used for different breakpoints just like in Primer CSS. Simply use an array with the four values required for `[none, small, medium, large]`. If no breakpoint is needed for a breakpoint, pass `nil`.
|
103
|
-
|
104
|
-
Example heading built with Primer CSS:
|
105
|
-
|
106
|
-
```html
|
107
|
-
<h1 class="mt-0 mt-lg-4">Hello world</h1>
|
108
|
-
```
|
109
|
-
|
110
|
-
The same label using `Primer::HeadingComponent`:
|
111
|
-
|
112
|
-
```erb
|
113
|
-
<%= render Primer::HeadingComponent.new(mt: [0, nil, nil, 4]) do %>
|
114
|
-
Hello world
|
115
|
-
<% end %>
|
116
|
-
```
|
117
|
-
|
118
|
-
## Contributing
|
119
|
-
|
120
|
-
Bug reports and pull requests are welcome on GitHub at [https://github.com/primer/view_components](https://github.com/primer/view_components). This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.
|
121
|
-
|
122
|
-
### Setting up
|
123
|
-
|
124
|
-
Run
|
125
|
-
|
126
|
-
```bash
|
127
|
-
script/setup
|
128
|
-
```
|
129
|
-
|
130
|
-
To install all necessary dependencies.
|
131
|
-
|
132
|
-
### Running tests
|
133
|
-
|
134
|
-
To run the full test suite:
|
135
|
-
|
136
|
-
```bash
|
137
|
-
bundle exec rake
|
138
|
-
```
|
139
|
-
|
140
|
-
### Writing documentation
|
141
|
-
|
142
|
-
Documentation is written as [YARD](https://yardoc.org/) comments directly in the source code, compiled into Markdown via `rake docs:build` and served by [Doctocat](https://github.com/primer/doctocat).
|
143
|
-
|
144
|
-
### Storybook / Documentation
|
145
|
-
|
146
|
-
To run Storybook and the documentation site, run:
|
147
|
-
|
148
|
-
```bash
|
149
|
-
script/dev
|
150
|
-
```
|
151
|
-
|
152
|
-
_Note: Overmind is required to run script/dev._
|
153
|
-
|
154
|
-
### Developing with another app
|
155
|
-
|
156
|
-
In your `Gemfile`, change:
|
157
|
-
|
158
|
-
```ruby
|
159
|
-
gem "primer_view_components"
|
160
|
-
```
|
161
|
-
|
162
|
-
to
|
163
|
-
|
164
|
-
```ruby
|
165
|
-
gem "primer_view_components", path: "path_to_the_gem" # e.g. path: "~/primer/view_components"
|
166
|
-
```
|
167
|
-
|
168
|
-
Then, `bundle install` to update references. You'll now be able to see changes from the gem without having to build it.
|
169
|
-
Remember that restarting the Rails server is necessary to see changes, as the gem is loaded at boot time.
|
170
|
-
|
171
|
-
To minimize the number of restarts, we recommend checking the component in Storybook first, and then when it's in a good state,
|
172
|
-
you can check it in your app.
|
173
|
-
|
174
|
-
### Documentation
|
175
|
-
|
176
|
-
Document components with [YARD](https://yardoc.org/). Docs are published to [RubyDoc.info](https://rubydoc.info/github/primer/view_components).
|
177
|
-
|
178
|
-
## Deploying to Heroku
|
179
|
-
|
180
|
-
We have both `staging` and `production` environments. To deploy Storybook to Heroku, run the following in `#primer-view-components-ops`:
|
181
|
-
|
182
|
-
```bash
|
183
|
-
.deploy primer-view-components</branch> to <environment>
|
184
|
-
```
|
185
|
-
|
186
|
-
If no `branch` is passed, `main` will be deployed.
|
11
|
+
Visit [https://view-components.primer.vercel.app/](https://view-components.primer.vercel.app/) to view documentation.
|
187
12
|
|
188
13
|
## License
|
189
14
|
|
@@ -56,7 +56,7 @@ module Primer
|
|
56
56
|
# @param title [String] Text that appears in a larger bold font.
|
57
57
|
# @param title_tag [Symbol] HTML tag to use for title.
|
58
58
|
# @param icon [String] Octicon icon to use at top of component.
|
59
|
-
# @param icon_size [Symbol]
|
59
|
+
# @param icon_size [Symbol] <%= one_of(Primer::OcticonComponent::SIZE_MAPPINGS.keys) %>
|
60
60
|
# @param image_src [String] Image to display.
|
61
61
|
# @param image_alt [String] Alt text for image.
|
62
62
|
# @param description [String] Text that appears below the title. Typically a whole sentence.
|
@@ -1,6 +1,7 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
module Primer
|
4
|
+
# BorderBox is a Box component with a border.
|
4
5
|
class BorderBoxComponent < Primer::Component
|
5
6
|
include ViewComponent::Slotable
|
6
7
|
|
@@ -9,6 +10,17 @@ module Primer
|
|
9
10
|
with_slot :footer, class_name: "Footer"
|
10
11
|
with_slot :row, collection: true, class_name: "Row"
|
11
12
|
|
13
|
+
# @example 350|Header, body, rows, and footer
|
14
|
+
# <%= render(Primer::BorderBoxComponent.new) do |component|
|
15
|
+
# component.slot(:header) { "Header" }
|
16
|
+
# component.slot(:body) { "Body" }
|
17
|
+
# component.slot(:row) { "Row one" }
|
18
|
+
# component.slot(:row) { "Row two" }
|
19
|
+
# component.slot(:row) { "Row three" }
|
20
|
+
# component.slot(:footer) { "Footer" }
|
21
|
+
# end %>
|
22
|
+
#
|
23
|
+
# @param kwargs [Hash] <%= link_to_style_arguments_docs %>
|
12
24
|
def initialize(**kwargs)
|
13
25
|
@kwargs = kwargs
|
14
26
|
@kwargs[:tag] = :div
|
@@ -23,8 +35,8 @@ module Primer
|
|
23
35
|
end
|
24
36
|
|
25
37
|
class Header < Primer::Slot
|
26
|
-
|
27
38
|
attr_reader :kwargs
|
39
|
+
# @param kwargs [Hash] <%= link_to_style_arguments_docs %>
|
28
40
|
def initialize(**kwargs)
|
29
41
|
@kwargs = kwargs
|
30
42
|
@kwargs[:tag] = :div
|
@@ -36,8 +48,8 @@ module Primer
|
|
36
48
|
end
|
37
49
|
|
38
50
|
class Body < Primer::Slot
|
39
|
-
|
40
51
|
attr_reader :kwargs
|
52
|
+
# @param kwargs [Hash] <%= link_to_style_arguments_docs %>
|
41
53
|
def initialize(**kwargs)
|
42
54
|
@kwargs = kwargs
|
43
55
|
@kwargs[:tag] = :div
|
@@ -49,8 +61,8 @@ module Primer
|
|
49
61
|
end
|
50
62
|
|
51
63
|
class Footer < Primer::Slot
|
52
|
-
|
53
64
|
attr_reader :kwargs
|
65
|
+
# @param kwargs [Hash] <%= link_to_style_arguments_docs %>
|
54
66
|
def initialize(**kwargs)
|
55
67
|
@kwargs = kwargs
|
56
68
|
@kwargs[:tag] = :div
|
@@ -62,8 +74,8 @@ module Primer
|
|
62
74
|
end
|
63
75
|
|
64
76
|
class Row < Primer::Slot
|
65
|
-
|
66
77
|
attr_reader :kwargs
|
78
|
+
# @param kwargs [Hash] <%= link_to_style_arguments_docs %>
|
67
79
|
def initialize(**kwargs)
|
68
80
|
@kwargs = kwargs
|
69
81
|
@kwargs[:tag] = :li
|
@@ -1,7 +1,9 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
module Primer
|
4
|
+
# A basic wrapper component for most layout related needs.
|
4
5
|
class BoxComponent < Primer::Component
|
6
|
+
# @param kwargs [Hash] <%= link_to_style_arguments_docs %>
|
5
7
|
def initialize(**kwargs)
|
6
8
|
@kwargs = kwargs
|
7
9
|
@kwargs[:tag] = :div
|
@@ -1,31 +1,20 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
##
|
4
|
-
# Breadcrumbs are used to display page hierarchy within a section of the site. All of the items in the breadcrumb "trail" are links except for the final item which is a plain string indicating the current page.
|
5
|
-
#
|
6
|
-
# ## Example
|
7
|
-
#
|
8
|
-
# The `Primer::BreadcrumbComponent` uses the [Slots API](https://github.com/github/view_component#slots-experimental) and at least one slot is required for the component to render. Each slot can accept the following parameters:
|
9
|
-
#
|
10
|
-
# 1. `href` (string). The URL to link to.
|
11
|
-
# 2. `selected` (boolean, default=false). Flag indicating whether or not the item is selected and not rendered as a link.
|
12
|
-
#
|
13
|
-
# Note that if if both `href` and `selected: true` are passed in, `href` will be ignored and the item will not be rendered as a link.
|
14
|
-
#
|
15
|
-
# ```ruby
|
16
|
-
# <%= render(Primer::BreadcrumbComponent.new) do |component| %>
|
17
|
-
# <% component.slot(:item, href: "/") do %>Home<% end %>
|
18
|
-
# <% component.slot(:item, href: "/about") do %>About<% end %>
|
19
|
-
# <% component.slot(:item, selected: true) do %>Team<% end %>
|
20
|
-
# <% end %>
|
21
|
-
# ```
|
22
|
-
##
|
23
3
|
module Primer
|
4
|
+
# Use breadcrumbs to display page hierarchy within a section of the site. All of the items in the breadcrumb "trail" are links except for the final item, which is a plain string indicating the current page.
|
24
5
|
class BreadcrumbComponent < Primer::Component
|
25
6
|
include ViewComponent::Slotable
|
26
7
|
|
27
8
|
with_slot :item, collection: true, class_name: "BreadcrumbItem"
|
28
9
|
|
10
|
+
# @example 40|Basic
|
11
|
+
# <%= render(Primer::BreadcrumbComponent.new) do |component| %>
|
12
|
+
# <% component.slot(:item, href: "/") do %>Home<% end %>
|
13
|
+
# <% component.slot(:item, href: "/about") do %>About<% end %>
|
14
|
+
# <% component.slot(:item, selected: true) do %>Team<% end %>
|
15
|
+
# <% end %>
|
16
|
+
#
|
17
|
+
# @param kwargs [Hash] <%= link_to_style_arguments_docs %>
|
29
18
|
def initialize(**kwargs)
|
30
19
|
@kwargs = kwargs
|
31
20
|
@kwargs[:tag] = :nav
|
@@ -36,9 +25,13 @@ module Primer
|
|
36
25
|
items.any?
|
37
26
|
end
|
38
27
|
|
28
|
+
# _Note: if both `href` and `selected: true` are passed in, `href` will be ignored and the item will not be rendered as a link._
|
39
29
|
class BreadcrumbItem < Primer::Slot
|
40
30
|
attr_reader :href, :kwargs
|
41
31
|
|
32
|
+
# @param href [String] The URL to link to.
|
33
|
+
# @param selected [Boolean] Whether or not the item is selected and not rendered as a link.
|
34
|
+
# @param kwargs [Hash] <%= link_to_style_arguments_docs %>
|
42
35
|
def initialize(href: nil, selected: false, **kwargs)
|
43
36
|
@href, @kwargs = href, kwargs
|
44
37
|
|
@@ -1,6 +1,7 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
module Primer
|
4
|
+
# Use buttons for actions (e.g. in forms). Use links for destinations, or moving from one page to another.
|
4
5
|
class ButtonComponent < Primer::Component
|
5
6
|
DEFAULT_BUTTON_TYPE = :default
|
6
7
|
BUTTON_TYPE_MAPPINGS = {
|
@@ -25,6 +26,22 @@ module Primer
|
|
25
26
|
DEFAULT_TYPE = :button
|
26
27
|
TYPE_OPTIONS = [DEFAULT_TYPE, :reset, :submit].freeze
|
27
28
|
|
29
|
+
# @example 50|Button types
|
30
|
+
# <%= render(Primer::ButtonComponent.new) { "Default" } %>
|
31
|
+
# <%= render(Primer::ButtonComponent.new(button_type: :primary)) { "Primary" } %>
|
32
|
+
# <%= render(Primer::ButtonComponent.new(button_type: :danger)) { "Danger" } %>
|
33
|
+
# <%= render(Primer::ButtonComponent.new(button_type: :outline)) { "Outline" } %>
|
34
|
+
#
|
35
|
+
# @example 50|Variants
|
36
|
+
# <%= render(Primer::ButtonComponent.new(variant: :small)) { "Small" } %>
|
37
|
+
# <%= render(Primer::ButtonComponent.new(variant: :medium)) { "Medium" } %>
|
38
|
+
# <%= render(Primer::ButtonComponent.new(variant: :large)) { "Large" } %>
|
39
|
+
#
|
40
|
+
# @param button_type [Symbol] <%= one_of(Primer::ButtonComponent::BUTTON_TYPE_OPTIONS) %>
|
41
|
+
# @param variant [Symbol] <%= one_of(Primer::ButtonComponent::VARIANT_OPTIONS) %>
|
42
|
+
# @param tag [Symbol] <%= one_of(Primer::ButtonComponent::TAG_OPTIONS) %>
|
43
|
+
# @param type [Symbol] <%= one_of(Primer::ButtonComponent::TYPE_OPTIONS) %>
|
44
|
+
# @param group_item [Boolean] Whether button is part of a ButtonGroup.
|
28
45
|
def initialize(
|
29
46
|
button_type: DEFAULT_BUTTON_TYPE,
|
30
47
|
variant: DEFAULT_VARIANT,
|
@@ -9,9 +9,9 @@ module Primer
|
|
9
9
|
class DetailsComponent < Primer::Component
|
10
10
|
include ViewComponent::Slotable
|
11
11
|
|
12
|
-
|
12
|
+
NO_OVERLAY = :none
|
13
13
|
OVERLAY_MAPPINGS = {
|
14
|
-
|
14
|
+
NO_OVERLAY => "",
|
15
15
|
:default => "details-overlay",
|
16
16
|
:dark => "details-overlay details-overlay-dark",
|
17
17
|
}.freeze
|
@@ -19,12 +19,12 @@ module Primer
|
|
19
19
|
with_slot :body, class_name: "Body"
|
20
20
|
with_slot :summary, class_name: "Summary"
|
21
21
|
|
22
|
-
def initialize(overlay:
|
22
|
+
def initialize(overlay: NO_OVERLAY, reset: false, **kwargs)
|
23
23
|
@kwargs = kwargs
|
24
24
|
@kwargs[:tag] = :details
|
25
25
|
@kwargs[:classes] = class_names(
|
26
26
|
kwargs[:classes],
|
27
|
-
OVERLAY_MAPPINGS[fetch_or_fallback(OVERLAY_MAPPINGS.keys, overlay,
|
27
|
+
OVERLAY_MAPPINGS[fetch_or_fallback(OVERLAY_MAPPINGS.keys, overlay, NO_OVERLAY)],
|
28
28
|
"details-reset" => reset
|
29
29
|
)
|
30
30
|
end
|
@@ -1,6 +1,7 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
module Primer
|
4
|
+
# Use the Flash component to inform users of successful or pending actions.
|
4
5
|
class FlashComponent < Primer::Component
|
5
6
|
include ViewComponent::Slotable
|
6
7
|
|
@@ -13,7 +14,35 @@ module Primer
|
|
13
14
|
:danger => "flash-error",
|
14
15
|
:success => "flash-success"
|
15
16
|
}.freeze
|
16
|
-
|
17
|
+
# @example 280|Variants
|
18
|
+
# <%= render(Primer::FlashComponent.new) { "This is a flash message!" } %>
|
19
|
+
# <%= render(Primer::FlashComponent.new(variant: :warning)) { "This is a warning flash message!" } %>
|
20
|
+
# <%= render(Primer::FlashComponent.new(variant: :danger)) { "This is a danger flash message!" } %>
|
21
|
+
# <%= render(Primer::FlashComponent.new(variant: :success)) { "This is a success flash message!" } %>
|
22
|
+
#
|
23
|
+
# @example 80|Full width
|
24
|
+
# <%= render(Primer::FlashComponent.new(full: true)) { "This is a full width flash message!" } %>
|
25
|
+
#
|
26
|
+
# @example 80|Dismissible
|
27
|
+
# <%= render(Primer::FlashComponent.new(dismissible: true)) { "This is a dismissible flash message!" } %>
|
28
|
+
#
|
29
|
+
# @example 80|Icon
|
30
|
+
# <%= render(Primer::FlashComponent.new(icon: "people")) { "This is a flash message with an icon!" } %>
|
31
|
+
#
|
32
|
+
# @example 80|With actions
|
33
|
+
# <%= render(Primer::FlashComponent.new) do |component| %>
|
34
|
+
# This is a flash message with actions!
|
35
|
+
# <% component.slot(:actions) do %>
|
36
|
+
# <%= render(Primer::ButtonComponent.new(variant: :small)) { "Take action" } %>
|
37
|
+
# <% end %>
|
38
|
+
# <% end %>
|
39
|
+
#
|
40
|
+
# @param full [Boolean] Whether the component should take up the full width of the screen.
|
41
|
+
# @param spacious [Boolean] Whether to add margin to the bottom of the component.
|
42
|
+
# @param dismissible [Boolean] Whether the component can be dismissed with an X button.
|
43
|
+
# @param icon [String] Name of Octicon icon to use.
|
44
|
+
# @param variant [Symbol] <%= one_of(Primer::FlashComponent::VARIANT_MAPPINGS.keys) %>
|
45
|
+
# @param kwargs [Hash] <%= link_to_style_arguments_docs %>
|
17
46
|
def initialize(full: false, spacious: false, dismissible: false, icon: nil, variant: DEFAULT_VARIANT, **kwargs)
|
18
47
|
@icon = icon
|
19
48
|
@dismissible = dismissible
|
@@ -33,6 +62,7 @@ module Primer
|
|
33
62
|
|
34
63
|
attr_reader :kwargs
|
35
64
|
|
65
|
+
# @param kwargs [Hash] <%= link_to_style_arguments_docs %>
|
36
66
|
def initialize(**kwargs)
|
37
67
|
@kwargs = kwargs
|
38
68
|
@kwargs[:tag] = :div
|
@@ -1,6 +1,7 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
module Primer
|
4
|
+
# Use labels to add contextual metadata to a design.
|
4
5
|
class LabelComponent < Primer::Component
|
5
6
|
SCHEME_MAPPINGS = {
|
6
7
|
# gray
|
@@ -28,6 +29,22 @@ module Primer
|
|
28
29
|
}.freeze
|
29
30
|
VARIANT_OPTIONS = VARIANT_MAPPINGS.keys << nil
|
30
31
|
|
32
|
+
# @example 40|Schemes
|
33
|
+
# <%= render(Primer::LabelComponent.new(title: "Label: Label")) { "default" } %>
|
34
|
+
# <%= render(Primer::LabelComponent.new(title: "Label: Label", scheme: :gray)) { "gray" } %>
|
35
|
+
# <%= render(Primer::LabelComponent.new(title: "Label: Label", scheme: :dark_gray)) { "dark_gray" } %>
|
36
|
+
# <%= render(Primer::LabelComponent.new(title: "Label: Label", scheme: :yellow)) { "yellow" } %>
|
37
|
+
# <%= render(Primer::LabelComponent.new(title: "Label: Label", scheme: :green)) { "green" } %>
|
38
|
+
# <%= render(Primer::LabelComponent.new(title: "Label: Label", scheme: :purple)) { "purple" } %>
|
39
|
+
#
|
40
|
+
# @example 40|Variants
|
41
|
+
# <%= render(Primer::LabelComponent.new(title: "Label: Label")) { "Default" } %>
|
42
|
+
# <%= render(Primer::LabelComponent.new(title: "Label: Label", variant: :large)) { "Large" } %>
|
43
|
+
#
|
44
|
+
# @param title [String] `title` attribute for the component element.
|
45
|
+
# @param scheme [Symbol] <%= one_of(Primer::LabelComponent::SCHEME_OPTIONS) %>
|
46
|
+
# @param variant [Symbol] <%= one_of(Primer::LabelComponent::VARIANT_OPTIONS) %>
|
47
|
+
# @param kwargs [Hash] <%= link_to_style_arguments_docs %>
|
31
48
|
def initialize(title:, scheme: nil, variant: nil, **kwargs)
|
32
49
|
@kwargs = kwargs
|
33
50
|
@kwargs[:bg] = :blue if scheme.nil?
|
@@ -1,6 +1,7 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
module Primer
|
4
|
+
# Use Layout to build a main/sidebar layout.
|
4
5
|
class LayoutComponent < Primer::Component
|
5
6
|
with_content_areas :main, :sidebar
|
6
7
|
|
@@ -11,6 +12,22 @@ module Primer
|
|
11
12
|
DEFAULT_SIDEBAR_COL = 3
|
12
13
|
ALLOWED_SIDEBAR_COLS = (1..(MAX_COL - 1)).to_a.freeze
|
13
14
|
|
15
|
+
# @example 40|Default
|
16
|
+
# <%= render(Primer::LayoutComponent.new) do |component| %>
|
17
|
+
# <% component.with(:sidebar) { "Sidebar" } %>
|
18
|
+
# <% component.with(:main) { "Main" } %>
|
19
|
+
# <% end %>
|
20
|
+
#
|
21
|
+
# @example 40|Left sidebar
|
22
|
+
# <%= render(Primer::LayoutComponent.new(side: :left)) do |component| %>
|
23
|
+
# <% component.with(:sidebar) { "Sidebar" } %>
|
24
|
+
# <% component.with(:main) { "Main" } %>
|
25
|
+
# <% end %>
|
26
|
+
#
|
27
|
+
# @param responsive [Boolean] Whether to collapse layout to a single column at smaller widths.
|
28
|
+
# @param side [Symbol] Which side to display the sidebar on. <%= one_of(Primer::LayoutComponent::ALLOWED_SIDES) %>
|
29
|
+
# @param sidebar_col [Integer] Sidebar column width.
|
30
|
+
# @param kwargs [Hash] <%= link_to_style_arguments_docs %>
|
14
31
|
def initialize(responsive: false, side: DEFAULT_SIDE, sidebar_col: DEFAULT_SIDEBAR_COL, **kwargs)
|
15
32
|
@kwargs = kwargs
|
16
33
|
@side = fetch_or_fallback(ALLOWED_SIDES, side, DEFAULT_SIDE)
|
@@ -1,7 +1,17 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
module Primer
|
4
|
+
# Use links for moving from one page to another. The Link component styles anchor tags with default blue styling and hover text-decoration.
|
4
5
|
class LinkComponent < Primer::Component
|
6
|
+
# @example 40|Default
|
7
|
+
# <%= render(Primer::LinkComponent.new(href: "http://www.google.com")) { "Link" } %>
|
8
|
+
#
|
9
|
+
# @example 40|Muted
|
10
|
+
# <%= render(Primer::LinkComponent.new(href: "http://www.google.com", muted: true)) { "Link" } %>
|
11
|
+
#
|
12
|
+
# @param href [String] URL to be used for the Link
|
13
|
+
# @param muted [Boolean] Uses light gray for Link color, and blue on hover
|
14
|
+
# @param kwargs [Hash] <%= link_to_style_arguments_docs %>
|
5
15
|
def initialize(href:, muted: false, **kwargs)
|
6
16
|
@kwargs = kwargs
|
7
17
|
@kwargs[:tag] = :a
|
@@ -1,6 +1,7 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
module Primer
|
4
|
+
# Renders an [Octicon](https://primer.style/octicons/) with <%= link_to_style_arguments_docs %>.
|
4
5
|
class OcticonComponent < Primer::Component
|
5
6
|
include Primer::ClassNameHelper
|
6
7
|
include OcticonsHelper
|
@@ -13,6 +14,18 @@ module Primer
|
|
13
14
|
}.freeze
|
14
15
|
SIZE_OPTIONS = SIZE_MAPPINGS.keys
|
15
16
|
|
17
|
+
# @example 25|Default
|
18
|
+
# <%= render(Primer::OcticonComponent.new(icon: "check")) %>
|
19
|
+
#
|
20
|
+
# @example 40|Medium
|
21
|
+
# <%= render(Primer::OcticonComponent.new(icon: "people", size: :medium)) %>
|
22
|
+
#
|
23
|
+
# @example 80|Large
|
24
|
+
# <%= render(Primer::OcticonComponent.new(icon: "x", size: :large)) %>
|
25
|
+
#
|
26
|
+
# @param icon [String] Name of [Octicon](https://primer.style/octicons/) to use.
|
27
|
+
# @param size [Symbol] <%= one_of(Primer::OcticonComponent::SIZE_OPTIONS) %>
|
28
|
+
# @param kwargs [Hash] <%= link_to_style_arguments_docs %>
|
16
29
|
def initialize(icon:, size: SIZE_DEFAULT, **kwargs)
|
17
30
|
@icon, @kwargs = icon, kwargs
|
18
31
|
|
@@ -1,12 +1,46 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
module Primer
|
4
|
+
# Use popovers to bring attention to specific user interface elements, typically to suggest an action or to guide users through a new experience.
|
5
|
+
#
|
6
|
+
# By default, the popover renders with absolute positioning, meaning it should usually be wrapped in an element with a relative position in order to be positioned properly. To render the popover with relative positioning, use the relative property.
|
4
7
|
class PopoverComponent < Primer::Component
|
5
8
|
include ViewComponent::Slotable
|
6
9
|
|
7
10
|
with_slot :heading, class_name: "Heading"
|
8
11
|
with_slot :body, class_name: "Body"
|
9
12
|
|
13
|
+
# @example 150|Default
|
14
|
+
# <%= render Primer::PopoverComponent.new do |component| %>
|
15
|
+
# <% component.slot(:heading) do %>
|
16
|
+
# Activity feed
|
17
|
+
# <% end %>
|
18
|
+
# <% component.slot(:body) do %>
|
19
|
+
# This is the Popover body.
|
20
|
+
# <% end %>
|
21
|
+
# <% end %>
|
22
|
+
#
|
23
|
+
# @example 150|Large
|
24
|
+
# <%= render Primer::PopoverComponent.new do |component| %>
|
25
|
+
# <% component.slot(:heading) do %>
|
26
|
+
# Activity feed
|
27
|
+
# <% end %>
|
28
|
+
# <% component.slot(:body, large: true) do %>
|
29
|
+
# This is the large Popover body.
|
30
|
+
# <% end %>
|
31
|
+
# <% end %>
|
32
|
+
#
|
33
|
+
# @example 150|Caret position
|
34
|
+
# <%= render Primer::PopoverComponent.new do |component| %>
|
35
|
+
# <% component.slot(:heading) do %>
|
36
|
+
# Activity feed
|
37
|
+
# <% end %>
|
38
|
+
# <% component.slot(:body, caret: :left) do %>
|
39
|
+
# This is the large Popover body.
|
40
|
+
# <% end %>
|
41
|
+
# <% end %>
|
42
|
+
#
|
43
|
+
# @param kwargs [Hash] <%= link_to_style_arguments_docs %>
|
10
44
|
def initialize(**kwargs)
|
11
45
|
@kwargs = kwargs
|
12
46
|
@kwargs[:tag] ||= :div
|
@@ -24,6 +58,7 @@ module Primer
|
|
24
58
|
end
|
25
59
|
|
26
60
|
class Heading < ViewComponent::Slot
|
61
|
+
# @param kwargs [Hash] <%= link_to_style_arguments_docs %>
|
27
62
|
def initialize(**kwargs)
|
28
63
|
@kwargs = kwargs
|
29
64
|
@kwargs[:mb] ||= 2
|
@@ -52,6 +87,9 @@ module Primer
|
|
52
87
|
:top_right => "Popover-message--top-right"
|
53
88
|
}.freeze
|
54
89
|
|
90
|
+
# @param caret [Symbol] <%= one_of(Primer::PopoverComponent::Body::CARET_MAPPINGS.keys) %>
|
91
|
+
# @param large [Boolean] Whether to use the large version of the component.
|
92
|
+
# @param kwargs [Hash] <%= link_to_style_arguments_docs %>
|
55
93
|
def initialize(caret: CARET_DEFAULT, large: false, **kwargs)
|
56
94
|
@kwargs = kwargs
|
57
95
|
@kwargs[:classes] = class_names(
|
@@ -1,23 +1,7 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
##
|
4
|
-
# Use progress components to visualize task completion.
|
5
|
-
|
6
|
-
## Basic example
|
7
|
-
#
|
8
|
-
# The `Primer::ProgressBarComponent` can take the following arguments:
|
9
|
-
#
|
10
|
-
# 1. `size` (string). Can be "small" or "large". Increases the height of the progress bar.
|
11
|
-
#
|
12
|
-
# The `Primer::ProgressBarComponent` uses the [Slots API](https://github.com/github/view_component#slots-experimental) and at least one slot is required for the component to render. Each slot accepts a `percentage` parameter, which is used to set the width of the completed bar.
|
13
|
-
#
|
14
|
-
# ```ruby
|
15
|
-
# <%= render(Primer::ProgressBarComponent.new(size: :small)) do |component| %>
|
16
|
-
# <% component.slot(:item, bg: :blue-4, percentage: 50) %>
|
17
|
-
# <% end %>
|
18
|
-
# ```
|
19
|
-
##
|
20
3
|
module Primer
|
4
|
+
# Use ProgressBar to visualize task completion.
|
21
5
|
class ProgressBarComponent < Primer::Component
|
22
6
|
include ViewComponent::Slotable
|
23
7
|
|
@@ -32,8 +16,31 @@ module Primer
|
|
32
16
|
}.freeze
|
33
17
|
|
34
18
|
SIZE_OPTIONS = SIZE_MAPPINGS.keys
|
35
|
-
|
36
|
-
|
19
|
+
# @example 20|Default
|
20
|
+
# <%= render(Primer::ProgressBarComponent.new) do |component| %>
|
21
|
+
# <% component.slot(:item, percentage: 25) %>
|
22
|
+
# <% end %>
|
23
|
+
#
|
24
|
+
# @example 20|Small
|
25
|
+
# <%= render(Primer::ProgressBarComponent.new(size: :small)) do |component| %>
|
26
|
+
# <% component.slot(:item, bg: :blue_4, percentage: 50) %>
|
27
|
+
# <% end %>
|
28
|
+
#
|
29
|
+
# @example 30|Large
|
30
|
+
# <%= render(Primer::ProgressBarComponent.new(size: :large)) do |component| %>
|
31
|
+
# <% component.slot(:item, bg: :red_4, percentage: 75) %>
|
32
|
+
# <% end %>
|
33
|
+
#
|
34
|
+
# @example 20|Multiple items
|
35
|
+
# <%= render(Primer::ProgressBarComponent.new) do |component| %>
|
36
|
+
# <% component.slot(:item, percentage: 10) %>
|
37
|
+
# <% component.slot(:item, bg: :blue_4, percentage: 20) %>
|
38
|
+
# <% component.slot(:item, bg: :red_4, percentage: 30) %>
|
39
|
+
# <% end %>
|
40
|
+
#
|
41
|
+
# @param size [Symbol] <%= one_of(Primer::ProgressBarComponent::SIZE_OPTIONS) %> Increases height.
|
42
|
+
# @param kwargs [Hash] <%= link_to_style_arguments_docs %>
|
43
|
+
def initialize(size: SIZE_DEFAULT, **kwargs)
|
37
44
|
@kwargs = kwargs
|
38
45
|
@kwargs[:classes] = class_names(
|
39
46
|
@kwargs[:classes],
|
@@ -52,6 +59,9 @@ module Primer
|
|
52
59
|
include ClassNameHelper
|
53
60
|
attr_reader :kwargs
|
54
61
|
|
62
|
+
# @param percentage [Integer] Percentage completion of item.
|
63
|
+
# @param bg [Symbol] Color of item.
|
64
|
+
# @param kwargs [Hash] <%= link_to_style_arguments_docs %>
|
55
65
|
def initialize(percentage: 0, bg: :green, **kwargs)
|
56
66
|
@percentage = percentage
|
57
67
|
@kwargs = kwargs
|
@@ -22,7 +22,7 @@ module Primer
|
|
22
22
|
# @example 80|Large
|
23
23
|
# <%= render(Primer::SpinnerComponent.new(size: :large)) %>
|
24
24
|
#
|
25
|
-
# @param size [Symbol]
|
25
|
+
# @param size [Symbol] <%= one_of(Primer::SpinnerComponent::SIZE_OPTIONS) %>
|
26
26
|
def initialize(size: DEFAULT_SIZE, **kwargs)
|
27
27
|
@kwargs = kwargs
|
28
28
|
@kwargs[:tag] = :svg
|
@@ -1,14 +1,8 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
module Primer
|
4
|
+
# Component for rendering the status of an item.
|
4
5
|
class StateComponent < Primer::Component
|
5
|
-
# Component for rendering the status of an item
|
6
|
-
#
|
7
|
-
# title(string): (required) title attribute
|
8
|
-
# color(symbol): label background color
|
9
|
-
# size(symbol): label size
|
10
|
-
# counter(integer): counter value
|
11
|
-
# **args(hash): utility parameters for Primer::Classify
|
12
6
|
COLOR_DEFAULT = :default
|
13
7
|
COLOR_MAPPINGS = {
|
14
8
|
COLOR_DEFAULT => "",
|
@@ -28,6 +22,24 @@ module Primer
|
|
28
22
|
TAG_DEFAULT = :span
|
29
23
|
TAG_OPTIONS = [TAG_DEFAULT, :div, :a]
|
30
24
|
|
25
|
+
# @example 40|Default
|
26
|
+
# <%= render(Primer::StateComponent.new(title: "title")) { "State" } %>
|
27
|
+
#
|
28
|
+
# @example 40|Colors
|
29
|
+
# <%= render(Primer::StateComponent.new(title: "title")) { "Default" } %>
|
30
|
+
# <%= render(Primer::StateComponent.new(title: "title", color: :green)) { "Green" } %>
|
31
|
+
# <%= render(Primer::StateComponent.new(title: "title", color: :red)) { "Red" } %>
|
32
|
+
# <%= render(Primer::StateComponent.new(title: "title", color: :purple)) { "Purple" } %>
|
33
|
+
#
|
34
|
+
# @example 40|Sizes
|
35
|
+
# <%= render(Primer::StateComponent.new(title: "title")) { "Default" } %>
|
36
|
+
# <%= render(Primer::StateComponent.new(title: "title", size: :small)) { "Small" } %>
|
37
|
+
#
|
38
|
+
# @param title [String] `title` HTML attribute.
|
39
|
+
# @param color [Symbol] Background color. <%= one_of(Primer::StateComponent::COLOR_OPTIONS) %>
|
40
|
+
# @param tag [Symbol] HTML tag for element. <%= one_of(Primer::StateComponent::TAG_OPTIONS) %>
|
41
|
+
# @param size [Symbol] <%= one_of(Primer::StateComponent::SIZE_OPTIONS) %>
|
42
|
+
# @param kwargs [Hash] <%= link_to_style_arguments_docs %>
|
31
43
|
def initialize(
|
32
44
|
title:,
|
33
45
|
color: COLOR_DEFAULT,
|
@@ -1,26 +1,7 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
# This component consists of a .Subhead container, which has a light gray bottom border.
|
4
|
-
|
5
|
-
# Use a heading element whenever possible as they can be
|
6
|
-
# used as navigation for assistive technologies, and avoid skipping levels.
|
7
|
-
|
8
|
-
# ## Basic example
|
9
|
-
|
10
|
-
# The `Primer::SubheadComponent` can take the following arguments:
|
11
|
-
|
12
|
-
# 1. `heading` (string). The heading to be rendered.
|
13
|
-
# 2. `actions` (content). Slot to render any actions to the right of heading.
|
14
|
-
# 3. `description` (string). Slot to render description under the heading.
|
15
|
-
|
16
|
-
# ```erb
|
17
|
-
# <%= Primer::SubheadComponent.new(heading: "Hello world")) do |component| %>
|
18
|
-
# <% component.slot(:actions) do %>
|
19
|
-
# My Actions
|
20
|
-
# <% end %>
|
21
|
-
# <% end %>
|
22
|
-
# ```
|
23
3
|
module Primer
|
4
|
+
# Use the Subhead component for page headings.
|
24
5
|
class SubheadComponent < Primer::Component
|
25
6
|
include ViewComponent::Slotable
|
26
7
|
|
@@ -28,6 +9,46 @@ module Primer
|
|
28
9
|
with_slot :actions, class_name: "Actions"
|
29
10
|
with_slot :description, class_name: "Description"
|
30
11
|
|
12
|
+
# @example 95|Default
|
13
|
+
# <%= render(Primer::SubheadComponent.new) do |component| %>
|
14
|
+
# <% component.slot(:heading) do %>
|
15
|
+
# My Heading
|
16
|
+
# <% end %>
|
17
|
+
# <% component.slot(:description) do %>
|
18
|
+
# My Description
|
19
|
+
# <% end %>
|
20
|
+
# <% end %>
|
21
|
+
#
|
22
|
+
# @example 95|Without border
|
23
|
+
# <%= render(Primer::SubheadComponent.new(hide_border: true)) do |component| %>
|
24
|
+
# <% component.slot(:heading) do %>
|
25
|
+
# My Heading
|
26
|
+
# <% end %>
|
27
|
+
# <% component.slot(:description) do %>
|
28
|
+
# My Description
|
29
|
+
# <% end %>
|
30
|
+
# <% end %>
|
31
|
+
#
|
32
|
+
# @example 95|With actions
|
33
|
+
# <%= render(Primer::SubheadComponent.new) do |component| %>
|
34
|
+
# <% component.slot(:heading) do %>
|
35
|
+
# My Heading
|
36
|
+
# <% end %>
|
37
|
+
# <% component.slot(:description) do %>
|
38
|
+
# My Description
|
39
|
+
# <% end %>
|
40
|
+
# <% component.slot(:actions) do %>
|
41
|
+
# <%= render(
|
42
|
+
# Primer::ButtonComponent.new(
|
43
|
+
# tag: :a, href: "http://www.google.com", button_type: :danger
|
44
|
+
# )
|
45
|
+
# ) { "Action" } %>
|
46
|
+
# <% end %>
|
47
|
+
# <% end %>
|
48
|
+
#
|
49
|
+
# @param spacious [Boolean] Whether to add spacing to the Subhead.
|
50
|
+
# @param hide_border [Boolean] Whether to hide the border under the heading.
|
51
|
+
# @param kwargs [Hash] <%= link_to_style_arguments_docs %>
|
31
52
|
def initialize(spacious: false, hide_border: false, **kwargs)
|
32
53
|
@kwargs = kwargs
|
33
54
|
|
@@ -51,6 +72,8 @@ module Primer
|
|
51
72
|
|
52
73
|
attr_reader :kwargs
|
53
74
|
|
75
|
+
# @param danger [Boolean] Whether to style the heading as dangerous.
|
76
|
+
# @param kwargs [Hash] <%= link_to_style_arguments_docs %>
|
54
77
|
def initialize(danger: false, **kwargs)
|
55
78
|
@kwargs = kwargs
|
56
79
|
@kwargs[:tag] ||= :div
|
@@ -67,6 +90,7 @@ module Primer
|
|
67
90
|
|
68
91
|
attr_reader :kwargs
|
69
92
|
|
93
|
+
# @param kwargs [Hash] <%= link_to_style_arguments_docs %>
|
70
94
|
def initialize(**kwargs)
|
71
95
|
@kwargs = kwargs
|
72
96
|
@kwargs[:tag] = :div
|
@@ -79,6 +103,7 @@ module Primer
|
|
79
103
|
|
80
104
|
attr_reader :kwargs
|
81
105
|
|
106
|
+
# @param kwargs [Hash] <%= link_to_style_arguments_docs %>
|
82
107
|
def initialize(**kwargs)
|
83
108
|
@kwargs = kwargs
|
84
109
|
@kwargs[:tag] = :div
|
@@ -1,7 +1,13 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
module Primer
|
4
|
+
# The Text component is a wrapper component that will apply typography styles to the text inside.
|
4
5
|
class TextComponent < Primer::Component
|
6
|
+
# @example 70|Default
|
7
|
+
# <%= render(Primer::TextComponent.new(tag: :p, font_weight: :bold)) { "Bold Text" } %>
|
8
|
+
# <%= render(Primer::TextComponent.new(tag: :p, color: :red_5)) { "Red Text" } %>
|
9
|
+
#
|
10
|
+
# @param kwargs [Hash] <%= link_to_style_arguments_docs %>
|
5
11
|
def initialize(**kwargs)
|
6
12
|
@kwargs = kwargs
|
7
13
|
@kwargs[:tag] ||= :span
|
@@ -1,6 +1,7 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
module Primer
|
4
|
+
# Use `TimelineItem` to display items on a vertical timeline, connected by badge elements.
|
4
5
|
class TimelineItemComponent < Primer::Component
|
5
6
|
include ViewComponent::Slotable
|
6
7
|
|
@@ -9,6 +10,18 @@ module Primer
|
|
9
10
|
with_slot :body, class_name: "Body"
|
10
11
|
|
11
12
|
attr_reader :kwargs
|
13
|
+
|
14
|
+
# @example 75|Default
|
15
|
+
# <div style="padding-left: 60px">
|
16
|
+
# <%= render(Primer::TimelineItemComponent.new) do |component| %>
|
17
|
+
# <% component.slot(:avatar, src: "https://github.com/github.png", alt: "github") %>
|
18
|
+
# <% component.slot(:badge, bg: :green, color: :white, icon: :check) %>
|
19
|
+
# <% component.slot(:body) { "Success!" } %>
|
20
|
+
# <% end %>
|
21
|
+
# </div>
|
22
|
+
#
|
23
|
+
# @param condensed [Boolean] Reduce the vertical padding and remove the background from the badge item. Most commonly used in commits.
|
24
|
+
# @param kwargs [Hash] <%= link_to_style_arguments_docs %>
|
12
25
|
def initialize(condensed: false, **kwargs)
|
13
26
|
@kwargs = kwargs
|
14
27
|
@kwargs[:tag] = :div
|
@@ -25,6 +38,12 @@ module Primer
|
|
25
38
|
|
26
39
|
class Avatar < Primer::Slot
|
27
40
|
attr_reader :kwargs, :alt, :src, :size, :square
|
41
|
+
|
42
|
+
# @param alt [String] Alt text for avatar image.
|
43
|
+
# @param src [String] Src attribute for avatar image.
|
44
|
+
# @param size [Integer] Image size.
|
45
|
+
# @param square [Boolean] Whether to round the edges of the image.
|
46
|
+
# @param kwargs [Hash] <%= link_to_style_arguments_docs %>
|
28
47
|
def initialize(alt: nil, src: nil, size: 40, square: true, **kwargs)
|
29
48
|
@alt = alt
|
30
49
|
@src = src
|
@@ -42,6 +61,9 @@ module Primer
|
|
42
61
|
|
43
62
|
class Badge < Primer::Slot
|
44
63
|
attr_reader :kwargs, :icon
|
64
|
+
|
65
|
+
# @param icon [String] Name of [Octicon](https://primer.style/octicons/) to use.
|
66
|
+
# @param kwargs [Hash] <%= link_to_style_arguments_docs %>
|
45
67
|
def initialize(icon: nil, **kwargs)
|
46
68
|
@icon = icon
|
47
69
|
|
@@ -56,6 +78,8 @@ module Primer
|
|
56
78
|
|
57
79
|
class Body < Primer::Slot
|
58
80
|
attr_reader :kwargs
|
81
|
+
|
82
|
+
# @param kwargs [Hash] <%= link_to_style_arguments_docs %>
|
59
83
|
def initialize(**kwargs)
|
60
84
|
@kwargs = kwargs
|
61
85
|
@kwargs[:tag] = :div
|
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.11
|
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-10-
|
11
|
+
date: 2020-10-26 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|
@@ -182,7 +182,7 @@ dependencies:
|
|
182
182
|
- - "~>"
|
183
183
|
- !ruby/object:Gem::Version
|
184
184
|
version: 0.9.25
|
185
|
-
description:
|
185
|
+
description:
|
186
186
|
email:
|
187
187
|
- opensource+primer_view_components@github.com
|
188
188
|
executables: []
|
@@ -245,7 +245,7 @@ licenses:
|
|
245
245
|
- MIT
|
246
246
|
metadata:
|
247
247
|
allowed_push_host: https://rubygems.org
|
248
|
-
post_install_message:
|
248
|
+
post_install_message:
|
249
249
|
rdoc_options: []
|
250
250
|
require_paths:
|
251
251
|
- lib
|
@@ -260,8 +260,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
260
260
|
- !ruby/object:Gem::Version
|
261
261
|
version: '0'
|
262
262
|
requirements: []
|
263
|
-
rubygems_version: 3.
|
264
|
-
signing_key:
|
263
|
+
rubygems_version: 3.1.2
|
264
|
+
signing_key:
|
265
265
|
specification_version: 4
|
266
266
|
summary: ViewComponents for the Primer Design System
|
267
267
|
test_files: []
|