1
- import * as React from ' react' ;
2
- import { List } from ' @fluentui/react/lib/List' ;
3
- import { Spinner } from ' @fluentui/react/lib/Spinner' ;
4
- import { Image , ImageFit } from ' @fluentui/react/lib/Image' ;
5
- import { IDocumentLibraryBrowserProps } from ' ./IDocumentLibraryBrowserProps' ;
6
- import { IDocumentLibraryBrowserState } from ' ./IDocumentLibraryBrowserState' ;
7
- import { ILibrary } from ' ../../../../services/FileBrowserService.types' ;
1
+ import * as React from " react" ;
2
+ import { Spinner } from " @fluentui/react/lib/Spinner" ;
3
+ import { Stack } from " @fluentui/react/lib/Stack" ;
4
+ import { Icon } from " @fluentui/react/lib/Icon" ;
5
+ import { IDocumentLibraryBrowserProps } from " ./IDocumentLibraryBrowserProps" ;
6
+ import { IDocumentLibraryBrowserState } from " ./IDocumentLibraryBrowserState" ;
7
+ import { ILibrary } from " ../../../../services/FileBrowserService.types" ;
8
8
9
- import { IRectangle } from '@fluentui/react/lib/Utilities' ;
10
- import { DefaultButton } from '@fluentui/react/lib/Button' ;
11
-
12
- import styles from './DocumentLibraryBrowser.module.scss' ;
13
- import * as strings from 'ControlStrings' ;
14
-
15
- /**
16
- * Rows per page
17
- */
18
- export const ROWS_PER_PAGE = 3 ;
19
-
20
- /**
21
- * Maximum row height
22
- */
23
- export const MAX_ROW_HEIGHT = 250 ;
9
+ import styles from "./DocumentLibraryBrowser.module.scss" ;
10
+ import * as strings from "ControlStrings" ;
24
11
25
12
/**
26
13
* This would have been better done as an Office Fabric TileList, but it isn't available yet for production use
27
14
*/
28
- export class DocumentLibraryBrowser extends React . Component < IDocumentLibraryBrowserProps , IDocumentLibraryBrowserState > {
29
- private _columnCount : number ;
30
- private _columnWidth : number ;
31
- private _rowHeight : number ;
15
+ export class DocumentLibraryBrowser extends React . Component <
16
+ IDocumentLibraryBrowserProps ,
17
+ IDocumentLibraryBrowserState
18
+ > {
32
19
33
20
constructor ( props : IDocumentLibraryBrowserProps ) {
34
21
super ( props ) ;
@@ -54,58 +41,42 @@ export class DocumentLibraryBrowser extends React.Component<IDocumentLibraryBrow
54
41
return (
55
42
< div className = { styles . documentLibraryBrowserContainer } >
56
43
{ isLoading && < Spinner label = { strings . Loading } /> }
57
- < List
58
- className = { styles . filePickerFolderCardGrid }
59
- items = { lists }
60
- getItemCountForPage = { this . _getItemCountForPage }
61
- getPageHeight = { this . _getPageHeight }
62
- renderedWindowsAhead = { 4 }
63
- onRenderCell = { this . _onRenderLibraryTile }
64
- />
44
+ < Stack wrap horizontal horizontalAlign = "start" verticalAlign = "center" >
45
+ { lists . map ( ( list , index ) =>
46
+ this . _onRenderLibraryTile ( list , index )
47
+ ) }
48
+ </ Stack >
65
49
</ div >
66
50
) ;
67
51
}
68
52
69
- /**
70
- * Calculates how many items there should be in the page
71
- */
72
- private _getItemCountForPage = ( itemIndex : number , surfaceRect : IRectangle ) : number => {
73
- if ( itemIndex === 0 ) {
74
- this . _columnCount = Math . ceil ( surfaceRect . width / MAX_ROW_HEIGHT ) ;
75
- this . _columnWidth = Math . floor ( surfaceRect . width / this . _columnCount ) ;
76
- this . _rowHeight = this . _columnWidth ;
77
- }
78
-
79
- return this . _columnCount * ROWS_PER_PAGE ;
80
- }
81
-
82
- /**
83
- * Gets the height of a list "page"
84
- */
85
- private _getPageHeight = ( ) : number => {
86
- return this . _rowHeight * ROWS_PER_PAGE ;
87
- }
88
-
89
- /**
53
+ /**
90
54
* Renders a cell for search suggestions
91
55
*/
92
56
private _onRenderLibraryTile = ( item : ILibrary , index : number | undefined ) : JSX . Element => {
93
- const imgSrc = item . iconPath ? item . iconPath : "" ;
94
57
95
58
return (
96
59
< div
60
+ key = { item . absoluteUrl }
97
61
className = { styles . filePickerFolderCardTile }
98
62
data-is-focusable = { true }
99
- style = { {
100
- width : 100 / this . _columnCount + '%'
101
- } }
63
+ onClick = { ( _event ) => this . _handleOpenLibrary ( item ) }
102
64
>
103
- < div className = { styles . filePickerFolderCardSizer } >
104
- < div className = { styles . filePickerFolderCardPadder } >
105
- < Image src = { imgSrc } className = { styles . filePickerFolderCardImage } imageFit = { ImageFit . cover } />
106
- < DefaultButton className = { styles . filePickerFolderCardLabel } onClick = { ( _event ) => this . _handleOpenLibrary ( item ) } > { item . title } </ DefaultButton >
65
+ < div className = { styles . filePickerFolderCardImage } >
66
+ < Icon
67
+ className = { styles . filePickerFolderCoverBack }
68
+ imageProps = { {
69
+ src : strings . FolderBackPlate
70
+ } } />
71
+ < Icon
72
+ className = { styles . filePickerFolderCoverFront }
73
+ imageProps = { {
74
+ src : strings . FolderFrontPlate
75
+ } } />
76
+ </ div >
77
+ < div className = { styles . filePickerFolderCardTitle } >
78
+ { item . title }
107
79
</ div >
108
- </ div >
109
80
</ div >
110
81
) ;
111
82
}
0 commit comments