Sha256: 17d474bc661a3e0e7c785592495004cfd48616d275661066f9357e8050b6cce4

Contents?: true

Size: 1.69 KB

Versions: 44

Compression:

Stored size: 1.69 KB

Contents

# frozen_string_literal: true

module Playbook
  module PbTimeRangeInline
    class TimeRangeInline
      include Playbook::Props

      partial "pb_time_range_inline/time_range_inline"

      prop :start_time, required: true
      prop :end_time, required: true
      prop :alignment, type: Playbook::Props::Enum,
                       values: %w[left center right],
                       default: "left"
      prop :size, type: Playbook::Props::Enum,
                  values: %w[sm xs],
                  default: "sm"
      prop :dark, default: false
      prop :icon, default: false
      prop :timezone, default: false

      def classname
        generate_classname("pb_time_range_inline_kit", dark_class, alignment)
      end

      def format_start_time_string
        "#{pb_date_start_time.to_hour}:#{pb_date_start_time.to_minutes}#{pb_date_start_time.to_meridian}"
      end

      def format_start_timezone_string
        pb_date_start_time.to_timezone.to_s
      end

      def format_end_time_string
        "#{pb_date_end_time.to_hour}:#{pb_date_end_time.to_minutes}#{pb_date_end_time.to_meridian}"
      end

      def format_end_timezone_string
        pb_date_end_time.convert_to_timezone.to_timezone.to_s
      end

      def pb_date_start_time
        Playbook::PbKit::PbDateTime.new(start_time)
      end

      def pb_date_end_time
        Playbook::PbKit::PbDateTime.new(end_time)
      end

      def text_timezone_color
        return "light" if size == "sm"

        nil
      end

      def text_kit
        case size
        when "xs"
          "caption"
        when "sm"
          "body"
        end
      end

    private

      def dark_class
        dark ? "dark" : nil
      end
    end
  end
end

Version data entries

44 entries across 44 versions & 1 rubygems

Version Path
playbook_ui-5.2.0.pre.alpha15 app/pb_kits/playbook/pb_time_range_inline/time_range_inline.rb
playbook_ui-5.2.0.pre.alpha14 app/pb_kits/playbook/pb_time_range_inline/time_range_inline.rb
playbook_ui-5.2.0.pre.alpha13 app/pb_kits/playbook/pb_time_range_inline/time_range_inline.rb
playbook_ui-5.2.0.pre.alpha12 app/pb_kits/playbook/pb_time_range_inline/time_range_inline.rb
playbook_ui-5.2.0.pre.alpha11 app/pb_kits/playbook/pb_time_range_inline/time_range_inline.rb
playbook_ui-5.5.1.pre.alpha4 app/pb_kits/playbook/pb_time_range_inline/time_range_inline.rb
playbook_ui-5.2.0.pre.alpha10 app/pb_kits/playbook/pb_time_range_inline/time_range_inline.rb
playbook_ui-5.5.1 app/pb_kits/playbook/pb_time_range_inline/time_range_inline.rb
playbook_ui-5.5.0 app/pb_kits/playbook/pb_time_range_inline/time_range_inline.rb
playbook_ui-5.5.0.pre.alpha1 app/pb_kits/playbook/pb_time_range_inline/time_range_inline.rb
playbook_ui-5.2.0.pre.alpha9 app/pb_kits/playbook/pb_time_range_inline/time_range_inline.rb
playbook_ui-5.2.0.pre.alpha8 app/pb_kits/playbook/pb_time_range_inline/time_range_inline.rb
playbook_ui-5.2.0.pre.alpha7 app/pb_kits/playbook/pb_time_range_inline/time_range_inline.rb
playbook_ui-5.3.0.pre.alpha1 app/pb_kits/playbook/pb_time_range_inline/time_range_inline.rb
playbook_ui-5.4.0 app/pb_kits/playbook/pb_time_range_inline/time_range_inline.rb
playbook_ui-5.2.0.pre.alpha6 app/pb_kits/playbook/pb_time_range_inline/time_range_inline.rb
playbook_ui-5.2.0.pre.alpha5 app/pb_kits/playbook/pb_time_range_inline/time_range_inline.rb
playbook_ui-5.3.0 app/pb_kits/playbook/pb_time_range_inline/time_range_inline.rb
playbook_ui-5.2.0.pre.alpha4 app/pb_kits/playbook/pb_time_range_inline/time_range_inline.rb
playbook_ui-5.2.0.pre.alpha3 app/pb_kits/playbook/pb_time_range_inline/time_range_inline.rb