Sha256: a8a16af122a694d133c1aa8573c40c21bc6199f12ff6b10d951738c1ab799d98

Contents?: true

Size: 1.71 KB

Versions: 1194

Compression:

Stored size: 1.71 KB

Contents

# frozen_string_literal: true

module Playbook
  module PbTimeRangeInline
    class TimeRangeInline < Playbook::KitBase
      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 icon_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

1,194 entries across 1,194 versions & 1 rubygems

Version Path
playbook_ui-14.11.1.pre.alpha.PLAY17445539 app/pb_kits/playbook/pb_time_range_inline/time_range_inline.rb
playbook_ui-14.11.1.pre.alpha.PBNTR798datepickerturbo5537 app/pb_kits/playbook/pb_time_range_inline/time_range_inline.rb
playbook_ui-14.11.1.pre.alpha.pbntr703collapsiblerowsrails5536 app/pb_kits/playbook/pb_time_range_inline/time_range_inline.rb
playbook_ui-14.11.1.pre.alpha.PLAY1751pbcontenttagpt25529 app/pb_kits/playbook/pb_time_range_inline/time_range_inline.rb
playbook_ui-14.11.1.pre.alpha.PBNTR7495495 app/pb_kits/playbook/pb_time_range_inline/time_range_inline.rb
playbook_ui-14.12.0.pre.rc.11 app/pb_kits/playbook/pb_time_range_inline/time_range_inline.rb
playbook_ui-14.12.0.pre.rc.10 app/pb_kits/playbook/pb_time_range_inline/time_range_inline.rb
playbook_ui-14.12.0.pre.rc.9 app/pb_kits/playbook/pb_time_range_inline/time_range_inline.rb
playbook_ui-14.12.0.pre.rc.8 app/pb_kits/playbook/pb_time_range_inline/time_range_inline.rb
playbook_ui-14.12.0.pre.rc.7 app/pb_kits/playbook/pb_time_range_inline/time_range_inline.rb
playbook_ui-14.11.1.pre.alpha.play1724darkmodeauditmap5437 app/pb_kits/playbook/pb_time_range_inline/time_range_inline.rb
playbook_ui-14.11.1.pre.alpha.PBNTR719listdraggablesimple5432 app/pb_kits/playbook/pb_time_range_inline/time_range_inline.rb
playbook_ui-14.11.1.pre.alpha.PBNTR768stickyrightcolumn5431 app/pb_kits/playbook/pb_time_range_inline/time_range_inline.rb
playbook_ui-14.12.0.pre.rc.6 app/pb_kits/playbook/pb_time_range_inline/time_range_inline.rb
playbook_ui-14.11.1.pre.alpha.PBNTR718simiplifieddraggablereact5415 app/pb_kits/playbook/pb_time_range_inline/time_range_inline.rb
playbook_ui-14.11.1.pre.alpha.play1724darkmodeauditmap5413 app/pb_kits/playbook/pb_time_range_inline/time_range_inline.rb
playbook_ui-14.12.0.pre.rc.5 app/pb_kits/playbook/pb_time_range_inline/time_range_inline.rb
playbook_ui-14.11.1.pre.alpha.play1724darkmodeauditmap5409 app/pb_kits/playbook/pb_time_range_inline/time_range_inline.rb
playbook_ui-14.11.1.pre.alpha.PBNTR718simiplifieddraggablereact5400 app/pb_kits/playbook/pb_time_range_inline/time_range_inline.rb
playbook_ui-14.11.1.pre.alpha.PBNTR718simiplifieddraggablereact5392 app/pb_kits/playbook/pb_time_range_inline/time_range_inline.rb