Skip to content

Commit a927a2c

Browse files
beth-panxnmetulev
andauthored
Update file list loading progress ring from fluent ui wc (#1221)
* Update file list loading progress ring from fluent ui wc * Update package structure * Update packages/mgt-components/src/components/mgt-file-list/mgt-file-list.ts Co-authored-by: Nikola Metulev <[email protected]> Co-authored-by: Nikola Metulev <[email protected]>
1 parent 43eafb1 commit a927a2c

File tree

3 files changed

+42
-25
lines changed

3 files changed

+42
-25
lines changed

packages/mgt-components/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@
4040
"@microsoft/microsoft-graph-client": "^2.2.1",
4141
"@microsoft/microsoft-graph-types": "^2.0.0",
4242
"@microsoft/microsoft-graph-types-beta": "^0.12.0-preview",
43+
"@fluentui/web-components": "^0.22.1",
4344
"office-ui-fabric-core": "11.0.0"
4445
},
4546
"publishConfig": {

packages/mgt-components/src/components/mgt-file-list/mgt-file-list.scss

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,8 @@ $show-more-button-background-color--hover: var(
3333
--show-more-button-background-color--hover,
3434
$file-item-background-color--hover
3535
);
36+
$progress-ring-size: var(--progress-ring-size, 24px);
37+
3638
:host {
3739
font-family: $font-family;
3840
font-size: $font-size;
@@ -89,6 +91,12 @@ mgt-file-item .file-list-wrapper {
8991
}
9092
}
9193

94+
.progress-ring {
95+
margin: 4px auto;
96+
width: $progress-ring-size;
97+
height: $progress-ring-size;
98+
}
99+
92100
.show-more {
93101
text-align: center;
94102
font-size: $show-more-button-font-size;

packages/mgt-components/src/components/mgt-file-list/mgt-file-list.ts

Lines changed: 33 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ import {
1313
ProviderState
1414
} from '@microsoft/mgt-element';
1515
import { DriveItem } from '@microsoft/microsoft-graph-types';
16-
import { customElement, html, property, TemplateResult } from 'lit-element';
16+
import { customElement, html, internalProperty, property, TemplateResult } from 'lit-element';
1717
import { repeat } from 'lit-html/directives/repeat';
1818
import {
1919
clearFilesCache,
@@ -40,6 +40,8 @@ import { styles } from './mgt-file-list-css';
4040
import { strings } from './strings';
4141
import { MgtFile } from '../mgt-file/mgt-file';
4242

43+
export { FluentDesignSystemProvider, FluentProgressRing } from '@fluentui/web-components';
44+
4345
/**
4446
* The File List component displays a list of multiple folders and files by
4547
* using the file/folder name, an icon, and other properties specicified by the developer.
@@ -69,6 +71,7 @@ import { MgtFile } from '../mgt-file/mgt-file';
6971
* @cssprop --show-more-button-padding - {String} Show more button padding
7072
* @cssprop --show-more-button-border-bottom-right-radius - {String} Show more button bottom right radius
7173
* @cssprop --show-more-button-border-bottom-left-radius - {String} Show more button bottom left radius
74+
* @cssprop --progress-ring-size -{String} Progress ring height and width
7275
*/
7376

7477
@customElement('mgt-file-list')
@@ -400,6 +403,8 @@ export class MgtFileList extends MgtTemplatedComponent {
400403
// tracking user arrow key input of selection for accessibility purpose
401404
private _focusedItemIndex: number = -1;
402405

406+
@internalProperty() private _isLoadingMore: boolean;
407+
403408
constructor() {
404409
super();
405410

@@ -525,9 +530,11 @@ export class MgtFileList extends MgtTemplatedComponent {
525530
* @memberof MgtFileList
526531
*/
527532
protected renderMoreFileButton(): TemplateResult {
528-
if (this.isLoadingState) {
533+
if (this._isLoadingMore) {
529534
return html`
530-
<mgt-spinner></mgt-spinner>
535+
<fluent-design-system-provider use-defaults>
536+
<fluent-progress-ring role="progressbar" viewBox="0 0 8 8" class="progress-ring"></fluent-progress-ring>
537+
</fluent-design-system-provider>
531538
`;
532539
} else {
533540
return html`<a id="show-more" class="show-more" @click=${() => this.renderNextPage()} tabindex="0" @keydown=${
@@ -768,28 +775,6 @@ export class MgtFileList extends MgtTemplatedComponent {
768775
* @memberof MgtFileList
769776
*/
770777
protected async renderNextPage() {
771-
const root = this.renderRoot.querySelector('file-list-wrapper');
772-
if (root && root.animate) {
773-
// play back
774-
root.animate(
775-
[
776-
{
777-
height: 'auto',
778-
transformOrigin: 'top left'
779-
},
780-
{
781-
height: 'auto',
782-
transformOrigin: 'top left'
783-
}
784-
],
785-
{
786-
duration: 1000,
787-
easing: 'ease-in-out',
788-
fill: 'both'
789-
}
790-
);
791-
}
792-
793778
// render next page from cache if exists, or else use iterator
794779
if (this._preloadedFiles.length > 0) {
795780
this.files = [
@@ -798,7 +783,30 @@ export class MgtFileList extends MgtTemplatedComponent {
798783
];
799784
} else {
800785
if (this.pageIterator.hasNext) {
786+
this._isLoadingMore = true;
787+
const root = this.renderRoot.querySelector('file-list-wrapper');
788+
if (root && root.animate) {
789+
// play back
790+
root.animate(
791+
[
792+
{
793+
height: 'auto',
794+
transformOrigin: 'top left'
795+
},
796+
{
797+
height: 'auto',
798+
transformOrigin: 'top left'
799+
}
800+
],
801+
{
802+
duration: 1000,
803+
easing: 'ease-in-out',
804+
fill: 'both'
805+
}
806+
);
807+
}
801808
await fetchNextAndCacheForFilesPageIterator(this.pageIterator);
809+
this._isLoadingMore = false;
802810
this.files = this.pageIterator.value;
803811
}
804812
}

0 commit comments

Comments
 (0)