Skip to content

Add IIconProps property to IDocumentCardPreviewImage interface #5315

Description

@pschaeflein

Describe the feature that you would like added
Add IIconProps property to IDocumentCardPreviewImage interface

What component or utility would this be added to
DocumentCard

Have you discussed this feature with our team, and if so, who
No

Additional context/screenshots

  • To render a document icon, the component provides for an IIconProps property.
  • To obtain the proper IIconProps for a document, the getFileTypeIconProps method exists in the file-type-icons module.
  • The IDocumentCardPreviewImage interface has a properties for the preview image (named 'previewImageSrc' ) and for an icon to represent the document type (named iconSrc).

Rendering a document icon on a DocumentCard is a common scenario. Getting the iconSrc for the icon is very difficult. It is possible via the GlobalSettings object The following is a working example:

import { initializeFileTypeIcons, getFileTypeIconProps, FileIconType } from '@uifabric/file-type-icons';
import { GlobalSettings } from 'office-ui-fabric-react/lib/Utilities';
let globalSettings = (window as any).__globalSettings__;
iconProps = getFileTypeIconProps({ extension: doc.fileType, size: 16 });
let previewImage: IDocumentCardPreviewImage = {
  name: doc.title,
  url: doc.webUrl,
  previewImageSrc: doc.thumbnailUrl,
  iconSrc: globalSettings.icons[iconProps.iconName].code.props.src   
};

It would feel more consistent to use the following pseudo-code:

let previewImage: IDocumentCardPreviewImage = {
  name: doc.title,
  url: doc.webUrl,
  previewImageSrc: doc.thumbnailUrl,
  iconProps: iconProps
};

Metadata

Metadata

Assignees

Type

No type

Fields

No fields configured for issues without a type.

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions