Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ListView - Added ability to apply header styling #1700

Open
wants to merge 1 commit into
base: dev
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
5 changes: 5 additions & 0 deletions src/controls/listView/IListView.ts
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,11 @@ export interface IListViewProps {
* Class name to apply additional styles on list view
*/
listClassName?: string;
/**
* Class name to apply additional styles on list view header
* (min-height 17px)
*/
headerClassName?: string;
/**
* Custom sorting function.
* @returns sorted collection of items
Expand Down
31 changes: 27 additions & 4 deletions src/controls/listView/ListView.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -572,17 +572,40 @@ export class ListView extends React.Component<IListViewProps, IListViewState> {
return null;
}

const headerProps = {
...props,
className: this.props.headerClassName,
styles: {
root: {
lineHeight: "normal",
minHeight: '17px',
'.ms-DetailsHeader-cell': {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Referencing the class name is likely to fail in the future as we have no control over style updates from external components. Can you think of a more reliable approach?

whiteSpace: 'normal',
lineHeight: 'normal',
height: '100%',
},
'.ms-DetailsHeader-cellTitle': {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same as above regarding class name

height: '100%',
display: 'flex',
flexDirection: 'row',
alignItems: 'center',
flexWrap: 'nowrap',
justifyContent: 'flex-start',
},
...props.styles,
},
},
}

if (this.props.stickyHeader) {
return (
<Sticky stickyPosition={StickyPositionType.Header} isScrollSynced>
{defaultRender({
...props,
})}
{defaultRender(headerProps)}
</Sticky>
);
}

return defaultRender(props);
return defaultRender(headerProps)
}
/**
* Default React component render method
Expand Down
6 changes: 6 additions & 0 deletions src/webparts/controlsTest/components/ControlsTest.module.scss
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,12 @@ $themePrimary: '[theme:themePrimary, default:#0078d7]';
.listViewWrapper {
height: 200px;
}

.listViewHeader {
padding-top: 1px;
padding-bottom: 1px;
height: 25px;
}
}

.dialogContainer {
Expand Down
1 change: 1 addition & 0 deletions src/webparts/controlsTest/components/ControlsTest.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -1549,6 +1549,7 @@ export default class ControlsTest extends React.Component<IControlsTestProps, IC
onDrop={this._getDropFiles}
stickyHeader={true}
className={styles.listViewWrapper}
headerClassName={styles.listViewHeader}
// defaultFilter="Team"
/>
</div>
Expand Down