From 13b299f4ff06a045269937f9e5fce5991bfca2d8 Mon Sep 17 00:00:00 2001 From: Clement Ho Date: Thu, 12 Oct 2017 12:43:00 -0500 Subject: [PATCH] Add ability to pass class name to spriteIcon helper --- app/assets/javascripts/lib/utils/common_utils.js | 6 +++++- spec/javascripts/lib/utils/common_utils_spec.js | 6 +++++- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/app/assets/javascripts/lib/utils/common_utils.js b/app/assets/javascripts/lib/utils/common_utils.js index 9f05cf16967..07899777a1e 100644 --- a/app/assets/javascripts/lib/utils/common_utils.js +++ b/app/assets/javascripts/lib/utils/common_utils.js @@ -403,7 +403,11 @@ export const setCiStatusFavicon = (pageUrl) => { }); }; -export const spriteIcon = icon => ``; +export const spriteIcon = (icon, className = '') => { + const classAttribute = className.length > 0 ? `class="${className}"` : ''; + + return ``; +}; export const imagePath = imgUrl => `${gon.asset_host || ''}${gon.relative_url_root || ''}/assets/${imgUrl}`; diff --git a/spec/javascripts/lib/utils/common_utils_spec.js b/spec/javascripts/lib/utils/common_utils_spec.js index f86f2f260c3..6613b7dee6b 100644 --- a/spec/javascripts/lib/utils/common_utils_spec.js +++ b/spec/javascripts/lib/utils/common_utils_spec.js @@ -474,7 +474,11 @@ describe('common_utils', () => { }); it('should return the svg for a linked icon', () => { - expect(gl.utils.spriteIcon('test')).toEqual(''); + expect(gl.utils.spriteIcon('test')).toEqual(''); + }); + + it('should set svg className when passed', () => { + expect(gl.utils.spriteIcon('test', 'fa fa-test')).toEqual(''); }); }); });