Skip to content

Commit 32a8caa

Browse files
committed
Add ColorPicker field
1 parent 92721fd commit 32a8caa

10 files changed

Lines changed: 189 additions & 2 deletions

File tree

assets/js/webform/colorPick.min.js

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

assets/js/webform/webform.js

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,7 @@ var WebForm = Class.extend({
6161
this.initPopovers();
6262
this.initCsrf();
6363
this.initTranslate();
64+
this.initColorPicker();
6465
},
6566

6667
/**
@@ -131,6 +132,25 @@ var WebForm = Class.extend({
131132
}, 1500);
132133
},
133134

135+
initColorPicker: function () {
136+
this.getWebForm().find('.colorpicker').each(function () {
137+
let $field = $(this);
138+
let $input = $field.find('.colorpicker__input');
139+
let $button = $field.find('.colorpicker__button');
140+
141+
$button.colorPick({
142+
'allowRecent': false,
143+
'paletteLabel': 'Kies een kleur',
144+
'initialColor': $field.data('color'),
145+
'palette': $field.data('colors'),
146+
'onColorSelected': function () {
147+
$input.val(this.color);
148+
$button.css('background-color', this.color);
149+
}
150+
});
151+
});
152+
},
153+
134154
/**
135155
* Initialize date fields
136156
*/
Lines changed: 81 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,81 @@
1+
@import "../../includes/variables";
2+
@import "../../includes/mixins";
3+
4+
.colorpicker{
5+
display: flex;
6+
gap: 5px;
7+
8+
&__button{
9+
width: 40px;
10+
height: 36px;
11+
border-radius: $defaultBorderRadius;
12+
border: 1px solid #e1e1e1;
13+
cursor: pointer;
14+
}
15+
}
16+
17+
.colorPickWrapper {
18+
position: relative;
19+
width: 0;
20+
height: 0
21+
}
22+
23+
#colorPick * {
24+
-webkit-transition: all linear .2s;
25+
-moz-transition: all linear .2s;
26+
-ms-transition: all linear .2s;
27+
-o-transition: all linear .2s;
28+
transition: all linear .2s
29+
}
30+
31+
#colorPick {
32+
background: rgba(255, 255, 255, .85);
33+
-webkit-backdrop-filter: blur(15px);
34+
position: absolute;
35+
border-radius: 5px;
36+
box-shadow: 0 3px 8px rgba(0, 0, 0, .2);
37+
padding: 15px;
38+
font-family: "Open Sans", sans-serif;
39+
box-sizing: content-box;
40+
z-index: 999;
41+
display: grid;
42+
grid-template-columns: 1fr 1fr 1fr 1fr;
43+
grid-gap: 5px;
44+
}
45+
46+
#colorPick span {
47+
display: none;
48+
}
49+
50+
.customColorHash {
51+
border-radius: 5px;
52+
height: 23px;
53+
width: 122px;
54+
margin: 1px 4px;
55+
padding: 0 4px;
56+
border: 1px solid #babbba;
57+
outline: 0
58+
}
59+
60+
.customColorHash.error {
61+
border-color: #ff424c;
62+
color: #ff424c
63+
}
64+
65+
.colorPickButton {
66+
width: 35px;
67+
height: 35px;
68+
cursor: pointer;
69+
display: block;
70+
border-radius: $defaultBorderRadius;
71+
border: 1px solid #e1e1e1;
72+
}
73+
74+
.colorPickButton:hover {
75+
transform: scale(1.2)
76+
}
77+
78+
.colorPickDummy {
79+
background: #fff;
80+
border: 1px dashed #bbb
81+
}

resources/css/cms.css

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

resources/js/cms.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)