forked from microsoft/fluentui
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
ProgressField implementation and stories (microsoft#25103)
* ProgressField implementation and stories * change file * update api * change files * remove private true in package.json * remove Progress Stories from vr-tests * update react-progress package.json and change file
- Loading branch information
Showing
15 changed files
with
125 additions
and
2 deletions.
There are no files selected for viewing
This file contains 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
7 changes: 7 additions & 0 deletions
7
change/@fluentui-react-field-02d4e520-824a-4fd4-9f19-6ff8f747e31f.json
This file contains 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 @@ | ||
{ | ||
"type": "prerelease", | ||
"comment": "Add ProgressField to @fluentui/react-field", | ||
"packageName": "@fluentui/react-field", | ||
"email": "ololubek@microsoft.com", | ||
"dependentChangeType": "patch" | ||
} |
7 changes: 7 additions & 0 deletions
7
change/@fluentui-react-progress-bf837b7d-856a-4256-94fc-ebd888027c86.json
This file contains 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 @@ | ||
{ | ||
"type": "prerelease", | ||
"comment": "Add justify-self styling to Progress styles", | ||
"packageName": "@fluentui/react-progress", | ||
"email": "ololubek@microsoft.com", | ||
"dependentChangeType": "patch" | ||
} |
This file contains 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 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 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 @@ | ||
export * from './components/ProgressField/index'; |
24 changes: 24 additions & 0 deletions
24
packages/react-components/react-field/src/components/ProgressField/ProgressField.test.tsx
This file contains 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,24 @@ | ||
import * as React from 'react'; | ||
import { render } from '@testing-library/react'; | ||
import { isConformant } from '../../common/isConformant'; | ||
import { ProgressField } from './ProgressField'; | ||
|
||
describe('ProgressField', () => { | ||
isConformant({ | ||
Component: ProgressField, | ||
displayName: 'ProgressField', | ||
}); | ||
|
||
// Most functionality is tested by Field.test.tsx, and RadioGroup's tests | ||
|
||
it('uses aria-labelledby for the label', () => { | ||
const result = render(<ProgressField label="Test label" />); | ||
|
||
const progress = result.getByRole('progressbar'); | ||
const label = result.getByText('Test label') as HTMLLabelElement; | ||
|
||
expect(label.id).toBeTruthy(); | ||
expect(progress.getAttribute('aria-labelledby')).toBe(label.id); | ||
expect(label.htmlFor).toBeFalsy(); | ||
}); | ||
}); |
21 changes: 21 additions & 0 deletions
21
packages/react-components/react-field/src/components/ProgressField/ProgressField.tsx
This file contains 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,21 @@ | ||
import * as React from 'react'; | ||
import { Progress } from '@fluentui/react-progress'; | ||
import type { ForwardRefComponent } from '@fluentui/react-utilities'; | ||
import type { FieldProps } from '../../Field'; | ||
import { getFieldClassNames, renderField_unstable, useFieldStyles_unstable, useField_unstable } from '../../Field'; | ||
|
||
export type ProgressFieldProps = FieldProps<typeof Progress>; | ||
|
||
export const progressFieldClassNames = getFieldClassNames('ProgressField'); | ||
|
||
export const ProgressField: ForwardRefComponent<ProgressFieldProps> = React.forwardRef((props, ref) => { | ||
const state = useField_unstable(props, ref, { | ||
component: Progress, | ||
classNames: progressFieldClassNames, | ||
labelConnection: 'aria-labelledby', | ||
}); | ||
useFieldStyles_unstable(state); | ||
return renderField_unstable(state); | ||
}); | ||
|
||
ProgressField.displayName = 'ProgressField'; |
1 change: 1 addition & 0 deletions
1
packages/react-components/react-field/src/components/ProgressField/index.ts
This file contains 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 @@ | ||
export * from './ProgressField'; |
This file contains 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
14 changes: 14 additions & 0 deletions
14
...s/react-components/react-field/src/stories/ProgressField/ProgressFieldDefault.stories.tsx
This file contains 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,14 @@ | ||
import * as React from 'react'; | ||
import type { ProgressFieldProps } from '@fluentui/react-field'; | ||
import { ProgressField } from '@fluentui/react-field'; | ||
|
||
export const Default = (props: Partial<ProgressFieldProps>) => ( | ||
<ProgressField | ||
label="Example Progress field" | ||
value={0.75} | ||
validationState="success" | ||
validationMessage="This is a success message" | ||
hint="This is a hint message" | ||
{...props} | ||
/> | ||
); |
14 changes: 14 additions & 0 deletions
14
...ct-components/react-field/src/stories/ProgressField/ProgressFieldDescription.md
This file contains 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,14 @@ | ||
ProgressField adds a Label, validation message, and hint text to the Progress control. | ||
|
||
<!-- Don't allow prettier to collapse code block into single line --> | ||
<!-- prettier-ignore --> | ||
> **⚠️ Preview components are considered unstable:** | ||
> | ||
> ```jsx | ||
> | ||
> import { ProgressField } from '@fluentui/react-components/unstable'; | ||
> | ||
> ``` | ||
> | ||
> - Features and APIs may change before final release | ||
> - Please contact us if you intend to use this in your product |
17 changes: 17 additions & 0 deletions
17
packages/react-components/react-field/src/stories/ProgressField/index.stories.tsx
This file contains 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,17 @@ | ||
import { ProgressField } from '@fluentui/react-field'; | ||
|
||
import descriptionMd from './ProgressFieldDescription.md'; | ||
|
||
export { Default } from './ProgressFieldDefault.stories'; | ||
|
||
export default { | ||
title: 'Preview Components/Field/ProgressField', | ||
component: ProgressField, | ||
parameters: { | ||
docs: { | ||
description: { | ||
component: descriptionMd, | ||
}, | ||
}, | ||
}, | ||
}; |
This file contains 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 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