Sha256: ee3275d402038e2c4ddf135d93be46a74123fbc2637d39484a29332c313f6cb9
Contents?: true
Size: 1.67 KB
Versions: 104
Compression:
Stored size: 1.67 KB
Contents
# frozen_string_literal: true module Playbook module PbWeekdayStacked class WeekdayStacked include ActionView::Helpers::TagHelper include ActionView::Context include Playbook::Props partial "pb_weekday_stacked/weekday_stacked" 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
104 entries across 104 versions & 1 rubygems