Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
D
drupal
Manage
Activity
Members
Labels
Plan
Wiki
Custom issue tracker
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Model registry
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
project
drupal
Merge requests
!5098
allow 3-character hexadecimal color inputs
Code
Review changes
Check out branch
Download
Patches
Plain diff
Open
allow 3-character hexadecimal color inputs
issue/drupal-3396018:3396018-allow-three-character
into
11.x
Overview
4
Commits
6
Pipelines
7
Changes
3
1 unresolved thread
Hide all comments
Open
Andy Blum
requested to merge
issue/drupal-3396018:3396018-allow-three-character
into
11.x
1 year ago
Overview
4
Commits
6
Pipelines
7
Changes
3
1 unresolved thread
Hide all comments
Expand
Closes
#3396018
0
0
Merge request reports
Compare
11.x
version 6
04955956
1 year ago
version 5
ff55bda0
1 year ago
version 4
d76323ac
1 year ago
version 3
27f862bf
1 year ago
version 2
97649638
1 year ago
version 1
8cb75a38
1 year ago
11.x (base)
and
latest version
latest version
fb71a829
6 commits,
1 year ago
version 6
04955956
5 commits,
1 year ago
version 5
ff55bda0
5 commits,
1 year ago
version 4
d76323ac
4 commits,
1 year ago
version 3
27f862bf
3 commits,
1 year ago
version 2
97649638
2 commits,
1 year ago
version 1
8cb75a38
1 commit,
1 year ago
3 files
+
54
−
10
Inline
Compare changes
Side-by-side
Inline
Show whitespace changes
Show one file at a time
Files
3
Search (e.g. *.vue) (Ctrl+P)
core/themes/olivero/js/color-picker.js
+
35
−
4
Options
@@ -27,6 +27,31 @@
Drupal
.
announce
(
announcement
);
}
/**
* Formats hexcode to full 6-character string for HTMLColorInput.
*
* @param {string} hex The hex code input.
* @returns {string} The same hex code, formatted.
*/
function
formatHex
(
hex
)
{
// Temporarily remove hash
if
(
hex
.
startsWith
(
'
#
'
))
{
hex
=
hex
.
substring
(
1
);
}
// Convert three-value to six-value syntax.
if
(
hex
.
length
===
3
)
{
hex
=
hex
.
split
(
''
)
.
flatMap
((
character
)
=>
[
character
,
character
])
.
join
(
''
);
}
hex
=
`#
${
hex
}
`
;
return
hex
;
}
/**
* `input` event callback to keep text & color inputs in sync.
*
@@ -34,10 +59,16 @@
* @param {HTMLElement} inputToSync input element to synchronize
*/
function
synchronizeInputs
(
changedInput
,
inputToSync
)
{
inputToSync
.
value
=
changedInput
.
value
;
inputToSync
.
value
=
formatHex
(
changedInput
.
value
)
;
changedInput
.
setAttribute
(
'
data-olivero-custom-color
'
,
changedInput
.
value
);
inputToSync
.
setAttribute
(
'
data-olivero-custom-color
'
,
changedInput
.
value
);
changedInput
.
setAttribute
(
'
data-olivero-custom-color
'
,
formatHex
(
changedInput
.
value
),
);
inputToSync
.
setAttribute
(
'
data-olivero-custom-color
'
,
formatHex
(
changedInput
.
value
),
);
const
colorSchemeSelect
=
document
.
querySelector
(
'
[data-drupal-selector="edit-color-scheme"]
'
,
@@ -130,7 +161,7 @@
'
form-element--type-color
'
,
'
form-element--api-color
'
,
);
colorInput
.
value
=
textInput
.
value
;
colorInput
.
value
=
formatHex
(
textInput
.
value
)
;
colorInput
.
setAttribute
(
'
name
'
,
`
${
textInput
.
name
}
_visual`
);
colorInput
.
setAttribute
(
'
data-olivero-custom-color
'
,
Loading