Skip to content

Commit 1539f8e

Browse files
authored
Merge pull request #38 from SharePoint/dev
FileTypeIcon bug fix
2 parents c652fcf + 3c7c20d commit 1539f8e

File tree

5 files changed

+26
-9
lines changed

5 files changed

+26
-9
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: 8 additions & 6 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,23 +188,23 @@ 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 = <Icon iconType={IconUIType.image} imageProps={{ className: `ms-BrandIcon--${iconImage.size} ms-BrandIcon--${iconImage.image}` }} />;
190192
} else {
191193
// Return a generic image
192194
let imgElm = <img />;
193195
// Check the size of the generic image which has to be returned
194196
switch (iconImage.size) {
195197
case 'icon16':
196-
imgElm = <img src={ICON_GENERIC_16} />;
198+
imgElm = <Icon iconType={IconUIType.image} imageProps={{ src: ICON_GENERIC_16 }} />;
197199
break;
198200
case 'icon48':
199-
imgElm = <img src={ICON_GENERIC_48} />;
201+
imgElm = <Icon iconType={IconUIType.image} imageProps={{ src: ICON_GENERIC_48}} />;
200202
break;
201203
case 'icon96':
202-
imgElm = <img src={ICON_GENERIC_96} />;
204+
imgElm = <Icon iconType={IconUIType.image} imageProps={{ src: ICON_GENERIC_96}} />;
203205
break;
204206
default:
205-
imgElm = <img src={ICON_GENERIC_16} />;
207+
imgElm = <Icon iconType={IconUIType.image} imageProps={{ src: ICON_GENERIC_16}} />;
206208
break;
207209
}
208210

@@ -215,7 +217,7 @@ export class FileTypeIcon extends React.Component<IFileTypeIconProps, {}> {
215217
} else {
216218
// Return the icon font element
217219
const iconClass = this._getIconClassName();
218-
iconElm = <i className={`ms-Icon ms-Icon--${iconClass}`} aria-hidden='true'></i>;
220+
iconElm = <Icon iconName={iconClass} />;
219221
}
220222

221223
// Return the icon element

0 commit comments

Comments
 (0)