Skip to content

Commit

Permalink
Bump @github/relative-time-element from 4.0.0 to 4.1.5 (#1736)
Browse files Browse the repository at this point in the history
Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: Keith Cirkel <keithamus@users.noreply.github.com>
  • Loading branch information
dependabot[bot] and keithamus committed Jan 9, 2023
1 parent 733dc78 commit 927a52c
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 6 deletions.
5 changes: 5 additions & 0 deletions .changeset/flat-frogs-lie.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@primer/view-components': minor
---

Add format_style to RelativeTime component
6 changes: 6 additions & 0 deletions app/components/primer/beta/relative_time.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,9 @@ class RelativeTime < Primer::Component
FORMAT_DEFAULT = :auto
FORMAT_OPTIONS = [FORMAT_DEFAULT, :micro, :elapsed].freeze

FORMAT_STYLE_DEFAULT = nil
FORMAT_STYLE_OPTIONS = [FORMAT_STYLE_DEFAULT, :long, :short, :narrow].freeze

SECOND_DEFAULT = nil
SECOND_MAPPINGS = {
SECOND_DEFAULT => nil,
Expand Down Expand Up @@ -104,6 +107,7 @@ class RelativeTime < Primer::Component
# @param threshold [string] The threshold, in ISO-8601 'durations' format, at which relative time displays become absolute.
# @param precision [Symbol] The precision elapsed time should display. <%= one_of(Primer::Beta::RelativeTime::PRECISION_OPTIONS) %>
# @param format [Symbol] The format the display should take. <%= one_of(Primer::Beta::RelativeTime::FORMAT_OPTIONS) %>
# @param format_style [Symbol] The format the display should take. <%= one_of(Primer::Beta::RelativeTime::FORMAT_STYLE_OPTIONS) %>
# @param lang [string] The language to use.
# @param title [string] Provide a custom title to the element.
# @param system_arguments [Hash] <%= link_to_system_arguments_docs %>
Expand All @@ -122,6 +126,7 @@ def initialize(
threshold: nil,
precision: PRECISION_DEFAULT,
format: nil,
format_style: nil,
lang: nil,
title: nil,
**system_arguments
Expand All @@ -143,6 +148,7 @@ def initialize(
@system_arguments[:title] = title if title.present?
@system_arguments[:lang] = lang if lang.present?
@system_arguments[:format] = fetch_or_fallback(FORMAT_OPTIONS, format, FORMAT_DEFAULT) if format.present?
@system_arguments[:"format-style"] = format_style if format_style.present?
if datetime.present? && datetime.respond_to?(:iso8601)
@datetime = datetime
@system_arguments[:datetime] = datetime.iso8601
Expand Down
12 changes: 6 additions & 6 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

15 changes: 15 additions & 0 deletions previews/primer/beta/relative_time_preview.rb
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ class RelativeTimePreview < ViewComponent::Preview
# @param time_zone_name [Symbol] select [~, long, short, short_offset, long_offset, short_generic, long_generic]
# @param precision [Symbol] select [~, second, minute, hour, day, month, year]
# @param format [Symbol] select [~, auto, micro, elapsed]
# @param format_style [Symbol] select [~, long, short, narrow]
# @param lang [String] text
# @param title [String] text
def playground(
Expand All @@ -37,6 +38,7 @@ def playground(
threshold: nil,
precision: nil,
format: nil,
format_style: nil,
datetime: Time.utc(2020, 1, 1, 0, 0, 0),
lang: nil,
title: nil
Expand All @@ -55,6 +57,7 @@ def playground(
threshold: threshold,
precision: precision,
format: format,
format_style: format_style,
datetime: datetime,
lang: lang,
title: title
Expand All @@ -75,6 +78,7 @@ def playground(
# @param time_zone_name [Symbol] select [~, long, short, short_offset, long_offset, short_generic, long_generic]
# @param precision [Symbol] select [~, second, minute, hour, day, month, year]
# @param format [Symbol] select [~, auto, micro, elapsed]
# @param format_style [Symbol] select [~, long, short, narrow]
# @param lang [String] text
# @param title [String] text
def default(
Expand All @@ -91,6 +95,7 @@ def default(
threshold: nil,
precision: nil,
format: nil,
format_style: nil,
datetime: Time.now.utc,
lang: nil,
title: nil
Expand All @@ -109,6 +114,7 @@ def default(
threshold: threshold,
precision: precision,
format: format,
format_style: format_style,
datetime: datetime,
lang: lang,
title: title
Expand All @@ -128,6 +134,7 @@ def default(
# @param year [Symbol] select [~, numeric, two_digit]
# @param time_zone_name [Symbol] select [~, long, short, short_offset, long_offset, short_generic, long_generic]
# @param precision [Symbol] select [~, second, minute, hour, day, month, year]
# @param format_style [Symbol] select [~, long, short, narrow]
# @param lang [String] text
# @param title [String] text
def micro_format(
Expand All @@ -143,6 +150,7 @@ def micro_format(
time_zone_name: nil,
threshold: nil,
precision: nil,
format_style: nil,
datetime: Time.now.iso8601,
lang: nil,
title: nil
Expand All @@ -161,6 +169,7 @@ def micro_format(
threshold: threshold,
precision: precision,
format: :micro,
format_style: format_style,
datetime: datetime,
lang: lang,
title: title
Expand All @@ -181,6 +190,7 @@ def micro_format(
# @param time_zone_name [Symbol] select [~, long, short, short_offset, long_offset, short_generic, long_generic]
# @param precision [Symbol] select [~, second, minute, hour, day, month, year]
# @param format [Symbol] select [~, auto, micro, elapsed]
# @param format_style [Symbol] select [~, long, short, narrow]
# @param lang [String] text
# @param title [String] text
def recent_time(
Expand All @@ -197,6 +207,7 @@ def recent_time(
threshold: nil,
precision: nil,
format: nil,
format_style: nil,
datetime: Time.now.iso8601,
lang: nil,
title: nil
Expand All @@ -215,6 +226,7 @@ def recent_time(
threshold: threshold,
precision: precision,
format: format,
format_style: format_style,
datetime: datetime,
lang: lang,
title: title
Expand All @@ -232,6 +244,7 @@ def recent_time(
# @param year [Symbol] select [~, numeric, two_digit]
# @param time_zone_name [Symbol] select [~, long, short, short_offset, long_offset, short_generic, long_generic]
# @param precision [Symbol] select [~, second, minute, hour, day, month, year]
# @param format_style [Symbol] select [~, long, short, narrow]
# @param lang [String] text
# @param title [String] text
def count_down_timer(
Expand All @@ -245,6 +258,7 @@ def count_down_timer(
time_zone_name: nil,
threshold: nil,
precision: nil,
format_style: nil,
datetime: Time.utc(2038, 1, 19, 0o3, 14, 8),
lang: nil,
title: nil
Expand All @@ -261,6 +275,7 @@ def count_down_timer(
threshold: threshold,
precision: precision,
format: :elapsed,
format_style: format_style,
datetime: datetime,
lang: lang,
title: title
Expand Down

0 comments on commit 927a52c

Please sign in to comment.