Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
50 commits
Select commit Hold shift + click to select a range
f84c2e4
Progress scaffold & implementation
tomi-msft Jul 21, 2022
2edb969
Update state styling and stories
tomi-msft Jul 21, 2022
e15e870
Merge branch 'master' of https://github.com/OfficeDev/office-ui-fabri…
tomi-msft Jul 21, 2022
1f2237a
update dependencies
tomi-msft Jul 21, 2022
96f8486
merge with master
tomi-msft Jul 22, 2022
b1be815
remove dup script from package.json
tomi-msft Jul 22, 2022
df8797e
Add appearance props and update styling
tomi-msft Jul 22, 2022
3e173de
Merge branch 'master' of https://github.com/OfficeDev/office-ui-fabri…
tomi-msft Jul 22, 2022
9507802
api update
tomi-msft Jul 22, 2022
622d491
add test to disabled conformance test array
tomi-msft Jul 25, 2022
58e9050
Add testOptions
tomi-msft Jul 25, 2022
771603d
Add size styling and stories
tomi-msft Aug 4, 2022
f58a3c7
Merge branch 'master' into react-progress-implementation
tomi-msft Aug 4, 2022
2b11456
api update
tomi-msft Aug 4, 2022
a7f1cc7
Merge branch 'react-progress-implementation' of https://github.com/to…
tomi-msft Aug 4, 2022
679f21e
Apply suggestions from code review
tomi-msft Aug 4, 2022
4bff1c8
react-label version update
tomi-msft Aug 4, 2022
96eb51c
merge with master
tomi-msft Aug 5, 2022
202fa99
merge with master
tomi-msft Sep 1, 2022
5ace35e
Merge branch 'master' of https://github.com/OfficeDev/office-ui-fabri…
tomi-msft Sep 1, 2022
52d74f3
Merge branch 'master' of https://github.com/OfficeDev/office-ui-fabri…
tomi-msft Sep 13, 2022
d44ddee
Update styling and package.json
tomi-msft Sep 15, 2022
858c591
change files
tomi-msft Sep 15, 2022
66074d3
Merge branch 'master' of https://github.com/OfficeDev/office-ui-fabri…
tomi-msft Sep 15, 2022
7b606d3
api update
tomi-msft Sep 15, 2022
e3fda55
fix dependency mismatch
tomi-msft Sep 15, 2022
adfe14c
Apply suggestions from code review
tomi-msft Sep 15, 2022
1655de0
Remove progressState file
tomi-msft Sep 26, 2022
f79f318
remove random spinbutton change
tomi-msft Sep 26, 2022
33a0119
change files
tomi-msft Sep 26, 2022
a3e86e6
fix dependency mismatch
tomi-msft Sep 26, 2022
e37a4ab
Add slots and update styling
tomi-msft Sep 26, 2022
96b480a
Update styling and add new slots
tomi-msft Sep 27, 2022
e3a9c72
add specificity to determinate style
tomi-msft Sep 27, 2022
0771d69
fix positioning
tomi-msft Sep 27, 2022
75243b1
remove unused file
tomi-msft Sep 27, 2022
d1bd42d
api update
tomi-msft Sep 27, 2022
c8a8e2f
Apply suggestions from code review
tomi-msft Sep 28, 2022
f7f3e98
Apply changes from code review
tomi-msft Sep 28, 2022
e6f3a9c
Clean up stories
tomi-msft Sep 29, 2022
3b567f3
Update snapshot
tomi-msft Sep 29, 2022
30b94ec
api update
tomi-msft Sep 29, 2022
387d030
Apply suggestions from code review
tomi-msft Sep 30, 2022
22d76d0
Remove animation from examples and cleanup
tomi-msft Sep 30, 2022
d81d803
cleanup
tomi-msft Sep 30, 2022
bf2697b
revert README.md
tomi-msft Sep 30, 2022
7c7b56b
update snapshot
tomi-msft Sep 30, 2022
b8d4e77
revert README.md
tomi-msft Sep 30, 2022
a28d531
Fix stories
tomi-msft Sep 30, 2022
884dd4a
api update
tomi-msft Sep 30, 2022
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import { Progress } from '@fluentui/react-progress';

console.log(Progress);

export default {
name: 'Progress',
};
Original file line number Diff line number Diff line change
Expand Up @@ -18,15 +18,23 @@ export const Progress: ForwardRefComponent<ProgressProps>;
export const progressClassNames: SlotClassNames<ProgressSlots>;

// @public
export type ProgressProps = ComponentProps<ProgressSlots> & {};
export type ProgressProps = Omit<ComponentProps<ProgressSlots>, 'size'> & {
indeterminate?: boolean;
percentComplete?: number;
thickness?: 'medium' | 'large';
};

// @public (undocumented)
export type ProgressSlots = {
root: Slot<'div'>;
root: NonNullable<Slot<'div'>>;
label?: Slot<'span'>;
bar?: NonNullable<Slot<'div'>>;
track?: NonNullable<Slot<'div'>>;
description?: Slot<'span'>;
};

// @public
export type ProgressState = ComponentState<ProgressSlots>;
export type ProgressState = ComponentState<ProgressSlots> & Required<Pick<ProgressProps, 'indeterminate' | 'percentComplete' | 'thickness'>>;

