primer_view_components 0.0.86 → 0.0.89
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +34 -0
- data/app/components/primer/alpha/text_field.rb +1 -1
- data/app/components/primer/alpha/tooltip.rb +1 -0
- data/app/components/primer/{button_group.html.erb → beta/button_group.html.erb} +0 -0
- data/app/components/primer/beta/button_group.rb +57 -0
- data/app/components/primer/blankslate_component.html.erb +25 -0
- data/app/components/primer/blankslate_component.rb +150 -2
- data/app/components/primer/box.rb +25 -0
- data/app/components/primer/box_component.rb +2 -20
- data/app/components/primer/button_group.rb +2 -50
- data/app/components/primer/flex_component.rb +20 -20
- data/app/components/primer/flex_item_component.rb +4 -4
- data/app/components/primer/icon_button.html.erb +8 -2
- data/app/components/primer/icon_button.rb +6 -0
- data/app/components/primer/label_component.rb +32 -10
- data/app/components/primer/link_component.rb +14 -0
- data/app/components/primer/popover_component.rb +1 -1
- data/app/helpers/primer/form_helper.rb +10 -0
- data/lib/primer/form_components.rb +2 -2
- data/lib/primer/forms/base.html.erb +1 -1
- data/lib/primer/forms/base.rb +5 -0
- data/lib/primer/forms/base_component.rb +4 -0
- data/lib/primer/forms/buffer_rewriter.rb +3 -2
- data/lib/primer/forms/builder.rb +48 -0
- data/lib/primer/forms/check_box_group.html.erb +1 -1
- data/lib/primer/forms/dsl/input.rb +1 -23
- data/lib/primer/forms/dsl/input_group.rb +0 -7
- data/lib/primer/forms/group.html.erb +1 -1
- data/lib/primer/forms/multi.html.erb +1 -1
- data/lib/primer/view_components/engine.rb +11 -0
- data/lib/primer/view_components/linters/argument_mappers/label.rb +11 -4
- data/lib/primer/view_components/linters/flash_migration_counter.rb +1 -1
- data/lib/primer/view_components/linters/helpers/deprecated_components_helpers.rb +2 -0
- data/lib/primer/view_components/version.rb +1 -1
- data/lib/rubocop/cop/primer/component_name_migration.rb +2 -0
- data/lib/rubocop/cop/primer/deprecated_label_variants.rb +71 -0
- data/lib/tasks/docs.rake +2 -2
- data/lib/yard/docs_helper.rb +1 -1
- data/static/arguments.yml +56 -48
- data/static/audited_at.json +2 -0
- data/static/classes.yml +2 -0
- data/static/constants.json +20 -7
- data/static/statuses.json +4 -2
- metadata +11 -6
- data/app/components/primer/link_component.html.erb +0 -12
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 549fdec61b2c1c8c5ae3632f2cc567939f00e7679c7b350e86198e6c50db00fe
|
4
|
+
data.tar.gz: e2ea2f9570dbb93b53c5cddc6d4e98f1ed7b6918b4c7f1a879179b48ccfda0b3
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: cd33068d7ba46698d4e31afff8bf2edbb51472d04fdddd3a776835721ee80bf56e2fe2c398fd8545a66cdf1250b65b55f567ce488e14791737a6ccc955e54e90
|
7
|
+
data.tar.gz: 7bc316d92551cd6cfd15108fd864ad39a9322f3988936dc8d6aab73583d1ece0f8be035cadd637d2a352ea96ac2722b752926ee6e6136f6c61bdb70b4388f9e5
|
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,39 @@
|
|
1
1
|
# CHANGELOG
|
2
2
|
|
3
|
+
## 0.0.89
|
4
|
+
|
5
|
+
### Patch Changes
|
6
|
+
|
7
|
+
- [#1284](https://github.com/primer/view_components/pull/1284) [`401dac2a`](https://github.com/primer/view_components/commit/401dac2a1ab2e026b231399ddb03cfb51bc7742f) Thanks [@jonrohan](https://github.com/jonrohan)! - Don't render tooltip on IconButton when tag is a summary element
|
8
|
+
|
9
|
+
* [#1283](https://github.com/primer/view_components/pull/1283) [`ea1c29d7`](https://github.com/primer/view_components/commit/ea1c29d7fa0d917a729cba684bf5f8ae039bb228) Thanks [@jonrohan](https://github.com/jonrohan)! - Updating label component to not always have large
|
10
|
+
|
11
|
+
## 0.0.88
|
12
|
+
|
13
|
+
### Patch Changes
|
14
|
+
|
15
|
+
- [#1275](https://github.com/primer/view_components/pull/1275) [`1e9ce95c`](https://github.com/primer/view_components/commit/1e9ce95cdc942acdb51807839b2924731a1ab295) Thanks [@mxriverlynn](https://github.com/mxriverlynn)! - move Primer::ButtonGroup to Primer::Beta::ButtonGroup, update all references, and add deprecated Primer::ButtonGroup for backwards compatibility
|
16
|
+
|
17
|
+
* [#1266](https://github.com/primer/view_components/pull/1266) [`7d2949de`](https://github.com/primer/view_components/commit/7d2949de758b97aa940287a1ceabd5d16209cae2) Thanks [@mxriverlynn](https://github.com/mxriverlynn)! - moving Primer::BoxComponent to Primer::Box and creating deprecated Primer::BoxComponent for backward compatibility
|
18
|
+
|
19
|
+
- [#1281](https://github.com/primer/view_components/pull/1281) [`843061de`](https://github.com/primer/view_components/commit/843061de168a1927a80fd22e7da795c1a9ddaacd) Thanks [@jonrohan](https://github.com/jonrohan)! - Always set `:absolute` position on Primer::Alpha::Tooltip
|
20
|
+
|
21
|
+
* [#934](https://github.com/primer/view_components/pull/934) [`d638fefb`](https://github.com/primer/view_components/commit/d638fefbb55ce9802e91b374903bcde9cc6ab612) Thanks [@pouretrebelle](https://github.com/pouretrebelle)! - Refactor the LabelComponent API
|
22
|
+
|
23
|
+
## 0.0.87
|
24
|
+
|
25
|
+
### Patch Changes
|
26
|
+
|
27
|
+
- [#1274](https://github.com/primer/view_components/pull/1274) [`c153f734`](https://github.com/primer/view_components/commit/c153f734a891fc3bc7dfc3bed34630ff38ab39d7) Thanks [@jonrohan](https://github.com/jonrohan)! - Fixing whitespace in rendered LinkComponent
|
28
|
+
|
29
|
+
* [#1273](https://github.com/primer/view_components/pull/1273) [`f38517ac`](https://github.com/primer/view_components/commit/f38517acf1aed43b27f2c6b94634d70b124883e6) Thanks [@camertron](https://github.com/camertron)! - Revert removal of BlankslateComponent
|
30
|
+
|
31
|
+
- [#1270](https://github.com/primer/view_components/pull/1270) [`44919308`](https://github.com/primer/view_components/commit/4491930812d16a9bcb5d8f05b4d94e49e469afa5) Thanks [@camertron](https://github.com/camertron)! - Use a custom form builder; introduce primer_form_for
|
32
|
+
|
33
|
+
* [#1269](https://github.com/primer/view_components/pull/1269) [`9ae9615f`](https://github.com/primer/view_components/commit/9ae9615f31acf43875feb89661cac6311527f9fd) Thanks [@mxriverlynn](https://github.com/mxriverlynn)! - updating component migrator script with improvements in component reference updates, deprecations, etc.
|
34
|
+
|
35
|
+
- [#1276](https://github.com/primer/view_components/pull/1276) [`759ea56f`](https://github.com/primer/view_components/commit/759ea56f00cbe3e536f4e558a9fb9a3e1b89bf7b) Thanks [@mxriverlynn](https://github.com/mxriverlynn)! - correcting the updates to nav.yml in the component status migrator
|
36
|
+
|
3
37
|
## 0.0.86
|
4
38
|
|
5
39
|
### Patch Changes
|
@@ -6,7 +6,7 @@ module Primer
|
|
6
6
|
|
7
7
|
# A text field suitable for use outside a form. For a text field input suitable for use
|
8
8
|
# within an HTML form, see the `Primer::Forms` namespace.
|
9
|
-
class TextField
|
9
|
+
class TextField < Primer::Component
|
10
10
|
status :alpha
|
11
11
|
|
12
12
|
# @!method initialize
|
@@ -91,6 +91,7 @@ module Primer
|
|
91
91
|
@system_arguments[:tag] = :"tool-tip"
|
92
92
|
@system_arguments[:style] = join_style_arguments(@system_arguments[:style], "visibility: hidden")
|
93
93
|
@system_arguments[:for] = for_id
|
94
|
+
@system_arguments[:position] = :absolute
|
94
95
|
@system_arguments[:"data-direction"] = fetch_or_fallback(DIRECTION_OPTIONS, direction, DIRECTION_DEFAULT).to_s
|
95
96
|
@system_arguments[:"data-type"] = fetch_or_fallback(TYPE_OPTIONS, type, TYPE_FALLBACK).to_s
|
96
97
|
end
|
File without changes
|
@@ -0,0 +1,57 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Primer
|
4
|
+
module Beta
|
5
|
+
# Use `ButtonGroup` to render a series of buttons.
|
6
|
+
class ButtonGroup < Primer::Component
|
7
|
+
status :beta
|
8
|
+
|
9
|
+
# Required list of buttons to be rendered.
|
10
|
+
#
|
11
|
+
# @param kwargs [Hash] The same arguments as <%= link_to_component(Primer::ButtonComponent) %> except for `size` and `group_item`.
|
12
|
+
renders_many :buttons, lambda { |**kwargs|
|
13
|
+
kwargs[:group_item] = true
|
14
|
+
kwargs[:size] = @size
|
15
|
+
|
16
|
+
Primer::ButtonComponent.new(**kwargs)
|
17
|
+
}
|
18
|
+
|
19
|
+
# @example Default
|
20
|
+
#
|
21
|
+
# <%= render(Primer::Beta::ButtonGroup.new) do |component| %>
|
22
|
+
# <% component.button { "Default" } %>
|
23
|
+
# <% component.button(scheme: :primary) { "Primary" } %>
|
24
|
+
# <% component.button(scheme: :danger) { "Danger" } %>
|
25
|
+
# <% component.button(scheme: :outline) { "Outline" } %>
|
26
|
+
# <% component.button(classes: "custom-class") { "Custom class" } %>
|
27
|
+
# <% end %>
|
28
|
+
#
|
29
|
+
# @example Sizes
|
30
|
+
#
|
31
|
+
# <%= render(Primer::Beta::ButtonGroup.new(size: :small)) do |component| %>
|
32
|
+
# <% component.button { "Default" } %>
|
33
|
+
# <% component.button(scheme: :primary) { "Primary" } %>
|
34
|
+
# <% component.button(scheme: :danger) { "Danger" } %>
|
35
|
+
# <% component.button(scheme: :outline) { "Outline" } %>
|
36
|
+
# <% end %>
|
37
|
+
#
|
38
|
+
# @param variant [Symbol] DEPRECATED. <%= one_of(Primer::ButtonComponent::SIZE_OPTIONS) %>
|
39
|
+
# @param size [Symbol] <%= one_of(Primer::ButtonComponent::SIZE_OPTIONS) %>
|
40
|
+
# @param system_arguments [Hash] <%= link_to_system_arguments_docs %>
|
41
|
+
def initialize(variant: nil, size: Primer::ButtonComponent::DEFAULT_SIZE, **system_arguments)
|
42
|
+
@size = variant || size
|
43
|
+
@system_arguments = deny_tag_argument(**system_arguments)
|
44
|
+
@system_arguments[:tag] = :div
|
45
|
+
|
46
|
+
@system_arguments[:classes] = class_names(
|
47
|
+
"BtnGroup",
|
48
|
+
system_arguments[:classes]
|
49
|
+
)
|
50
|
+
end
|
51
|
+
|
52
|
+
def render?
|
53
|
+
buttons.any?
|
54
|
+
end
|
55
|
+
end
|
56
|
+
end
|
57
|
+
end
|
@@ -0,0 +1,25 @@
|
|
1
|
+
<%# erblint:counter ButtonComponentMigrationCounter 1 %>
|
2
|
+
<%= render Primer::BaseComponent.new(**@system_arguments) do %>
|
3
|
+
<% if spinner.present? %>
|
4
|
+
<%= spinner %>
|
5
|
+
<% elsif @icon.present? %>
|
6
|
+
<%= primer_octicon @icon, size: @icon_size, classes: "blankslate-icon" %>
|
7
|
+
<% elsif @image_src.present? && @image_alt.present? %>
|
8
|
+
<%= image_tag @image_src.to_s, class: "mb-3", size: "56x56", alt: @image_alt.to_s %>
|
9
|
+
<% end %>
|
10
|
+
<% if @title.present? %>
|
11
|
+
<%= render Primer::BaseComponent.new(tag: @title_tag, mb: 1) do %><%= @title %><% end %>
|
12
|
+
<% end %>
|
13
|
+
<% if @description.present? %>
|
14
|
+
<p><%= @description %></p>
|
15
|
+
<% end %>
|
16
|
+
<%= content %>
|
17
|
+
<% if @button_text.present? && @button_url.present? %>
|
18
|
+
<a class="btn <%= @button_classes %>" href="<%= @button_url %>"><%= @button_text %></a>
|
19
|
+
<% end %>
|
20
|
+
<% if @link_text.present? && @link_url.present? %>
|
21
|
+
<p>
|
22
|
+
<%= link_to @link_url.to_s do %><%= @link_text %><% end %>
|
23
|
+
</p>
|
24
|
+
<% end %>
|
25
|
+
<% end %>
|
@@ -1,8 +1,156 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
module Primer
|
4
|
-
#
|
5
|
-
|
4
|
+
# Use `Blankslate` when there is a lack of content within a page or section. Use as placeholder to tell users why something isn't there.
|
5
|
+
# @accessibility
|
6
|
+
# `Blankslate` renders an `<h3>` element for the title by default. Update the heading level based on what is appropriate for your page hierarchy by setting `title_tag`.
|
7
|
+
# <%= link_to_heading_practices %>
|
8
|
+
class BlankslateComponent < Primer::Component
|
6
9
|
status :deprecated
|
10
|
+
|
11
|
+
# Optional Spinner.
|
12
|
+
#
|
13
|
+
# @param kwargs [Hash] The same arguments as <%= link_to_component(Primer::SpinnerComponent) %>.
|
14
|
+
renders_one :spinner, lambda { |**system_arguments|
|
15
|
+
system_arguments[:mb] ||= 3
|
16
|
+
Primer::SpinnerComponent.new(**system_arguments)
|
17
|
+
}
|
18
|
+
|
19
|
+
#
|
20
|
+
# @example Basic
|
21
|
+
# <%= render Primer::BlankslateComponent.new(
|
22
|
+
# title: "Title",
|
23
|
+
# description: "Description",
|
24
|
+
# ) %>
|
25
|
+
#
|
26
|
+
# @example Icon
|
27
|
+
# @description
|
28
|
+
# Add an `icon` to give additional context. Refer to the [Octicons](https://primer.style/octicons/) documentation to choose an icon.
|
29
|
+
# @code
|
30
|
+
# <%= render Primer::BlankslateComponent.new(
|
31
|
+
# icon: :globe,
|
32
|
+
# title: "Title",
|
33
|
+
# description: "Description",
|
34
|
+
# ) %>
|
35
|
+
#
|
36
|
+
# @example Loading
|
37
|
+
# @description
|
38
|
+
# Add a [SpinnerComponent](https://primer.style/view-components/components/spinner) to the blankslate in place of an icon.
|
39
|
+
# @code
|
40
|
+
# <%= render Primer::BlankslateComponent.new(
|
41
|
+
# title: "Title",
|
42
|
+
# description: "Description",
|
43
|
+
# ) do |component| %>
|
44
|
+
# <% component.spinner(size: :large) %>
|
45
|
+
# <% end %>
|
46
|
+
#
|
47
|
+
# @example Custom content
|
48
|
+
# @description
|
49
|
+
# Pass custom content as a block in place of `description`.
|
50
|
+
# @code
|
51
|
+
# <%= render Primer::BlankslateComponent.new(
|
52
|
+
# title: "Title",
|
53
|
+
# ) do %>
|
54
|
+
# <em>Your custom content here</em>
|
55
|
+
# <% end %>
|
56
|
+
#
|
57
|
+
# @example Action button
|
58
|
+
# @description
|
59
|
+
# Provide a button to guide users to take action from the blankslate. The button appears below the description and custom content.
|
60
|
+
# @code
|
61
|
+
# <%= render Primer::BlankslateComponent.new(
|
62
|
+
# icon: :book,
|
63
|
+
# title: "Welcome to the mona wiki!",
|
64
|
+
# 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.",
|
65
|
+
#
|
66
|
+
# button_text: "Create the first page",
|
67
|
+
# button_url: "https://github.com/monalisa/mona/wiki/_new",
|
68
|
+
# ) %>
|
69
|
+
#
|
70
|
+
# @example Link
|
71
|
+
# @description
|
72
|
+
# Add an additional link to help users learn more about a feature. The link will be shown at the very bottom:
|
73
|
+
# @code
|
74
|
+
# <%= render Primer::BlankslateComponent.new(
|
75
|
+
# icon: :book,
|
76
|
+
# title: "Welcome to the mona wiki!",
|
77
|
+
# 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.",
|
78
|
+
# link_text: "Learn more about wikis",
|
79
|
+
# link_url: "https://docs.github.com/en/github/building-a-strong-community/about-wikis",
|
80
|
+
# ) %>
|
81
|
+
#
|
82
|
+
# @example Variations
|
83
|
+
# @description
|
84
|
+
# 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.
|
85
|
+
# @code
|
86
|
+
# <%= render Primer::BlankslateComponent.new(
|
87
|
+
# icon: :book,
|
88
|
+
# title: "Welcome to the mona wiki!",
|
89
|
+
# 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.",
|
90
|
+
# narrow: true,
|
91
|
+
# large: true,
|
92
|
+
# spacious: true,
|
93
|
+
# ) %>
|
94
|
+
#
|
95
|
+
# @param title [String] Text that appears in a larger bold font.
|
96
|
+
# @param title_tag [Symbol] HTML tag to use for title.
|
97
|
+
# @param icon [Symbol] Octicon icon to use at top of component.
|
98
|
+
# @param icon_size [Symbol] <%= one_of(Primer::OcticonComponent::SIZE_MAPPINGS, sort: false) %>
|
99
|
+
# @param image_src [String] Image to display.
|
100
|
+
# @param image_alt [String] Alt text for image.
|
101
|
+
# @param description [String] Text that appears below the title. Typically a whole sentence.
|
102
|
+
# @param button_text [String] The text of the button.
|
103
|
+
# @param button_url [String] The URL where the user will be taken after clicking the button.
|
104
|
+
# @param button_classes [String] Classes to apply to action button
|
105
|
+
# @param link_text [String] The text of the link.
|
106
|
+
# @param link_url [String] The URL where the user will be taken after clicking the link.
|
107
|
+
# @param narrow [Boolean] Adds a maximum width.
|
108
|
+
# @param large [Boolean] Increases the font size.
|
109
|
+
# @param spacious [Boolean] Adds extra padding.
|
110
|
+
# @param system_arguments [Hash] <%= link_to_system_arguments_docs %>
|
111
|
+
def initialize(
|
112
|
+
title: "",
|
113
|
+
title_tag: :h3,
|
114
|
+
icon: "",
|
115
|
+
icon_size: :medium,
|
116
|
+
image_src: "",
|
117
|
+
image_alt: " ",
|
118
|
+
description: "",
|
119
|
+
button_text: "",
|
120
|
+
button_url: "",
|
121
|
+
button_classes: "btn-primary my-3",
|
122
|
+
link_text: "",
|
123
|
+
link_url: "",
|
124
|
+
|
125
|
+
# variations
|
126
|
+
narrow: false,
|
127
|
+
large: false,
|
128
|
+
spacious: false,
|
129
|
+
|
130
|
+
**system_arguments
|
131
|
+
)
|
132
|
+
@system_arguments = system_arguments
|
133
|
+
@system_arguments[:tag] = :div
|
134
|
+
@system_arguments[:classes] = class_names(
|
135
|
+
@system_arguments[:classes],
|
136
|
+
"blankslate",
|
137
|
+
"blankslate-narrow": narrow,
|
138
|
+
"blankslate-large": large,
|
139
|
+
"blankslate-spacious": spacious
|
140
|
+
)
|
141
|
+
|
142
|
+
@title_tag = title_tag
|
143
|
+
@icon = icon
|
144
|
+
@icon_size = icon_size
|
145
|
+
@image_src = image_src
|
146
|
+
@image_alt = image_alt
|
147
|
+
@title = title
|
148
|
+
@description = description
|
149
|
+
@button_text = button_text
|
150
|
+
@button_url = button_url
|
151
|
+
@button_classes = button_classes
|
152
|
+
@link_text = link_text
|
153
|
+
@link_url = link_url
|
154
|
+
end
|
7
155
|
end
|
8
156
|
end
|
@@ -0,0 +1,25 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Primer
|
4
|
+
# `Box` is a basic wrapper component for most layout related needs.
|
5
|
+
class Box < Primer::Component
|
6
|
+
status :stable
|
7
|
+
|
8
|
+
# @example Default
|
9
|
+
# <%= render(Primer::Box.new) { "Your content here" } %>
|
10
|
+
#
|
11
|
+
# @example Color and padding
|
12
|
+
# <%= render(Primer::Box.new(bg: :subtle, p: 3)) { "Hello world" } %>
|
13
|
+
#
|
14
|
+
# @param system_arguments [Hash] <%= link_to_system_arguments_docs %>
|
15
|
+
def initialize(**system_arguments)
|
16
|
+
@system_arguments = deny_tag_argument(**system_arguments)
|
17
|
+
|
18
|
+
@system_arguments[:tag] = :div
|
19
|
+
end
|
20
|
+
|
21
|
+
def call
|
22
|
+
render(Primer::BaseComponent.new(**@system_arguments)) { content }
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
@@ -1,25 +1,7 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
module Primer
|
4
|
-
|
5
|
-
|
6
|
-
status :stable
|
7
|
-
|
8
|
-
# @example Default
|
9
|
-
# <%= render(Primer::BoxComponent.new) { "Your content here" } %>
|
10
|
-
#
|
11
|
-
# @example Color and padding
|
12
|
-
# <%= render(Primer::BoxComponent.new(bg: :subtle, p: 3)) { "Hello world" } %>
|
13
|
-
#
|
14
|
-
# @param system_arguments [Hash] <%= link_to_system_arguments_docs %>
|
15
|
-
def initialize(**system_arguments)
|
16
|
-
@system_arguments = deny_tag_argument(**system_arguments)
|
17
|
-
|
18
|
-
@system_arguments[:tag] = :div
|
19
|
-
end
|
20
|
-
|
21
|
-
def call
|
22
|
-
render(Primer::BaseComponent.new(**@system_arguments)) { content }
|
23
|
-
end
|
4
|
+
class BoxComponent < Primer::Box
|
5
|
+
status :deprecated
|
24
6
|
end
|
25
7
|
end
|
@@ -1,55 +1,7 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
module Primer
|
4
|
-
|
5
|
-
|
6
|
-
status :beta
|
7
|
-
|
8
|
-
# Required list of buttons to be rendered.
|
9
|
-
#
|
10
|
-
# @param kwargs [Hash] The same arguments as <%= link_to_component(Primer::ButtonComponent) %> except for `size` and `group_item`.
|
11
|
-
renders_many :buttons, lambda { |**kwargs|
|
12
|
-
kwargs[:group_item] = true
|
13
|
-
kwargs[:size] = @size
|
14
|
-
|
15
|
-
Primer::ButtonComponent.new(**kwargs)
|
16
|
-
}
|
17
|
-
|
18
|
-
# @example Default
|
19
|
-
#
|
20
|
-
# <%= render(Primer::ButtonGroup.new) do |component| %>
|
21
|
-
# <% component.button { "Default" } %>
|
22
|
-
# <% component.button(scheme: :primary) { "Primary" } %>
|
23
|
-
# <% component.button(scheme: :danger) { "Danger" } %>
|
24
|
-
# <% component.button(scheme: :outline) { "Outline" } %>
|
25
|
-
# <% component.button(classes: "custom-class") { "Custom class" } %>
|
26
|
-
# <% end %>
|
27
|
-
#
|
28
|
-
# @example Sizes
|
29
|
-
#
|
30
|
-
# <%= render(Primer::ButtonGroup.new(size: :small)) do |component| %>
|
31
|
-
# <% component.button { "Default" } %>
|
32
|
-
# <% component.button(scheme: :primary) { "Primary" } %>
|
33
|
-
# <% component.button(scheme: :danger) { "Danger" } %>
|
34
|
-
# <% component.button(scheme: :outline) { "Outline" } %>
|
35
|
-
# <% end %>
|
36
|
-
#
|
37
|
-
# @param variant [Symbol] DEPRECATED. <%= one_of(Primer::ButtonComponent::SIZE_OPTIONS) %>
|
38
|
-
# @param size [Symbol] <%= one_of(Primer::ButtonComponent::SIZE_OPTIONS) %>
|
39
|
-
# @param system_arguments [Hash] <%= link_to_system_arguments_docs %>
|
40
|
-
def initialize(variant: nil, size: Primer::ButtonComponent::DEFAULT_SIZE, **system_arguments)
|
41
|
-
@size = variant || size
|
42
|
-
@system_arguments = deny_tag_argument(**system_arguments)
|
43
|
-
@system_arguments[:tag] = :div
|
44
|
-
|
45
|
-
@system_arguments[:classes] = class_names(
|
46
|
-
"BtnGroup",
|
47
|
-
system_arguments[:classes]
|
48
|
-
)
|
49
|
-
end
|
50
|
-
|
51
|
-
def render?
|
52
|
-
buttons.any?
|
53
|
-
end
|
4
|
+
class ButtonGroup < Primer::Beta::ButtonGroup
|
5
|
+
status :deprecated
|
54
6
|
end
|
55
7
|
end
|
@@ -7,7 +7,7 @@ module Primer
|
|
7
7
|
# Boxes](https://developer.mozilla.org/en-US/docs/Web/CSS/CSS_Flexible_Box_Layout/Basic_Concepts_of_Flexbox).
|
8
8
|
#
|
9
9
|
# @deprecated
|
10
|
-
# Use <%= link_to_component(Primer::
|
10
|
+
# Use <%= link_to_component(Primer::Box) %> instead.
|
11
11
|
#
|
12
12
|
# **Before**:
|
13
13
|
#
|
@@ -22,11 +22,11 @@ module Primer
|
|
22
22
|
# **After**:
|
23
23
|
#
|
24
24
|
# ```erb
|
25
|
-
# <%%= render Primer::
|
26
|
-
# <%%= render Primer::
|
27
|
-
# <%%= render Primer::
|
28
|
-
# <%%= render Primer::
|
29
|
-
# <%%= render Primer::
|
25
|
+
# <%%= render Primer::Box.new(display: :flex, justify_content: :center) %>
|
26
|
+
# <%%= render Primer::Box.new(display: :inline_flex) %>
|
27
|
+
# <%%= render Primer::Box.new(display: :flex, flex_wrap: :wrap) %>
|
28
|
+
# <%%= render Primer::Box.new(display: :flex, align_items: :start) %>
|
29
|
+
# <%%= render Primer::Box.new(display: :flex, direction: :column) %>
|
30
30
|
# ```
|
31
31
|
class FlexComponent < Primer::Component
|
32
32
|
status :deprecated
|
@@ -62,30 +62,30 @@ module Primer
|
|
62
62
|
|
63
63
|
# @example Default
|
64
64
|
# <%= render(Primer::FlexComponent.new(bg: :subtle)) do %>
|
65
|
-
# <%= render(Primer::
|
66
|
-
# <%= render(Primer::
|
67
|
-
# <%= render(Primer::
|
65
|
+
# <%= render(Primer::Box.new(p: 5, bg: :subtle, classes: "border")) { "Item 1" } %>
|
66
|
+
# <%= render(Primer::Box.new(p: 5, bg: :subtle, classes: "border")) { "Item 2" } %>
|
67
|
+
# <%= render(Primer::Box.new(p: 5, bg: :subtle, classes: "border")) { "Item 3" } %>
|
68
68
|
# <% end %>
|
69
69
|
#
|
70
70
|
# @example Justify center
|
71
71
|
# <%= render(Primer::FlexComponent.new(justify_content: :center, bg: :subtle)) do %>
|
72
|
-
# <%= render(Primer::
|
73
|
-
# <%= render(Primer::
|
74
|
-
# <%= render(Primer::
|
72
|
+
# <%= render(Primer::Box.new(p: 5, bg: :subtle, classes: "border")) { "Item 1" } %>
|
73
|
+
# <%= render(Primer::Box.new(p: 5, bg: :subtle, classes: "border")) { "Item 2" } %>
|
74
|
+
# <%= render(Primer::Box.new(p: 5, bg: :subtle, classes: "border")) { "Item 3" } %>
|
75
75
|
# <% end %>
|
76
76
|
#
|
77
77
|
# @example Align end
|
78
78
|
# <%= render(Primer::FlexComponent.new(align_items: :end, bg: :subtle)) do %>
|
79
|
-
# <%= render(Primer::
|
80
|
-
# <%= render(Primer::
|
81
|
-
# <%= render(Primer::
|
79
|
+
# <%= render(Primer::Box.new(p: 5, bg: :subtle, classes: "border")) { "Item 1" } %>
|
80
|
+
# <%= render(Primer::Box.new(p: 5, bg: :subtle, classes: "border")) { "Item 2" } %>
|
81
|
+
# <%= render(Primer::Box.new(p: 5, bg: :subtle, classes: "border")) { "Item 3" } %>
|
82
82
|
# <% end %>
|
83
83
|
#
|
84
84
|
# @example Direction column
|
85
85
|
# <%= render(Primer::FlexComponent.new(direction: :column, bg: :subtle)) do %>
|
86
|
-
# <%= render(Primer::
|
87
|
-
# <%= render(Primer::
|
88
|
-
# <%= render(Primer::
|
86
|
+
# <%= render(Primer::Box.new(p: 5, bg: :subtle, classes: "border")) { "Item 1" } %>
|
87
|
+
# <%= render(Primer::Box.new(p: 5, bg: :subtle, classes: "border")) { "Item 2" } %>
|
88
|
+
# <%= render(Primer::Box.new(p: 5, bg: :subtle, classes: "border")) { "Item 3" } %>
|
89
89
|
# <% end %>
|
90
90
|
#
|
91
91
|
# @param justify_content [Symbol] Use this param to distribute space between and around flex items along the main axis of the container. <%= one_of(Primer::FlexComponent::JUSTIFY_CONTENT_OPTIONS) %>
|
@@ -102,7 +102,7 @@ module Primer
|
|
102
102
|
direction: nil,
|
103
103
|
**system_arguments
|
104
104
|
)
|
105
|
-
deprecated_component_warning(new_class: Primer::
|
105
|
+
deprecated_component_warning(new_class: Primer::Box, version: "0.0.40")
|
106
106
|
|
107
107
|
@align_items = fetch_or_fallback(ALIGN_ITEMS_OPTIONS, align_items, ALIGN_ITEMS_DEFAULT)
|
108
108
|
@justify_content = fetch_or_fallback(JUSTIFY_CONTENT_OPTIONS, justify_content, JUSTIFY_CONTENT_DEFAULT)
|
@@ -122,7 +122,7 @@ module Primer
|
|
122
122
|
end
|
123
123
|
|
124
124
|
def call
|
125
|
-
render(Primer::
|
125
|
+
render(Primer::Box.new(**@system_arguments)) { content }
|
126
126
|
end
|
127
127
|
|
128
128
|
private
|
@@ -5,7 +5,7 @@ module Primer
|
|
5
5
|
# dimensions to fill available space.
|
6
6
|
#
|
7
7
|
# @deprecated
|
8
|
-
# Use <%= link_to_component(Primer::
|
8
|
+
# Use <%= link_to_component(Primer::Box) %> instead.
|
9
9
|
#
|
10
10
|
# **Before**:
|
11
11
|
#
|
@@ -16,7 +16,7 @@ module Primer
|
|
16
16
|
# **After**:
|
17
17
|
#
|
18
18
|
# ```erb
|
19
|
-
# <%%= render Primer::
|
19
|
+
# <%%= render Primer::Box.new(flex: :auto) %>
|
20
20
|
# ```
|
21
21
|
class FlexItemComponent < Primer::Component
|
22
22
|
status :deprecated
|
@@ -38,7 +38,7 @@ module Primer
|
|
38
38
|
# @param flex_auto [Boolean] Fills available space and auto-sizes based on the content. Defaults to <%= Primer::FlexItemComponent::FLEX_AUTO_DEFAULT %>
|
39
39
|
# @param system_arguments [Hash] <%= link_to_system_arguments_docs %>
|
40
40
|
def initialize(flex_auto: FLEX_AUTO_DEFAULT, **system_arguments)
|
41
|
-
deprecated_component_warning(new_class: Primer::
|
41
|
+
deprecated_component_warning(new_class: Primer::Box, version: "0.0.40")
|
42
42
|
|
43
43
|
@system_arguments = system_arguments
|
44
44
|
@system_arguments[:classes] =
|
@@ -49,7 +49,7 @@ module Primer
|
|
49
49
|
end
|
50
50
|
|
51
51
|
def call
|
52
|
-
render(Primer::
|
52
|
+
render(Primer::Box.new(**@system_arguments)) { content }
|
53
53
|
end
|
54
54
|
end
|
55
55
|
end
|
@@ -1,6 +1,12 @@
|
|
1
|
-
|
1
|
+
<% if render_tooltip? %>
|
2
|
+
<%= render Primer::BaseComponent.new(tag: :div, position: :relative, display: :inline_block) do %>
|
3
|
+
<%= render Primer::Beta::BaseButton.new(**@system_arguments) do -%>
|
4
|
+
<%= render Primer::OcticonComponent.new(icon: @icon) %>
|
5
|
+
<% end -%>
|
6
|
+
<%= render Primer::Alpha::Tooltip.new(**@tooltip_arguments) %>
|
7
|
+
<% end %>
|
8
|
+
<% else %>
|
2
9
|
<%= render Primer::Beta::BaseButton.new(**@system_arguments) do -%>
|
3
10
|
<%= render Primer::OcticonComponent.new(icon: @icon) %>
|
4
11
|
<% end -%>
|
5
|
-
<%= render Primer::Alpha::Tooltip.new(**@tooltip_arguments) %>
|
6
12
|
<% end %>
|
@@ -32,11 +32,18 @@ module Primer
|
|
32
32
|
DEPRECATED_SCHEME_OPTIONS = [:info, :warning, :orange, :purple].freeze
|
33
33
|
SCHEME_OPTIONS = (SCHEME_MAPPINGS.keys - DEPRECATED_SCHEME_OPTIONS).freeze
|
34
34
|
|
35
|
-
|
36
|
-
|
37
|
-
|
35
|
+
DEFAULT_SIZE = :medium
|
36
|
+
SIZE_MAPPINGS = {
|
37
|
+
DEFAULT_SIZE => nil,
|
38
|
+
:large => "Label--large"
|
38
39
|
}.freeze
|
39
|
-
|
40
|
+
SIZE_OPTIONS = SIZE_MAPPINGS.keys
|
41
|
+
|
42
|
+
DEFAULT_VARIANT = :none
|
43
|
+
VARIANT_OPTIONS = [DEFAULT_VARIANT].freeze
|
44
|
+
DEPRECATED_VARIANT_OPTIONS = [:large, :inline].freeze
|
45
|
+
|
46
|
+
INLINE_CLASS = "Label--inline"
|
40
47
|
|
41
48
|
# @example Schemes
|
42
49
|
# <%= render(Primer::LabelComponent.new) { "Default" } %>
|
@@ -50,22 +57,37 @@ module Primer
|
|
50
57
|
# <%= render(Primer::LabelComponent.new(scheme: :done)) { "Done" } %>
|
51
58
|
# <%= render(Primer::LabelComponent.new(scheme: :sponsors)) { "Sponsors" } %>
|
52
59
|
#
|
53
|
-
# @example
|
60
|
+
# @example Sizes
|
61
|
+
# <%= render(Primer::LabelComponent.new) { "Medium" } %>
|
62
|
+
# <%= render(Primer::LabelComponent.new(size: :large)) { "Large" } %>
|
63
|
+
#
|
64
|
+
# @example Inline
|
54
65
|
# <%= render(Primer::LabelComponent.new) { "Default" } %>
|
55
|
-
# <%= render(Primer::LabelComponent.new(
|
66
|
+
# <%= render(Primer::LabelComponent.new(inline: true)) { "Inline" } %>
|
56
67
|
#
|
57
68
|
# @param tag [Symbol] <%= one_of(Primer::LabelComponent::TAG_OPTIONS) %>
|
58
69
|
# @param scheme [Symbol] <%= one_of(Primer::LabelComponent::SCHEME_MAPPINGS.keys) %>
|
59
|
-
# @param
|
70
|
+
# @param size [Symbol] <%= one_of(Primer::LabelComponent::SIZE_OPTIONS) %>
|
71
|
+
# @param inline [Boolean] Whether or not to render this label inline.
|
72
|
+
# @param variant [Symbol] <%= one_of(Primer::LabelComponent::VARIANT_OPTIONS + Primer::LabelComponent::DEPRECATED_VARIANT_OPTIONS) %>
|
60
73
|
# @param system_arguments [Hash] <%= link_to_system_arguments_docs %>
|
61
|
-
|
74
|
+
|
75
|
+
def initialize(tag: DEFAULT_TAG, scheme: DEFAULT_SCHEME, size: DEFAULT_SIZE, inline: false, variant: DEFAULT_VARIANT, **system_arguments)
|
62
76
|
@system_arguments = system_arguments
|
77
|
+
|
78
|
+
@variant = fetch_or_fallback(VARIANT_OPTIONS, variant, nil, deprecated_values: DEPRECATED_VARIANT_OPTIONS)
|
79
|
+
@scheme = fetch_or_fallback(SCHEME_OPTIONS, scheme, DEFAULT_SCHEME, deprecated_values: DEPRECATED_SCHEME_OPTIONS)
|
80
|
+
@size = fetch_or_fallback(SIZE_OPTIONS, size, DEFAULT_SIZE)
|
81
|
+
@size = :large if @variant == :large
|
82
|
+
@inline = inline || @variant == :inline
|
83
|
+
|
63
84
|
@system_arguments[:tag] = fetch_or_fallback(TAG_OPTIONS, tag, DEFAULT_TAG)
|
64
85
|
@system_arguments[:classes] = class_names(
|
65
86
|
"Label",
|
66
87
|
system_arguments[:classes],
|
67
|
-
SCHEME_MAPPINGS[
|
68
|
-
|
88
|
+
SCHEME_MAPPINGS[@scheme],
|
89
|
+
SIZE_MAPPINGS[@size],
|
90
|
+
@inline ? INLINE_CLASS : nil
|
69
91
|
)
|
70
92
|
end
|
71
93
|
|