Sha256: 8966b3a566f4e564757ce827a4cbed804e7557e516c221923f807fe4c727d4eb

Contents?: true

Size: 1.63 KB

Versions: 1123

Compression:

Stored size: 1.63 KB

Contents

# frozen_string_literal: true

module Playbook
  module PbDateStacked
    class DateStacked < Playbook::KitBase
      prop :date, type: Playbook::Props::Date, required: true
      prop :align, type: Playbook::Props::Enum,
                   values: %w[left center right],
                   default: "left"
      prop :size, type: Playbook::Props::Enum,
                  values: %w[sm md],
                  default: "sm"
      prop :reverse, type: Playbook::Props::Boolean,
                     default: false
      prop :dark, type: Playbook::Props::Boolean,
                  default: false
      prop :bold, type: Playbook::Props::Boolean,
                  default: false

      def classname
        generate_classname("pb_date_stacked_kit", align, size, bold, reverse_class, dark_class)
      end

      def title_size
        size == "md" ? 3 : 4
      end

      def day
        day = Playbook::PbKit::PbDateTime.new(date)
        content_tag(:time, datetime: day.to_iso) do
          day.to_day.to_s
        end
      end

      def month
        pb_date_time.to_month.capitalize
      end

      def year
        current_year = DateTime.now.year.to_i
        year = Playbook::PbKit::PbDateTime.new(date).to_year.to_i
        if current_year != year
          content_tag(:time, datetime: year) do
            year.to_s
          end
        end
      end

      def bold_class
        bold ? "bold" : nil
      end

    private

      def pb_date_time
        Playbook::PbKit::PbDateTime.new(date)
      end

      def reverse_class
        reverse ? "reverse" : nil
      end

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

Version data entries

1,123 entries across 1,123 versions & 1 rubygems

Version Path
playbook_ui-14.10.0.pre.alpha.play1662cssbargraph5201 app/pb_kits/playbook/pb_date_stacked/date_stacked.rb
playbook_ui-14.11.0.pre.rc.9 app/pb_kits/playbook/pb_date_stacked/date_stacked.rb
playbook_ui-14.10.0.pre.alpha.play1662cssbargraph5200 app/pb_kits/playbook/pb_date_stacked/date_stacked.rb
playbook_ui-14.11.0.pre.rc.8 app/pb_kits/playbook/pb_date_stacked/date_stacked.rb
playbook_ui-14.11.0.pre.rc.7 app/pb_kits/playbook/pb_date_stacked/date_stacked.rb
playbook_ui-14.11.0.pre.rc.6 app/pb_kits/playbook/pb_date_stacked/date_stacked.rb
playbook_ui-14.11.0.pre.rc.5 app/pb_kits/playbook/pb_date_stacked/date_stacked.rb
playbook_ui-14.10.0.pre.alpha.play1662cssbargraph5193 app/pb_kits/playbook/pb_date_stacked/date_stacked.rb
playbook_ui-14.11.0.pre.rc.4 app/pb_kits/playbook/pb_date_stacked/date_stacked.rb
playbook_ui-14.11.0.pre.rc.3 app/pb_kits/playbook/pb_date_stacked/date_stacked.rb
playbook_ui-14.10.0.pre.alpha.PBNTR662stickyrightcolumnreact5160 app/pb_kits/playbook/pb_date_stacked/date_stacked.rb
playbook_ui-14.11.0.pre.rc.2 app/pb_kits/playbook/pb_date_stacked/date_stacked.rb
playbook_ui-14.11.0.pre.rc.1 app/pb_kits/playbook/pb_date_stacked/date_stacked.rb
playbook_ui-14.10.0.pre.alpha.PBNTR775formmatingmaskdefaultvalue5137 app/pb_kits/playbook/pb_date_stacked/date_stacked.rb
playbook_ui-14.11.0.pre.rc.0 app/pb_kits/playbook/pb_date_stacked/date_stacked.rb
playbook_ui-14.9.0.pre.alpha.PBNTR767advancedtablemultiheadercolumns5136 app/pb_kits/playbook/pb_date_stacked/date_stacked.rb
playbook_ui-14.9.0.pre.alpha.PBNTR775formmatingmaskdefaultvalue5121 app/pb_kits/playbook/pb_date_stacked/date_stacked.rb
playbook_ui-14.9.0.pre.alpha.PBNTR775formmatingmaskdefaultvalue5120 app/pb_kits/playbook/pb_date_stacked/date_stacked.rb
playbook_ui-14.10.0 app/pb_kits/playbook/pb_date_stacked/date_stacked.rb
playbook_ui-14.10.0.pre.rc.24 app/pb_kits/playbook/pb_date_stacked/date_stacked.rb