// @public
export const renderProgress_unstable: (state: ProgressState) => JSX.Element;
Expand Down
2 changes: 2 additions & 0 deletions packages/react-components/react-progress/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
"license": "MIT",
"scripts": {
"build": "just-scripts build",
"bundle-size": "bundle-size measure",
"clean": "just-scripts clean",
"code-style": "just-scripts code-style",
"just": "just-scripts",
Expand All @@ -32,6 +33,7 @@
"@fluentui/scripts": "^1.0.0"
},
"dependencies": {
"@fluentui/react-shared-contexts": "^9.0.1",
"@fluentui/react-theme": "^9.1.0",
"@fluentui/react-utilities": "^9.1.0",
"@griffel/react": "^1.3.0",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,16 @@ describe('Progress', () => {
isConformant({
Component: Progress,
displayName: 'Progress',
testOptions: {
'has-static-classnames': [
{
props: {
label: 'Test Label',
description: 'Test Description',
},
},
],
},
});

// TODO add more tests here, and create visual regression tests in /apps/vr-tests
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import type { ProgressProps } from './Progress.types';
import type { ForwardRefComponent } from '@fluentui/react-utilities';

/**
* Progress component - TODO: add more docs
* A progress bar shows the progression of a task.
*/
export const Progress: ForwardRefComponent<ProgressProps> = React.forwardRef((props, ref) => {
const state = useProgress_unstable(props, ref);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,17 +1,55 @@
import type { ComponentProps, ComponentState, Slot } from '@fluentui/react-utilities';

export type ProgressSlots = {
root: Slot<'div'>;
/**
* The root of the Progress
* The root slot receives the `className` and `style` specified directly on the `<Progress>`.
*/
root: NonNullable<Slot<'div'>>;
/**
* The title of the Progress.
* The label slot receives the styling related to the title associated with the Progress.
*/
label?: Slot<'span'>;
/**
* The animated slot of the Progress
* The bar slot receives the styling related to the loading bar associated with the Progress
*/
bar?: NonNullable<Slot<'div'>>;
/**
* The track slot of the Progress
* The track slot receives the styling related to the loading bar track associated with the Progress
*/
track?: NonNullable<Slot<'div'>>;
/**
* The description slot of the Progress
* The description slot receives the styling related to the description associated with the Progress
*/
description?: Slot<'span'>;
};

/**
* Progress Props
*/
export type ProgressProps = ComponentProps<ProgressSlots> & {};
export type ProgressProps = Omit<ComponentProps<ProgressSlots>, 'size'> & {
/**
* Prop to set whether the Progress is determinate or indeterminate
* @default false
*/
indeterminate?: boolean;
/**
* Percentage of the operation's completeness, numerically between 0 and 100.
*/
percentComplete?: number;
/**
* The thickness of the Progress bar
* @default 'medium'
*/
thickness?: 'medium' | 'large';
};

/**
* State used in rendering Progress
*/
export type ProgressState = ComponentState<ProgressSlots>;
// TODO: Remove semicolon from previous line, uncomment next line, and provide union of props to pick from ProgressProps
// & Required<Pick<ProgressProps, 'propName'>>
export type ProgressState = ComponentState<ProgressSlots> &
Required<Pick<ProgressProps, 'indeterminate' | 'percentComplete' | 'thickness'>>;
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,18 @@ exports[`Progress renders a default state 1`] = `
<div>
<div
class="fui-Progress"
role="progressbar"
>
Default Progress
<div
class="fui-Progress__track"
/>
<div
aria-valuemax="100"
aria-valuemin="0"
aria-valuenow="0"
class="fui-Progress__bar"
style="--fui-Progress--percentage: 0%;"
/>
</div>
</div>
`;
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,12 @@ import type { ProgressState, ProgressSlots } from './Progress.types';
*/
export const renderProgress_unstable = (state: ProgressState) => {
const { slots, slotProps } = getSlots<ProgressSlots>(state);

// TODO Add additional slots in the appropriate place
return <slots.root {...slotProps.root} />;
return (
<slots.root {...slotProps.root}>
{slots.label && <slots.label {...slotProps.label} />}
{slots.track && <slots.track {...slotProps.track} />}
{slots.bar && <slots.bar {...slotProps.bar} />}
{slots.description && <slots.description {...slotProps.description} />}
</slots.root>
);
};

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
import * as React from 'react';
import { getNativeElementProps, resolveShorthand, useId } from '@fluentui/react-utilities';
import type { ProgressProps, ProgressState } from './Progress.types';

/**
* Create the state required to render Progress.
*
* The returned state can be modified with hooks such as useProgressStyles_unstable,
* before being passed to renderProgress_unstable.
*
* @param props - props from this instance of Progress
* @param ref - reference to root HTMLElement of Progress
*/
export const useProgress_unstable = (props: ProgressProps, ref: React.Ref<HTMLElement>): ProgressState => {
// Props
const { thickness = 'medium', indeterminate = false, percentComplete = 0 } = props;
const baseId = useId('progress-');

const root = getNativeElementProps('div', { ref, role: 'progressbar', ...props });

const label = resolveShorthand(props.label, {
defaultProps: {
id: baseId + '__label',
},
});

const description = resolveShorthand(props.description, {
defaultProps: {
id: baseId + '__description',
},
});

const bar = resolveShorthand(props.bar, {
required: true,
defaultProps: {
'aria-valuemin': indeterminate ? undefined : 0,
'aria-valuemax': indeterminate ? undefined : 100,
'aria-valuenow': indeterminate ? undefined : Math.floor(percentComplete),
},
});

const track = resolveShorthand(props.track, {
required: true,
});

if (label && !root['aria-label'] && !root['aria-labelledby']) {
root['aria-labelledby'] = label.id;
}

const state: ProgressState = {
indeterminate,
percentComplete,
thickness,
components: {
root: 'div',
bar: 'div',
track: 'div',
label: 'span',
description: 'span',
},
root,
bar,
track,
label,
description,
};

return state;
};
Loading