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

Surface entire Lightning Time object in clock hook #18

Merged
merged 4 commits into from
Dec 13, 2023

Conversation

MatthewStanciu
Copy link
Member

@MatthewStanciu MatthewStanciu commented Dec 11, 2023

The current useLightningTimeClock() hook only surfaces two strings: lightningTimeClock and normalTimeClock. A new Hack Night dashboard implementation changes the color of each part, and the person who wrote that dashboard wrote their own implementation of Lightning Time to make it work. I realized that in order to achieve the same thing with this library, you would have to re-implement logic that is already in this library but not surfaced in the clock.

This PR surfaces the entire Lightning Time object in the useLightningTimeClock() hook.

Before:

import { useLightningTimeClock } from '@purduehackers/time/react'

export default function MyComponent() {
  const { lightningTimeClock, normalTimeClock, timeColors } =
    useLightningTimeClock()

  return <p>{lightningTimeClock}</p>
}

After:

import { useLightningTimeClock } from '@purduehackers/time/react'

export default function MyComponent() {
  const { colors, lightningString, formattedNormalTime } =
    useLightningTimeClock(); // Can use anything from the LightningString object

  return <p>{lightningString}</p>
}

This is a breaking API change, which would technically warrant a new major version 1.0.0, but if I merge this I will ignore semver because I want to save 1.0.0 for an API overhaul and I know for sure nobody other than me is using the clock in production.

@MatthewStanciu MatthewStanciu marked this pull request as ready for review December 13, 2023 17:34
@MatthewStanciu MatthewStanciu merged commit 59fcfda into main Dec 13, 2023
1 check passed
@MatthewStanciu MatthewStanciu deleted the hook-expose-entire-time-string branch December 13, 2023 17:36
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.

1 participant