Update wording

"label" is more suitable here than "caption"
This commit is contained in:
Eugene Chaikin 2025-06-11 12:55:00 +02:00
parent 1d980ac956
commit c64ed78a53
16 changed files with 29 additions and 29 deletions

View File

@ -5,7 +5,7 @@
<%= render component("ui/forms/field").text_field(f, :name, class: "required") %> <%= render component("ui/forms/field").text_field(f, :name, class: "required") %>
<%= render component("ui/forms/field").text_field(f, :code, class: "required") %> <%= render component("ui/forms/field").text_field(f, :code, class: "required") %>
<%= render component("ui/forms/checkbox").new(object_name: f.object_name, method: :active, checked: f.object.active) do |checkbox| %> <%= render component("ui/forms/checkbox").new(object_name: f.object_name, method: :active, checked: f.object.active) do |checkbox| %>
<%= checkbox.with_caption(text: Spree::AdjustmentReason.human_attribute_name(:active), weight: :semibold, size: :xs, classes: 'ml-2') %> <%= checkbox.with_label(text: Spree::AdjustmentReason.human_attribute_name(:active), weight: :semibold, size: :xs, classes: 'ml-2') %>
<%= checkbox.with_hint(text: t(".hints.active")) %> <%= checkbox.with_hint(text: t(".hints.active")) %>
<% end %> <% end %>
</div> </div>

View File

@ -5,7 +5,7 @@
<%= render component("ui/forms/field").text_field(f, :name, class: "required") %> <%= render component("ui/forms/field").text_field(f, :name, class: "required") %>
<%= render component("ui/forms/field").text_field(f, :code, class: "required") %> <%= render component("ui/forms/field").text_field(f, :code, class: "required") %>
<%= render component("ui/forms/checkbox").new(object_name: f.object_name, method: :active, checked: f.object.active) do |checkbox| %> <%= render component("ui/forms/checkbox").new(object_name: f.object_name, method: :active, checked: f.object.active) do |checkbox| %>
<%= checkbox.with_caption(text: Spree::AdjustmentReason.human_attribute_name(:active), weight: :semibold, size: :xs, classes: 'ml-2') %> <%= checkbox.with_label(text: Spree::AdjustmentReason.human_attribute_name(:active), weight: :semibold, size: :xs, classes: 'ml-2') %>
<%= checkbox.with_hint(text: t(".hints.active")) %> <%= checkbox.with_hint(text: t(".hints.active")) %>
<% end %> <% end %>
</div> </div>

View File

@ -37,7 +37,7 @@
method: use_attribute, method: use_attribute,
checked: @address == (@type == 'ship' ? @order.bill_address : @order.ship_address) checked: @address == (@type == 'ship' ? @order.bill_address : @order.ship_address)
) do |checkbox| %> ) do |checkbox| %>
<%= checkbox.with_caption(text: t(".use_this_address.#{@type}"), size: :xs) %> <%= checkbox.with_label(text: t(".use_this_address.#{@type}"), size: :xs) %>
<% end %> <% end %>
</div> </div>
<% end %> <% end %>

View File

@ -118,7 +118,7 @@
value: f.object.discontinue_on&.to_date value: f.object.discontinue_on&.to_date
) %> ) %>
<%= render component("ui/forms/checkbox").new(object_name: f.object_name, method: :promotionable, checked: f.object.promotionable) do |checkbox| %> <%= render component("ui/forms/checkbox").new(object_name: f.object_name, method: :promotionable, checked: f.object.promotionable) do |checkbox| %>
<%= checkbox.with_caption(text: Spree::Product.human_attribute_name(:promotionable), size: :xs) %> <%= checkbox.with_label(text: Spree::Product.human_attribute_name(:promotionable), size: :xs) %>
<%= checkbox.with_hint(text: t(".hints.promotionable_html")) %> <%= checkbox.with_hint(text: t(".hints.promotionable_html")) %>
<% end %> <% end %>
<% end %> <% end %>

View File

