-
Notifications
You must be signed in to change notification settings - Fork 376
feat(SimpleFileUpload): consumed Penta updates #10026
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
Merged
wise-king-sullyman
merged 5 commits into
patternfly:v6
from
thatblindgeye:simpleFileUploadPenta
Jan 31, 2024
Merged
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
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
27 changes: 27 additions & 0 deletions
27
packages/react-core/src/components/FileUpload/FileUploadHelperText.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,27 @@ | ||
| import * as React from 'react'; | ||
| import styles from '@patternfly/react-styles/css/components/FileUpload/file-upload'; | ||
| import { css } from '@patternfly/react-styles'; | ||
|
|
||
| /** A container for helper text content. This sub-component should be passed as a child to | ||
| * the main file upload or file upload field component. | ||
| */ | ||
|
|
||
| export interface FileUploadHelperTextProps extends React.HTMLProps<HTMLDivElement> { | ||
| /** Content to render inside the file upload helper text container. Typically this will be | ||
| * the helper text component. | ||
| */ | ||
| children: React.ReactNode; | ||
| /** Additional classes added to the file upload helper text container element. */ | ||
| className?: string; | ||
| } | ||
|
|
||
| export const FileUploadHelperText: React.FunctionComponent<FileUploadHelperTextProps> = ({ | ||
| children, | ||
| className, | ||
| ...props | ||
| }: FileUploadHelperTextProps) => ( | ||
| <div className={css(`${styles.fileUpload}__helper-text`, className)} {...props}> | ||
| {children} | ||
| </div> | ||
| ); | ||
| FileUploadHelperText.displayName = 'FileUploadHelperText'; |
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
27 changes: 27 additions & 0 deletions
27
packages/react-core/src/components/FileUpload/__tests__/FileUploadHelperText.test.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,27 @@ | ||
| import * as React from 'react'; | ||
| import { FileUploadHelperText } from '../FileUploadHelperText'; | ||
| import { render, screen } from '@testing-library/react'; | ||
| import styles from '@patternfly/react-styles/css/components/FileUpload/file-upload'; | ||
|
|
||
| test(`Renders only with class ${styles.fileUpload}__helper-text by default`, () => { | ||
| render(<FileUploadHelperText>Content</FileUploadHelperText>); | ||
|
|
||
| expect(screen.getByText('Content')).toHaveClass(`${styles.fileUpload}__helper-text`, { exact: true }); | ||
| }); | ||
|
|
||
| test(`Renders with custom class when className is passed in`, () => { | ||
| render(<FileUploadHelperText className="test">Content</FileUploadHelperText>); | ||
|
|
||
| expect(screen.getByText('Content')).toHaveClass('test'); | ||
| }); | ||
|
|
||
| test(`Spreads props when passed in`, () => { | ||
| render(<FileUploadHelperText id="test-id">Content</FileUploadHelperText>); | ||
|
|
||
| expect(screen.getByText('Content')).toHaveAttribute('id', 'test-id'); | ||
| }); | ||
|
|
||
| test('Matches the snapshot', () => { | ||
| const { asFragment } = render(<FileUploadHelperText>Content</FileUploadHelperText>); | ||
| expect(asFragment()).toMatchSnapshot(); | ||
| }); |
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
11 changes: 11 additions & 0 deletions
11
...core/src/components/FileUpload/__tests__/__snapshots__/FileUploadHelperText.test.tsx.snap
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,11 @@ | ||
| // Jest Snapshot v1, https://goo.gl/fbAQLP | ||
|
|
||
| exports[`Matches the snapshot 1`] = ` | ||
| <DocumentFragment> | ||
| <div | ||
| class="pf-v5-c-file-upload__helper-text" | ||
| > | ||
| Content | ||
| </div> | ||
| </DocumentFragment> | ||
| `; |
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
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.
We could keep this in, but if we're going to expose an ID on the browse button then we should consider allowing an ID to be passed to all other input elements within the component. For now I included this in the codemod issue patternfly/pf-codemods#551