Sha256: cfbe6d8e9a2ee80fd18f8de59cdcd6f823b41e484c7e963dbc25370293374680

Contents?: true

Size: 1.52 KB

Versions: 1193

Compression:

Stored size: 1.52 KB

Contents

# frozen_string_literal: true

module Playbook
  module PbWeekdayStacked
    class WeekdayStacked < Playbook::KitBase
      prop :align, type: Playbook::Props::Enum,
                   values: %w[left center right],
                   default: "left"

      prop :date, type: Playbook::Props::Date,
                  default: ::Date.current

      prop :compact, type: Playbook::Props::Boolean,
                     default: false

      prop :variant, type: Playbook::Props::Enum,
                     values: %w[day_only expanded month_day],
                     default: "month_day"

      def classname
        generate_classname("pb_weekday_stacked_kit", align)
      end

      def day_of_week
        day = Playbook::PbKit::PbDateTime.new(date)
        formatted_day = compact ? day.to_day_of_week_compact : day.to_day_of_week
        content_tag(:time, datetime: day.to_iso) do
          formatted_day
        end
      end

      def formatted_month_and_day
        case variant
        when "day_only" then day
        when "expanded" then month_and_day(format: "%b %-d")
        else month_and_day
        end
      end

    private

      def month_and_day(format: "%-m/%-d")
        month_and_day = Playbook::PbKit::PbDateTime.new(date)
        content_tag(:time, datetime: month_and_day.to_iso) do
          date.strftime(format)
        end
      end

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

Version data entries

1,193 entries across 1,193 versions & 1 rubygems

Version Path
playbook_ui-14.10.0.pre.rc.23 app/pb_kits/playbook/pb_weekday_stacked/weekday_stacked.rb
playbook_ui-14.10.0.pre.rc.22 app/pb_kits/playbook/pb_weekday_stacked/weekday_stacked.rb
playbook_ui-14.10.0.pre.rc.21 app/pb_kits/playbook/pb_weekday_stacked/weekday_stacked.rb
playbook_ui-14.9.0.pre.alpha.play1703errorstatealignment5060 app/pb_kits/playbook/pb_weekday_stacked/weekday_stacked.rb
playbook_ui-14.10.0.pre.rc.20 app/pb_kits/playbook/pb_weekday_stacked/weekday_stacked.rb
playbook_ui-14.10.0.pre.rc.19 app/pb_kits/playbook/pb_weekday_stacked/weekday_stacked.rb
playbook_ui-14.10.0.pre.rc.18 app/pb_kits/playbook/pb_weekday_stacked/weekday_stacked.rb
playbook_ui-14.9.0.pre.alpha.PLAY1660reactdropzone5020 app/pb_kits/playbook/pb_weekday_stacked/weekday_stacked.rb
playbook_ui-14.10.0.pre.rc.17 app/pb_kits/playbook/pb_weekday_stacked/weekday_stacked.rb
playbook_ui-14.10.0.pre.rc.16 app/pb_kits/playbook/pb_weekday_stacked/weekday_stacked.rb
playbook_ui-14.9.0.pre.alpha.play17004992 app/pb_kits/playbook/pb_weekday_stacked/weekday_stacked.rb
playbook_ui-14.9.0.pre.alpha.play1703errorstatealignment4991 app/pb_kits/playbook/pb_weekday_stacked/weekday_stacked.rb
playbook_ui-14.10.0.pre.rc.15 app/pb_kits/playbook/pb_weekday_stacked/weekday_stacked.rb
playbook_ui-14.9.0.pre.alpha.PLAY16264952 app/pb_kits/playbook/pb_weekday_stacked/weekday_stacked.rb
playbook_ui-14.9.0.pre.alpha.PLAY1731inputmasking4927 app/pb_kits/playbook/pb_weekday_stacked/weekday_stacked.rb
playbook_ui-14.9.0.pre.alpha.play1742globalheightfixes4926 app/pb_kits/playbook/pb_weekday_stacked/weekday_stacked.rb
playbook_ui-14.9.0.pre.alpha.play1742globalheightfixes4925 app/pb_kits/playbook/pb_weekday_stacked/weekday_stacked.rb
playbook_ui-14.10.0.pre.rc.14 app/pb_kits/playbook/pb_weekday_stacked/weekday_stacked.rb
playbook_ui-14.10.0.pre.rc.13 app/pb_kits/playbook/pb_weekday_stacked/weekday_stacked.rb
playbook_ui-14.9.0.pre.alpha.PBNTR746datepickerdefaultbug4903 app/pb_kits/playbook/pb_weekday_stacked/weekday_stacked.rb