Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Boxiang Sun
gitlab-ce
Commits
13b299f4
Commit
13b299f4
authored
Oct 12, 2017
by
Clement Ho
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add ability to pass class name to spriteIcon helper
parent
05f46b82
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
10 additions
and
2 deletions
+10
-2
app/assets/javascripts/lib/utils/common_utils.js
app/assets/javascripts/lib/utils/common_utils.js
+5
-1
spec/javascripts/lib/utils/common_utils_spec.js
spec/javascripts/lib/utils/common_utils_spec.js
+5
-1
No files found.
app/assets/javascripts/lib/utils/common_utils.js
View file @
13b299f4
...
...
@@ -403,7 +403,11 @@ export const setCiStatusFavicon = (pageUrl) => {
});
};
export
const
spriteIcon
=
icon
=>
`<svg><use xlink:href="
${
gon
.
sprite_icons
}
#
${
icon
}
" /></svg>`
;
export
const
spriteIcon
=
(
icon
,
className
=
''
)
=>
{
const
classAttribute
=
className
.
length
>
0
?
`class="
${
className
}
"`
:
''
;
return
`<svg
${
classAttribute
}
><use xlink:href="
${
gon
.
sprite_icons
}
#
${
icon
}
" /></svg>`
;
};
export
const
imagePath
=
imgUrl
=>
`
${
gon
.
asset_host
||
''
}${
gon
.
relative_url_root
||
''
}
/assets/
${
imgUrl
}
`
;
...
...
spec/javascripts/lib/utils/common_utils_spec.js
View file @
13b299f4
...
...
@@ -474,7 +474,11 @@ describe('common_utils', () => {
});
it
(
'
should return the svg for a linked icon
'
,
()
=>
{
expect
(
gl
.
utils
.
spriteIcon
(
'
test
'
)).
toEqual
(
'
<svg><use xlink:href="icons.svg#test" /></svg>
'
);
expect
(
gl
.
utils
.
spriteIcon
(
'
test
'
)).
toEqual
(
'
<svg ><use xlink:href="icons.svg#test" /></svg>
'
);
});
it
(
'
should set svg className when passed
'
,
()
=>
{
expect
(
gl
.
utils
.
spriteIcon
(
'
test
'
,
'
fa fa-test
'
)).
toEqual
(
'
<svg class="fa fa-test"><use xlink:href="icons.svg#test" /></svg>
'
);
});
});
});
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment