-
Notifications
You must be signed in to change notification settings - Fork 72
[LG-5532] feat(time-input) display segment values #3379
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
Open
shaneeza
wants to merge
18
commits into
LG-5538/segments-parse-time
Choose a base branch
from
LG-5532/segments-display-values
base: LG-5538/segments-parse-time
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 11 commits
Commits
Show all changes
18 commits
Select commit
Hold shift + click to select a range
1db42af
feat(time-input): add TimeFormField and TimeFormFieldInputContainer c…
shaneeza bb3916d
refactor(time-input): clean up unused select unit logic and improve s…
shaneeza df69d22
feat(time-input): enhance TimeInput component with new constants for …
shaneeza 2f5707f
refactor(time-input): update time segment rules and default values to…
shaneeza 1ef4c97
merge conflits
shaneeza 87023fb
feat(time-input): enhance TimeInput stories with new argTypes for dar…
shaneeza 580c90f
test(time-input): add comprehensive unit tests for TimeInputSegment c…
shaneeza 2495aa1
test(time-input): add comprehensive unit tests for TimeInputSegment c…
shaneeza 4cad730
refactor(time-input): update time segment handling to use explicit is…
shaneeza 6e265a7
chore(pnpm-lock): add workspace links for @leafygreen-ui/input-box to…
shaneeza 10d4039
merge conflict
shaneeza e46a73c
refactor(time-input): clean up comments and improve test descriptions…
shaneeza 7e42f34
merge conflict
shaneeza d9b99ec
Merge branch 'LG-5538/segments-parse-time' of github.com:mongodb/leaf…
shaneeza f07a1b8
merge conflict
shaneeza ed87ee7
test(time-input): add unit tests for TimeInputBox component
shaneeza e18c444
feat(time-input): integrate LGIDs into TimeInput components for impro…
shaneeza a361ba7
test(time-input): add test to verify seconds input is not rendered wh…
shaneeza File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
41 changes: 41 additions & 0 deletions
41
packages/time-input/src/TimeFormField/TimeFormField/TimeFormField.tsx
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,41 @@ | ||
| import React from 'react'; | ||
|
|
||
| import { FormField } from '@leafygreen-ui/form-field'; | ||
|
|
||
| import { useTimeInputDisplayContext } from '../../Context/TimeInputDisplayContext'; | ||
|
|
||
| import { TimeFormFieldProps } from './TimeFormField.types'; | ||
|
|
||
| /** | ||
| * A wrapper around `FormField` that sets the relevant | ||
| * attributes, and styling | ||
| */ | ||
| export const TimeFormField = React.forwardRef< | ||
| HTMLDivElement, | ||
| TimeFormFieldProps | ||
| >(({ children, ...rest }: TimeFormFieldProps, fwdRef) => { | ||
| const { | ||
| label, | ||
| description, | ||
| // stateNotification: { state, message: errorMessage }, | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. do we need to remove this? |
||
| disabled, | ||
| size, | ||
| } = useTimeInputDisplayContext(); | ||
|
|
||
| return ( | ||
| <FormField | ||
| label={label} | ||
| description={description} | ||
| disabled={disabled} | ||
| // state={state} | ||
| // errorMessage={errorMessage} | ||
| size={size} | ||
| ref={fwdRef} | ||
| {...rest} | ||
| > | ||
| {children} | ||
| </FormField> | ||
| ); | ||
| }); | ||
|
|
||
| TimeFormField.displayName = 'TimeFormField'; | ||
5 changes: 5 additions & 0 deletions
5
packages/time-input/src/TimeFormField/TimeFormField/TimeFormField.types.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| import { FormFieldProps } from '@leafygreen-ui/form-field'; | ||
|
|
||
| export type TimeFormFieldProps = React.ComponentPropsWithoutRef<'div'> & { | ||
| children: FormFieldProps['children']; | ||
| }; |
22 changes: 22 additions & 0 deletions
22
...input/src/TimeFormField/TimeFormFieldInputContainer/TimeFormFieldInputContainer.styles.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,22 @@ | ||
| import { css, cx } from '@leafygreen-ui/emotion'; | ||
|
|
||
| const selectStyles = css` | ||
| border-top-right-radius: 0; | ||
| border-bottom-right-radius: 0; | ||
| `; | ||
|
|
||
| const baseStyles = css` | ||
| &:hover, | ||
| &:focus-within { | ||
| z-index: 1; | ||
| } | ||
| `; | ||
|
|
||
| export const getContainerStyles = ({ | ||
| is12HourFormat, | ||
| }: { | ||
| is12HourFormat: boolean; | ||
| }) => | ||
| cx(baseStyles, { | ||
| [selectStyles]: is12HourFormat, | ||
| }); |
40 changes: 40 additions & 0 deletions
40
.../time-input/src/TimeFormField/TimeFormFieldInputContainer/TimeFormFieldInputContainer.tsx
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,40 @@ | ||
| import React from 'react'; | ||
|
|
||
| import { FormFieldInputContainer } from '@leafygreen-ui/form-field'; | ||
|
|
||
| import { useTimeInputDisplayContext } from '../../Context/TimeInputDisplayContext'; | ||
|
|
||
| import { getContainerStyles } from './TimeFormFieldInputContainer.styles'; | ||
| import { TimeFormFieldInputContainerProps } from './TimeFormFieldInputContainer.types'; | ||
|
|
||
| /** | ||
| * A wrapper around `FormField` that sets the relevant | ||
| * attributes, and styling | ||
| */ | ||
| export const TimeFormFieldInputContainer = React.forwardRef< | ||
| HTMLDivElement, | ||
| TimeFormFieldInputContainerProps | ||
| >(({ children, onInputClick }: TimeFormFieldInputContainerProps, fwdRef) => { | ||
| const { label, ariaLabelProp, ariaLabelledbyProp, is12HourFormat } = | ||
| useTimeInputDisplayContext(); | ||
|
|
||
| return ( | ||
| <FormFieldInputContainer | ||
| ref={fwdRef} | ||
| role="combobox" | ||
| tabIndex={-1} | ||
| aria-label={!label && ariaLabelProp ? ariaLabelProp : undefined} | ||
| aria-labelledby={ | ||
| !label && !ariaLabelProp && ariaLabelledbyProp | ||
| ? ariaLabelledbyProp | ||
| : undefined | ||
| } | ||
| onClick={onInputClick} | ||
| className={getContainerStyles({ is12HourFormat })} | ||
| > | ||
| {children} | ||
| </FormFieldInputContainer> | ||
| ); | ||
| }); | ||
|
|
||
| TimeFormFieldInputContainer.displayName = 'TimeFormFieldInputContainer'; |
7 changes: 7 additions & 0 deletions
7
...-input/src/TimeFormField/TimeFormFieldInputContainer/TimeFormFieldInputContainer.types.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,7 @@ | ||
| import { FormFieldProps } from '@leafygreen-ui/form-field'; | ||
|
|
||
| export type TimeFormFieldInputContainerProps = | ||
| React.ComponentPropsWithoutRef<'div'> & { | ||
| children: FormFieldProps['children']; | ||
| onInputClick?: React.MouseEventHandler<HTMLDivElement>; | ||
| }; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,2 @@ | ||
| export { TimeFormField } from './TimeFormField/TimeFormField'; | ||
| export { TimeFormFieldInputContainer } from './TimeFormFieldInputContainer/TimeFormFieldInputContainer'; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
Empty file.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,31 @@ | ||
| import React from 'react'; | ||
|
|
||
| import { InputBox } from '@leafygreen-ui/input-box'; | ||
|
|
||
| import { getTimeSegmentRules } from '../constants'; | ||
| import { useTimeInputDisplayContext } from '../Context/TimeInputDisplayContext/TimeInputDisplayContext'; | ||
| import { TimeSegment } from '../shared.types'; | ||
| import { TimeInputSegment } from '../TimeInputSegment/TimeInputSegment'; | ||
|
|
||
| import { TimeInputBoxProps } from './TimeInputBox.types'; | ||
|
|
||
| export const TimeInputBox = React.forwardRef<HTMLDivElement, TimeInputBoxProps>( | ||
| ({ children, ...rest }: TimeInputBoxProps, fwdRef) => { | ||
| const { disabled, formatParts, size, is12HourFormat } = | ||
| useTimeInputDisplayContext(); | ||
| return ( | ||
| <InputBox | ||
| ref={fwdRef} | ||
| segmentEnum={TimeSegment} | ||
| segmentRules={getTimeSegmentRules({ is12HourFormat })} | ||
| disabled={disabled} | ||
| segmentComponent={TimeInputSegment} | ||
| size={size} | ||
| formatParts={formatParts} | ||
| {...rest} | ||
| /> | ||
| ); | ||
| }, | ||
| ); | ||
|
|
||
| TimeInputBox.displayName = 'TimeInputBox'; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,7 @@ | ||
| import { TimeSegment, TimeSegmentsState } from '../shared.types'; | ||
|
|
||
| export interface TimeInputBoxProps | ||
| extends React.ComponentPropsWithoutRef<'div'> { | ||
| segments: TimeSegmentsState; | ||
| setSegment: (segment: TimeSegment, value: string) => void; | ||
| } |
Empty file.
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Nit: Would be helpful to create a backlog ticket for this and reference that in this comment