@ -5,7 +5,7 @@
<%= render component("ui/forms/field").text_field(f, :name, class: "required") %> <%= render component("ui/forms/field").text_field(f, :name, class: "required") %>
<%= render component("ui/forms/field").text_field(f, :code, class: "required") %> <%= render component("ui/forms/field").text_field(f, :code, class: "required") %>
<%= render component("ui/forms/checkbox").new(object_name: f.object_name, method: :active, checked: f.object.active) do |checkbox| %> <%= render component("ui/forms/checkbox").new(object_name: f.object_name, method: :active, checked: f.object.active) do |checkbox| %>
<%= checkbox.with_caption(text: Spree::RefundReason.human_attribute_name(:active), weight: :semibold, size: :xs, classes: 'ml-2') %> <%= checkbox.with_label(text: Spree::RefundReason.human_attribute_name(:active), weight: :semibold, size: :xs, classes: 'ml-2') %>
<%= checkbox.with_hint(text: t(".hints.active")) %> <%= checkbox.with_hint(text: t(".hints.active")) %>
<% end %> <% end %>
</div> </div>

View File

@ -5,7 +5,7 @@
<%= render component("ui/forms/field").text_field(f, :name, class: "required") %> <%= render component("ui/forms/field").text_field(f, :name, class: "required") %>
<%= render component("ui/forms/field").text_field(f, :code, class: "required") %> <%= render component("ui/forms/field").text_field(f, :code, class: "required") %>
<%= render component("ui/forms/checkbox").new(object_name: f.object_name, method: :active, checked: f.object.active) do |checkbox| %> <%= render component("ui/forms/checkbox").new(object_name: f.object_name, method: :active, checked: f.object.active) do |checkbox| %>
<%= checkbox.with_caption(text: Spree::RefundReason.human_attribute_name(:active), weight: :semibold, size: :xs, classes: 'ml-2') %> <%= checkbox.with_label(text: Spree::RefundReason.human_attribute_name(:active), weight: :semibold, size: :xs, classes: 'ml-2') %>
<%= checkbox.with_hint(text: t(".hints.active")) %> <%= checkbox.with_hint(text: t(".hints.active")) %>
<% end %> <% end %>
</div> </div>

View File

@ -4,7 +4,7 @@
<div class="flex flex-col gap-6 pb-4"> <div class="flex flex-col gap-6 pb-4">
<%= render component("ui/forms/field").text_field(f, :name, class: "required") %> <%= render component("ui/forms/field").text_field(f, :name, class: "required") %>
<%= render component("ui/forms/checkbox").new(object_name: f.object_name, method: :active, checked: f.object.active) do |checkbox| %> <%= render component("ui/forms/checkbox").new(object_name: f.object_name, method: :active, checked: f.object.active) do |checkbox| %>
<%= checkbox.with_caption(text: Spree::ReturnReason.human_attribute_name(:active), weight: :semibold, size: :xs, classes: 'ml-2') %> <%= checkbox.with_label(text: Spree::ReturnReason.human_attribute_name(:active), weight: :semibold, size: :xs, classes: 'ml-2') %>
<%= checkbox.with_hint(text: t(".hints.active")) %> <%= checkbox.with_hint(text: t(".hints.active")) %>
<% end %> <% end %>
</div> </div>

View File

@ -4,7 +4,7 @@
<div class="flex flex-col gap-6 pb-4"> <div class="flex flex-col gap-6 pb-4">
<%= render component("ui/forms/field").text_field(f, :name, class: "required") %> <%= render component("ui/forms/field").text_field(f, :name, class: "required") %>
<%= render component("ui/forms/checkbox").new(object_name: f.object_name, method: :active, checked: f.object.active) do |checkbox| %> <%= render component("ui/forms/checkbox").new(object_name: f.object_name, method: :active, checked: f.object.active) do |checkbox| %>
<%= checkbox.with_caption(text: Spree::ReturnReason.human_attribute_name(:active), weight: :semibold, size: :xs, classes: 'ml-2') %> <%= checkbox.with_label(text: Spree::ReturnReason.human_attribute_name(:active), weight: :semibold, size: :xs, classes: 'ml-2') %>
<%= checkbox.with_hint(text: t(".hints.active")) %> <%= checkbox.with_hint(text: t(".hints.active")) %>
<% end %> <% end %>
</div> </div>

