diff --git a/.changeset/breezy-wombats-act.md b/.changeset/breezy-wombats-act.md new file mode 100644 index 0000000000..412f9be8ce --- /dev/null +++ b/.changeset/breezy-wombats-act.md @@ -0,0 +1,5 @@ +--- +"@primer/view-components": patch +--- + +Removing the deprecated Primer::LocalTime component diff --git a/app/components/primer/local_time.rb b/app/components/primer/local_time.rb deleted file mode 100644 index fe12bff174..0000000000 --- a/app/components/primer/local_time.rb +++ /dev/null @@ -1,63 +0,0 @@ -# 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 - status :deprecated - - 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 - end -end diff --git a/app/components/primer/local_time.ts b/app/components/primer/local_time.ts deleted file mode 100644 index ce859fe727..0000000000 --- a/app/components/primer/local_time.ts +++ /dev/null @@ -1 +0,0 @@ -import '@github/relative-time-element' diff --git a/app/components/primer/primer.ts b/app/components/primer/primer.ts index d3e190c4a1..f2f0722837 100644 --- a/app/components/primer/primer.ts +++ b/app/components/primer/primer.ts @@ -8,7 +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/tab_container' import './time_ago_component' import '../../../lib/primer/forms/primer_multi_input' diff --git a/docs/src/@primer/gatsby-theme-doctocat/nav.yml b/docs/src/@primer/gatsby-theme-doctocat/nav.yml index 71600d896e..8eb96e48d3 100644 --- a/docs/src/@primer/gatsby-theme-doctocat/nav.yml +++ b/docs/src/@primer/gatsby-theme-doctocat/nav.yml @@ -125,8 +125,6 @@ url: "/components/button" - title: IconButton url: "/components/iconbutton" - - title: LocalTime - url: "/components/localtime" - title: TimeAgo url: "/components/timeago" - title: Tooltip diff --git a/lib/primer/deprecations.yml b/lib/primer/deprecations.yml index 5fbd1c1cbd..3c8e9a1b2b 100644 --- a/lib/primer/deprecations.yml +++ b/lib/primer/deprecations.yml @@ -26,11 +26,6 @@ deprecations: autocorrect: true replacement: "Primer::Beta::IconButton" - - component: "Primer::LocalTime" - autocorrect: false - replacement: "Primer::Beta::RelativeTime" - guide: "https://primer.style/view-components/guides/primer_local_time" - - component: "Primer::TimeAgoComponent" autocorrect: false replacement: "Primer::Beta::RelativeTime" diff --git a/lib/primer/yard/component_manifest.rb b/lib/primer/yard/component_manifest.rb index 0d2f558711..f3d3ebd3c4 100644 --- a/lib/primer/yard/component_manifest.rb +++ b/lib/primer/yard/component_manifest.rb @@ -13,7 +13,6 @@ class ComponentManifest Primer::Alpha::Layout => {}, Primer::Alpha::HellipButton => {}, Primer::Alpha::Image => {}, - Primer::LocalTime => { js: true }, Primer::Alpha::OcticonSymbols => {}, Primer::Alpha::ImageCrop => { js: true }, Primer::IconButton => { js: true }, diff --git a/previews/primer/local_time_component_preview.rb b/previews/primer/local_time_component_preview.rb deleted file mode 100644 index af81cfc2f6..0000000000 --- a/previews/primer/local_time_component_preview.rb +++ /dev/null @@ -1,57 +0,0 @@ -# frozen_string_literal: true - -# rubocop:disable Primer/ComponentNameMigration - -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 -# rubocop:enable Primer/ComponentNameMigration diff --git a/static/arguments.json b/static/arguments.json index f542bdd45d..6d731cb556 100644 --- a/static/arguments.json +++ b/static/arguments.json @@ -2325,80 +2325,6 @@ } ] }, - { - "component": "LocalTime", - "status": "deprecated", - "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": "Navigation::Tab", "status": "alpha", diff --git a/static/audited_at.json b/static/audited_at.json index a5436bb3d5..c2bcdcb7cc 100644 --- a/static/audited_at.json +++ b/static/audited_at.json @@ -78,7 +78,6 @@ "Primer::Content": "", "Primer::IconButton": "", "Primer::LayoutComponent": "", - "Primer::LocalTime": "", "Primer::Navigation::TabComponent": "", "Primer::TimeAgoComponent": "", "Primer::Tooltip": "", diff --git a/static/constants.json b/static/constants.json index 47bc9c4478..59822bd94e 100644 --- a/static/constants.json +++ b/static/constants.json @@ -1066,18 +1066,6 @@ "DEFAULT_SIDEBAR_COL": 3, "MAX_COL": 12 }, - "Primer::LocalTime": { - "DEFAULT_DIGIT_TYPE": "numeric", - "DEFAULT_TEXT_TYPE": "short", - "DIGIT_TYPE_OPTIONS": [ - "numeric", - "2-digit" - ], - "TEXT_TYPE_OPTIONS": [ - "short", - "long" - ] - }, "Primer::Navigation::TabComponent": { "ARIA_CURRENT_OPTIONS_FOR_ANCHOR": [ true, diff --git a/static/statuses.json b/static/statuses.json index 03b3336804..49f4340928 100644 --- a/static/statuses.json +++ b/static/statuses.json @@ -78,7 +78,6 @@ "Primer::Content": "stable", "Primer::IconButton": "deprecated", "Primer::LayoutComponent": "alpha", - "Primer::LocalTime": "deprecated", "Primer::Navigation::TabComponent": "alpha", "Primer::TimeAgoComponent": "deprecated", "Primer::Tooltip": "deprecated", diff --git a/test/components/component_test.rb b/test/components/component_test.rb index 920acaefcb..0a97fd30ac 100644 --- a/test/components/component_test.rb +++ b/test/components/component_test.rb @@ -28,7 +28,6 @@ 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::ImageCrop, { src: "Foo" }], [Primer::IconButton, { icon: :star, "aria-label": "Label" }], [Primer::Alpha::ActionList, { aria: { label: "Action List" } }, lambda do |component| diff --git a/test/components/local_time_test.rb b/test/components/local_time_test.rb deleted file mode 100644 index 4ed50e18e0..0000000000 --- a/test/components/local_time_test.rb +++ /dev/null @@ -1,35 +0,0 @@ -# frozen_string_literal: true - -require "components/test_helper" - -class PrimerLocalTimeTest < Minitest::Test - include Primer::ComponentTestHelpers - - def test_renders - render_inline Primer::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( - 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 - ) - - assert_selector("relative-time[data-view-component][threshold=\"PT0S\"][prefix=\"\"][weekday=\"long\"][datetime=\"2016-06-01T13:05:07+00:00\"][year=\"2-digit\"][month=\"long\"][day=\"2-digit\"][hour=\"2-digit\"][minute=\"2-digit\"][second=\"2-digit\"][time-zone-name=\"long\"]", text: "June 1, 2016 13:05 +00:00") - end - - def test_contents - render_inline Primer::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 -end diff --git a/test/system/local_time_component_test.rb b/test/system/local_time_component_test.rb deleted file mode 100644 index 77f88db9b2..0000000000 --- a/test/system/local_time_component_test.rb +++ /dev/null @@ -1,23 +0,0 @@ -# frozen_string_literal: true - -require "system/test_case" - -class IntegrationLocalTimeComponentTest < System::TestCase - def test_default - visit_preview(:default) - - assert_selector("relative-time[data-view-component][prefix='']") - end - - def test_with_all_the_options - visit_preview(:with_all_the_options) - - assert_selector("relative-time[data-view-component][prefix=''][year='2-digit'][month='long']") - end - - def test_with_contents - visit_preview(:with_contents) - - assert_selector("relative-time[data-view-component][prefix='']") - end -end