Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bug fixes: Button and TextField #1965

Merged
merged 6 commits into from
Apr 25, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/plenty-emus-sip.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@primer/view-components": patch
---

Adjust background color for Button with Counter, fix small and large TextField visual alignment bugs
4 changes: 2 additions & 2 deletions app/components/primer/alpha/text_field.pcss
Original file line number Diff line number Diff line change
Expand Up @@ -352,7 +352,7 @@

/* size modifications can be refactored with :has() - FormControl-input-wrap:has(.FormControl-large)
// sizes */
&.FormControl-small {
&.FormControl-input-wrap--small {
& .FormControl-input-leadingVisualWrap {
top: calc(var(--control-medium-paddingInline-condensed, 8px) - 0.125rem); /* 6px */
left: calc(var(--control-medium-paddingInline-condensed, 8px) - 0.125rem); /* 6px */
Expand Down Expand Up @@ -402,7 +402,7 @@
}
}

&.FormControl-large {
&.FormControl-input-wrap--large {
& .FormControl-input-leadingVisualWrap {
top: var(--control-medium-paddingInline-normal, 12px);
left: var(--control-medium-paddingInline-normal, 12px);
Expand Down
9 changes: 9 additions & 0 deletions app/components/primer/beta/button.pcss
Original file line number Diff line number Diff line change
Expand Up @@ -201,6 +201,11 @@ summary.Button {
border-color: var(--color-btn-primary-disabled-border);
fill: var(--color-btn-primary-disabled-text);
}

& .Counter {
color: inherit;
background-color: var(--color-btn-primary-counter-bg);
}
}

/* default (secondary) */
Expand Down Expand Up @@ -262,6 +267,10 @@ summary.Button {

& .Button-visual {
color: var(--color-fg-muted);

& .Counter {
color: var(--color-fg-default);
}
}
}

Expand Down
6 changes: 6 additions & 0 deletions lib/primer/forms/text_field.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,11 @@ module Forms
class TextField < BaseComponent
delegate :builder, :form, to: :@input

INPUT_WRAP_SIZE = {
small: "FormControl-input-wrap--small",
large: "FormControl-input-wrap--large"
}.freeze

def initialize(input:)
@input = input

Expand All @@ -17,6 +22,7 @@ def initialize(input:)
@field_wrap_arguments = {
class: class_names(
"FormControl-input-wrap",
INPUT_WRAP_SIZE[input.size],
"FormControl-input-wrap--trailingAction": @input.show_clear_button?,
"FormControl-input-wrap--leadingVisual": @input.leading_visual?
),
Expand Down
15 changes: 15 additions & 0 deletions previews/primer/beta/button_preview.rb
Original file line number Diff line number Diff line change
Expand Up @@ -266,6 +266,21 @@ def trailing_action(
})
end

# @label Trailing Counter
# @param block toggle
# @param align_content select [center, start]
def trailing_counter(
block: false,
id: "button-preview",
align_content: :center
)
render_with_template(locals: {
block: block,
id: id,
align_content: align_content
})
end

# @label With tooltip
# @param scheme select [default, primary, danger, invisible, link]
# @param size select [small, medium]
Expand Down
11 changes: 11 additions & 0 deletions previews/primer/beta/button_preview/trailing_counter.html.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<%= render(Primer::Beta::Button.new(
scheme: :primary,
size: :medium,
block: block,
id: id,
align_content: align_content
)) do |component| %>
<% component.with_leading_visual_icon(icon: :star) %>
<% component.with_trailing_visual_counter(count: 15) %>
Button
<% end %>
8 changes: 4 additions & 4 deletions static/classes.json
Original file line number Diff line number Diff line change
Expand Up @@ -372,10 +372,10 @@
"ActionListWrap--inset": [
"Primer::Alpha::ActionList"
],
"ActionListItem-action": [
"ActionListItem-visual": [
"Primer::Alpha::ActionList"
],
"ActionListItem-visual": [
"ActionListItem-action": [
"Primer::Alpha::ActionList"
],
"SegmentedControl-item": [
Expand Down Expand Up @@ -510,10 +510,10 @@
"FormControl-inlineValidation": [
"Primer::Alpha::TextField"
],
"FormControl-check-group-wrap": [
"FormControl-radio-group-wrap": [
"Primer::Alpha::TextField"
],
"FormControl-radio-group-wrap": [
"FormControl-check-group-wrap": [
"Primer::Alpha::TextField"
],
"Popover-message--bottom-left": [
Expand Down