View File

@ -4,7 +4,7 @@
<div class="flex flex-col gap-6 pb-4"> <div class="flex flex-col gap-6 pb-4">
<%= render component("ui/forms/field").text_field(f, :name, class: "required") %> <%= render component("ui/forms/field").text_field(f, :name, class: "required") %>
<%= render component("ui/forms/checkbox").new(object_name: f.object_name, method: :active, checked: f.object.active) do |checkbox| %> <%= render component("ui/forms/checkbox").new(object_name: f.object_name, method: :active, checked: f.object.active) do |checkbox| %>
<%= checkbox.with_caption(text: Spree::StoreCreditReason.human_attribute_name(:active), weight: :semibold, size: :xs, classes: 'ml-2') %> <%= checkbox.with_label(text: Spree::StoreCreditReason.human_attribute_name(:active), weight: :semibold, size: :xs, classes: 'ml-2') %>
<%= checkbox.with_hint(text: t(".hints.active")) %> <%= checkbox.with_hint(text: t(".hints.active")) %>
<% end %> <% end %>
</div> </div>

View File

@ -4,7 +4,7 @@
<div class="flex flex-col gap-6 pb-4"> <div class="flex flex-col gap-6 pb-4">
<%= render component("ui/forms/field").text_field(f, :name, class: "required") %> <%= render component("ui/forms/field").text_field(f, :name, class: "required") %>
<%= render component("ui/forms/checkbox").new(object_name: f.object_name, method: :active, checked: f.object.active) do |checkbox| %> <%= render component("ui/forms/checkbox").new(object_name: f.object_name, method: :active, checked: f.object.active) do |checkbox| %>
<%= checkbox.with_caption(text: Spree::StoreCreditReason.human_attribute_name(:active), weight: :semibold, size: :xs, classes: 'ml-2') %> <%= checkbox.with_label(text: Spree::StoreCreditReason.human_attribute_name(:active), weight: :semibold, size: :xs, classes: 'ml-2') %>
<%= checkbox.with_hint(text: t(".hints.active")) %> <%= checkbox.with_hint(text: t(".hints.active")) %>
<% end %> <% end %>
</div> </div>

View File

@ -6,7 +6,7 @@
<%= render component("ui/forms/field").text_field(f, :tax_code) %> <%= render component("ui/forms/field").text_field(f, :tax_code) %>
<%= render component("ui/forms/field").text_field(f, :description) %> <%= render component("ui/forms/field").text_field(f, :description) %>
<%= render component("ui/forms/checkbox").new(object_name: f.object_name, method: :is_default, checked: f.object.is_default) do |checkbox| %> <%= render component("ui/forms/checkbox").new(object_name: f.object_name, method: :is_default, checked: f.object.is_default) do |checkbox| %>
<%= checkbox.with_caption(text: Spree::TaxCategory.human_attribute_name(:is_default), weight: :semibold, size: :xs, classes: 'ml-2') %> <%= checkbox.with_label(text: Spree::TaxCategory.human_attribute_name(:is_default), weight: :semibold, size: :xs, classes: 'ml-2') %>
<%= checkbox.with_hint(text: t(".hints.is_default")) %> <%= checkbox.with_hint(text: t(".hints.is_default")) %>
<% end %> <% end %>
</div> </div>

View File

