primer_view_components 0.0.116 → 0.0.117
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/assets/javascripts/primer_view_components.js +1 -1
- data/app/assets/javascripts/primer_view_components.js.map +1 -1
- data/app/assets/styles/primer_view_components.css +2 -2
- data/app/assets/styles/primer_view_components.css.map +1 -1
- data/app/components/primer/alpha/action_list.css +1 -1
- data/app/components/primer/alpha/action_list.css.json +1 -1
- data/app/components/primer/alpha/action_list.css.map +1 -1
- data/app/components/primer/alpha/auto_complete/item.rb +4 -4
- data/app/components/primer/alpha/auto_complete.rb +6 -6
- data/app/components/primer/alpha/dialog.rb +0 -2
- data/app/components/primer/alpha/dropdown.rb +53 -53
- data/app/components/primer/alpha/hellip_button.rb +41 -0
- data/app/components/primer/alpha/hidden_text_expander.rb +1 -1
- data/app/components/primer/alpha/layout.rb +48 -48
- data/app/components/primer/alpha/menu.css +1 -1
- data/app/components/primer/alpha/menu.css.json +1 -1
- data/app/components/primer/alpha/menu.css.map +1 -1
- data/app/components/primer/alpha/menu.rb +5 -5
- data/app/components/primer/alpha/segmented_control.rb +20 -20
- data/app/components/primer/{tab_container_component.d.ts → alpha/tab_container.d.ts} +0 -0
- data/app/components/primer/{tab_container_component.js → alpha/tab_container.js} +0 -0
- data/app/components/primer/alpha/tab_container.rb +43 -0
- data/app/components/primer/{tab_container_component.ts → alpha/tab_container.ts} +0 -0
- data/app/components/primer/alpha/tab_nav.css +1 -1
- data/app/components/primer/alpha/tab_nav.css.json +1 -1
- data/app/components/primer/alpha/tab_nav.css.map +1 -1
- data/app/components/primer/alpha/tab_nav.rb +32 -32
- data/app/components/primer/alpha/tool_tip.js +3 -7
- data/app/components/primer/alpha/tool_tip.ts +3 -7
- data/app/components/primer/alpha/tooltip.rb +18 -18
- data/app/components/primer/alpha/underline_nav.css +1 -1
- data/app/components/primer/alpha/underline_nav.css.json +1 -1
- data/app/components/primer/alpha/underline_nav.css.map +1 -1
- data/app/components/primer/alpha/underline_nav.rb +18 -18
- data/app/components/primer/beta/auto_complete/item.rb +2 -3
- data/app/components/primer/beta/auto_complete.rb +14 -16
- data/app/components/primer/beta/avatar_stack.rb +12 -14
- data/app/components/primer/beta/blankslate.rb +0 -1
- data/app/components/primer/beta/border_box/header.rb +0 -2
- data/app/components/primer/beta/border_box.rb +0 -2
- data/app/components/primer/beta/breadcrumbs.css +1 -1
- data/app/components/primer/beta/breadcrumbs.css.json +1 -1
- data/app/components/primer/beta/breadcrumbs.css.map +1 -1
- data/app/components/primer/beta/breadcrumbs.rb +0 -1
- data/app/components/primer/beta/button.rb +9 -10
- data/app/components/primer/beta/button_group.rb +0 -1
- data/app/components/primer/beta/details.rb +0 -1
- data/app/components/primer/beta/flash.rb +0 -1
- data/app/components/primer/beta/link.rb +2 -3
- data/app/components/primer/beta/octicon.rb +0 -1
- data/app/components/primer/beta/popover.rb +0 -1
- data/app/components/primer/{state_component.css → beta/state.css} +0 -0
- data/app/components/primer/beta/state.css.json +1 -0
- data/app/components/primer/beta/state.css.map +1 -0
- data/app/components/primer/{state_component.pcss → beta/state.pcss} +0 -0
- data/app/components/primer/beta/state.rb +76 -0
- data/app/components/primer/{subhead_component.css → beta/subhead.css} +0 -0
- data/app/components/primer/beta/subhead.css.json +1 -0
- data/app/components/primer/beta/subhead.css.map +1 -0
- data/app/components/primer/{subhead_component.html.erb → beta/subhead.html.erb} +0 -0
- data/app/components/primer/{subhead_component.pcss → beta/subhead.pcss} +0 -0
- data/app/components/primer/beta/subhead.rb +135 -0
- data/app/components/primer/{timeline_item_component.css → beta/timeline_item.css} +0 -0
- data/app/components/primer/beta/timeline_item.css.json +1 -0
- data/app/components/primer/beta/timeline_item.css.map +1 -0
- data/app/components/primer/{timeline_item_component.html.erb → beta/timeline_item.html.erb} +0 -0
- data/app/components/primer/{timeline_item_component.pcss → beta/timeline_item.pcss} +0 -0
- data/app/components/primer/beta/timeline_item.rb +90 -0
- data/app/components/primer/beta/truncate.css +1 -1
- data/app/components/primer/beta/truncate.css.json +1 -1
- data/app/components/primer/beta/truncate.css.map +1 -1
- data/app/components/primer/beta/truncate.rb +0 -1
- data/app/components/primer/button_component.rb +9 -9
- data/app/components/primer/component.rb +0 -1
- data/app/components/primer/hellip_button.rb +2 -34
- data/app/components/primer/navigation/tab_component.rb +16 -16
- data/app/components/primer/primer.d.ts +1 -1
- data/app/components/primer/primer.js +1 -1
- data/app/components/primer/primer.pcss +3 -3
- data/app/components/primer/primer.ts +1 -1
- data/app/components/primer/state_component.rb +2 -69
- data/app/components/primer/subhead_component.rb +2 -128
- data/app/components/primer/tab_container_component.rb +2 -36
- data/app/components/primer/timeline_item_component.rb +5 -78
- data/app/forms/example_toggle_switch_form/example_field_caption.html.erb +1 -0
- data/app/forms/example_toggle_switch_form.rb +8 -0
- data/app/forms/submit_button_form.rb +4 -4
- data/app/lib/primer/tabbed_component_helper.rb +1 -1
- data/lib/primer/deprecations.rb +7 -13
- data/lib/primer/deprecations.yml +24 -0
- data/lib/primer/forms/button.html.erb +2 -2
- data/lib/primer/forms/dsl/toggle_switch_input.rb +35 -0
- data/lib/primer/forms/toggle_switch.html.erb +17 -0
- data/lib/primer/forms/toggle_switch.rb +19 -0
- data/lib/primer/forms/toggle_switch_form.rb +74 -0
- data/lib/primer/view_components/linters/subhead_component_migration_counter.rb +1 -1
- data/lib/primer/view_components/version.rb +1 -1
- data/lib/rubocop/cop/primer/component_name_migration.rb +2 -1
- data/lib/tasks/docs.rake +6 -6
- data/previews/primer/alpha/action_list_preview.rb +44 -44
- data/previews/primer/alpha/dropdown_preview.rb +97 -97
- data/previews/primer/alpha/hellip_button_preview.rb +24 -0
- data/previews/primer/alpha/layout_preview.rb +63 -63
- data/previews/primer/alpha/menu_preview/default.html.erb +5 -5
- data/previews/primer/alpha/menu_preview/playground.html.erb +5 -5
- data/previews/primer/alpha/segmented_control_preview.rb +60 -60
- data/previews/primer/alpha/tab_nav_preview.rb +22 -22
- data/previews/primer/alpha/tab_panels_preview.rb +2 -2
- data/previews/primer/alpha/tooltip_preview/with_multiple_on_a_page.html.erb +6 -6
- data/previews/primer/alpha/tooltip_preview.rb +12 -12
- data/previews/primer/alpha/underline_nav_preview.rb +4 -4
- data/previews/primer/alpha/underline_panels_preview.rb +8 -8
- data/previews/primer/beta/auto_complete_item_preview/default.html.erb +2 -2
- data/previews/primer/beta/auto_complete_item_preview/playground.html.erb +2 -2
- data/previews/primer/beta/auto_complete_item_preview/with_description.html.erb +3 -3
- data/previews/primer/beta/auto_complete_preview/with_submit_button.html.erb +2 -2
- data/previews/primer/beta/auto_complete_preview.rb +18 -18
- data/previews/primer/beta/avatar_stack_preview.rb +32 -32
- data/previews/primer/beta/blankslate_preview.rb +40 -40
- data/previews/primer/beta/border_box_preview.rb +38 -38
- data/previews/primer/beta/breadcrumbs_preview.rb +2 -2
- data/previews/primer/beta/button_group_preview.rb +10 -10
- data/previews/primer/beta/button_preview/all_schemes.html.erb +4 -4
- data/previews/primer/beta/button_preview/invisible_all_visuals.html.erb +16 -16
- data/previews/primer/beta/button_preview/leading_visual.html.erb +2 -2
- data/previews/primer/beta/button_preview/trailing_action.html.erb +2 -2
- data/previews/primer/beta/button_preview/trailing_visual.html.erb +2 -2
- data/previews/primer/beta/button_preview/with_tooltip.html.erb +2 -2
- data/previews/primer/beta/details_preview.rb +6 -6
- data/previews/primer/beta/state_preview.rb +66 -0
- data/previews/primer/beta/subhead_preview/actions.html.erb +14 -0
- data/previews/primer/beta/subhead_preview.rb +99 -0
- data/previews/primer/beta/timeline_item_preview.rb +30 -0
- data/previews/primer/forms/forms_preview/example_toggle_switch_form.html.erb +1 -0
- data/previews/primer/forms/forms_preview.rb +2 -0
- data/static/arguments.json +118 -118
- data/static/audited_at.json +6 -0
- data/static/constants.json +67 -54
- data/static/statuses.json +12 -6
- metadata +36 -23
- data/app/components/primer/state_component.css.json +0 -1
- data/app/components/primer/state_component.css.map +0 -1
- data/app/components/primer/subhead_component.css.json +0 -1
- data/app/components/primer/subhead_component.css.map +0 -1
- data/app/components/primer/timeline_item_component.css.json +0 -1
- data/app/components/primer/timeline_item_component.css.map +0 -1
- data/previews/primer/hellip_button_preview.rb +0 -22
- data/previews/primer/state_component_preview.rb +0 -26
- data/previews/primer/subhead_component_preview.rb +0 -40
- data/previews/primer/timeline_item_component_preview.rb +0 -28
@@ -0,0 +1,135 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Primer
|
4
|
+
module Beta
|
5
|
+
# Use `Subhead` as the start of a section. The `:heading` slot will render an `<h2>` font-sized text.
|
6
|
+
#
|
7
|
+
# - Optionally set the `:description` slot to render a short description and the `:actions` slot for a related action.
|
8
|
+
# - Use a succinct, one-line description for the `:description` slot. For longer descriptions, omit the description slot and render a paragraph below the `Subhead`.
|
9
|
+
# - Use the actions slot to render a related action to the right of the heading. Use <%= link_to_component(Primer::ButtonComponent) %> or <%= link_to_component(Primer::Beta::Link) %>.
|
10
|
+
#
|
11
|
+
# @accessibility
|
12
|
+
# The `:heading` slot defaults to rendering a `<div>`. Update the tag to a heading element with the appropriate level to improve page navigation for assistive technologies.
|
13
|
+
# <%= link_to_heading_practices %>
|
14
|
+
class Subhead < Primer::Component
|
15
|
+
status :beta
|
16
|
+
|
17
|
+
DEFAULT_HEADING_TAG = :div
|
18
|
+
HEADING_TAG_OPTIONS = [DEFAULT_HEADING_TAG, :h1, :h2, :h3, :h4, :h5, :h6].freeze
|
19
|
+
|
20
|
+
# The heading
|
21
|
+
#
|
22
|
+
# @param tag [Symbol] <%= one_of(Primer::Beta::Subhead::HEADING_TAG_OPTIONS)%>
|
23
|
+
# @param danger [Boolean] Whether to style the heading as dangerous.
|
24
|
+
# @param system_arguments [Hash] <%= link_to_system_arguments_docs %>
|
25
|
+
renders_one :heading, lambda { |tag: DEFAULT_HEADING_TAG, danger: false, **system_arguments|
|
26
|
+
system_arguments[:tag] = fetch_or_fallback(HEADING_TAG_OPTIONS, tag, DEFAULT_HEADING_TAG)
|
27
|
+
system_arguments[:classes] = class_names(
|
28
|
+
system_arguments[:classes],
|
29
|
+
"Subhead-heading",
|
30
|
+
"Subhead-heading--danger": danger
|
31
|
+
)
|
32
|
+
|
33
|
+
Primer::BaseComponent.new(**system_arguments)
|
34
|
+
}
|
35
|
+
|
36
|
+
# Actions
|
37
|
+
#
|
38
|
+
# @param system_arguments [Hash] <%= link_to_system_arguments_docs %>
|
39
|
+
renders_one :actions, lambda { |**system_arguments|
|
40
|
+
deny_tag_argument(**system_arguments)
|
41
|
+
system_arguments[:tag] = :div
|
42
|
+
system_arguments[:classes] = class_names(system_arguments[:classes], "Subhead-actions")
|
43
|
+
|
44
|
+
Primer::BaseComponent.new(**system_arguments)
|
45
|
+
}
|
46
|
+
|
47
|
+
# The description
|
48
|
+
#
|
49
|
+
# @param system_arguments [Hash] <%= link_to_system_arguments_docs %>
|
50
|
+
renders_one :description, lambda { |**system_arguments|
|
51
|
+
deny_tag_argument(**system_arguments)
|
52
|
+
system_arguments[:tag] = :div
|
53
|
+
system_arguments[:classes] = class_names(system_arguments[:classes], "Subhead-description")
|
54
|
+
|
55
|
+
Primer::BaseComponent.new(**system_arguments)
|
56
|
+
}
|
57
|
+
|
58
|
+
# @example Default
|
59
|
+
# <%= render(Primer::Beta::Subhead.new) do |component| %>
|
60
|
+
# <% component.with_heading(tag: :h3) do %>
|
61
|
+
# My Heading
|
62
|
+
# <% end %>
|
63
|
+
# <% component.with_description do %>
|
64
|
+
# My Description
|
65
|
+
# <% end %>
|
66
|
+
# <% end %>
|
67
|
+
#
|
68
|
+
# @example With dangerous heading
|
69
|
+
# <%= render(Primer::Beta::Subhead.new) do |component| %>
|
70
|
+
# <% component.with_heading(tag: :h3, danger: true) do %>
|
71
|
+
# My Heading
|
72
|
+
# <% end %>
|
73
|
+
# <% component.with_description do %>
|
74
|
+
# My Description
|
75
|
+
# <% end %>
|
76
|
+
# <% end %>
|
77
|
+
#
|
78
|
+
# @example With long description
|
79
|
+
# <%= render(Primer::Beta::Subhead.new) do |component| %>
|
80
|
+
# <% component.with_heading(tag: :h3) do %>
|
81
|
+
# My Heading
|
82
|
+
# <% end %>
|
83
|
+
# <% end %>
|
84
|
+
# <p> This is a longer description that is sitting below the Subhead. It's much longer than a description that could sit comfortably in the Subhead. </p>
|
85
|
+
#
|
86
|
+
# @example Without border
|
87
|
+
# <%= render(Primer::Beta::Subhead.new(hide_border: true)) do |component| %>
|
88
|
+
# <% component.with_heading do %>
|
89
|
+
# My Heading
|
90
|
+
# <% end %>
|
91
|
+
# <% component.with_description do %>
|
92
|
+
# My Description
|
93
|
+
# <% end %>
|
94
|
+
# <% end %>
|
95
|
+
#
|
96
|
+
# @example With actions
|
97
|
+
# <%= render(Primer::Beta::Subhead.new) do |component| %>
|
98
|
+
# <% component.with_heading do %>
|
99
|
+
# My Heading
|
100
|
+
# <% end %>
|
101
|
+
# <% component.with_description do %>
|
102
|
+
# My Description
|
103
|
+
# <% end %>
|
104
|
+
# <% component.with_actions do %>
|
105
|
+
# <%= render(
|
106
|
+
# Primer::ButtonComponent.new(
|
107
|
+
# tag: :a, href: "http://www.google.com", scheme: :danger
|
108
|
+
# )
|
109
|
+
# ) { "Action" } %>
|
110
|
+
# <% end %>
|
111
|
+
# <% end %>
|
112
|
+
#
|
113
|
+
# @param spacious [Boolean] Whether to add spacing to the Subhead.
|
114
|
+
# @param hide_border [Boolean] Whether to hide the border under the heading.
|
115
|
+
# @param system_arguments [Hash] <%= link_to_system_arguments_docs %>
|
116
|
+
def initialize(spacious: false, hide_border: false, **system_arguments)
|
117
|
+
@system_arguments = deny_tag_argument(**system_arguments)
|
118
|
+
|
119
|
+
@system_arguments[:tag] = :div
|
120
|
+
@system_arguments[:classes] =
|
121
|
+
class_names(
|
122
|
+
@system_arguments[:classes],
|
123
|
+
"Subhead",
|
124
|
+
"Subhead--spacious": spacious,
|
125
|
+
"border-bottom-0": hide_border
|
126
|
+
)
|
127
|
+
@system_arguments[:mb] ||= hide_border ? 0 : nil
|
128
|
+
end
|
129
|
+
|
130
|
+
def render?
|
131
|
+
heading.present?
|
132
|
+
end
|
133
|
+
end
|
134
|
+
end
|
135
|
+
end
|
File without changes
|
@@ -0,0 +1 @@
|
|
1
|
+
{"name":"beta/timeline_item","selectors":[".TimelineItem",".TimelineItem:before",".TimelineItem:target .TimelineItem-badge",".TimelineItem-badge",".TimelineItem-badge--success",".TimelineItem-body",".TimelineItem-avatar",".TimelineItem-break",".TimelineItem--condensed",".TimelineItem--condensed:last-child",".TimelineItem--condensed .TimelineItem-badge"]}
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"sources":["timeline_item.pcss"],"names":[],"mappings":"AAEA,cAEE,YAAa,CAEb,+CAAiD,CADjD,iDAAmD,CAFnD,iBAqBF,CAfE,qBAQE,0CAA2C,CAL3C,QAAS,CAIT,UAAW,CAFX,aAAc,CADd,MAAO,CAHP,iBAAkB,CAClB,KAAM,CAIN,yCAGF,CAEA,yCACE,yCAA0C,CAC1C,6CACF,CAGF,oBASE,kBAAmB,CACnB,+CAAgD,CAChD,4EAA8E,CAC9E,iBAAkB,CAJlB,2BAA4B,CAL5B,YAAa,CAWb,aAAc,CATd,6CAA+C,CAQ/C,sBAAuB,CANvB,kEAAqE,CADrE,gEAAkE,CALlE,iBAAkB,CAGlB,4CAA8C,CAF9C,SAaF,CAEA,6BAEE,8CAA+C,CAC/C,qDAA6D,CAF7D,iCAGF,CAEA,mBAIE,2BAA4B,CAC5B,SAAU,CAFV,iCAAmC,CADnC,cAAe,CADf,WAKF,CAEA,qBAEE,UAAW,CADX,iBAAkB,CAElB,SACF,CAEA,oBAOE,4CAA6C,CAC7C,QAAS,CACT,kFAAoF,CANpF,4CAA8C,CAC9C,QAAS,CACT,2DAA8D,CAC9D,iBAAkB,CALlB,iBAAkB,CAClB,SAQF,CAEA,yBAEE,gBAAiB,CADjB,kCAgBF,CAZE,oCACE,kDACF,CAEA,6CAKE,4CAA6C,CAC7C,QAAS,CAFT,2BAA4B,CAH5B,+BAAiC,CAEjC,oCAAsC,CADtC,iCAKF","file":"timeline_item.css","sourcesContent":["/* TimelineItem */\n\n.TimelineItem {\n position: relative;\n display: flex;\n padding: var(--primer-stack-padding-normal, 16px) 0;\n margin-left: var(--primer-stack-gap-normal, 16px);\n\n /* The Timeline */\n &::before {\n position: absolute;\n top: 0;\n bottom: 0;\n left: 0;\n display: block;\n width: var(--primer-borderWidth-thick, 2px);\n content: '';\n background-color: var(--color-border-muted);\n }\n\n &:target .TimelineItem-badge {\n border-color: var(--color-accent-emphasis);\n box-shadow: 0 0 0.2em var(--color-accent-muted);\n }\n}\n\n.TimelineItem-badge {\n position: relative;\n z-index: 1;\n display: flex;\n width: var(--primer-control-medium-size, 32px);\n height: var(--primer-control-medium-size, 32px);\n margin-right: var(--primer-controlStack-medium-gap-condensed, 8px);\n margin-left: calc(var(--primer-control-medium-size, 32px) / -2 + 1px);\n color: var(--color-fg-muted);\n align-items: center;\n background-color: var(--color-timeline-badge-bg);\n border: var(--primer-borderWidth-thick, 2px) solid var(--color-canvas-default);\n border-radius: 50%;\n justify-content: center;\n flex-shrink: 0;\n}\n\n.TimelineItem-badge--success {\n color: var(--color-fg-on-emphasis);\n background-color: var(--color-success-emphasis);\n border: var(--primer-borderWidth-thin, 1px) solid transparent;\n}\n\n.TimelineItem-body {\n min-width: 0;\n max-width: 100%;\n margin-top: var(--base-size-4, 4px);\n color: var(--color-fg-muted);\n flex: auto;\n}\n\n.TimelineItem-avatar {\n position: absolute;\n left: -72px;\n z-index: 1;\n}\n\n.TimelineItem-break {\n position: relative;\n z-index: 1;\n height: var(--primer-stack-gap-spacious, 24px);\n margin: 0;\n margin-bottom: calc(var(--primer-stack-gap-normal, 16px) * -1);\n margin-left: -56px;\n background-color: var(--color-canvas-default);\n border: 0;\n border-top: var(--primer-borderWidth-thicker, 4px) solid var(--color-border-default);\n}\n\n.TimelineItem--condensed {\n padding-top: var(--base-size-4, 4px);\n padding-bottom: 0;\n\n /* TimelineItem--condensed is often grouped. (commits) */\n &:last-child {\n padding-bottom: var(--primer-stack-gap-normal, 16px);\n }\n\n & .TimelineItem-badge {\n height: var(--base-size-16, 16px);\n margin-top: var(--base-size-8, 8px);\n margin-bottom: var(--base-size-8, 8px);\n color: var(--color-fg-muted);\n background-color: var(--color-canvas-default);\n border: 0;\n }\n}\n"]}
|
File without changes
|
File without changes
|
@@ -0,0 +1,90 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Primer
|
4
|
+
module Beta
|
5
|
+
# Use `TimelineItem` to display items on a vertical timeline, connected by badge elements.
|
6
|
+
class TimelineItem < Primer::Component
|
7
|
+
status :beta
|
8
|
+
|
9
|
+
# Avatar to be rendered to the left of the Badge.
|
10
|
+
#
|
11
|
+
# @param kwargs [Hash] The same arguments as <%= link_to_component(Primer::Beta::Avatar) %>.
|
12
|
+
renders_one :avatar, lambda { |src:, size: 40, shape: :square, **system_arguments|
|
13
|
+
system_arguments[:classes] = class_names(
|
14
|
+
"TimelineItem-avatar",
|
15
|
+
system_arguments[:classes]
|
16
|
+
)
|
17
|
+
|
18
|
+
Primer::Beta::Avatar.new(src: src, size: size, shape: shape, **system_arguments)
|
19
|
+
}
|
20
|
+
|
21
|
+
# Badge that will be connected to other TimelineItems.
|
22
|
+
#
|
23
|
+
# @param icon [String] Name of <%= link_to_octicons %> to use.
|
24
|
+
# @param system_arguments [Hash] <%= link_to_system_arguments_docs %>
|
25
|
+
renders_one :badge, "Badge"
|
26
|
+
|
27
|
+
# Body to be rendered to the left of the Badge.
|
28
|
+
#
|
29
|
+
# @param system_arguments [Hash] <%= link_to_system_arguments_docs %>
|
30
|
+
renders_one :body, lambda { |**system_arguments|
|
31
|
+
deny_tag_argument(**system_arguments)
|
32
|
+
system_arguments[:tag] = :div
|
33
|
+
system_arguments[:classes] = class_names(
|
34
|
+
"TimelineItem-body",
|
35
|
+
system_arguments[:classes]
|
36
|
+
)
|
37
|
+
|
38
|
+
Primer::BaseComponent.new(**system_arguments)
|
39
|
+
}
|
40
|
+
|
41
|
+
# @example Default
|
42
|
+
# <div style="padding-left: 60px">
|
43
|
+
# <%= render(Primer::Beta::TimelineItem.new) do |component| %>
|
44
|
+
# <% component.with_avatar(src: Primer::ExampleImage::BASE64_SRC, alt: "github") %>
|
45
|
+
# <% component.with_badge(bg: :success_emphasis, color: :on_emphasis, icon: :check) %>
|
46
|
+
# <% component.with_body { "Success!" } %>
|
47
|
+
# <% end %>
|
48
|
+
# </div>
|
49
|
+
#
|
50
|
+
# @param condensed [Boolean] Reduce the vertical padding and remove the background from the badge item. Most commonly used in commits.
|
51
|
+
# @param system_arguments [Hash] <%= link_to_system_arguments_docs %>
|
52
|
+
def initialize(condensed: false, **system_arguments)
|
53
|
+
@system_arguments = deny_tag_argument(**system_arguments)
|
54
|
+
@system_arguments[:tag] = :div
|
55
|
+
@system_arguments[:classes] = class_names(
|
56
|
+
"TimelineItem",
|
57
|
+
condensed ? "TimelineItem--condensed" : "",
|
58
|
+
system_arguments[:classes]
|
59
|
+
)
|
60
|
+
end
|
61
|
+
|
62
|
+
def render?
|
63
|
+
avatar? || badge? || body?
|
64
|
+
end
|
65
|
+
|
66
|
+
# This component is part of `Primer::Beta::TimelineItem` and should not be
|
67
|
+
# used as a standalone component.
|
68
|
+
class Badge < Primer::Component
|
69
|
+
status :beta
|
70
|
+
|
71
|
+
def initialize(icon: nil, **system_arguments)
|
72
|
+
@icon = icon
|
73
|
+
|
74
|
+
@system_arguments = deny_tag_argument(**system_arguments)
|
75
|
+
@system_arguments[:tag] = :div
|
76
|
+
@system_arguments[:classes] = class_names(
|
77
|
+
"TimelineItem-badge",
|
78
|
+
system_arguments[:classes]
|
79
|
+
)
|
80
|
+
end
|
81
|
+
|
82
|
+
def call
|
83
|
+
render(Primer::BaseComponent.new(**@system_arguments)) do
|
84
|
+
render(Primer::Beta::Octicon.new(@icon))
|
85
|
+
end
|
86
|
+
end
|
87
|
+
end
|
88
|
+
end
|
89
|
+
end
|
90
|
+
end
|
@@ -1 +1 @@
|
|
1
|
-
.Truncate{display:inline-flex;max-width:100%;min-width:0}.Truncate>.Truncate-text{max-width:-moz-fit-content;max-width:fit-content;min-width:1ch;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
|
1
|
+
.Truncate{display:inline-flex;max-width:100%;min-width:0}.Truncate>.Truncate-text{max-width:-moz-fit-content;max-width:fit-content;min-width:1ch;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.Truncate>.Truncate-text+.Truncate-text{margin-left:var(--primer-control-small-gap,4px)}.Truncate>.Truncate-text.Truncate-text--primary{flex-basis:200%}.Truncate>.Truncate-text.Truncate-text--expandable:active,.Truncate>.Truncate-text.Truncate-text--expandable:focus,.Truncate>.Truncate-text.Truncate-text--expandable:hover{cursor:pointer;flex-shrink:0;max-width:100%!important}
|
@@ -1 +1 @@
|
|
1
|
-
{"name":"beta/truncate","selectors":[".Truncate",".Truncate>.Truncate-text","
|
1
|
+
{"name":"beta/truncate","selectors":[".Truncate",".Truncate>.Truncate-text",".Truncate>.Truncate-text+.Truncate-text",".Truncate>.Truncate-text.Truncate-text--primary",".Truncate>.Truncate-text.Truncate-text--expandable:active",".Truncate>.Truncate-text.Truncate-text--expandable:focus",".Truncate>.Truncate-text.Truncate-text--expandable:hover"]}
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"sources":["truncate.pcss"],"names":[],"mappings":"AAEA,UACE,mBAAoB,CAEpB,cAAe,CADf,WA0BF,CAvBE,yBAEE,0BAAsB,CAAtB,qBAAsB,CADtB,aAAc,CAEd,eAAgB,CAChB,sBAAuB,CACvB,kBAiBF,CAfE,
|
1
|
+
{"version":3,"sources":["truncate.pcss"],"names":[],"mappings":"AAEA,UACE,mBAAoB,CAEpB,cAAe,CADf,WA0BF,CAvBE,yBAEE,0BAAsB,CAAtB,qBAAsB,CADtB,aAAc,CAEd,eAAgB,CAChB,sBAAuB,CACvB,kBAiBF,CAfE,wCACE,+CACF,CAEA,gDACE,eACF,CAEA,4KAKE,cAAe,CADf,aAAc,CADd,wBAGF","file":"truncate.css","sourcesContent":["/* Truncate */\n\n.Truncate {\n display: inline-flex;\n min-width: 0;\n max-width: 100%;\n\n & > .Truncate-text {\n min-width: 1ch;\n max-width: fit-content;\n overflow: hidden;\n text-overflow: ellipsis;\n white-space: nowrap;\n\n & + .Truncate-text {\n margin-left: var(--primer-control-small-gap, 4px);\n }\n\n &.Truncate-text--primary {\n flex-basis: 200%;\n }\n\n &.Truncate-text--expandable:hover,\n &.Truncate-text--expandable:focus,\n &.Truncate-text--expandable:active {\n max-width: 100% !important;\n flex-shrink: 0;\n cursor: pointer;\n }\n }\n}\n"]}
|
@@ -88,21 +88,21 @@ module Primer
|
|
88
88
|
# <%= render(Primer::ButtonComponent.new(block: :true, scheme: :primary)) { "Primary block" } %>
|
89
89
|
#
|
90
90
|
# @example With leading visual
|
91
|
-
# <%= render(Primer::ButtonComponent.new) do |
|
92
|
-
# <%
|
91
|
+
# <%= render(Primer::ButtonComponent.new) do |component| %>
|
92
|
+
# <% component.with_leading_visual_icon(icon: :star) %>
|
93
93
|
# Button
|
94
94
|
# <% end %>
|
95
95
|
#
|
96
96
|
# @example With trailing visual
|
97
|
-
# <%= render(Primer::ButtonComponent.new) do |
|
98
|
-
# <%
|
97
|
+
# <%= render(Primer::ButtonComponent.new) do |component| %>
|
98
|
+
# <% component.with_trailing_visual_counter(count: 15) %>
|
99
99
|
# Button
|
100
100
|
# <% end %>
|
101
101
|
#
|
102
102
|
# @example With leading and trailing visuals
|
103
|
-
# <%= render(Primer::ButtonComponent.new) do |
|
104
|
-
# <%
|
105
|
-
# <%
|
103
|
+
# <%= render(Primer::ButtonComponent.new) do |component| %>
|
104
|
+
# <% component.with_leading_visual_icon(icon: :star) %>
|
105
|
+
# <% component.with_trailing_visual_counter(count: 15) %>
|
106
106
|
# Button
|
107
107
|
# <% end %>
|
108
108
|
#
|
@@ -115,8 +115,8 @@ module Primer
|
|
115
115
|
# @description
|
116
116
|
# Use tooltips sparingly and as a last resort. Consult the <%= link_to_component(Primer::Alpha::Tooltip) %> documentation for more information.
|
117
117
|
# @code
|
118
|
-
# <%= render(Primer::ButtonComponent.new(id: "button-with-tooltip")) do |
|
119
|
-
# <%
|
118
|
+
# <%= render(Primer::ButtonComponent.new(id: "button-with-tooltip")) do |component| %>
|
119
|
+
# <% component.with_tooltip(text: "Tooltip text") %>
|
120
120
|
# Button
|
121
121
|
# <% end %>
|
122
122
|
#
|
@@ -6,7 +6,6 @@ module Primer
|
|
6
6
|
# @private
|
7
7
|
# :nocov:
|
8
8
|
class Component < ViewComponent::Base
|
9
|
-
warn_on_deprecated_slot_setter
|
10
9
|
include ViewComponent::SlotableV2 unless ViewComponent::Base < ViewComponent::SlotableV2
|
11
10
|
include ViewComponent::PolymorphicSlots unless ViewComponent::Base < ViewComponent::PolymorphicSlots
|
12
11
|
include ClassNameHelper
|
@@ -1,39 +1,7 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
module Primer
|
4
|
-
|
5
|
-
|
6
|
-
# Always set an accessible label to help the user interact with the component.
|
7
|
-
#
|
8
|
-
# * This button is displaying a hellip as its content (The three dots character). Therefore a label is needed for screen readers.
|
9
|
-
# * Set the attribute `aria-label` on the system arguments. E.g. `Primer::HellipButton.new("aria-label": "Expand next part")`
|
10
|
-
class HellipButton < Primer::Component
|
11
|
-
# @example Default
|
12
|
-
# <%= render(Primer::HellipButton.new("aria-label": "No effect")) %>
|
13
|
-
#
|
14
|
-
# @example Inline
|
15
|
-
# <%= render(Primer::HellipButton.new(inline: true, "aria-label": "No effect")) %>
|
16
|
-
#
|
17
|
-
# @example Styling the button
|
18
|
-
# <%= render(Primer::HellipButton.new(p: 1, classes: "custom-class", "aria-label": "No effect")) %>
|
19
|
-
#
|
20
|
-
# @param inline [Boolean] Whether or not the button is inline.
|
21
|
-
# @param system_arguments [Hash] <%= link_to_system_arguments_docs %>
|
22
|
-
def initialize(inline: false, **system_arguments)
|
23
|
-
@system_arguments = deny_tag_argument(**system_arguments)
|
24
|
-
|
25
|
-
validate_aria_label
|
26
|
-
|
27
|
-
@system_arguments[:tag] = :button
|
28
|
-
@system_arguments[:"aria-expanded"] = false
|
29
|
-
@system_arguments[:classes] = class_names(
|
30
|
-
@system_arguments[:classes],
|
31
|
-
"inline" => inline
|
32
|
-
)
|
33
|
-
end
|
34
|
-
|
35
|
-
def call
|
36
|
-
render(Primer::Beta::BaseButton.new(**@system_arguments)) { "…".html_safe }
|
37
|
-
end
|
4
|
+
class HellipButton < Primer::Alpha::HellipButton
|
5
|
+
status :deprecated
|
38
6
|
end
|
39
7
|
end
|
@@ -63,31 +63,31 @@ module Primer
|
|
63
63
|
attr_reader :selected
|
64
64
|
|
65
65
|
# @example Default
|
66
|
-
# <%= render(Primer::Navigation::TabComponent.new(selected: true)) do |
|
67
|
-
# <%
|
66
|
+
# <%= render(Primer::Navigation::TabComponent.new(selected: true)) do |component| %>
|
67
|
+
# <% component.with_text { "Selected" } %>
|
68
68
|
# <% end %>
|
69
|
-
# <%= render(Primer::Navigation::TabComponent.new) do |
|
70
|
-
# <%
|
69
|
+
# <%= render(Primer::Navigation::TabComponent.new) do |component| %>
|
70
|
+
# <% component.with_text { "Not selected" } %>
|
71
71
|
# <% end %>
|
72
72
|
#
|
73
73
|
# @example With icons and counters
|
74
|
-
# <%= render(Primer::Navigation::TabComponent.new) do |
|
75
|
-
# <%
|
76
|
-
# <%
|
74
|
+
# <%= render(Primer::Navigation::TabComponent.new) do |component| %>
|
75
|
+
# <% component.with_icon(:star) %>
|
76
|
+
# <% component.with_text { "Tab" } %>
|
77
77
|
# <% end %>
|
78
|
-
# <%= render(Primer::Navigation::TabComponent.new) do |
|
79
|
-
# <%
|
80
|
-
# <%
|
81
|
-
# <%
|
78
|
+
# <%= render(Primer::Navigation::TabComponent.new) do |component| %>
|
79
|
+
# <% component.with_icon(:star) %>
|
80
|
+
# <% component.with_text { "Tab" } %>
|
81
|
+
# <% component.with_counter(count: 10) %>
|
82
82
|
# <% end %>
|
83
|
-
# <%= render(Primer::Navigation::TabComponent.new) do |
|
84
|
-
# <%
|
85
|
-
# <%
|
83
|
+
# <%= render(Primer::Navigation::TabComponent.new) do |component| %>
|
84
|
+
# <% component.with_text { "Tab" } %>
|
85
|
+
# <% component.with_counter(count: 10) %>
|
86
86
|
# <% end %>
|
87
87
|
#
|
88
88
|
# @example Inside a list
|
89
|
-
# <%= render(Primer::Navigation::TabComponent.new(list: true)) do |
|
90
|
-
# <%
|
89
|
+
# <%= render(Primer::Navigation::TabComponent.new(list: true)) do |component| %>
|
90
|
+
# <% component.with_text { "Tab" } %>
|
91
91
|
# <% end %>
|
92
92
|
#
|
93
93
|
# @example With custom HTML
|
@@ -9,7 +9,7 @@ import './alpha/x_banner';
|
|
9
9
|
import './beta/auto_complete/auto_complete';
|
10
10
|
import './beta/clipboard_copy';
|
11
11
|
import './local_time';
|
12
|
-
import './
|
12
|
+
import './alpha/tab_container';
|
13
13
|
import './time_ago_component';
|
14
14
|
import '../../../lib/primer/forms/primer_multi_input';
|
15
15
|
import '../../../lib/primer/forms/primer_text_field';
|
@@ -9,7 +9,7 @@ import './alpha/x_banner';
|
|
9
9
|
import './beta/auto_complete/auto_complete';
|
10
10
|
import './beta/clipboard_copy';
|
11
11
|
import './local_time';
|
12
|
-
import './
|
12
|
+
import './alpha/tab_container';
|
13
13
|
import './time_ago_component';
|
14
14
|
import '../../../lib/primer/forms/primer_multi_input';
|
15
15
|
import '../../../lib/primer/forms/primer_text_field';
|
@@ -28,10 +28,10 @@
|
|
28
28
|
@import "./beta/link.pcss";
|
29
29
|
@import "./beta/popover.pcss";
|
30
30
|
@import "./beta/progress_bar.pcss";
|
31
|
+
@import "./beta/state.pcss";
|
32
|
+
@import "./beta/subhead.pcss";
|
31
33
|
@import "./beta/truncate.pcss";
|
32
34
|
|
33
35
|
/* to be renamed */
|
34
|
-
@import "./
|
35
|
-
@import "./subhead_component.pcss";
|
36
|
-
@import "./timeline_item_component.pcss";
|
36
|
+
@import "./beta/timeline_item.pcss";
|
37
37
|
@import "./truncate.pcss";
|
@@ -9,7 +9,7 @@ import './alpha/x_banner'
|
|
9
9
|
import './beta/auto_complete/auto_complete'
|
10
10
|
import './beta/clipboard_copy'
|
11
11
|
import './local_time'
|
12
|
-
import './
|
12
|
+
import './alpha/tab_container'
|
13
13
|
import './time_ago_component'
|
14
14
|
import '../../../lib/primer/forms/primer_multi_input'
|
15
15
|
import '../../../lib/primer/forms/primer_text_field'
|
@@ -1,74 +1,7 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
module Primer
|
4
|
-
|
5
|
-
|
6
|
-
status :beta
|
7
|
-
|
8
|
-
SCHEME_DEFAULT = :default
|
9
|
-
NEW_SCHEME_MAPPINGS = {
|
10
|
-
open: "State--open",
|
11
|
-
closed: "State--closed",
|
12
|
-
merged: "State--merged"
|
13
|
-
}.freeze
|
14
|
-
|
15
|
-
DEPRECATED_SCHEME_MAPPINGS = {
|
16
|
-
SCHEME_DEFAULT => "",
|
17
|
-
:green => "State--open",
|
18
|
-
:red => "State--closed",
|
19
|
-
:purple => "State--merged"
|
20
|
-
}.freeze
|
21
|
-
SCHEME_MAPPINGS = NEW_SCHEME_MAPPINGS.merge(DEPRECATED_SCHEME_MAPPINGS)
|
22
|
-
SCHEME_OPTIONS = SCHEME_MAPPINGS.keys
|
23
|
-
|
24
|
-
SIZE_DEFAULT = :default
|
25
|
-
SIZE_MAPPINGS = {
|
26
|
-
SIZE_DEFAULT => "",
|
27
|
-
:small => "State--small"
|
28
|
-
}.freeze
|
29
|
-
SIZE_OPTIONS = SIZE_MAPPINGS.keys
|
30
|
-
|
31
|
-
TAG_DEFAULT = :span
|
32
|
-
TAG_OPTIONS = [TAG_DEFAULT, :div].freeze
|
33
|
-
|
34
|
-
# @example Default
|
35
|
-
# <%= render(Primer::StateComponent.new(title: "title")) { "State" } %>
|
36
|
-
#
|
37
|
-
# @example Schemes
|
38
|
-
# <%= render(Primer::StateComponent.new(title: "title")) { "Default" } %>
|
39
|
-
# <%= render(Primer::StateComponent.new(title: "title", scheme: :open)) { "Open" } %>
|
40
|
-
# <%= render(Primer::StateComponent.new(title: "title", scheme: :closed)) { "Closed" } %>
|
41
|
-
# <%= render(Primer::StateComponent.new(title: "title", scheme: :merged)) { "Merged" } %>
|
42
|
-
#
|
43
|
-
# @example Sizes
|
44
|
-
# <%= render(Primer::StateComponent.new(title: "title")) { "Default" } %>
|
45
|
-
# <%= render(Primer::StateComponent.new(title: "title", size: :small)) { "Small" } %>
|
46
|
-
#
|
47
|
-
# @param title [String] `title` HTML attribute.
|
48
|
-
# @param scheme [Symbol] Background color. <%= one_of(Primer::StateComponent::SCHEME_OPTIONS) %>
|
49
|
-
# @param tag [Symbol] HTML tag for element. <%= one_of(Primer::StateComponent::TAG_OPTIONS) %>
|
50
|
-
# @param size [Symbol] <%= one_of(Primer::StateComponent::SIZE_OPTIONS) %>
|
51
|
-
# @param system_arguments [Hash] <%= link_to_system_arguments_docs %>
|
52
|
-
def initialize(
|
53
|
-
title:,
|
54
|
-
scheme: SCHEME_DEFAULT,
|
55
|
-
tag: TAG_DEFAULT,
|
56
|
-
size: SIZE_DEFAULT,
|
57
|
-
**system_arguments
|
58
|
-
)
|
59
|
-
@system_arguments = system_arguments
|
60
|
-
@system_arguments[:title] = title
|
61
|
-
@system_arguments[:tag] = fetch_or_fallback(TAG_OPTIONS, tag, TAG_DEFAULT)
|
62
|
-
@system_arguments[:classes] = class_names(
|
63
|
-
@system_arguments[:classes],
|
64
|
-
"State",
|
65
|
-
SCHEME_MAPPINGS[fetch_or_fallback(SCHEME_OPTIONS, scheme, SCHEME_DEFAULT)],
|
66
|
-
SIZE_MAPPINGS[fetch_or_fallback(SIZE_OPTIONS, size, SIZE_DEFAULT)]
|
67
|
-
)
|
68
|
-
end
|
69
|
-
|
70
|
-
def call
|
71
|
-
render(Primer::BaseComponent.new(**@system_arguments)) { content }
|
72
|
-
end
|
4
|
+
class StateComponent < Primer::Beta::State
|
5
|
+
status :deprecated
|
73
6
|
end
|
74
7
|
end
|