BigW Consortium Gitlab
Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
G
gitlab-ce
Project
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
Forest Godfrey
gitlab-ce
Commits
6b0f594c
Commit
6b0f594c
authored
Nov 28, 2017
by
Tim Zallmann
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'icon-sizes' into 'master'
limit icon component size to valid values See merge request gitlab-org/gitlab-ce!15618
parents
4d89f520
539ea5eb
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
18 additions
and
5 deletions
+18
-5
icon.vue
app/assets/javascripts/vue_shared/components/icon.vue
+9
-2
icon_spec.js
spec/javascripts/vue_shared/components/icon_spec.js
+9
-3
No files found.
app/assets/javascripts/vue_shared/components/icon.vue
View file @
6b0f594c
...
...
@@ -12,6 +12,9 @@
/>
*/
// only allow classes in images.scss e.g. s12
const
validSizes
=
[
8
,
12
,
16
,
18
,
24
,
32
,
48
,
72
];
export
default
{
props
:
{
name
:
{
...
...
@@ -22,7 +25,10 @@
size
:
{
type
:
Number
,
required
:
false
,
default
:
0
,
default
:
16
,
validator
(
value
)
{
return
validSizes
.
includes
(
value
);
},
},
cssClasses
:
{
...
...
@@ -42,10 +48,11 @@
},
};
</
script
>
<
template
>
<svg
:class=
"[iconSizeClass, cssClasses]"
>
<use
<use
v-bind=
"
{'xlink:href':spriteHref}"/>
</svg>
</
template
>
spec/javascripts/vue_shared/components/icon_spec.js
View file @
6b0f594c
...
...
@@ -11,7 +11,7 @@ describe('Sprite Icon Component', function () {
icon
=
mountComponent
(
IconComponent
,
{
name
:
'test'
,
size
:
99
,
size
:
32
,
cssClasses
:
'extraclasses'
,
});
});
...
...
@@ -34,12 +34,18 @@ describe('Sprite Icon Component', function () {
});
it
(
'should properly compute iconSizeClass'
,
function
()
{
expect
(
icon
.
iconSizeClass
).
toBe
(
's99'
);
expect
(
icon
.
iconSizeClass
).
toBe
(
's32'
);
});
it
(
'forbids invalid size prop'
,
()
=>
{
expect
(
icon
.
$options
.
props
.
size
.
validator
(
NaN
)).
toBeFalsy
();
expect
(
icon
.
$options
.
props
.
size
.
validator
(
0
)).
toBeFalsy
();
expect
(
icon
.
$options
.
props
.
size
.
validator
(
9001
)).
toBeFalsy
();
});
it
(
'should properly render img css'
,
function
()
{
const
classList
=
icon
.
$el
.
classList
;
const
containsSizeClass
=
classList
.
contains
(
's
99
'
);
const
containsSizeClass
=
classList
.
contains
(
's
32
'
);
const
containsCustomClass
=
classList
.
contains
(
'extraclasses'
);
expect
(
containsSizeClass
).
toBe
(
true
);
expect
(
containsCustomClass
).
toBe
(
true
);
...
...
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