Skip to content

Commit

Permalink
Merge pull request #37 from SharePoint/FileTypeIcon-fix
Browse files Browse the repository at this point in the history
File type icon fix
  • Loading branch information
estruyf authored Jan 16, 2018
2 parents 2969370 + 71f90ab commit 3c7c20d
Show file tree
Hide file tree
Showing 5 changed files with 26 additions and 9 deletions.
6 changes: 5 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,12 @@
# Releases

## 1.1.3

- `FileTypeIcon` icon fixed. This control should now also work in SPFx extensions.

## 1.1.2

- Fix for WebPartTitle control to inherit color
- Fix for `WebPartTitle` control to inherit color
- Improved telemetry with some object checks

## 1.1.1
Expand Down
4 changes: 4 additions & 0 deletions docs/documentation/docs/about/release-notes.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# Releases

## 1.1.3

- `FileTypeIcon` icon fixed. This control should now also work in SPFx extensions.

## 1.1.2

- Fix for WebPartTitle control to inherit color
Expand Down
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "@pnp/spfx-controls-react",
"description": "Reusable React controls for SharePoint Framework solutions",
"version": "1.1.2",
"version": "1.1.3",
"engines": {
"node": ">=0.10.0"
},
Expand Down Expand Up @@ -58,6 +58,6 @@
"url": "https://github.com/SharePoint/sp-dev-fx-controls-react/issues"
},
"main":"lib/index.js",

"homepage": "https://github.com/SharePoint/sp-dev-fx-controls-react"
}
7 changes: 7 additions & 0 deletions src/controls/fileTypeIcon/FileTypeIcon.module.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
@import '~office-ui-fabric-react/dist/sass/References.scss';

// Retrieve all the CSS classes for brand icons from Office UI Fabric
:global {
@import '~office-ui-fabric-react/dist/sass/mixins/BrandIcon.Mixins';
@import '~office-ui-fabric-react/dist/sass/BrandIcon';
}
14 changes: 8 additions & 6 deletions src/controls/fileTypeIcon/FileTypeIcon.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ import * as React from 'react';
import { findIndex } from '@microsoft/sp-lodash-subset';
import { IFileTypeIconProps, ApplicationType, ApplicationIconList, IconType, IconSizes, ImageSize, IImageResult, ICON_GENERIC_16, ICON_GENERIC_48, ICON_GENERIC_96 } from './IFileTypeIcon';
import * as appInsights from '../../common/appInsights';
import { Icon, IconType as IconUIType } from 'office-ui-fabric-react/lib/components/Icon';
import * as styles from './FileTypeIcon.module.scss';

const ICON_GENERIC = 'Page';
const ICON_DEFAULT_SIZE = 'icon16';
Expand Down Expand Up @@ -186,23 +188,23 @@ export class FileTypeIcon extends React.Component<IFileTypeIconProps, {}> {
const iconImage = this._getIconImageName();
// Check if the image was found, otherwise a generic image will be returned
if (typeof iconImage.image !== 'undefined' && iconImage.image !== null) {
iconElm = <div style={{ display: 'inline-block' }} className={`ms-BrandIcon--${iconImage.size} ms-BrandIcon--${iconImage.image}`}></div>;
iconElm = <Icon iconType={IconUIType.image} imageProps={{ className: `ms-BrandIcon--${iconImage.size} ms-BrandIcon--${iconImage.image}` }} />;
} else {
// Return a generic image
let imgElm = <img />;
// Check the size of the generic image which has to be returned
switch (iconImage.size) {
case 'icon16':
imgElm = <img src={ICON_GENERIC_16} />;
imgElm = <Icon iconType={IconUIType.image} imageProps={{ src: ICON_GENERIC_16 }} />;
break;
case 'icon48':
imgElm = <img src={ICON_GENERIC_48} />;
imgElm = <Icon iconType={IconUIType.image} imageProps={{ src: ICON_GENERIC_48}} />;
break;
case 'icon96':
imgElm = <img src={ICON_GENERIC_96} />;
imgElm = <Icon iconType={IconUIType.image} imageProps={{ src: ICON_GENERIC_96}} />;
break;
default:
imgElm = <img src={ICON_GENERIC_16} />;
imgElm = <Icon iconType={IconUIType.image} imageProps={{ src: ICON_GENERIC_16}} />;
break;
}

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

// Return the icon element
Expand Down

0 comments on commit 3c7c20d

Please sign in to comment.