@ -6,7 +6,7 @@
<%= render component("ui/forms/field").text_field(f, :tax_code) %> <%= render component("ui/forms/field").text_field(f, :tax_code) %>
<%= render component("ui/forms/field").text_field(f, :description) %> <%= render component("ui/forms/field").text_field(f, :description) %>
<%= render component("ui/forms/checkbox").new(object_name: f.object_name, method: :is_default, checked: f.object.is_default) do |checkbox| %> <%= render component("ui/forms/checkbox").new(object_name: f.object_name, method: :is_default, checked: f.object.is_default) do |checkbox| %>
<%= checkbox.with_caption(text: Spree::TaxCategory.human_attribute_name(:is_default), weight: :semibold, size: :xs, classes: 'ml-2') %> <%= checkbox.with_label(text: Spree::TaxCategory.human_attribute_name(:is_default), weight: :semibold, size: :xs, classes: 'ml-2') %>
<%= checkbox.with_hint(text: t(".hints.is_default")) %> <%= checkbox.with_hint(text: t(".hints.is_default")) %>
<% end %> <% end %>
</div> </div>

View File

@ -7,7 +7,7 @@
checked: @checked, checked: @checked,
**@attributes **@attributes
) %> ) %>
<%= caption %> <%= label %>
</label> </label>
<%= hint if hint? %> <%= hint if hint? %>

View File

