Sha256: 49bfe0b35778737141736d5248d153d214d617152ac9b8b247475d21885f5355

Contents?: true

Size: 878 Bytes

Versions: 2

Compression:

Stored size: 878 Bytes

Contents

module Coco
  module App
    class PlanCard < Coco::Component
      include Concerns::AcceptsOptions

      accepts_option :active, from: [true, false]
      accepts_option :recommended, from: [true, false]

      renders_one :action, ->(*args, **kwargs, &block) do
        coco_button(*args, **kwargs,
          size: :sm,
          fit: :full,
          disabled: active?,
          &block)
      end

      renders_many :benefits, ->(benefit, &block) do
        @benefits[benefit] = block&.call
      end

      attr_reader :name, :price, :promo

      def initialize(name:, price:, promo: nil, **kwargs)
        @name = name
        @price = price
        @promo = promo
        @benefits = {}
      end

      def recommended?
        get_option_value(:recommended) == true
      end

      def active?
        get_option_value(:active) == true
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
coveragebook_components-0.13.1 app/components/coco/app/plan_card/plan_card.rb
coveragebook_components-0.13.0 app/components/coco/app/plan_card/plan_card.rb