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
1
Merge Requests
1
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
nexedi
gitlab-ce
Commits
55babfe9
Commit
55babfe9
authored
Feb 25, 2022
by
Jonas Waelter
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Allow to pass suggestedColors to ColorPicker
Changelog: added
parent
084dce0b
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
19 additions
and
3 deletions
+19
-3
app/assets/javascripts/vue_shared/components/color_picker/color_picker.vue
...ripts/vue_shared/components/color_picker/color_picker.vue
+6
-3
spec/frontend/vue_shared/components/color_picker/color_picker_spec.js
...d/vue_shared/components/color_picker/color_picker_spec.js
+13
-0
No files found.
app/assets/javascripts/vue_shared/components/color_picker/color_picker.vue
View file @
55babfe9
...
...
@@ -7,6 +7,7 @@
:invalid-feedback="__('Please enter a valid hex (#RRGGBB or #RGB) color value')"
:label="__('Background color')"
:value="#FF0000"
:suggestedColors="{ '#ff0000': 'Red', '#808080': 'Gray' }",
state="isValidColor"
/>
*/
...
...
@@ -48,6 +49,11 @@ export default {
required
:
false
,
default
:
null
,
},
suggestedColors
:
{
type
:
Object
,
required
:
false
,
default
:
()
=>
gon
.
suggested_label_colors
,
},
},
computed
:
{
description
()
{
...
...
@@ -55,9 +61,6 @@ export default {
?
this
.
$options
.
i18n
.
fullDescription
:
this
.
$options
.
i18n
.
shortDescription
;
},
suggestedColors
()
{
return
gon
.
suggested_label_colors
;
},
previewColor
()
{
if
(
this
.
state
)
{
return
{
backgroundColor
:
this
.
value
};
...
...
spec/frontend/vue_shared/components/color_picker/color_picker_spec.js
View file @
55babfe9
...
...
@@ -127,5 +127,18 @@ describe('ColorPicker', () => {
expect
(
wrapper
.
emitted
().
input
[
0
]).
toStrictEqual
([
setColor
]);
});
it
(
'
shows the suggested colors passed using props
'
,
()
=>
{
const
customColors
=
{
'
#ff0000
'
:
'
Red
'
,
'
#808080
'
:
'
Gray
'
,
};
createComponent
(
shallowMount
,
{
suggestedColors
:
customColors
});
expect
(
description
()).
toBe
(
'
Enter any color or choose one of the suggested colors below.
'
);
expect
(
presetColors
()).
toHaveLength
(
2
);
expect
(
presetColors
().
at
(
0
).
attributes
(
'
title
'
)).
toBe
(
'
Red
'
);
expect
(
presetColors
().
at
(
1
).
attributes
(
'
title
'
)).
toBe
(
'
Gray
'
);
});
});
});
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