primer_view_components 0.0.10 → 0.0.15
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 +35 -1
- data/README.md +2 -175
- data/app/components/primer/avatar_component.rb +11 -11
- data/app/components/primer/base_component.rb +101 -9
- data/app/components/primer/blankslate_component.html.erb +1 -1
- data/app/components/primer/blankslate_component.rb +6 -6
- data/app/components/primer/border_box_component.html.erb +5 -5
- data/app/components/primer/border_box_component.rb +45 -33
- data/app/components/primer/box_component.rb +6 -4
- data/app/components/primer/breadcrumb_component.html.erb +2 -2
- data/app/components/primer/breadcrumb_component.rb +23 -30
- data/app/components/primer/button_component.rb +26 -9
- data/app/components/primer/component.rb +1 -0
- data/app/components/primer/counter_component.rb +16 -15
- data/app/components/primer/details_component.html.erb +1 -1
- data/app/components/primer/details_component.rb +18 -18
- data/app/components/primer/dropdown_menu_component.html.erb +1 -1
- data/app/components/primer/dropdown_menu_component.rb +6 -6
- data/app/components/primer/flash_component.html.erb +2 -2
- data/app/components/primer/flash_component.rb +42 -12
- data/app/components/primer/flex_component.rb +5 -5
- data/app/components/primer/flex_item_component.rb +5 -5
- data/app/components/primer/heading_component.rb +4 -4
- data/app/components/primer/label_component.rb +37 -14
- data/app/components/primer/layout_component.html.erb +1 -1
- data/app/components/primer/layout_component.rb +22 -5
- data/app/components/primer/link_component.rb +17 -7
- data/app/components/primer/octicon_component.rb +20 -7
- data/app/components/primer/popover_component.html.erb +1 -1
- data/app/components/primer/popover_component.rb +61 -23
- data/app/components/primer/progress_bar_component.html.erb +2 -2
- data/app/components/primer/progress_bar_component.rb +40 -30
- data/app/components/primer/slot.rb +1 -0
- data/app/components/primer/spinner_component.html.erb +1 -1
- data/app/components/primer/spinner_component.rb +12 -11
- data/app/components/primer/state_component.rb +26 -14
- data/app/components/primer/subhead_component.html.erb +4 -4
- data/app/components/primer/subhead_component.rb +68 -43
- data/app/components/primer/text_component.rb +10 -4
- data/app/components/primer/timeline_item_component.html.erb +4 -4
- data/app/components/primer/timeline_item_component.rb +48 -24
- data/app/components/primer/underline_nav_component.html.erb +1 -1
- data/app/components/primer/underline_nav_component.rb +5 -5
- data/lib/primer/classify.rb +7 -6
- data/lib/primer/view_components/version.rb +1 -1
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c2957082e3fcbcfe88a4bed4f13c1dd8e46971a4792f4e4539cf396293d2b753
|
4
|
+
data.tar.gz: 0cfc136341d4b04c8602851085131fb35eea924439c8b577081993e2540e4992
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ba13e8bb5fab035a22483269d350ede659f95a36feaf07031c88076750c2ec9775bf3f8a34e65807dfdf5b874a3ba9efb0cdfdfafefcbaa22bef0f55b98e86ee
|
7
|
+
data.tar.gz: d9c0d1615202ddc1f0a193a8555812cb97ad1f371df7e8ed2ce66ee2899f41a266af10d3e9eda205d187fb0e20f154a82034bda8e5f732c48ec17ab0cee9c9ac
|
data/CHANGELOG.md
CHANGED
@@ -2,6 +2,40 @@
|
|
2
2
|
|
3
3
|
## main
|
4
4
|
|
5
|
+
## 0.0.15
|
6
|
+
|
7
|
+
* Add ability to disable `limit` on Counter.
|
8
|
+
|
9
|
+
*Christian Giordano*
|
10
|
+
|
11
|
+
* Rename `v` system argument to `visibility`.
|
12
|
+
|
13
|
+
*Joel Hawksley*
|
14
|
+
|
15
|
+
## 0.0.14
|
16
|
+
|
17
|
+
* Add functional colors to Label.
|
18
|
+
|
19
|
+
*Joel Hawksley*
|
20
|
+
|
21
|
+
## 0.0.13
|
22
|
+
|
23
|
+
* Add support for `xl` breakpoint.
|
24
|
+
|
25
|
+
*Joel Hawksley*
|
26
|
+
|
27
|
+
## 0.0.12
|
28
|
+
|
29
|
+
* Adds support for disabling inline box-sizing style for `SpinnerComponent` via style parameter `Primer::SpinnerComponent.new(style: nil)`.
|
30
|
+
|
31
|
+
*Chris Wilson*
|
32
|
+
|
33
|
+
## 0.0.11
|
34
|
+
|
35
|
+
* Renames DetailsComponent::OVERLAY_DEFAULT to DetailsComponent::NO_OVERLAY to more correctly describe its value.
|
36
|
+
|
37
|
+
*Justin Kenyon*
|
38
|
+
|
5
39
|
## 0.0.10
|
6
40
|
|
7
41
|
* Add SpinnerComponent
|
@@ -76,7 +110,7 @@
|
|
76
110
|
|
77
111
|
## 0.0.3
|
78
112
|
|
79
|
-
* Add support for responsive `float`
|
113
|
+
* Add support for responsive `float` system argument.
|
80
114
|
|
81
115
|
*Joel Hawksley*
|
82
116
|
|
data/README.md
CHANGED
@@ -8,182 +8,9 @@
|
|
8
8
|
|
9
9
|
_Note: This library is in pre-release development and should not be considered stable._
|
10
10
|
|
11
|
-
##
|
11
|
+
## Documentation
|
12
12
|
|
13
|
-
|
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.
|
13
|
+
Visit [https://primer.style/view-components/](https://primer.style/view-components//) to view documentation.
|
187
14
|
|
188
15
|
## License
|
189
16
|
|
@@ -15,25 +15,25 @@ module Primer
|
|
15
15
|
# @param alt [String] Passed through to alt on img tag
|
16
16
|
# @param size [Integer] Adds the avatar-small class if less than 24
|
17
17
|
# @param square [Boolean] Used to create a square avatar.
|
18
|
-
def initialize(src:, alt:, size: 20, square: false, **
|
19
|
-
@
|
20
|
-
@
|
21
|
-
@
|
22
|
-
@
|
23
|
-
@
|
24
|
-
@
|
25
|
-
@
|
18
|
+
def initialize(src:, alt:, size: 20, square: false, **system_arguments)
|
19
|
+
@system_arguments = system_arguments
|
20
|
+
@system_arguments[:tag] = :img
|
21
|
+
@system_arguments[:src] = src
|
22
|
+
@system_arguments[:alt] = alt
|
23
|
+
@system_arguments[:size] = size
|
24
|
+
@system_arguments[:height] = size
|
25
|
+
@system_arguments[:width] = size
|
26
26
|
|
27
|
-
@
|
27
|
+
@system_arguments[:classes] = class_names(
|
28
28
|
"avatar",
|
29
|
-
|
29
|
+
system_arguments[:classes],
|
30
30
|
"avatar--small" => size < SMALL_THRESHOLD,
|
31
31
|
"CircleBadge" => !square
|
32
32
|
)
|
33
33
|
end
|
34
34
|
|
35
35
|
def call
|
36
|
-
render(Primer::BaseComponent.new(**@
|
36
|
+
render(Primer::BaseComponent.new(**@system_arguments)) { content }
|
37
37
|
end
|
38
38
|
end
|
39
39
|
end
|
@@ -1,22 +1,114 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
module Primer
|
4
|
-
#
|
4
|
+
# All Primer ViewComponents accept a standard set of options called system arguments, mimicking the [styled-system API](https://styled-system.com/table) used by [Primer React](https://primer.style/components/system-props).
|
5
|
+
#
|
6
|
+
# Under the hood, system arguments are [mapped](https://github.com/primer/view_components/blob/main/lib/primer/classify.rb) to Primer CSS classes, with any remaining options passed to Rails' [`content_tag`](https://api.rubyonrails.org/classes/ActionView/Helpers/TagHelper.html#method-i-content_tag).
|
7
|
+
#
|
8
|
+
# ## Responsive values
|
9
|
+
#
|
10
|
+
# To apply different values across responsive breakpoints, pass an array with up to five values in the order `[default, small, medium, large, xlarge]`. To skip a breakpoint, pass `nil`.
|
11
|
+
#
|
12
|
+
# For example:
|
13
|
+
#
|
14
|
+
# ```erb
|
15
|
+
# <%= render Primer::HeadingComponent.new(mt: [0, nil, nil, 4, 2]) do %>
|
16
|
+
# Hello world
|
17
|
+
# <% end %>
|
18
|
+
# ```
|
19
|
+
#
|
20
|
+
# Renders:
|
21
|
+
#
|
22
|
+
# ```html
|
23
|
+
# <h1 class="mt-0 mt-lg-4 mt-xl-2">Hello world</h1>
|
24
|
+
# ```
|
25
|
+
#
|
26
|
+
# ## HTML attributes
|
27
|
+
#
|
28
|
+
# System arguments include most HTML attributes. For example:
|
29
|
+
#
|
30
|
+
# | Name | Type | Description |
|
31
|
+
# | :- | :- | :- |
|
32
|
+
# | `width` | `Integer` | Width. |
|
33
|
+
# | `height` | `Integer` | Height. |
|
34
|
+
# | `data` | `Hash` | Data attributes: `data: { foo: :bar }` renders `data-foo='bar'`. |
|
35
|
+
# | `aria` | `Hash` | Aria attributes: `aria: { label: "foo" }` renders `aria-label='foo'`. |
|
36
|
+
# | `title` | `String` | The `title` attribute. |
|
37
|
+
# | `hidden` | `Boolean` | Whether to assign the `hidden` attribute. |
|
5
38
|
class BaseComponent < Primer::Component
|
6
39
|
TEST_SELECTOR_TAG = :test_selector
|
7
|
-
|
40
|
+
# @param test_selector [String] Adds `data-test-selector='given value'` in non-Production environments for testing purposes.
|
41
|
+
#
|
42
|
+
# @param m [Integer] Margin. <%= one_of((-6..6).to_a) %>
|
43
|
+
# @param mt [Integer] Margin left. <%= one_of((-6..6).to_a) %>
|
44
|
+
# @param mr [Integer] Margin right. <%= one_of((-6..6).to_a) %>
|
45
|
+
# @param mb [Integer] Margin bottom. <%= one_of((-6..6).to_a) %>
|
46
|
+
# @param ml [Integer] Margin left. <%= one_of((-6..6).to_a) %>
|
47
|
+
# @param mx [Integer] Horizontal margins. <%= one_of((-6..6).to_a + [:auto]) %>
|
48
|
+
# @param my [Integer] Vertical margins. <%= one_of((-6..6).to_a) %>
|
49
|
+
# @param p [Integer] Padding. <%= one_of((0..6).to_a) %>
|
50
|
+
# @param pt [Integer] Padding left. <%= one_of((0..6).to_a) %>
|
51
|
+
# @param pr [Integer] Padding right. <%= one_of((0..6).to_a) %>
|
52
|
+
# @param pb [Integer] Padding bottom. <%= one_of((0..6).to_a) %>
|
53
|
+
# @param pl [Integer] Padding left. <%= one_of((0..6).to_a) %>
|
54
|
+
# @param px [Integer] Horizontal padding. <%= one_of((0..6).to_a) %>
|
55
|
+
# @param py [Integer] Vertical padding. <%= one_of((0..6).to_a) %>
|
56
|
+
#
|
57
|
+
# @param position [Symbol] <%= one_of([:relative, :absolute, :fixed]) %>
|
58
|
+
#
|
59
|
+
# @param top [Boolean] If `false`, sets `top: 0`.
|
60
|
+
# @param right [Boolean] If `false`, sets `right: 0`.
|
61
|
+
# @param bottom [Boolean] If `false`, sets `bottom: 0`.
|
62
|
+
# @param left [Boolean] If `false`, sets `left: 0`.
|
63
|
+
#
|
64
|
+
# @param display [Symbol] <%= one_of([:block, :none, :inline, :inline_block, :table, :table_cell]) %>
|
65
|
+
#
|
66
|
+
# @param v [Symbol] Visibility. <%= one_of([:hidden, :visible]) %>
|
67
|
+
#
|
68
|
+
# @param hide [Symbol] Hide the element at a specific breakpoint. <%= one_of([:sm, :md, :lg, :xl]) %>
|
69
|
+
#
|
70
|
+
# @param vertical_align [Symbol] <%= one_of([:baseline, :top, :middle, :bottom, :text_top, :text_bottom]) %>
|
71
|
+
#
|
72
|
+
# @param float [Symbol] <%= one_of([:left, :right]) %>
|
73
|
+
#
|
74
|
+
# @param col [Integer] Number of columns.
|
75
|
+
#
|
76
|
+
# @param underline [Boolean] Whether text should be underlined.
|
77
|
+
#
|
78
|
+
# @param color [Symbol] Text color. <%= one_of([:blue, :red, :gray_light, :gray, :gray_dark, :green, :orange, :orange_light, :purple, :pink, :white, :inherit]) %> Note: this API is subject to change as we move to functional colors.
|
79
|
+
# @param bg [String, Symbol] Background color. Accepts either a hex value as a String or a color name as a Symbol.
|
80
|
+
#
|
81
|
+
# @param box_shadow [Boolean, Symbol] Box shadow. <%= one_of([true, :medium, :large, :extra_large, :none]) %>
|
82
|
+
# @param border [Symbol] <%= one_of([:left, :top, :bottom, :right, :y, :x]) %>
|
83
|
+
# @param border_color [Symbol] <%= one_of([:blue, :blue_light, :gray, :gray_dark, :green, :purple, :red, :red_light, :white, :yellow, :black_fade]) %> Note: this API is subject to change as we move to functional colors.
|
84
|
+
# @param border_top [Integer] Set to `0` to remove the top border.
|
85
|
+
# @param border_bottom [Integer] Set to `0` to remove the bottom border.
|
86
|
+
# @param border_left [Integer] Set to `0` to remove the left border.
|
87
|
+
# @param border_right [Integer] Set to `0` to remove the right border.
|
88
|
+
#
|
89
|
+
# @param font_size [String, Integer] <%= one_of(["00", 0, 1, 2, 3, 4, 5, 6]) %>
|
90
|
+
# @param text_align [Symbol] Text alignment. <%= one_of([:left, :right, :center]) %>
|
91
|
+
# @param font_weight [Symbol] Font weight. <%= one_of([:light, :normal, :bold]) %>
|
92
|
+
#
|
93
|
+
# @param flex [Integer, Symbol] <%= one_of([1, :auto]) %>
|
94
|
+
# @param flex_grow [Integer] To enable, set to `0`.
|
95
|
+
# @param flex_shrink [Integer] To enable, set to `0`.
|
96
|
+
# @param align_self [Symbol] <%= one_of([:auto, :start, :end, :center, :baseline, :stretch]) %>
|
97
|
+
# @param justify_content [Symbol] <%= one_of([:flex_start, :flex_end, :center, :space_between, :space_around]) %>
|
98
|
+
# @param align_items [Symbol] <%= one_of([:flex_start, :flex_end, :center, :baseline, :stretch]) %>
|
99
|
+
# @param width [Symbol] <%= one_of([:fit, :fill]) %>
|
100
|
+
# @param height [Symbol] <%= one_of([:fit, :fill]) %>
|
8
101
|
#
|
9
|
-
# @
|
10
|
-
# <%= render(Primer::BaseComponent.new(tag: :a, href: "http://www.google.com", mt: 4)) { "Link" } %>
|
102
|
+
# @param word_break [Symbol] Whether to break words on line breaks. Can only be `:break_all`.
|
11
103
|
#
|
12
|
-
# @param tag [Symbol] HTML tag name to be passed to tag.send
|
13
|
-
# @param classes [String] CSS class name value to be concatenated with generated Primer CSS classes
|
14
|
-
def initialize(tag:, classes: nil, **
|
104
|
+
# @param tag [Symbol] HTML tag name to be passed to `tag.send`.
|
105
|
+
# @param classes [String] CSS class name value to be concatenated with generated Primer CSS classes.
|
106
|
+
def initialize(tag:, classes: nil, **system_arguments)
|
15
107
|
@tag = tag
|
16
|
-
@result = Primer::Classify.call(**
|
108
|
+
@result = Primer::Classify.call(**system_arguments.merge(classes: classes))
|
17
109
|
|
18
110
|
# Filter out Primer keys so they don't get assigned as HTML attributes
|
19
|
-
@content_tag_args = add_test_selector(
|
111
|
+
@content_tag_args = add_test_selector(system_arguments).except(*Primer::Classify::VALID_KEYS)
|
20
112
|
end
|
21
113
|
|
22
114
|
def call
|
@@ -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) %>
|
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.
|
@@ -87,12 +87,12 @@ module Primer
|
|
87
87
|
large: false,
|
88
88
|
spacious: false,
|
89
89
|
|
90
|
-
**
|
90
|
+
**system_arguments
|
91
91
|
)
|
92
|
-
@
|
93
|
-
@
|
94
|
-
@
|
95
|
-
@
|
92
|
+
@system_arguments = system_arguments
|
93
|
+
@system_arguments[:tag] ||= :div
|
94
|
+
@system_arguments[:classes] = class_names(
|
95
|
+
@system_arguments[:classes],
|
96
96
|
"blankslate",
|
97
97
|
"blankslate-narrow": narrow,
|
98
98
|
"blankslate-large": large,
|
@@ -1,25 +1,25 @@
|
|
1
|
-
<%= render Primer::BaseComponent.new(**@
|
1
|
+
<%= render Primer::BaseComponent.new(**@system_arguments) do %>
|
2
2
|
<% if header %>
|
3
|
-
<%= render Primer::BaseComponent.new(**header.
|
3
|
+
<%= render Primer::BaseComponent.new(**header.system_arguments) do %>
|
4
4
|
<%= header.content %>
|
5
5
|
<% end %>
|
6
6
|
<% end %>
|
7
7
|
<% if body %>
|
8
|
-
<%= render Primer::BaseComponent.new(**body.
|
8
|
+
<%= render Primer::BaseComponent.new(**body.system_arguments) do %>
|
9
9
|
<%= body.content %>
|
10
10
|
<% end %>
|
11
11
|
<% end %>
|
12
12
|
<% if rows.any? %>
|
13
13
|
<ul>
|
14
14
|
<% rows.each do |row| %>
|
15
|
-
<%= render Primer::BaseComponent.new(**row.
|
15
|
+
<%= render Primer::BaseComponent.new(**row.system_arguments) do %>
|
16
16
|
<%= row.content %>
|
17
17
|
<% end %>
|
18
18
|
<% end %>
|
19
19
|
</ul>
|
20
20
|
<% end %>
|
21
21
|
<% if footer %>
|
22
|
-
<%= render Primer::BaseComponent.new(**footer.
|
22
|
+
<%= render Primer::BaseComponent.new(**footer.system_arguments) do %>
|
23
23
|
<%= footer.content %>
|
24
24
|
<% end %>
|
25
25
|
<% end %>
|