-
Notifications
You must be signed in to change notification settings - Fork 13
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
Add DistanceUnitFormatter and DurationUnitFormatter, two react compon… #777
Conversation
I could also add one for speeds : m/s, km/h, mph, etc |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Verify code lint though
Very nice! |
fixed! |
83c3a2c
to
5a52ba0
Compare
added |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good! You can further type the states though, to limit to the possible values.
const DistanceUnitFormatter: React.FunctionComponent<DistanceUnitFormatterProps> = ( | ||
props: DistanceUnitFormatterProps | ||
) => { | ||
const [destinationUnit, setDestinationUnit] = useState<string | undefined>(props.destinationUnit); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Instead of string
, you can use your destinationUnitOptionType
const DurationUnitFormatter: React.FunctionComponent<DurationUnitFormatterProps> = ( | ||
props: DurationUnitFormatterProps | ||
) => { | ||
const [destinationUnit, setDestinationUnit] = useState<string | undefined>(props.destinationUnit); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same here, use destiantionUnitOptionsType
…matically choose the best unit for a value They also allow clicking on the values to cycle between the different possible units. Example usage is shown in transit routing output for the walking mode, and route statistics for speed. Fixes chairemobilite#775
@tahini fixed :) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks!
…ents to automatically choose the best unit for a value
They also allow clicking on the values to cycle between the different possible units. Example usage is shown in transit routing output for the walking mode. If code and UX seems satisfactory to you, I will use these components in many other parts of transition.
Demo:
Screen.Recording.2023-11-22.at.11.20.26.mov
Fixes #775