Sha256: 98e7446e09b6679f6fd25cc5e13520f61d08e5e5e7b60211a2046fe84e85c780

Contents?: true

Size: 1.01 KB

Versions: 40

Compression:

Stored size: 1.01 KB

Contents

# frozen_string_literal: true

module Satis
  module ProgressBar
    class Component < Satis::ApplicationComponent
      attr_reader :percentage

      def initialize(percentage, size: :default, label: false)
        super
        @percentage = percentage
        @size = size
        @label = label
      end

      def label
        return if size == :small || size == :default
        if @label.is_a? FalseClass
          ''
        elsif @label.is_a? TrueClass
          "#{percentage}%"
        else
          @label
        end
      end

      def padding
        if @size == :large
          "p-0.5"
        elsif @size == :xlarge
          "p-1"
        end
      end

      def text_size
        if @size == :large
          "text-xs"
        elsif @size == :xlarge
          "text-sm"
        end
      end


      def size
        case @size
        when :small
          "h-1.5"
        when :large
          "h-4"
        when :xlarge
          "h-6"
        else
          "h-2"
        end
      end
    end
  end
end

Version data entries

40 entries across 40 versions & 1 rubygems

Version Path
satis-2.1.47 app/components/satis/progress_bar/component.rb
satis-2.1.46 app/components/satis/progress_bar/component.rb
satis-2.1.45 app/components/satis/progress_bar/component.rb
satis-2.1.44 app/components/satis/progress_bar/component.rb
satis-2.1.43 app/components/satis/progress_bar/component.rb
satis-2.1.42 app/components/satis/progress_bar/component.rb
satis-2.1.41 app/components/satis/progress_bar/component.rb
satis-2.1.40 app/components/satis/progress_bar/component.rb
satis-2.1.39 app/components/satis/progress_bar/component.rb
satis-2.1.38 app/components/satis/progress_bar/component.rb
satis-2.1.37 app/components/satis/progress_bar/component.rb
satis-2.1.36 app/components/satis/progress_bar/component.rb
satis-2.1.35 app/components/satis/progress_bar/component.rb
satis-2.1.33 app/components/satis/progress_bar/component.rb
satis-2.1.31 app/components/satis/progress_bar/component.rb
satis-2.1.30 app/components/satis/progress_bar/component.rb
satis-2.1.29 app/components/satis/progress_bar/component.rb
satis-2.1.28 app/components/satis/progress_bar/component.rb
satis-2.1.27 app/components/satis/progress_bar/component.rb
satis-2.1.26 app/components/satis/progress_bar/component.rb