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.11.1.pre.alpha.PLAY17445539 app/pb_kits/playbook/pb_weekday_stacked/weekday_stacked.rb
playbook_ui-14.11.1.pre.alpha.PBNTR798datepickerturbo5537 app/pb_kits/playbook/pb_weekday_stacked/weekday_stacked.rb
playbook_ui-14.11.1.pre.alpha.pbntr703collapsiblerowsrails5536 app/pb_kits/playbook/pb_weekday_stacked/weekday_stacked.rb
playbook_ui-14.11.1.pre.alpha.PLAY1751pbcontenttagpt25529 app/pb_kits/playbook/pb_weekday_stacked/weekday_stacked.rb
playbook_ui-14.11.1.pre.alpha.PBNTR7495495 app/pb_kits/playbook/pb_weekday_stacked/weekday_stacked.rb
playbook_ui-14.12.0.pre.rc.11 app/pb_kits/playbook/pb_weekday_stacked/weekday_stacked.rb
playbook_ui-14.12.0.pre.rc.10 app/pb_kits/playbook/pb_weekday_stacked/weekday_stacked.rb
playbook_ui-14.12.0.pre.rc.9 app/pb_kits/playbook/pb_weekday_stacked/weekday_stacked.rb
playbook_ui-14.12.0.pre.rc.8 app/pb_kits/playbook/pb_weekday_stacked/weekday_stacked.rb
playbook_ui-14.12.0.pre.rc.7 app/pb_kits/playbook/pb_weekday_stacked/weekday_stacked.rb
playbook_ui-14.11.1.pre.alpha.play1724darkmodeauditmap5437 app/pb_kits/playbook/pb_weekday_stacked/weekday_stacked.rb
playbook_ui-14.11.1.pre.alpha.PBNTR719listdraggablesimple5432 app/pb_kits/playbook/pb_weekday_stacked/weekday_stacked.rb
playbook_ui-14.11.1.pre.alpha.PBNTR768stickyrightcolumn5431 app/pb_kits/playbook/pb_weekday_stacked/weekday_stacked.rb
playbook_ui-14.12.0.pre.rc.6 app/pb_kits/playbook/pb_weekday_stacked/weekday_stacked.rb
playbook_ui-14.11.1.pre.alpha.PBNTR718simiplifieddraggablereact5415 app/pb_kits/playbook/pb_weekday_stacked/weekday_stacked.rb
playbook_ui-14.11.1.pre.alpha.play1724darkmodeauditmap5413 app/pb_kits/playbook/pb_weekday_stacked/weekday_stacked.rb
playbook_ui-14.12.0.pre.rc.5 app/pb_kits/playbook/pb_weekday_stacked/weekday_stacked.rb
playbook_ui-14.11.1.pre.alpha.play1724darkmodeauditmap5409 app/pb_kits/playbook/pb_weekday_stacked/weekday_stacked.rb
playbook_ui-14.11.1.pre.alpha.PBNTR718simiplifieddraggablereact5400 app/pb_kits/playbook/pb_weekday_stacked/weekday_stacked.rb
playbook_ui-14.11.1.pre.alpha.PBNTR718simiplifieddraggablereact5392 app/pb_kits/playbook/pb_weekday_stacked/weekday_stacked.rb