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
Léo-Paul Géneau
gitlab-ce
Commits
539ea5eb
Commit
539ea5eb
authored
Nov 28, 2017
by
Simon Knox
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
limit icon component size to valid values
parent
815f35be
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
18 additions
and
5 deletions
+18
-5
app/assets/javascripts/vue_shared/components/icon.vue
app/assets/javascripts/vue_shared/components/icon.vue
+9
-2
spec/javascripts/vue_shared/components/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 @
539ea5eb
...
...
@@ -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,6 +48,7 @@
},
};
</
script
>
<
template
>
<svg
:class=
"[iconSizeClass, cssClasses]"
>
...
...
spec/javascripts/vue_shared/components/icon_spec.js
View file @
539ea5eb
...
...
@@ -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