From 055d61f1d0cebfd612fd3493c53b547f3f4058a8 Mon Sep 17 00:00:00 2001 From: Cameron Dutro Date: Mon, 16 Aug 2021 15:35:18 -0700 Subject: [PATCH 1/4] Deprecate Base#with_variant --- lib/view_component/base.rb | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/lib/view_component/base.rb b/lib/view_component/base.rb index 9c784e2b9..13df5182a 100644 --- a/lib/view_component/base.rb +++ b/lib/view_component/base.rb @@ -218,9 +218,15 @@ def format # Use the provided variant instead of the one determined by the current request. # + # @deprecated Define separate per-variant templates instead. Will be removed in v3.0.0. # @param variant [Symbol] The variant to be used by the component. # @return [self] def with_variant(variant) + ActiveSupport::Deprecation.warn( + "`with_variant` is deprecated and will be removed in ViewComponent v3.0.0.\n\n" \ + "Define separate per-variant templates instead." + ) + @__vc_variant = variant self From 32c4ffa6155c3c22fc032049fe1a93608128389a Mon Sep 17 00:00:00 2001 From: Cameron Dutro Date: Mon, 16 Aug 2021 15:45:57 -0700 Subject: [PATCH 2/4] Add entry to changelog --- docs/CHANGELOG.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/docs/CHANGELOG.md b/docs/CHANGELOG.md index f59e365e2..0b9582af2 100644 --- a/docs/CHANGELOG.md +++ b/docs/CHANGELOG.md @@ -11,6 +11,10 @@ title: Changelog *Blake Williams*, *Cameron Dutro*, *Joel Hawksley* +* Deprecate `Base#with_variant`. + + *Cameron Dutro* + ## 2.38.0 * Add `--stimulus` flag to the component generator. Generates a Stimulus controller alongside the component. From 97677b434c3b91af322889db9c66577521c62129 Mon Sep 17 00:00:00 2001 From: Cameron Dutro Date: Tue, 17 Aug 2021 11:39:34 -0700 Subject: [PATCH 3/4] Remove guidance --- lib/view_component/base.rb | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/lib/view_component/base.rb b/lib/view_component/base.rb index 13df5182a..e95254a32 100644 --- a/lib/view_component/base.rb +++ b/lib/view_component/base.rb @@ -223,8 +223,7 @@ def format # @return [self] def with_variant(variant) ActiveSupport::Deprecation.warn( - "`with_variant` is deprecated and will be removed in ViewComponent v3.0.0.\n\n" \ - "Define separate per-variant templates instead." + "`with_variant` is deprecated and will be removed in ViewComponent v3.0.0." ) @__vc_variant = variant From aef0e0b9fbf3ec21fb5a9876453046ace9f31308 Mon Sep 17 00:00:00 2001 From: Joel Hawksley Date: Tue, 17 Aug 2021 15:44:06 -0600 Subject: [PATCH 4/4] Update lib/view_component/base.rb --- lib/view_component/base.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/view_component/base.rb b/lib/view_component/base.rb index e95254a32..213216694 100644 --- a/lib/view_component/base.rb +++ b/lib/view_component/base.rb @@ -218,7 +218,7 @@ def format # Use the provided variant instead of the one determined by the current request. # - # @deprecated Define separate per-variant templates instead. Will be removed in v3.0.0. + # @deprecated Will be removed in v3.0.0. # @param variant [Symbol] The variant to be used by the component. # @return [self] def with_variant(variant)