Skip to content

Commit 71dff8b

Browse files
committed
Merge branch 'MonalisaBaltatescu-feature/listview-styles' into dev
2 parents a32a00b + c681f3f commit 71dff8b

File tree

5 files changed

+49
-33
lines changed

5 files changed

+49
-33
lines changed

docs/documentation/docs/controls/ListView.md

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,9 @@ import { ListView, IViewField, SelectionMode, GroupOrder, IGrouping } from "@pnp
3737
groupByFields={groupByFields}
3838
dragDropFiles={true}
3939
onDrop={this._getDropFiles}
40-
stickyHeader={true} />
40+
stickyHeader={true}
41+
className={styles.listWrapper}
42+
listClassName={styles.list} />
4143
```
4244
- The control provides full text filtering through all the columns. If you want to execute filtering on the specified columns, you can use syntax : `<ColumndName>`:`<FilterValue>`. Use `':'` as a separator between column name and value. Control support both `'fieldName'` and `'name'` properties of IColumn interface.
4345

@@ -98,6 +100,8 @@ The ListView control can be configured with the following properties:
98100
| onDrop | file | no | Event handler returns files from drag and drop. |
99101
| stickyHeader | boolean | no | Specifies if the header of the `ListView`, including search box, is sticky |
100102
| sortItems | (items: any[], columnName: string, descending: boolean) =&gt; any[] | no | Custom sorting function to handle sorting by column |
103+
| className | string | no | Class name to apply additional styles on list view wrapper |
104+
| listClassName | string | no | Class name to apply additional styles on list view |
101105

102106
The `IViewField` has the following implementation:
103107

src/controls/listView/IListView.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,14 @@ export interface IListViewProps {
6868
* Set to false by default
6969
*/
7070
stickyHeader?: boolean;
71+
/**
72+
* Class name to apply additional styles on list view wrapper
73+
*/
74+
className?: string;
75+
/**
76+
* Class name to apply additional styles on list view
77+
*/
78+
listClassName?: string;
7179
/**
7280
* Custom sorting function.
7381
* @returns sorted collection of items

src/controls/listView/ListView.tsx

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -30,14 +30,14 @@ const classNames = mergeStyleSets({
3030
/**
3131
* Wrap the listview in a scrollable pane if sticky header = true
3232
*/
33-
const ListViewWrapper = ({ stickyHeader, children }) => (stickyHeader ?
34-
<div className={classNames.wrapper} >
35-
<ScrollablePane scrollbarVisibility={ScrollbarVisibility.auto}>
36-
{children}
37-
</ScrollablePane>
38-
</div>
39-
: children
40-
);
33+
const ListViewWrapper = ({ stickyHeader, children, className }) => (stickyHeader ?
34+
<div className={`${classNames.wrapper} ${className ?? ""}`} >
35+
<ScrollablePane scrollbarVisibility={ScrollbarVisibility.auto}>
36+
{children}
37+
</ScrollablePane>
38+
</div>
39+
: children
40+
);
4141

4242
/**
4343
* Lock the searchbox when scrolling if sticky header = true
@@ -580,7 +580,7 @@ export class ListView extends React.Component<IListViewProps, IListViewState> {
580580
public render(): React.ReactElement<IListViewProps> {
581581
let groupProps: IGroupRenderProps = {};
582582

583-
let { showFilter, filterPlaceHolder, dragDropFiles, stickyHeader, selectionMode, compact } = this.props;
583+
let { showFilter, filterPlaceHolder, dragDropFiles, stickyHeader, selectionMode, compact, className, listClassName } = this.props;
584584
let { filterValue, items, columns, groups } = this.state;
585585

586586
// Check if selection mode is single selection,
@@ -595,7 +595,7 @@ export class ListView extends React.Component<IListViewProps, IListViewState> {
595595
}
596596

597597
return (
598-
<ListViewWrapper stickyHeader={!!this.props.stickyHeader}>
598+
<ListViewWrapper stickyHeader={!!stickyHeader} className={className}>
599599
<DragDropFiles enable={dragDropFiles}
600600
iconName="BulkUpload"
601601
labelMessage={strings.UploadFileHeader}
@@ -607,7 +607,7 @@ export class ListView extends React.Component<IListViewProps, IListViewState> {
607607
} >
608608
{
609609
showFilter &&
610-
<SearchBoxWrapper stickyHeader={!!this.props.stickyHeader}>
610+
<SearchBoxWrapper stickyHeader={!!stickyHeader}>
611611
<SearchBox placeholder={filterPlaceHolder || strings.ListViewFilterLabel} onSearch={this._updateFilterValue} onChange={(e, value) => this._updateFilterValue(value)} value={filterValue} />
612612
</SearchBoxWrapper>
613613
}
@@ -623,6 +623,7 @@ export class ListView extends React.Component<IListViewProps, IListViewState> {
623623
compact={compact}
624624
setKey='ListViewControl'
625625
groupProps={groupProps}
626+
className={listClassName}
626627
onRenderDetailsHeader={this._onRenderDetailsHeader}
627628
componentRef={ref => {
628629
if (ref) {

src/webparts/controlsTest/components/ControlsTest.module.scss

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,10 @@ $themePrimary: '[theme:themePrimary, default:#0078d7]';
8282
.carouselImageContent {
8383
height: 400px;
8484
}
85+
86+
.listViewWrapper {
87+
height: 200px;
88+
}
8589
}
8690

8791
.dialogContainer {

src/webparts/controlsTest/components/ControlsTest.tsx

Lines changed: 20 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -438,7 +438,7 @@ export default class ControlsTest extends React.Component<IControlsTestProps, IC
438438
canMoveNext: true,
439439
currentCarouselElement: this.carouselElements[0],
440440
comboBoxListItemPickerListId: '0ffa51d7-4ad1-4f04-8cfe-98209905d6da',
441-
comboBoxListItemPickerIds: [{Id: 1, Title: '111'}],
441+
comboBoxListItemPickerIds: [{ Id: 1, Title: '111' }],
442442
treeViewSelectedKeys: ['gc1', 'gc3'],
443443
showAnimatedDialog: false,
444444
showCustomisedAnimatedDialog: false,
@@ -1290,21 +1290,20 @@ export default class ControlsTest extends React.Component<IControlsTestProps, IC
12901290
</DragDropFiles>
12911291
<br></br>
12921292

1293-
1294-
<ListView items={this.state.items}
1295-
viewFields={viewFields}
1296-
iconFieldName='ServerRelativeUrl'
1297-
groupByFields={groupByFields}
1298-
compact={true}
1299-
selectionMode={SelectionMode.single}
1300-
selection={this._getSelection}
1301-
showFilter={true}
1302-
dragDropFiles={true}
1303-
onDrop={this._getDropFiles}
1304-
stickyHeader={true}
1305-
// defaultFilter="Team"
1306-
/>
1307-
1293+
<ListView items={this.state.items}
1294+
viewFields={viewFields}
1295+
iconFieldName='ServerRelativeUrl'
1296+
groupByFields={groupByFields}
1297+
compact={true}
1298+
selectionMode={SelectionMode.single}
1299+
selection={this._getSelection}
1300+
showFilter={true}
1301+
dragDropFiles={true}
1302+
onDrop={this._getDropFiles}
1303+
stickyHeader={true}
1304+
className={styles.listViewWrapper}
1305+
// defaultFilter="Team"
1306+
/>
13081307

13091308
<ChartControl type={ChartType.Bar}
13101309
data={{
@@ -1393,7 +1392,7 @@ export default class ControlsTest extends React.Component<IControlsTestProps, IC
13931392

13941393

13951394
<div className="ms-font-m">Site picker tester:
1396-
<SitePicker
1395+
<SitePicker
13971396
context={this.props.context}
13981397
label={'select sites'}
13991398
mode={'site'}
@@ -1459,7 +1458,7 @@ export default class ControlsTest extends React.Component<IControlsTestProps, IC
14591458
}} />
14601459
<PrimaryButton text="Change default items" onClick={() => {
14611460
this.setState({
1462-
comboBoxListItemPickerIds: [{Id: 2, Title: '222'}]
1461+
comboBoxListItemPickerIds: [{ Id: 2, Title: '222' }]
14631462
});
14641463
}} />
14651464

@@ -1770,7 +1769,7 @@ export default class ControlsTest extends React.Component<IControlsTestProps, IC
17701769
>
17711770
<NorthstarText size="large" weight="semibold">
17721771
Content #1
1773-
</NorthstarText>
1772+
</NorthstarText>
17741773
</Flex>
17751774
),
17761775
},
@@ -1785,7 +1784,7 @@ export default class ControlsTest extends React.Component<IControlsTestProps, IC
17851784
>
17861785
<NorthstarText size="large" weight="semibold">
17871786
Content #2
1788-
</NorthstarText>
1787+
</NorthstarText>
17891788
</Flex>
17901789
),
17911790
},
@@ -1800,7 +1799,7 @@ export default class ControlsTest extends React.Component<IControlsTestProps, IC
18001799
>
18011800
<NorthstarText size="large" weight="semibold">
18021801
Content #3
1803-
</NorthstarText>
1802+
</NorthstarText>
18041803
</Flex>
18051804
),
18061805
},

0 commit comments

Comments
 (0)