Skip to content

Commit 21e4246

Browse files
Mnickiigavinbarron
andauthored
feature: update File List component to Fluent UI (#1833)
* update: update file list, file-upload to fluent design * update: upload button style * update: change variable naming to snake_case * update: change file conflict style to include keeping both files * update: remove maximum files in file upload * update: update button colour * update: update upload status * update: fix rtl padding * update: fix file rtl padding * Update packages/mgt-components/src/components/mgt-file-list/mgt-file-upload/strings.ts Co-authored-by: Gavin Barron <[email protected]> * update: fix dark theme * update: fix accessibility issues --------- Co-authored-by: Gavin Barron <[email protected]>
1 parent d7247a0 commit 21e4246

File tree

14 files changed

+92
-147
lines changed

14 files changed

+92
-147
lines changed

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

Lines changed: 5 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -20,19 +20,12 @@ $file-list-box-shadow: var(
2020
);
2121
$file-list-border: var(--file-list-border, none);
2222
$file-item-border-radius: var(--file-item-border-radius, 2px);
23-
$file-item-margin: var(--file-item-margin, 0 4px);
23+
$file-item-margin: var(--file-item-margin, 0 4px 0 4px);
2424
$show-more-button-font-size: var(--show-more-button-font-size, 12px);
2525
$show-more-button-padding: var(--show-more-button-padding, 6px);
2626
$show-more-button-border-bottom-right-radius: var(--show-more-button-border-bottom-right-radius, 8px);
2727
$show-more-button-border-bottom-left-radius: var(--show-more-button-border-bottom-left-radius, 8px);
28-
$show-more-button-background-color: var(
29-
--show-more-button-background-color,
30-
set-var(background-color__sub2, $theme-default, $common)
31-
);
32-
$show-more-button-background-color--hover: var(
33-
--show-more-button-background-color--hover,
34-
$file-item-background-color--hover
35-
);
28+
$show-more-button-background-color--hover: var(--show-more-button-background-color--hover, $show_more_button_hover);
3629
$progress-ring-size: var(--progress-ring-size, 24px);
3730

3831
:host {
@@ -64,6 +57,9 @@ $progress-ring-size: var(--progress-ring-size, 24px);
6457
border-right: var(--file-item-border-right, none);
6558
border-bottom: var(--file-item-border-bottom, none);
6659
margin: $file-item-margin;
60+
padding-inline-start: var(--file-item-padding-inline-start, 24px);
61+
padding-top: var(--file-item-padding-top, 10px);
62+
padding-bottom: var(--file-item-padding-bottom, 8px);
6763
border-radius: $file-item-border-radius;
6864
cursor: pointer;
6965

@@ -74,7 +70,6 @@ $progress-ring-size: var(--progress-ring-size, 24px);
7470
&:hover,
7571
&.focused {
7672
background-color: $file-item-background-color--hover;
77-
border-radius: 4px;
7873

7974
.mgt-file-item {
8075
--file-background-color: $file-item-background-color--hover;
@@ -105,7 +100,6 @@ $progress-ring-size: var(--progress-ring-size, 24px);
105100
border-bottom-right-radius: $show-more-button-border-bottom-right-radius;
106101
border-bottom-left-radius: $show-more-button-border-bottom-left-radius;
107102
cursor: pointer;
108-
background-color: $show-more-button-background-color;
109103

110104
&:hover {
111105
background-color: $show-more-button-background-color--hover;

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

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,12 @@
1010
$file-list: (
1111
list__item__background-color--hover: (
1212
_var: --file-item-background-color--hover,
13-
light: rgba(0, 0, 0, 0.1),
13+
light: rgba(247, 247, 247, 1),
1414
dark: #0078d4
1515
),
1616
list__item__background-color--active: (
1717
_var: --file-item-background-color--active,
18-
light: rgba(0, 0, 0, 0.05),
18+
light: rgba(251, 251, 251, 1),
1919
dark: #238ada
2020
),
2121
list__background-color: (
@@ -36,12 +36,12 @@ $file-list: (
3636
upload__dialog__content__background-color: (
3737
_var: --file-upload-dialog-content-background-color,
3838
light: rgb(255, 255, 255),
39-
dark: rgb(74, 74, 74)
39+
dark: #787878
4040
),
4141
upload__dialog__content__color: (
4242
_var: --file-upload-dialog-content-color,
4343
light: rgb(50, 49, 48),
44-
dark: rgb(255, 255, 255)
44+
dark: #000
4545
),
4646
upload__dialog__primarybutton__color: (
4747
_var: --file-upload-dialog-primarybutton-color,

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -898,6 +898,8 @@ export class MgtFileList extends MgtTemplatedComponent {
898898
const li = event.target.closest('li');
899899
const index = nodes.indexOf(li);
900900
this._focusedItemIndex = index;
901+
const clickedItem = fileList.children[this._focusedItemIndex];
902+
this.updateItemBackgroundColor(fileList, clickedItem, 'selected');
901903

902904
for (let i = 0; i < fileList.children.length; i++) {
903905
fileList.children[i].classList.remove('focused');

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

Lines changed: 22 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -25,36 +25,40 @@ $file-upload-dialog-primarybutton-background-color: set-var(
2525
$file-upload-button-background-color: set-var(upload__button__background-color, $theme-default, $file-upload);
2626
$file-item-background-color--hover: set-var(list__item__background-color--hover, $theme-default, $file-upload);
2727
$file-item-background-color--active: set-var(list__item__background-color--active, $theme-default, $file-upload);
28-
$file-upload-icon-button-background-color: var(--color, inherit);
28+
$file-upload-icon-button-background-color: var(--color, fileUploadIconBackground);
2929
$file-list-box-shadow: var(
3030
--file-list-box-shadow,
3131
0px 3.2px 7.2px rgba(0, 0, 0, 0.132),
3232
0px 0.6px 1.8px rgba(0, 0, 0, 0.108)
3333
);
3434
:host .file-upload-area-button {
3535
width: 100%;
36+
--neutral-fill-hover: $file-upload-button-background-color;
37+
--neutral-fill-rest: $file-upload-button-background-color;
38+
--neutral-fill-active: $file-upload-button-background-color;
39+
--neutral-fill-focus: $file-upload-button-background-color;
3640
div {
3741
float: var(--file-upload-button-float, right);
3842
text-align: center;
3943
display: table;
40-
margin-top: 39px;
41-
margin-right: 16px;
42-
margin-left: 16px;
44+
margin-top: 30px;
45+
margin-right: 36px;
4346
}
4447

4548
fluent-button.file-upload-button {
46-
color: var(--file-upload-button-color, inherit);
49+
color: var(--file-upload-button-color, $fileButtonColour);
4750
vertical-align: middle;
48-
display: table-cell;
4951
background-color: $file-upload-button-background-color;
5052
width: 120px;
5153
height: 32px;
5254
cursor: pointer;
5355
font-size: $font-size;
5456
font-family: $font-family;
5557
position: relative;
56-
&:hover {
57-
background-color: $file-item-background-color--hover;
58+
59+
.upload-text {
60+
font-weight: 400;
61+
line-height: 20px;
5862
}
5963
}
6064

@@ -86,8 +90,7 @@ $file-list-box-shadow: var(
8690

8791
.file-upload-status {
8892
position: absolute;
89-
top: 12px;
90-
left: 16px;
93+
left: 48px;
9194
}
9295

9396
fluent-progress.file-upload-bar {
@@ -115,11 +118,11 @@ $file-list-box-shadow: var(
115118

116119
:host .mgt-file-item {
117120
--file-background-color: transparent;
121+
margin: 0 0 20px 26px;
118122
}
119123

120124
:host .upload-icon {
121-
fill: var(--file-upload-button-color, $file-upload-icon-button-background-color);
122-
height: 12px;
125+
fill: var(--file-upload-button-color, $fileButtonColour);
123126
}
124127

125128
:host .file-upload-Template {
@@ -200,11 +203,15 @@ $file-list-box-shadow: var(
200203
.file-upload-dialog-ok {
201204
height: 32px;
202205
min-width: 60px;
203-
border: 1px solid $file-upload-dialog-primarybutton-background-color;
204-
background-color: $file-upload-dialog-primarybutton-background-color;
205-
color: $file-upload-dialog-primarybutton-color;
206+
border: 1px solid rgb(138, 136, 134);
207+
background-color: $file-upload-button-background-color;
208+
color: $fileButtonColour;
206209
font-size: $font-size;
207210
margin-right: 5px;
211+
--neutral-fill-rest: $fileButtonColour;
212+
--neutral-fill-hover: $fileButtonColour;
213+
--neutral-fill-active: $fileButtonColour;
214+
--neutral-fill-focus: $fileButtonColour;
208215
}
209216

210217
.file-upload-dialog-cancel {

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

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,17 +10,17 @@
1010
$file-upload: (
1111
list__item__background-color--hover: (
1212
_var: --file-item-background-color--hover,
13-
light: rgba(0, 0, 0, 0.1),
13+
light: rgba(247, 247, 247, 1),
1414
dark: #0078d4
1515
),
1616
list__item__background-color--active: (
1717
_var: --file-item-background-color--active,
18-
light: rgba(0, 0, 0, 0.05),
18+
light: rgba(251, 251, 251, 1),
1919
dark: #238ada
2020
),
2121
upload__button__background-color: (
2222
_var: --file-upload-button-background-color,
23-
light: rgb(243, 242, 241),
23+
light: #036ac4,
2424
dark: #006cbe
2525
),
2626
upload__dialog__background-color: (
@@ -31,12 +31,12 @@ $file-upload: (
3131
upload__dialog__content__background-color: (
3232
_var: --file-upload-dialog-content-background-color,
3333
light: rgb(255, 255, 255),
34-
dark: rgb(74, 74, 74)
34+
dark: #787878
3535
),
3636
upload__dialog__content__color: (
3737
_var: --file-upload-dialog-content-color,
3838
light: rgb(50, 49, 48),
39-
dark: rgb(255, 255, 255)
39+
dark: #000
4040
),
4141
upload__dialog__primarybutton__color: (
4242
_var: --file-upload-dialog-primarybutton-color,
@@ -50,4 +50,6 @@ $file-upload: (
5050
)
5151
);
5252

53+
$fileButtonColour: #ffffff;
54+
5355
@include create-themes($file-upload);

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

Lines changed: 6 additions & 65 deletions
Original file line numberDiff line numberDiff line change
@@ -266,7 +266,6 @@ export class MgtFileUpload extends MgtBaseComponent {
266266
private _dialogCheckBox: string = '';
267267
private _applyAll: boolean = false;
268268
private _applyAllConflitBehavior: number = null;
269-
private _maximumFiles: boolean = false;
270269
private _maximumFileSize: boolean = false;
271270
private _excludedFileType: boolean = false;
272271

@@ -318,13 +317,17 @@ export class MgtFileUpload extends MgtBaseComponent {
318317
<div>
319318
<input
320319
id="file-upload-input"
320+
title="${this.strings.uploadButtonLabel}"
321+
tabindex="-1"
321322
aria-label="file upload input"
322323
type="file"
323324
multiple="true"
324325
@change="${this.onFileUploadChange}"
325326
/>
326-
<fluent-button class="file-upload-button" @click=${this.onFileUploadClick}>
327-
${getSvg(SvgIcon.Upload)}${strings.buttonUploadFile}
327+
<fluent-button class="file-upload-button" @click=${this.onFileUploadClick} label=${
328+
this.strings.uploadButtonLabel
329+
}>
330+
${getSvg(SvgIcon.Upload)} <span class="upload-text">${this.strings.buttonUploadFile}</span>
328331
</fluent-button>
329332
</div>
330333
</div>
@@ -566,7 +569,6 @@ export class MgtFileUpload extends MgtBaseComponent {
566569
const fileItemsCompleted: MgtFileUploadItem[] = [];
567570
this._applyAll = false;
568571
this._applyAllConflitBehavior = null;
569-
this._maximumFiles = false;
570572
this._maximumFileSize = false;
571573
this._excludedFileType = false;
572574

@@ -585,27 +587,6 @@ export class MgtFileUpload extends MgtBaseComponent {
585587
// Initialize variable for File validation
586588
let acceptFile = true;
587589

588-
// Exclude file based on max files upload allowed
589-
if (fileItems.length >= this.fileUploadList.maxUploadFile) {
590-
acceptFile = false;
591-
if (!this._maximumFiles) {
592-
const maximumFiles: (number | true)[] = await this.getFileUploadStatus(
593-
file,
594-
fullPath,
595-
'MaxFiles',
596-
this.fileUploadList
597-
);
598-
if (maximumFiles !== null) {
599-
if (maximumFiles[0] === 0) {
600-
return null;
601-
}
602-
if (maximumFiles[0] === 1) {
603-
this._maximumFiles = true;
604-
}
605-
}
606-
}
607-
}
608-
609590
// Exclude file based on max file size allowed
610591
if (this.fileUploadList.maxFileSize !== undefined && acceptFile) {
611592
if (file.size > this.fileUploadList.maxFileSize * 1024) {
@@ -778,46 +759,6 @@ export class MgtFileUpload extends MgtBaseComponent {
778759
return null;
779760
}
780761
break;
781-
case 'MaxFiles':
782-
fileUploadDialog.classList.add('visible');
783-
this._dialogTitle = strings.maximumFilesTitle;
784-
this._dialogContent = strings.maximumFiles.split('{MaxNumber}').join(fileUploadList.maxUploadFile.toString());
785-
this._dialogCheckBox = strings.checkApplyAll;
786-
this._dialogPrimaryButton = strings.buttonUpload;
787-
this._dialogSecondaryButton = strings.buttonReselect;
788-
super.requestStateUpdate(true);
789-
790-
return new Promise<number[]>(async resolve => {
791-
const fileUploadDialogOk: HTMLElement = this.renderRoot.querySelector('.file-upload-dialog-ok');
792-
const fileUploadDialogCancel: HTMLElement = this.renderRoot.querySelector('.file-upload-dialog-cancel');
793-
const fileUploadDialogClose: HTMLElement = this.renderRoot.querySelector('.file-upload-dialog-close');
794-
const fileUploadDialogCheck: HTMLInputElement = this.renderRoot.querySelector('#file-upload-dialog-check');
795-
fileUploadDialogCheck.checked = false;
796-
fileUploadDialogCheck.classList.add('hide');
797-
798-
// Remove and include event listener to validate options.
799-
fileUploadDialogOk.removeEventListener('click', onOkDialogClick);
800-
fileUploadDialogCancel.removeEventListener('click', onCancelDialogClick);
801-
fileUploadDialogClose.removeEventListener('click', onCancelDialogClick);
802-
fileUploadDialogOk.addEventListener('click', onOkDialogClick);
803-
fileUploadDialogCancel.addEventListener('click', onCancelDialogClick);
804-
fileUploadDialogClose.addEventListener('click', onCancelDialogClick);
805-
806-
// tslint:disable-next-line: completed-docs
807-
function onOkDialogClick() {
808-
fileUploadDialog.classList.remove('visible');
809-
// Continue upload
810-
resolve([1]);
811-
}
812-
813-
// tslint:disable-next-line: completed-docs
814-
function onCancelDialogClick() {
815-
fileUploadDialog.classList.remove('visible');
816-
// Cancel all
817-
resolve([0]);
818-
}
819-
});
820-
break;
821762
case 'ExcludedFileType':
822763
fileUploadDialog.classList.add('visible');
823764
this._dialogTitle = strings.fileTypeTitle;

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

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,10 @@ export const strings = {
2121
buttonOk: 'OK',
2222
buttonCancel: 'Cancel',
2323
buttonUpload: 'Upload',
24-
buttonKeep: 'Keep',
24+
buttonKeep: 'Keep both',
2525
buttonReplace: 'Replace',
2626
buttonReselect: 'Reselect',
2727
fileReplaceTitle: 'Replace file',
28-
fileReplace: 'Do you want to replace the file "{FileName}" or keep file with new name?'
28+
fileReplace: 'Do you want to replace the file "{FileName}" or keep both files?',
29+
uploadButtonLabel: 'File upload button'
2930
};

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

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ mgt-file .item {
5050
}
5151

5252
&__details {
53-
padding: 0 0 0 14px;
53+
padding-inline-start: var(--file-padding-inline-start, 14px);
5454

5555
.line1 {
5656
font-size: $font-size;
@@ -83,7 +83,6 @@ mgt-file .item {
8383
direction: rtl;
8484
&__details {
8585
direction: rtl;
86-
padding: 0 14px 0 0;
8786
}
8887
}
8988
}

packages/mgt-components/src/components/mgt-person-card/mgt-person-card.scss

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -411,7 +411,7 @@ $person-card-nav-back-arrow-hover-color: var(--person-card-nav-back-arrow-hover-
411411
&:hover {
412412
cursor: pointer;
413413
color: $person-card-show-more-hover-color;
414-
background-color: $greyHover;
414+
background-color: $gray_hover;
415415
}
416416
}
417417

packages/mgt-components/src/components/mgt-person-card/sections/mgt-person-card-files/mgt-person-card-files.scss

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@
3333
padding: 11px 20px;
3434

3535
&:hover {
36-
background-color: $greyHover;
36+
background-color: $gray_hover;
3737
cursor: pointer;
3838
}
3939

0 commit comments

Comments
 (0)