Class: Www::SaleBadgeComponent

Inherits:
ApplicationComponent show all
Defined in:
app/components/www/sale_badge_component.rb

Overview

ViewComponent: renders the sale badge block.

Displays a Bootstrap badge with the discount percentage, sized
according to the size option (:small, :normal, or :large).

Instance Method Summary collapse

Methods inherited from ApplicationComponent

#cms_link, #fetch_or_fallback, #image_asset_tag, #image_tag, #number_to_currency, #number_with_delimiter, #post_path, #post_url, #strip_tags

Constructor Details

#initialize(percentage:, size: :normal) ⇒ Www::SaleBadgeComponent

Returns a new instance of the component.

Parameters:

  • percentage (Integer)

    the discount percentage to display

  • size (Symbol) (defaults to: :normal)

    badge size variant (:small, :normal, or :large)



11
12
13
14
# File 'app/components/www/sale_badge_component.rb', line 11

def initialize(percentage:, size: :normal)
  @percentage = percentage
  @size = size
end