Skip to content

Commit

Permalink
Upgrade to font awesome 5.x finos#3002
Browse files Browse the repository at this point in the history
-show warning for renamed icons

CTCTOWALTZ-926
  • Loading branch information
kamransaleem committed May 15, 2018
1 parent 3175086 commit e3dd304
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 19 deletions.
24 changes: 8 additions & 16 deletions waltz-ng/client/widgets/icon-utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -468,26 +468,26 @@ const faReplacements = _
.chain(faV4Shims)
.map(arr => ({
previous: arr[0],
class: arr[1],
iconSet: arr[1],
current: arr[2]
}))
.keyBy('previous')
.value();


function mkNamespace(name) {
export function mkIconSetName(currentIconSet, name) {
if (faReplacements[name]) {
const namespace = faReplacements[name].class;
if (namespace === 'fab') {
console.warn(`Icon [${name}] namespace updated to [${namespace}]`);
return `fa ${namespace}`;
const iconSet = faReplacements[name].iconSet;
if (iconSet && iconSet !== currentIconSet) {
console.warn(`Icon [${name}] namespace updated to [${iconSet}]`);
return `${iconSet}`;
}
}
return 'fa';
return currentIconSet;
}


function mkCurrentName(name) {
export function mkCurrentName(name) {
if (faReplacements[name]) {
const currentName = faReplacements[name].current;
if (currentName) {
Expand All @@ -498,11 +498,3 @@ function mkCurrentName(name) {
return `fa-${name}`;

}


export function mkIconClasses(name) {
return [
mkNamespace(name),
mkCurrentName(name)
];
}
13 changes: 10 additions & 3 deletions waltz-ng/client/widgets/icon.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,12 @@
*/

import '@fortawesome/fontawesome-free/js/all'
import {mkIconClasses} from './icon-utils';
import {mkCurrentName, mkIconSetName} from './icon-utils';
import {initialiseData} from "../common/index";

const bindings = {
name: '@',
iconSet: '@',
size: '@',
flip: '@',
rotate: '@',
Expand All @@ -31,15 +33,20 @@ const bindings = {
spin: '@'
};

const initialState = {
iconSet: 'fa'
};


const template = '<span style="font-size: smaller; opacity: 0.8;"><i ng-class="$ctrl.classNames"/></span>';


function controller() {
const vm = this;
const vm = initialiseData(this, initialState);
vm.$onChanges = () => {
vm.classNames = [
mkIconClasses(vm.name).join(' '),
mkIconSetName(vm.iconSet, vm.name),
mkCurrentName(vm.name),
vm.flip ? `fa-flip-${vm.flip}` : '',
vm.rotate ? `fa-rotate-${vm.rotate}` : '',
vm.size ? `fa-${vm.size}` : '',
Expand Down

0 comments on commit e3dd304

Please sign in to comment.