Skip to content

Conversation

@micahjones13
Copy link
Collaborator

@micahjones13 micahjones13 commented Mar 5, 2025

Brief Description

Adds the rux-datetime-picker component. This component uses the new rux-calendar and rux-day components.

General Notes

Props

<rux-datetime-picker>

  • precision: Controls the granularity of the time (hour, min, sec, ms)
  • julian-format: Controls whether or not the datepicker is in julian mode
  • max-year: The max year value the datepicker can have
  • min-year: The min year value the datepicker can have
  • help-text: The help text. Same as our rux-input
  • error-text: The error text. Same as our rux-input
  • disabled: renders the datepicker as disabled.
  • label: Controls the label text for the datepicker
  • name: Controls the name of the datepicker input
  • value: The value of the datepicker. Must be a valid ISO or Julian ISO string
  • size: The size of the datepicker. small, medium or large

<rux-calendar> and <rux-day> both have their own props which are passed down the component tree originating from <rux-datetime-picker>. These props are internal for the time being, until the need for a standalone calendar arises.

Events

  • <rux-datetime-picker>
    • rux-change: fired when the value of rux-datetime-picker is changed and commited.
      • This also fires when a rux-day is selceted via the calendar.
    • rux-input: fires when the user inputs values into the datepicker
    • rux-blur: fires when datetime-picker loses focus

Motivation and Context

Adds an astro component for handling datetime selection. Provides users with a julian formatted datetime picker.

Issues and Limitations

Types of changes

  • Bug fix
  • New feature
  • Breaking change

Checklist

  • This PR adds or removes a Storybook story.
  • I have added tests to cover my changes.
  • Regressions are passing and/or failures are documented
  • Changes have been checked in evergreen browsers

@netlify
Copy link

netlify bot commented Mar 5, 2025

Deploy Preview for astro-preview ready!

Name Link
🔨 Latest commit 02bd78e
🔍 Latest deploy log https://app.netlify.com/projects/astro-preview/deploys/6864919ddbb94b000811400e
😎 Deploy Preview https://deploy-preview-1370--astro-preview.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

@netlify
Copy link

netlify bot commented Mar 5, 2025

Deploy Preview for astro-stencil ready!

Name Link
🔨 Latest commit 02bd78e
🔍 Latest deploy log https://app.netlify.com/projects/astro-stencil/deploys/6864919d61f5d0000822589f
😎 Deploy Preview https://deploy-preview-1370--astro-stencil.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

@Paterma

This comment was marked as resolved.

@changeset-bot
Copy link

changeset-bot bot commented Mar 6, 2025

⚠️ No Changeset found

Latest commit: 02bd78e

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

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

@micahjones13 micahjones13 changed the title Mj.datepicker feat: add datetime-picker component May 22, 2025
@Paterma
Copy link
Contributor

Paterma commented May 22, 2025

Functionality wise - couldn't find a thing wrong when testing them all! Very impressed 👏🏼
You were missing the precision="min" prop on the Minutes datepicker under precision examples but it's obviously not a bug - just pointing it since it defaults to milliseconds. Code looks solid, too. Aside from loading it up to storybook - I think you're good!

@micahjones13 micahjones13 requested a review from dgwiltjer May 27, 2025 16:46
@micahjones13 micahjones13 requested a review from brothhammer July 1, 2025 21:47
Copy link
Collaborator

@brothhammer brothhammer left a comment

Choose a reason for hiding this comment

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

Wow! this is really impressive and myself coming in at the last minute is struggling to understand how you have kept everything straight for so long.

I have only dug into rux-datetime-picker.tsx. There are places where we are making fairly expensive calculations in the render method that would be good to memoize or in some cases move to a constants file (like the static regex). I also took a shot at code splitting this file on a seperate branch #1408

For maintainability our future selves and other developers I think we need to continue to explore ways to break up rux-datetime-picker.tsx and rux-calendar.tsx. In my view it is okay to have very long files when that file is doing the same thing over and over again (like a testing file or routing file). I'm not married to how I split things and was making some pretty quick decisions.

Additionally given the size of this PR I would greatly appreciate a code walk through meeting to better understand.

Again this is very impressive and I believe the functionality is there. Just want to move it in a direction that can be more easily understood. Happy to pair up or look further into how memoization works in Stencil to keep this moving.

this.isCalendarOpen = !this.isCalendarOpen
}

determineMinMax(type: PartKey, isMicro: boolean, isJulian?: boolean) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

This is a very expensive calculation in the render method. We should look into a way to memoize in Stencil. This method is called multiple times per render cycle but the result only depends on minYear, maxYear and JulianFormat - that don't change often. We want to avoid frequent recalculations of the same min/max values.

<input
key={i}
class={{
part: true,
Copy link
Collaborator

Choose a reason for hiding this comment

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

This class object is in the render method and recreated with each render. It only needs to be recreated if type or precision changes.

//check if incoming value is in an Oridnal ISO format. If so, convert it to gregorian since we're not in julianFormat.
const ordinalFormatMatch = value.match(
/^([0-9]{4})(?:-([0-9]{1,3}))?(?:T([0-9]{2})(?::([0-9]{2}))?(?::([0-9]{2})(?:\.([0-9]{1,6}))?)?Z?)?$/
)
Copy link
Collaborator

Choose a reason for hiding this comment

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

Regex compilation is expensive and this is static. We should move this so it doesn't need to get recompiled for every call of handleInitialValue

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.

4 participants