Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Create RelativeTime component #2484

Merged
merged 31 commits into from
Dec 6, 2022
Merged

Create RelativeTime component #2484

merged 31 commits into from
Dec 6, 2022

Conversation

keithamus
Copy link
Member

@changeset-bot
Copy link

changeset-bot bot commented Oct 26, 2022

🦋 Changeset detected

Latest commit: 02c67ea

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
@primer/react Minor

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@keithamus keithamus force-pushed the relative-time branch 4 times, most recently from 780f9e7 to b2b54e7 Compare November 4, 2022 15:05
@github-actions
Copy link
Contributor

github-actions bot commented Nov 4, 2022

size-limit report 📦

Path Size
dist/browser.esm.js 82.75 KB (+4.82% 🔺)
dist/browser.umd.js 83.4 KB (+4.8% 🔺)

@keithamus keithamus temporarily deployed to github-pages November 4, 2022 15:13 Inactive
@keithamus keithamus marked this pull request as ready for review November 8, 2022 13:57
@keithamus keithamus requested review from a team and joshblack November 8, 2022 13:57
src/RelativeTime/RelativeTime.tsx Show resolved Hide resolved
src/RelativeTime/RelativeTime.tsx Outdated Show resolved Hide resolved
Copy link
Member

@joshblack joshblack left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Super cool! Just left a couple of comments/questions 👀

})

it('renders a <relative-time>', () => {
expect(render(<RelativeTime />).type).toEqual('relative-time')
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would it be helpful to enforce a default formatted date as a part of this elements types to match the guidance from relative-time? Specifically:

Add a element to your markup. Provide a default formatted date as the element's text content (e.g. April 1, 2014).

expect.extend(toHaveNoViolations)

describe('RelativeTime', () => {
behavesAsComponent({Component: RelativeTime})
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would it help to use the getElement option for a more helpful snapshot? (or just ditch the snapshot altogether 😅 )

src/__tests__/RelativeTime.test.tsx Show resolved Hide resolved
jest.config.js Outdated Show resolved Hide resolved
@siddharthkp
Copy link
Member

siddharthkp commented Nov 22, 2022

size-limit report 📦

Path Size
dist/browser.esm.js 84.1 KB (+6.57% 🔺)
dist/browser.umd.js 84.73 KB (+6.52% 🔺)

That's a bit strange! Looks like most of the diff is coming from @github/time-elements, is there something we should do to reduce this? 🤔

@keithamus
Copy link
Member Author

@siddharthkp @github/time-elements is a bit bigger than it needs to be because it has multiple elements, and also needs to internally polyfill things like Intl.DateTimeFormat. A lot of that will change in a breaking release but work needs to be done in the monolith before the breaking release can be made.

Also bear in mind for the monolith, it already loads the element and so this won't have a material impact to the monolith codebase.

@github-actions github-actions bot temporarily deployed to storybook-preview-2484 November 24, 2022 10:07 Inactive
@github-actions github-actions bot temporarily deployed to storybook-preview-2484 November 24, 2022 10:09 Inactive
@keithamus
Copy link
Member Author

I believe this is now ready to go. I'd appreciate a review from one of the @primer/react-reviewers and we can merge it and release it!

@keithamus keithamus temporarily deployed to github-pages November 24, 2022 10:13 Inactive
@github-actions github-actions bot temporarily deployed to storybook-preview-2484 November 24, 2022 10:14 Inactive
@keithamus keithamus temporarily deployed to github-pages November 29, 2022 17:12 Inactive
@github-actions github-actions bot temporarily deployed to storybook-preview-2484 November 29, 2022 17:12 Inactive
@keithamus keithamus temporarily deployed to github-pages November 29, 2022 17:51 Inactive
@github-actions github-actions bot temporarily deployed to storybook-preview-2484 November 29, 2022 17:51 Inactive
Copy link
Contributor

@colebemis colebemis left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks great 🚀

Thanks for walking me through the API decisions, @keithamus! I think all the props make sense, given the complexity of this component.

@josepmartins
Copy link
Contributor

josepmartins commented Nov 30, 2022

I have one concern regarding the micro being an option in the format list. I believe micro should be tied to responsive behavior, as mocked in the initial API specs, as an option for standalone use-cases, when used in compact spaces or in a mobile environment.

For instance, if there's enough space in the UI, the format="elapsed" should use a readable X year X month... style by default, and only Xm Xy ... micro style for mobile or narrow spaces.

As a side note, and from the accessibility review, using micro requires extra markup for screen readers, and doesn't allow native browser translation.

@keithamus keithamus enabled auto-merge (squash) December 6, 2022 18:21
@keithamus
Copy link
Member Author

I have one concern regarding the micro being an option in the format list. I believe micro should be tied to responsive behavior, as mocked in the initial API specs, as an option for standalone use-cases, when used in compact spaces or in a mobile environment.

Acknowledged. Let's explore some options here in a follow up, as I'd like to get this shipped today and in front of engineers, and we can extend to adding support for this later (especially as there's no active areas where responsive format changes are used).

As a side note, and from the accessibility review, using micro requires extra markup for screen readers, and doesn't allow native browser translation.

Acknowledge this too. I'll follow up in the web component itself to make sure we're accessible here, as it is best placed to resolve this.

@keithamus keithamus merged commit 5eb6939 into main Dec 6, 2022
@keithamus keithamus deleted the relative-time branch December 6, 2022 18:28
@keithamus keithamus temporarily deployed to github-pages December 6, 2022 18:28 Inactive
@primer-css primer-css mentioned this pull request Dec 6, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

6 participants