Skip to content

Commit 8c2bc29

Browse files
committed
Fix for FileTypeIcon in extensions
1 parent 2969370 commit 8c2bc29

File tree

5 files changed

+24
-5
lines changed

5 files changed

+24
-5
lines changed

CHANGELOG.md

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,12 @@
11
# Releases
22

3+
## 1.1.3
4+
5+
- `FileTypeIcon` icon fixed. This control should now also work in SPFx extensions.
6+
37
## 1.1.2
48

5-
- Fix for WebPartTitle control to inherit color
9+
- Fix for `WebPartTitle` control to inherit color
610
- Improved telemetry with some object checks
711

812
## 1.1.1

docs/documentation/docs/about/release-notes.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
# Releases
22

3+
## 1.1.3
4+
5+
- `FileTypeIcon` icon fixed. This control should now also work in SPFx extensions.
6+
37
## 1.1.2
48

59
- Fix for WebPartTitle control to inherit color

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "@pnp/spfx-controls-react",
33
"description": "Reusable React controls for SharePoint Framework solutions",
4-
"version": "1.1.2",
4+
"version": "1.1.3",
55
"engines": {
66
"node": ">=0.10.0"
77
},
@@ -58,6 +58,6 @@
5858
"url": "https://github.com/SharePoint/sp-dev-fx-controls-react/issues"
5959
},
6060
"main":"lib/index.js",
61-
61+
6262
"homepage": "https://github.com/SharePoint/sp-dev-fx-controls-react"
6363
}
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
@import '~office-ui-fabric-react/dist/sass/References.scss';
2+
3+
// Retrieve all the CSS classes for brand icons from Office UI Fabric
4+
:global {
5+
@import '~office-ui-fabric-react/dist/sass/mixins/BrandIcon.Mixins';
6+
@import '~office-ui-fabric-react/dist/sass/BrandIcon';
7+
}

src/controls/fileTypeIcon/FileTypeIcon.tsx

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@ import * as React from 'react';
22
import { findIndex } from '@microsoft/sp-lodash-subset';
33
import { IFileTypeIconProps, ApplicationType, ApplicationIconList, IconType, IconSizes, ImageSize, IImageResult, ICON_GENERIC_16, ICON_GENERIC_48, ICON_GENERIC_96 } from './IFileTypeIcon';
44
import * as appInsights from '../../common/appInsights';
5+
import { Icon, IconType as IconUIType } from 'office-ui-fabric-react/lib/components/Icon';
6+
import * as styles from './FileTypeIcon.module.scss';
57

68
const ICON_GENERIC = 'Page';
79
const ICON_DEFAULT_SIZE = 'icon16';
@@ -186,7 +188,8 @@ export class FileTypeIcon extends React.Component<IFileTypeIconProps, {}> {
186188
const iconImage = this._getIconImageName();
187189
// Check if the image was found, otherwise a generic image will be returned
188190
if (typeof iconImage.image !== 'undefined' && iconImage.image !== null) {
189-
iconElm = <div style={{ display: 'inline-block' }} className={`ms-BrandIcon--${iconImage.size} ms-BrandIcon--${iconImage.image}`}></div>;
191+
// iconElm = <div style={{ display: 'inline-block' }} className={`ms-BrandIcon--${iconImage.size} ms-BrandIcon--${iconImage.image}`}></div>;
192+
iconElm = <Icon iconType={IconUIType.image} imageProps={{ className: `ms-BrandIcon--${iconImage.size} ms-BrandIcon--${iconImage.image}` }} />;
190193
} else {
191194
// Return a generic image
192195
let imgElm = <img />;
@@ -215,7 +218,8 @@ export class FileTypeIcon extends React.Component<IFileTypeIconProps, {}> {
215218
} else {
216219
// Return the icon font element
217220
const iconClass = this._getIconClassName();
218-
iconElm = <i className={`ms-Icon ms-Icon--${iconClass}`} aria-hidden='true'></i>;
221+
// iconElm = <i className={`ms-Icon ms-Icon--${iconClass}`} aria-hidden='true'></i>;
222+
iconElm = <Icon iconName={iconClass} />;
219223
}
220224

221225
// Return the icon element

0 commit comments

Comments
 (0)