Skip to content

Commit

Permalink
Updating label component to not always have large (#1283)
Browse files Browse the repository at this point in the history
* Updating label component to not always have large

* Create thin-countries-happen.md

* Update label_component_test.rb
  • Loading branch information
jonrohan authored Aug 8, 2022
1 parent 2e190f0 commit ea1c29d
Show file tree
Hide file tree
Showing 5 changed files with 30 additions and 3 deletions.
5 changes: 5 additions & 0 deletions .changeset/thin-countries-happen.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@primer/view-components": patch
---

Updating label component to not always have large
3 changes: 2 additions & 1 deletion app/components/primer/label_component.rb
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,8 @@ def initialize(tag: DEFAULT_TAG, scheme: DEFAULT_SCHEME, size: DEFAULT_SIZE, inl

@variant = fetch_or_fallback(VARIANT_OPTIONS, variant, nil, deprecated_values: DEPRECATED_VARIANT_OPTIONS)
@scheme = fetch_or_fallback(SCHEME_OPTIONS, scheme, DEFAULT_SCHEME, deprecated_values: DEPRECATED_SCHEME_OPTIONS)
@size = fetch_or_fallback(SIZE_OPTIONS, size) || @variant == :large ? :large : nil || DEFAULT_SIZE
@size = fetch_or_fallback(SIZE_OPTIONS, size, DEFAULT_SIZE)
@size = :large if @variant == :large
@inline = inline || @variant == :inline

@system_arguments[:tag] = fetch_or_fallback(TAG_OPTIONS, tag, DEFAULT_TAG)
Expand Down
4 changes: 2 additions & 2 deletions lookbook/Gemfile.lock
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
PATH
remote: ..
specs:
primer_view_components (0.0.86)
primer_view_components (0.0.88)
actionview (>= 5.0.0)
activesupport (>= 5.0.0)
octicons (>= 17.0.0)
view_component (>= 2.0.0, < 3.0)
view_component (>= 2.57.0, < 3.0)

GEM
remote: https://rubygems.org/
Expand Down
6 changes: 6 additions & 0 deletions test/components/label_component_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,12 @@ def test_renders_content
assert_text("private")
end

def test_renders_only_label_class_by_default
render_inline(Primer::LabelComponent.new) { "label" }

assert_selector("[class='Label']")
end

def test_falls_back_when_tag_isnt_valid
without_fetch_or_fallback_raises do
render_inline(Primer::LabelComponent.new(tag: :h1))
Expand Down
15 changes: 15 additions & 0 deletions test/previews/primer/label_component_preview.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# frozen_string_literal: true

module Primer
# @label LabelComponent
class LabelComponentPreview < ViewComponent::Preview
# @label Default Options
#
# @param size [Symbol] select [medium, large]
# @param tag [Symbol] select [span, summary, a, div]
# @param inline [Boolean] toggle
def default(size: :medium, tag: :span, inline: false)
render(Primer::LabelComponent.new(tag: tag, size: size, inline: inline)) { "Label" }
end
end
end

0 comments on commit ea1c29d

Please sign in to comment.