diff --git a/.changeset/thin-countries-happen.md b/.changeset/thin-countries-happen.md new file mode 100644 index 0000000000..8408813aa7 --- /dev/null +++ b/.changeset/thin-countries-happen.md @@ -0,0 +1,5 @@ +--- +"@primer/view-components": patch +--- + +Updating label component to not always have large diff --git a/app/components/primer/label_component.rb b/app/components/primer/label_component.rb index 75cbe5f824..b79c33d1d5 100644 --- a/app/components/primer/label_component.rb +++ b/app/components/primer/label_component.rb @@ -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) diff --git a/lookbook/Gemfile.lock b/lookbook/Gemfile.lock index d153255735..20536a03c5 100644 --- a/lookbook/Gemfile.lock +++ b/lookbook/Gemfile.lock @@ -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/ diff --git a/test/components/label_component_test.rb b/test/components/label_component_test.rb index 253be7690e..cb2ad70c48 100644 --- a/test/components/label_component_test.rb +++ b/test/components/label_component_test.rb @@ -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)) diff --git a/test/previews/primer/label_component_preview.rb b/test/previews/primer/label_component_preview.rb new file mode 100644 index 0000000000..da898acdc5 --- /dev/null +++ b/test/previews/primer/label_component_preview.rb @@ -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