@ -11,7 +11,7 @@ class SolidusAdmin::UI::Forms::Checkbox::Component < SolidusAdmin::BaseComponent
s: 'text-sm', s: 'text-sm',
}.freeze }.freeze
renders_one :caption, ->(text:, weight: :normal, size: :s, **options) do renders_one :label, ->(text:, weight: :normal, size: :s, **options) do
tag.span( tag.span(
text, text,
class: " class: "

View File

@ -7,7 +7,7 @@ class SolidusAdmin::UI::Forms::Checkbox::ComponentPreview < ViewComponent::Previ
# Forms checkbox component utilises regular checkbox component and encapsulates some functionality # Forms checkbox component utilises regular checkbox component and encapsulates some functionality
# that is shared between admin forms checkboxes: # that is shared between admin forms checkboxes:
# - adds `hidden_field_tag` to function properly # - adds `hidden_field_tag` to function properly
# - provides a way to customise label caption (font size/weight, custom styles) # - provides a way to customise label (font size/weight, custom styles)
# - optionally include a toggletip hint # - optionally include a toggletip hint
# #
# Requires `object_name` and `method` parameters that will form a name of the hidden input and checkbox input fields. # Requires `object_name` and `method` parameters that will form a name of the hidden input and checkbox input fields.
@ -18,7 +18,7 @@ class SolidusAdmin::UI::Forms::Checkbox::ComponentPreview < ViewComponent::Previ
# #
# ```erb # ```erb
# <%= render component('ui/forms/checkbox').new(object_name: 'stock_location', method: :default, checked: true) do |checkbox| %> # <%= render component('ui/forms/checkbox').new(object_name: 'stock_location', method: :default, checked: true) do |checkbox| %>
# <%= checkbox.with_caption(text: "Default") %> # <%= checkbox.with_label(text: "Default") %>
# <%= checkbox.with_hint(text: "Will be used by default") %> # <%= checkbox.with_hint(text: "Will be used by default") %>
# <% end %> # <% end %>
# ``` # ```
@ -35,7 +35,7 @@ class SolidusAdmin::UI::Forms::Checkbox::ComponentPreview < ViewComponent::Previ
# @param hint_position select { choices: [above, below] } # @param hint_position select { choices: [above, below] }
def playground(caption_size: :s, caption_weight: :normal, caption_classes: '', hint: true, hint_text: "This will be helpful", hint_position: :above) def playground(caption_size: :s, caption_weight: :normal, caption_classes: '', hint: true, hint_text: "This will be helpful", hint_position: :above)
render current_component.new(object_name: "store", method: :active, checked: true) do |component| render current_component.new(object_name: "store", method: :active, checked: true) do |component|
component.with_caption(text: "Active", size: caption_size, weight: caption_weight, classes: caption_classes) component.with_label(text: "Active", size: caption_size, weight: caption_weight, classes: caption_classes)
component.with_hint(text: hint_text, position: hint_position) if hint component.with_hint(text: hint_text, position: hint_position) if hint
end end
end end

View File

@ -2,53 +2,53 @@
<div class="flex flex-col"> <div class="flex flex-col">
<div class="mb-8"> <div class="mb-8">
<h6 class="text-gray-500 mb-3 mt-0"> <h6 class="text-gray-500 mb-3 mt-0">
Regular caption Regular label
</h6> </h6>
<%= render current_component.new(object_name: 'store', method: :active, checked: true) do |checkbox| %> <%= render current_component.new(object_name: 'store', method: :active, checked: true) do |checkbox| %>
<%= checkbox.with_caption(text: 'Active') %> <%= checkbox.with_label(text: 'Active') %>
<% end %> <% end %>
</div> </div>
<div class="mb-8"> <div class="mb-8">
<h6 class="text-gray-500 mb-3 mt-0"> <h6 class="text-gray-500 mb-3 mt-0">
Smaller caption Smaller label
</h6> </h6>
<%= render current_component.new(object_name: 'store', method: :active, checked: true) do |checkbox| %> <%= render current_component.new(object_name: 'store', method: :active, checked: true) do |checkbox| %>
<%= checkbox.with_caption(text: 'Active', size: :xs) %> <%= checkbox.with_label(text: 'Active', size: :xs) %>
<% end %> <% end %>
</div> </div>
<div class="mb-8"> <div class="mb-8">
<h6 class="text-gray-500 mb-3 mt-0"> <h6 class="text-gray-500 mb-3 mt-0">
Semibold caption Semibold label
</h6> </h6>
<%= render current_component.new(object_name: 'store', method: :active, checked: true) do |checkbox| %> <%= render current_component.new(object_name: 'store', method: :active, checked: true) do |checkbox| %>
<%= checkbox.with_caption(text: 'Active', weight: :semibold) %> <%= checkbox.with_label(text: 'Active', weight: :semibold) %>
<% end %> <% end %>
</div> </div>
</div> </div>
<div class="flex flex-col"> <div class="flex flex-col">
<div class="mb-8"> <div class="mb-8">
<h6 class="text-gray-500 mb-3 mt-0"> <h6 class="text-gray-500 mb-3 mt-0">
Caption with custom styles applied Label with custom styles applied
</h6> </h6>
<%= render current_component.new(object_name: 'store', method: :active, checked: true) do |checkbox| %> <%= render current_component.new(object_name: 'store', method: :active, checked: true) do |checkbox| %>
<%= checkbox.with_caption(text: 'Active', classes: 'text-gray-500') %> <%= checkbox.with_label(text: 'Active', classes: 'text-gray-500') %>
<% end %> <% end %>
</div> </div>
<div class="mb-8"> <div class="mb-8">
<h6 class="text-gray-500 mb-3 mt-0"> <h6 class="text-gray-500 mb-3 mt-0">
With caption and hint above With label and hint above
</h6> </h6>
<%= render current_component.new(object_name: 'store', method: :active, checked: true) do |checkbox| %> <%= render current_component.new(object_name: 'store', method: :active, checked: true) do |checkbox| %>
<%= checkbox.with_caption(text: 'Active') %> <%= checkbox.with_label(text: 'Active') %>
<%= checkbox.with_hint(text: 'This means something') %> <%= checkbox.with_hint(text: 'This means something') %>
<% end %> <% end %>
</div> </div>
<div class="mb-8"> <div class="mb-8">
<h6 class="text-gray-500 mb-3 mt-0"> <h6 class="text-gray-500 mb-3 mt-0">
With caption and hint below With label and hint below
</h6> </h6>
<%= render current_component.new(object_name: 'store', method: :active, checked: true) do |checkbox| %> <%= render current_component.new(object_name: 'store', method: :active, checked: true) do |checkbox| %>
<%= checkbox.with_caption(text: 'Active') %> <%= checkbox.with_label(text: 'Active') %>
<%= checkbox.with_hint(text: 'This means something', position: :below) %> <%= checkbox.with_hint(text: 'This means something', position: :below) %>
<% end %> <% end %>
</div> </div>