diff --git a/.changeset/sharp-plants-flow.md b/.changeset/sharp-plants-flow.md new file mode 100644 index 0000000000..585a4efdc2 --- /dev/null +++ b/.changeset/sharp-plants-flow.md @@ -0,0 +1,5 @@ +--- +'@primer/view-components': patch +--- + +Move Primer::LocalTime to Primer::Alpha::LocalTime, and deprecate the original diff --git a/.playwright/screenshots/previews.test.ts-snapshots/primer/alpha/local_time_preview/default.png b/.playwright/screenshots/previews.test.ts-snapshots/primer/alpha/local_time_preview/default.png new file mode 100644 index 0000000000..2ac89a1d32 Binary files /dev/null and b/.playwright/screenshots/previews.test.ts-snapshots/primer/alpha/local_time_preview/default.png differ diff --git a/.playwright/screenshots/previews.test.ts-snapshots/primer/alpha/local_time_preview/focused.png b/.playwright/screenshots/previews.test.ts-snapshots/primer/alpha/local_time_preview/focused.png new file mode 100644 index 0000000000..2ac89a1d32 Binary files /dev/null and b/.playwright/screenshots/previews.test.ts-snapshots/primer/alpha/local_time_preview/focused.png differ diff --git a/app/components/primer/alpha/local_time.rb b/app/components/primer/alpha/local_time.rb new file mode 100644 index 0000000000..0a5df23d9e --- /dev/null +++ b/app/components/primer/alpha/local_time.rb @@ -0,0 +1,63 @@ +# frozen_string_literal: true + +module Primer + module Alpha + # Use `LocalTime` to format a date and time in the user's preferred locale format. This component requires JavaScript. + class LocalTime < Primer::Component + DEFAULT_DIGIT_TYPE = :numeric + DIGIT_TYPE_OPTIONS = [DEFAULT_DIGIT_TYPE, :"2-digit"].freeze + + DEFAULT_TEXT_TYPE = :short + TEXT_TYPE_OPTIONS = [DEFAULT_TEXT_TYPE, :long].freeze + + # @example Default + # <%= render(Primer::Alpha::LocalTime.new(datetime: DateTime.parse("2014-06-01T13:05:07Z"))) %> + # + # @example All the options + # <%= render(Primer::Alpha::LocalTime.new(datetime: DateTime.parse("2014-06-01T13:05:07Z"), weekday: :long, year: :"2-digit", month: :long, day: :"2-digit", hour: :"2-digit", minute: :"2-digit", second: :"2-digit", time_zone_name: :long)) %> + # + # @example With initial content + # <%= render(Primer::Alpha::LocalTime.new(datetime: DateTime.parse("2014-06-01T13:05:07Z"))) do %> + # + # 2014/06/01 13:05 + # <% end %> + # + # @param datetime [DateTime] The date to parse + # @param initial_text [String] Text to render before component is initialized + # @param weekday [Symbol] <%= one_of(Primer::Alpha::LocalTime::TEXT_TYPE_OPTIONS) %> + # @param year [Symbol] <%= one_of(Primer::Alpha::LocalTime::DIGIT_TYPE_OPTIONS) %> + # @param month [Symbol] <%= one_of(Primer::Alpha::LocalTime::TEXT_TYPE_OPTIONS) %> + # @param day [Symbol] <%= one_of(Primer::Alpha::LocalTime::DIGIT_TYPE_OPTIONS) %> + # @param hour [Symbol] <%= one_of(Primer::Alpha::LocalTime::DIGIT_TYPE_OPTIONS) %> + # @param minute [Symbol] <%= one_of(Primer::Alpha::LocalTime::DIGIT_TYPE_OPTIONS) %> + # @param second [Symbol] <%= one_of(Primer::Alpha::LocalTime::DIGIT_TYPE_OPTIONS) %> + # @param time_zone_name [Symbol] <%= one_of(Primer::Alpha::LocalTime::TEXT_TYPE_OPTIONS) %> + # @param system_arguments [Hash] <%= link_to_system_arguments_docs %> + def initialize(datetime:, initial_text: nil, weekday: DEFAULT_TEXT_TYPE, year: DEFAULT_DIGIT_TYPE, month: DEFAULT_TEXT_TYPE, day: DEFAULT_DIGIT_TYPE, hour: DEFAULT_DIGIT_TYPE, minute: DEFAULT_DIGIT_TYPE, second: DEFAULT_DIGIT_TYPE, time_zone_name: DEFAULT_TEXT_TYPE, **system_arguments) + @system_arguments = deny_tag_argument(**system_arguments) + + @datetime = datetime + + @system_arguments[:tag] = "relative-time" + @system_arguments[:threshold] = "PT0S" + @system_arguments[:prefix] = "" + @system_arguments[:datetime] = datetime + + @initial_text = initial_text + + @system_arguments[:weekday] = fetch_or_fallback(TEXT_TYPE_OPTIONS, weekday, DEFAULT_TEXT_TYPE) + @system_arguments[:year] = fetch_or_fallback(DIGIT_TYPE_OPTIONS, year, DEFAULT_DIGIT_TYPE) + @system_arguments[:month] = fetch_or_fallback(TEXT_TYPE_OPTIONS, month, DEFAULT_TEXT_TYPE) + @system_arguments[:day] = fetch_or_fallback(DIGIT_TYPE_OPTIONS, day, DEFAULT_DIGIT_TYPE) + @system_arguments[:hour] = fetch_or_fallback(DIGIT_TYPE_OPTIONS, hour, DEFAULT_DIGIT_TYPE) + @system_arguments[:minute] = fetch_or_fallback(DIGIT_TYPE_OPTIONS, minute, DEFAULT_DIGIT_TYPE) + @system_arguments[:second] = fetch_or_fallback(DIGIT_TYPE_OPTIONS, second, DEFAULT_DIGIT_TYPE) + @system_arguments[:"time-zone-name"] = fetch_or_fallback(TEXT_TYPE_OPTIONS, time_zone_name, DEFAULT_TEXT_TYPE) + end + + def call + render(Primer::BaseComponent.new(**@system_arguments).with_content(@initial_text || @datetime.strftime("%B %-d, %Y %H:%M %Z"))) + end + end + end +end diff --git a/app/components/primer/local_time.ts b/app/components/primer/alpha/local_time.ts similarity index 100% rename from app/components/primer/local_time.ts rename to app/components/primer/alpha/local_time.ts diff --git a/app/components/primer/local_time.rb b/app/components/primer/local_time.rb index cb6c83d630..9322334587 100644 --- a/app/components/primer/local_time.rb +++ b/app/components/primer/local_time.rb @@ -1,61 +1,7 @@ # frozen_string_literal: true module Primer - # Use `LocalTime` to format a date and time in the user's preferred locale format. This component requires JavaScript. - class LocalTime < Primer::Component - DEFAULT_DIGIT_TYPE = :numeric - DIGIT_TYPE_OPTIONS = [DEFAULT_DIGIT_TYPE, :"2-digit"].freeze - - DEFAULT_TEXT_TYPE = :short - TEXT_TYPE_OPTIONS = [DEFAULT_TEXT_TYPE, :long].freeze - - # @example Default - # <%= render(Primer::LocalTime.new(datetime: DateTime.parse("2014-06-01T13:05:07Z"))) %> - # - # @example All the options - # <%= render(Primer::LocalTime.new(datetime: DateTime.parse("2014-06-01T13:05:07Z"), weekday: :long, year: :"2-digit", month: :long, day: :"2-digit", hour: :"2-digit", minute: :"2-digit", second: :"2-digit", time_zone_name: :long)) %> - # - # @example With initial content - # <%= render(Primer::LocalTime.new(datetime: DateTime.parse("2014-06-01T13:05:07Z"))) do %> - # - # 2014/06/01 13:05 - # <% end %> - # - # @param datetime [DateTime] The date to parse - # @param initial_text [String] Text to render before component is initialized - # @param weekday [Symbol] <%= one_of(Primer::LocalTime::TEXT_TYPE_OPTIONS) %> - # @param year [Symbol] <%= one_of(Primer::LocalTime::DIGIT_TYPE_OPTIONS) %> - # @param month [Symbol] <%= one_of(Primer::LocalTime::TEXT_TYPE_OPTIONS) %> - # @param day [Symbol] <%= one_of(Primer::LocalTime::DIGIT_TYPE_OPTIONS) %> - # @param hour [Symbol] <%= one_of(Primer::LocalTime::DIGIT_TYPE_OPTIONS) %> - # @param minute [Symbol] <%= one_of(Primer::LocalTime::DIGIT_TYPE_OPTIONS) %> - # @param second [Symbol] <%= one_of(Primer::LocalTime::DIGIT_TYPE_OPTIONS) %> - # @param time_zone_name [Symbol] <%= one_of(Primer::LocalTime::TEXT_TYPE_OPTIONS) %> - # @param system_arguments [Hash] <%= link_to_system_arguments_docs %> - def initialize(datetime:, initial_text: nil, weekday: DEFAULT_TEXT_TYPE, year: DEFAULT_DIGIT_TYPE, month: DEFAULT_TEXT_TYPE, day: DEFAULT_DIGIT_TYPE, hour: DEFAULT_DIGIT_TYPE, minute: DEFAULT_DIGIT_TYPE, second: DEFAULT_DIGIT_TYPE, time_zone_name: DEFAULT_TEXT_TYPE, **system_arguments) - @system_arguments = deny_tag_argument(**system_arguments) - - @datetime = datetime - - @system_arguments[:tag] = "relative-time" - @system_arguments[:threshold] = "PT0S" - @system_arguments[:prefix] = "" - @system_arguments[:datetime] = datetime - - @initial_text = initial_text - - @system_arguments[:weekday] = fetch_or_fallback(TEXT_TYPE_OPTIONS, weekday, DEFAULT_TEXT_TYPE) - @system_arguments[:year] = fetch_or_fallback(DIGIT_TYPE_OPTIONS, year, DEFAULT_DIGIT_TYPE) - @system_arguments[:month] = fetch_or_fallback(TEXT_TYPE_OPTIONS, month, DEFAULT_TEXT_TYPE) - @system_arguments[:day] = fetch_or_fallback(DIGIT_TYPE_OPTIONS, day, DEFAULT_DIGIT_TYPE) - @system_arguments[:hour] = fetch_or_fallback(DIGIT_TYPE_OPTIONS, hour, DEFAULT_DIGIT_TYPE) - @system_arguments[:minute] = fetch_or_fallback(DIGIT_TYPE_OPTIONS, minute, DEFAULT_DIGIT_TYPE) - @system_arguments[:second] = fetch_or_fallback(DIGIT_TYPE_OPTIONS, second, DEFAULT_DIGIT_TYPE) - @system_arguments[:"time-zone-name"] = fetch_or_fallback(TEXT_TYPE_OPTIONS, time_zone_name, DEFAULT_TEXT_TYPE) - end - - def call - render(Primer::BaseComponent.new(**@system_arguments).with_content(@initial_text || @datetime.strftime("%B %-d, %Y %H:%M %Z"))) - end + class LocalTime < Primer::Alpha::LocalTime + status :deprecated end end diff --git a/app/components/primer/primer.ts b/app/components/primer/primer.ts index 6c1e503222..ecf756e149 100644 --- a/app/components/primer/primer.ts +++ b/app/components/primer/primer.ts @@ -8,6 +8,6 @@ import './alpha/tool_tip' import './alpha/x_banner' import './beta/auto_complete/auto_complete' import './beta/clipboard_copy' -import './local_time' +import './alpha/local_time' import './tab_container_component' import './time_ago_component' diff --git a/component_status_migrator.thor b/component_status_migrator.thor index 6d853be71f..850632a3f0 100644 --- a/component_status_migrator.thor +++ b/component_status_migrator.thor @@ -38,6 +38,14 @@ class ComponentStatusMigrator < Thor::Group move_file("template", template_path, template_path_with_status) end + def move_reamining_files + Dir["app/components/primer/#{name.underscore}.*"].each do |file_path| + file_name = File.basename(file_path) + new_path = "#{status_full_path}#{file_name}" + move_file("misc", file_path, new_path) + end + end + def move_test move_file("test", test_path, test_path_with_status) end @@ -69,7 +77,11 @@ class ComponentStatusMigrator < Thor::Group end def remove_suffix_from_preview_class - if name == name_without_suffix + if preview_path.include?("_component") && !name.include?("Component") # rubocop:disable Rails/NegateInclude + # if the class name does not include 'Component', but the file name does include '_component', + # this line will correct it by removing the incosistency with the word 'Component' + gsub_file(preview_path_with_status, "class #{name}Component", "class #{name_without_suffix}") + elsif name == name_without_suffix puts "No change needed - component suffix not removed from lookbook preview class name" else gsub_file(preview_path_with_status, "class #{name}", "class #{name_without_suffix}") @@ -90,6 +102,13 @@ class ComponentStatusMigrator < Thor::Group gsub_file(nav_file, "url: \"/components/#{name_without_suffix.downcase}\"", "url: \"/components/#{status_url}#{name_without_suffix.downcase}\"") end + def update_primer_js_imports + primer_js = "app/components/primer/primer.ts" + original_content = "import './#{name.underscore}'" + updated_content = "import './#{status_folder_name}#{name_without_suffix.underscore}'" + gsub_file(primer_js, original_content, updated_content) + end + def update_all_references exclude_files = [ ".overmind.sock", @@ -202,7 +221,11 @@ class ComponentStatusMigrator < Thor::Group end def preview_path - @preview_path ||= "previews/primer/#{name.underscore}_preview.rb" + @preview_path ||= begin + path = "previews/primer/#{name.underscore}_preview.rb" + path_with_component = "previews/primer/#{name.underscore}_component_preview.rb" + File.exist?(path_with_component) ? path_with_component : path + end end def preview_path_with_status @@ -221,6 +244,10 @@ class ComponentStatusMigrator < Thor::Group @status_module ||= "#{class_status}::" unless stable? end + def status_full_path + @status_full_path ||= "app/components/primer/#{status_folder_name}" + end + def template_path @template_path ||= "app/components/primer/#{name.underscore}.html.erb" end diff --git a/docs/src/@primer/gatsby-theme-doctocat/nav.yml b/docs/src/@primer/gatsby-theme-doctocat/nav.yml index dd8f999b78..a67658f239 100644 --- a/docs/src/@primer/gatsby-theme-doctocat/nav.yml +++ b/docs/src/@primer/gatsby-theme-doctocat/nav.yml @@ -70,7 +70,7 @@ - title: Link url: "/components/beta/link" - title: LocalTime - url: "/components/localtime" + url: "/components/alpha/localtime" - title: Markdown url: "/components/markdown" - title: Menu diff --git a/lib/primer/deprecations.yml b/lib/primer/deprecations.yml index 0b2593ca36..836cf5781f 100644 --- a/lib/primer/deprecations.yml +++ b/lib/primer/deprecations.yml @@ -59,6 +59,10 @@ deprecations: autocorrect: true replacement: "Primer::Beta::Link" + - component: "Primer::LocalTime" + autocorrect: true + replacement: "Primer::Alpha::LocalTime" + - component: "Primer::PopoverComponent" autocorrect: true replacement: "Primer::Beta::Popover" diff --git a/lib/tasks/docs.rake b/lib/tasks/docs.rake index f3ee1221f5..707d4c2b03 100644 --- a/lib/tasks/docs.rake +++ b/lib/tasks/docs.rake @@ -36,7 +36,7 @@ namespace :docs do Primer::Alpha::Layout, Primer::HellipButton, Primer::Alpha::Image, - Primer::LocalTime, + Primer::Alpha::LocalTime, Primer::OcticonSymbolsComponent, Primer::Alpha::ImageCrop, Primer::IconButton, @@ -101,7 +101,7 @@ namespace :docs do js_components = [ Primer::Alpha::Dropdown, - Primer::LocalTime, + Primer::Alpha::LocalTime, Primer::Alpha::ImageCrop, Primer::Beta::AutoComplete, Primer::Alpha::Banner, diff --git a/previews/primer/alpha/local_time_preview.rb b/previews/primer/alpha/local_time_preview.rb new file mode 100644 index 0000000000..101b4485fd --- /dev/null +++ b/previews/primer/alpha/local_time_preview.rb @@ -0,0 +1,56 @@ +# frozen_string_literal: true + +module Primer + module Alpha + # @label LocalTime + class LocalTimePreview < ViewComponent::Preview + # @param datetime datetime-local + # @param weekday [Symbol] select [long, short] + # @param month [Symbol] select [long, short] + # @param year [Symbol] select [numeric, "2-digit"] + # @param day [Symbol] select [numeric, "2-digit"] + # @param hour [Symbol] select [numeric, "2-digit"] + # @param minute [Symbol] select [numeric, "2-digit"] + # @param second [Symbol] select [numeric, "2-digit"] + # @param time_zone_name [Symbol] select [long, short] + def playground(datetime: "2014-04-01T16:30:00-08:00", weekday: :short, month: :short, year: :numeric, day: :numeric, hour: :numeric, minute: :numeric, second: :numeric, time_zone_name: :short) + render(Primer::Alpha::LocalTime.new(datetime: DateTime.parse(datetime), weekday: weekday, month: month, year: year, day: day, hour: hour, minute: minute, second: second, time_zone_name: time_zone_name)) + end + + # @param datetime datetime-local + # @param weekday [Symbol] select [long, short] + # @param month [Symbol] select [long, short] + # @param year [Symbol] select [numeric, "2-digit"] + # @param day [Symbol] select [numeric, "2-digit"] + # @param hour [Symbol] select [numeric, "2-digit"] + # @param minute [Symbol] select [numeric, "2-digit"] + # @param second [Symbol] select [numeric, "2-digit"] + # @param time_zone_name [Symbol] select [long, short] + def default(datetime: "2014-04-01T16:30:00-08:00", weekday: :short, month: :short, year: :numeric, day: :numeric, hour: :numeric, minute: :numeric, second: :numeric, time_zone_name: :short) + render(Primer::Alpha::LocalTime.new(datetime: DateTime.parse(datetime), weekday: weekday, month: month, year: year, day: day, hour: hour, minute: minute, second: second, time_zone_name: time_zone_name)) + end + + # @hidden + def with_all_the_options + render(Primer::Alpha::LocalTime.new( + datetime: DateTime.parse("2016-06-01T13:05:07Z"), + weekday: :long, + year: :"2-digit", + month: :long, + day: :"2-digit", + hour: :"2-digit", + minute: :"2-digit", + second: :"2-digit", + time_zone_name: :long + )) + end + + # @label With replaceable content + # + # @param initial_text [String] textarea + def with_contents(initial_text: "This will be replaced") + render Primer::Alpha::LocalTime.new(datetime: DateTime.parse("2014-04-01T16:30:00-08:00"), initial_text: initial_text) + end + end + end +end diff --git a/previews/primer/local_time_component_preview.rb b/previews/primer/local_time_component_preview.rb deleted file mode 100644 index fabf0f1004..0000000000 --- a/previews/primer/local_time_component_preview.rb +++ /dev/null @@ -1,54 +0,0 @@ -# frozen_string_literal: true - -module Primer - # @label LocalTime - class LocalTimeComponentPreview < ViewComponent::Preview - # @param datetime datetime-local - # @param weekday [Symbol] select [long, short] - # @param month [Symbol] select [long, short] - # @param year [Symbol] select [numeric, "2-digit"] - # @param day [Symbol] select [numeric, "2-digit"] - # @param hour [Symbol] select [numeric, "2-digit"] - # @param minute [Symbol] select [numeric, "2-digit"] - # @param second [Symbol] select [numeric, "2-digit"] - # @param time_zone_name [Symbol] select [long, short] - def playground(datetime: "2014-04-01T16:30:00-08:00", weekday: :short, month: :short, year: :numeric, day: :numeric, hour: :numeric, minute: :numeric, second: :numeric, time_zone_name: :short) - render(Primer::LocalTime.new(datetime: DateTime.parse(datetime), weekday: weekday, month: month, year: year, day: day, hour: hour, minute: minute, second: second, time_zone_name: time_zone_name)) - end - - # @param datetime datetime-local - # @param weekday [Symbol] select [long, short] - # @param month [Symbol] select [long, short] - # @param year [Symbol] select [numeric, "2-digit"] - # @param day [Symbol] select [numeric, "2-digit"] - # @param hour [Symbol] select [numeric, "2-digit"] - # @param minute [Symbol] select [numeric, "2-digit"] - # @param second [Symbol] select [numeric, "2-digit"] - # @param time_zone_name [Symbol] select [long, short] - def default(datetime: "2014-04-01T16:30:00-08:00", weekday: :short, month: :short, year: :numeric, day: :numeric, hour: :numeric, minute: :numeric, second: :numeric, time_zone_name: :short) - render(Primer::LocalTime.new(datetime: DateTime.parse(datetime), weekday: weekday, month: month, year: year, day: day, hour: hour, minute: minute, second: second, time_zone_name: time_zone_name)) - end - - # @hidden - def with_all_the_options - render(Primer::LocalTime.new( - datetime: DateTime.parse("2016-06-01T13:05:07Z"), - weekday: :long, - year: :"2-digit", - month: :long, - day: :"2-digit", - hour: :"2-digit", - minute: :"2-digit", - second: :"2-digit", - time_zone_name: :long - )) - end - - # @label With replaceable content - # - # @param initial_text [String] textarea - def with_contents(initial_text: "This will be replaced") - render Primer::LocalTime.new(datetime: DateTime.parse("2014-04-01T16:30:00-08:00"), initial_text: initial_text) - end - end -end diff --git a/static/arguments.json b/static/arguments.json index 9b08fa8d58..b55707daad 100644 --- a/static/arguments.json +++ b/static/arguments.json @@ -497,6 +497,80 @@ } ] }, + { + "component": "LocalTime", + "status": "alpha", + "source": "https://github.com/primer/view_components/tree/main/app/components/primer/alpha/local_time.rb", + "lookbook": "https://primer.style/view-components/lookbook/inspect/primer/alpha/local_time/default/", + "parameters": [ + { + "name": "datetime", + "type": "DateTime", + "default": "N/A", + "description": "The date to parse" + }, + { + "name": "initial_text", + "type": "String", + "default": "`nil`", + "description": "Text to render before component is initialized" + }, + { + "name": "weekday", + "type": "Symbol", + "default": "`:short`", + "description": "One of `:long` or `:short`." + }, + { + "name": "year", + "type": "Symbol", + "default": "`:numeric`", + "description": "One of `:2-digit` or `:numeric`." + }, + { + "name": "month", + "type": "Symbol", + "default": "`:short`", + "description": "One of `:long` or `:short`." + }, + { + "name": "day", + "type": "Symbol", + "default": "`:numeric`", + "description": "One of `:2-digit` or `:numeric`." + }, + { + "name": "hour", + "type": "Symbol", + "default": "`:numeric`", + "description": "One of `:2-digit` or `:numeric`." + }, + { + "name": "minute", + "type": "Symbol", + "default": "`:numeric`", + "description": "One of `:2-digit` or `:numeric`." + }, + { + "name": "second", + "type": "Symbol", + "default": "`:numeric`", + "description": "One of `:2-digit` or `:numeric`." + }, + { + "name": "time_zone_name", + "type": "Symbol", + "default": "`:short`", + "description": "One of `:long` or `:short`." + }, + { + "name": "system_arguments", + "type": "Hash", + "default": "N/A", + "description": "[System arguments](/system-arguments)" + } + ] + }, { "component": "NavList", "status": "alpha", @@ -2141,80 +2215,6 @@ } ] }, - { - "component": "LocalTime", - "status": "alpha", - "source": "https://github.com/primer/view_components/tree/main/app/components/primer/local_time.rb", - "lookbook": "https://primer.style/view-components/lookbook/inspect/primer/local_time/default/", - "parameters": [ - { - "name": "datetime", - "type": "DateTime", - "default": "N/A", - "description": "The date to parse" - }, - { - "name": "initial_text", - "type": "String", - "default": "`nil`", - "description": "Text to render before component is initialized" - }, - { - "name": "weekday", - "type": "Symbol", - "default": "`:short`", - "description": "One of `:long` or `:short`." - }, - { - "name": "year", - "type": "Symbol", - "default": "`:numeric`", - "description": "One of `:2-digit` or `:numeric`." - }, - { - "name": "month", - "type": "Symbol", - "default": "`:short`", - "description": "One of `:long` or `:short`." - }, - { - "name": "day", - "type": "Symbol", - "default": "`:numeric`", - "description": "One of `:2-digit` or `:numeric`." - }, - { - "name": "hour", - "type": "Symbol", - "default": "`:numeric`", - "description": "One of `:2-digit` or `:numeric`." - }, - { - "name": "minute", - "type": "Symbol", - "default": "`:numeric`", - "description": "One of `:2-digit` or `:numeric`." - }, - { - "name": "second", - "type": "Symbol", - "default": "`:numeric`", - "description": "One of `:2-digit` or `:numeric`." - }, - { - "name": "time_zone_name", - "type": "Symbol", - "default": "`:short`", - "description": "One of `:long` or `:short`." - }, - { - "name": "system_arguments", - "type": "Hash", - "default": "N/A", - "description": "[System arguments](/system-arguments)" - } - ] - }, { "component": "Markdown", "status": "beta", diff --git a/static/audited_at.json b/static/audited_at.json index a0c94e87e4..0512b3d9b8 100644 --- a/static/audited_at.json +++ b/static/audited_at.json @@ -20,6 +20,7 @@ "Primer::Alpha::Layout": "", "Primer::Alpha::Layout::Main": "", "Primer::Alpha::Layout::Sidebar": "", + "Primer::Alpha::LocalTime": "", "Primer::Alpha::NavList": "", "Primer::Alpha::NavList::Item": "", "Primer::Alpha::NavList::Section": "", diff --git a/static/constants.json b/static/constants.json index edd9ae72a9..1dc267bcb5 100644 --- a/static/constants.json +++ b/static/constants.json @@ -300,6 +300,18 @@ "section" ] }, + "Primer::Alpha::LocalTime": { + "DEFAULT_DIGIT_TYPE": "numeric", + "DEFAULT_TEXT_TYPE": "short", + "DIGIT_TYPE_OPTIONS": [ + "numeric", + "2-digit" + ], + "TEXT_TYPE_OPTIONS": [ + "short", + "long" + ] + }, "Primer::Alpha::NavList": { "Item": "Primer::Alpha::NavList::Item", "Section": "Primer::Alpha::NavList::Section" @@ -975,16 +987,6 @@ "Primer::LinkComponent": { }, "Primer::LocalTime": { - "DEFAULT_DIGIT_TYPE": "numeric", - "DEFAULT_TEXT_TYPE": "short", - "DIGIT_TYPE_OPTIONS": [ - "numeric", - "2-digit" - ], - "TEXT_TYPE_OPTIONS": [ - "short", - "long" - ] }, "Primer::Markdown": { "DEFAULT_TAG": "div", diff --git a/static/statuses.json b/static/statuses.json index 02cd9b6ddf..aca16cc6af 100644 --- a/static/statuses.json +++ b/static/statuses.json @@ -20,6 +20,7 @@ "Primer::Alpha::Layout": "alpha", "Primer::Alpha::Layout::Main": "alpha", "Primer::Alpha::Layout::Sidebar": "alpha", + "Primer::Alpha::LocalTime": "alpha", "Primer::Alpha::NavList": "alpha", "Primer::Alpha::NavList::Item": "alpha", "Primer::Alpha::NavList::Section": "alpha", @@ -76,7 +77,7 @@ "Primer::LabelComponent": "deprecated", "Primer::LayoutComponent": "alpha", "Primer::LinkComponent": "deprecated", - "Primer::LocalTime": "alpha", + "Primer::LocalTime": "deprecated", "Primer::Markdown": "beta", "Primer::MenuComponent": "alpha", "Primer::Navigation::TabComponent": "alpha", diff --git a/test/components/local_time_test.rb b/test/components/alpha/local_time_test.rb similarity index 80% rename from test/components/local_time_test.rb rename to test/components/alpha/local_time_test.rb index 4ed50e18e0..1f81674078 100644 --- a/test/components/local_time_test.rb +++ b/test/components/alpha/local_time_test.rb @@ -2,17 +2,17 @@ require "components/test_helper" -class PrimerLocalTimeTest < Minitest::Test +class PrimerAlphaLocalTimeTest < Minitest::Test include Primer::ComponentTestHelpers def test_renders - render_inline Primer::LocalTime.new(datetime: DateTime.parse("2014-06-01T13:05:07Z")) + render_inline Primer::Alpha::LocalTime.new(datetime: DateTime.parse("2014-06-01T13:05:07Z")) assert_selector("relative-time[data-view-component][threshold=\"PT0S\"][prefix=\"\"][datetime=\"2014-06-01T13:05:07+00:00\"][year=\"numeric\"][month=\"short\"][day=\"numeric\"][hour=\"numeric\"][minute=\"numeric\"][second=\"numeric\"]", text: "June 1, 2014 13:05 +00:00") end def test_all_options - render_inline Primer::LocalTime.new( + render_inline Primer::Alpha::LocalTime.new( datetime: DateTime.parse("2016-06-01T13:05:07Z"), weekday: :long, year: :"2-digit", @@ -28,7 +28,7 @@ def test_all_options end def test_contents - render_inline Primer::LocalTime.new(datetime: DateTime.parse("2014-06-01T13:05:07Z"), initial_text: "2014/06/01 13:05") + render_inline Primer::Alpha::LocalTime.new(datetime: DateTime.parse("2014-06-01T13:05:07Z"), initial_text: "2014/06/01 13:05") assert_selector("relative-time[data-view-component][threshold=\"PT0S\"][prefix=\"\"][datetime=\"2014-06-01T13:05:07+00:00\"][year=\"numeric\"][month=\"short\"][day=\"numeric\"][hour=\"numeric\"][minute=\"numeric\"][second=\"numeric\"]", text: "2014/06/01 13:05") end diff --git a/test/components/component_test.rb b/test/components/component_test.rb index 3bec8175a7..f127b8bf1c 100644 --- a/test/components/component_test.rb +++ b/test/components/component_test.rb @@ -27,7 +27,7 @@ class PrimerComponentTest < Minitest::Test [Primer::Alpha::TabNav, { label: "label" }], [Primer::Alpha::UnderlinePanels, { label: "Panel label" }], [Primer::Alpha::Image, { src: "https://github.com/github.png", alt: "alt" }], - [Primer::LocalTime, { datetime: DateTime.parse("2014-06-01T13:05:07Z") }], + [Primer::Alpha::LocalTime, { datetime: DateTime.parse("2014-06-01T13:05:07Z") }], [Primer::Alpha::ImageCrop, { src: "Foo" }], [Primer::IconButton, { icon: :star, "aria-label": "Label" }], [Primer::Alpha::ActionList, { aria: { label: "Action List" } }, lambda do |component| @@ -111,6 +111,7 @@ class PrimerComponentTest < Minitest::Test def test_registered_components ignored_components = [ + "Primer::LocalTime", "Primer::ClipboardCopy", "Primer::LabelComponent", "Primer::LinkComponent", diff --git a/test/system/local_time_component_test.rb b/test/system/local_time_component_test.rb index 77f88db9b2..9b8b4a24fb 100644 --- a/test/system/local_time_component_test.rb +++ b/test/system/local_time_component_test.rb @@ -2,7 +2,7 @@ require "system/test_case" -class IntegrationLocalTimeComponentTest < System::TestCase +class IntegrationAlphaLocalTimeTest < System::TestCase def test_default visit_preview(:default)