I'm a fan of the Eye Dropper in Umbraco as it is a very intuitive and elegant UI and gives editors total creative freedom to create beautiful landing pages.
However, I would like to edit the palette on the left side to contain only approved "corporate" colors. Is this possible? How?
I looked in the uda for my data type but only found this
The idea is to provide the eye dropper tool to pick any color - but you can use it with a 'pallette' of predefined colours, and you can also tell the instance of spectrum to ONLY use the palette.
You can see in the examples how when you call initiate the plugin you can pass in the options for showPalette, showPaletteOnly, and then also a palette of colour options to pick...
However, these options do not appear to be built into the UI for the Umbraco.ColorPicker.Eyedropper, the datatype uses the following umb-color-picker directive
to configure the spectrum editor how you'd like it...
... alternatively if you just want the editors to pick from a palette of prescribed corporate colours, have a look at the alternative Color Picker Property Editor that enables you to do just that.
Hi Marc, thanks for a comprehensive reply with some very useful links. I will definitely look into the 'create your own' option as I want to keep the 'select any color and transparency' option to the right but simply provide easy access to corporate colors on the left. This is next level to me but probably a nice way to learn building custom property editors.
In an App_Plugins folder place a package.manifest similar to this (I have used multivalues prevalue editor, but you could create your own to add and remove palettes):
Controller name in view and js changed to something unique
Config in controller modified to fetch palettes prevalue.
//setup the default config
const config = {
showAlpha: true,
showPalette: true,
allowEmpty: true
};
// map the user config
Utilities.extend(config, $scope.model.config);
if (config.palettes.length) {
config.palette = config.palettes.map(x => x.value);
delete config.palettes;
}
// map back to the model
$scope.model.config = config;
It alias of prevalue was palette is would match spectrum colorpicker palette property https://seballot.github.io/spectrum/ and in that case you could just have this:
//setup the default config
const config = {
showAlpha: true,
showPalette: true,
allowEmpty: true
};
// map the user config
Utilities.extend(config, $scope.model.config);
if (config.palette.length) {
config.palette = config.palette.map(x => x.value);
}
// map back to the model
$scope.model.config = config;
Hi Bjarne, this looks awesome. Custom Property Editors is unchartered terrain to me, but this looks like something I can follow step by step and --hopefully-- get some level of understanding of the ins and outs of those. I will find a quiet evening for this very soon (fingers crossed).
It solves a similar problem, but without a full-blown color picker (it's mainly used by editors who knows how to get the hex color for any additional color that's not one of the presets :-)
Eye Dropper Palette, how to change default colors
I'm a fan of the Eye Dropper in Umbraco as it is a very intuitive and elegant UI and gives editors total creative freedom to create beautiful landing pages.
However, I would like to edit the palette on the left side to contain only approved "corporate" colors. Is this possible? How?
I looked in the uda for my data type but only found this
Hi Jesper
The Umbraco.ColorPicker.Eyedropper is implemented using the following javascript plugin: Spectrum
https://bgrins.github.io/spectrum/
The idea is to provide the eye dropper tool to pick any color - but you can use it with a 'pallette' of predefined colours, and you can also tell the instance of spectrum to ONLY use the palette.
https://bgrins.github.io/spectrum/#options-showPalette
You can see in the examples how when you call initiate the plugin you can pass in the options for showPalette, showPaletteOnly, and then also a palette of colour options to pick...
However, these options do not appear to be built into the UI for the Umbraco.ColorPicker.Eyedropper, the datatype uses the following umb-color-picker directive
https://github.com/umbraco/Umbraco-CMS/blob/6d4809132815b41a6e048904d0769c042abde1cc/src/Umbraco.Web.UI.Client/src/common/directives/components/umbcolorpicker.directive.js#L170
(or at least I can't see any :-(, I may be wrong)
But it looks like you could create your own 'Property Editor' that was a wrapper around this directive that set these options via 'defaultConfig' -
https://our.umbraco.com/Documentation/Extending/Property-Editors/Package-Manifest/#default-config
to configure the spectrum editor how you'd like it...
... alternatively if you just want the editors to pick from a palette of prescribed corporate colours, have a look at the alternative Color Picker Property Editor that enables you to do just that.
https://docs.umbraco.com/umbraco-cms/fundamentals/backoffice/property-editors/built-in-umbraco-property-editors/color-picker
regards
Marc
Hi Marc, thanks for a comprehensive reply with some very useful links. I will definitely look into the 'create your own' option as I want to keep the 'select any color and transparency' option to the right but simply provide easy access to corporate colors on the left. This is next level to me but probably a nice way to learn building custom property editors.
Just want to eleborate that Eyedropper property editor isn't using the orginal spectrum project: https://bgrins.github.io/spectrum/
but a fork of it:
https://seballot.github.io/spectrum/
https://github.com/seballot/spectrum/
https://www.npmjs.com/package/spectrum-colorpicker2
which has a few changes from the original spectrum color picker.
great
and the palette is right there on line 56 in https://github.com/seballot/spectrum/blob/master/src/spectrum.js
maybe I can find a way to modify this in "my" Umbraco.
Being on Umbraco Cloud I looked in KUDU and found spectrum.js which indeed looks identical to https://github.com/seballot/spectrum/blob/master/src/spectrum.js
Modifying color codes in the palette does not have any immediate effect on the Eye Dropper datatype in Umbraco though.
Any suggestions to next step?
It should be possible to create your own property editor by using
<umb-color-picker>
directive.https://github.com/umbraco/Umbraco-CMS/blob/1f24b795319681c4b8b34a4018b6f5498d585ee6/src/Umbraco.Web.UI.Client/src/common/directives/components/umbcolorpicker.directive.js#L33-L40
You can add a custom configuration class inheriting the
EyeDropperColorPickerConfiguration
and extend with a Palettes property using a custom prevalue editor or eventuallymultivalues
: https://github.com/umbraco/Umbraco-CMS/blob/1f24b795319681c4b8b34a4018b6f5498d585ee6/src/Umbraco.Core/PropertyEditors/EyeDropperColorPickerConfiguration.cs#L6and a property editor similar to this with your custom view: https://github.com/umbraco/Umbraco-CMS/blob/1f24b795319681c4b8b34a4018b6f5498d585ee6/src/Umbraco.Core/PropertyEditors/EyeDropperColorPickerPropertyEditor.cs#L12
Most of it can be archieved with a package.manifest, HTML, CSS and JS.
Hi Jesper
Here an example how to handle this using a
package.manifest
(but you could also register it via C# by implementing aIManifestFilter
: https://docs.umbraco.com/umbraco-cms/extending/property-editors/package-manifest or register the property editor using C#.In an
App_Plugins
folder place a package.manifest similar to this (I have usedmultivalues
prevalue editor, but you could create your own to add and remove palettes):The view and controller are basically a copy of the
eyedroppper
property editor found here https://github.com/umbraco/Umbraco-CMS/tree/contrib/src/Umbraco.Web.UI.Client/src/views/propertyeditors/eyedropper with a few changes:It alias of prevalue was
palette
is would match spectrum colorpicker palette property https://seballot.github.io/spectrum/ and in that case you could just have this:View:
Controller:
Eventually you can also set
showPaletteOnly: true
if you don't want the full color spectrum to be displayed to content editors.Hi Jesper
Yes THIS what Bjarne says... is what I was vaguely explaining as the 'way to go'!
Thanks Bjarne!!
regards
Marc
Hi Bjarne, this looks awesome. Custom Property Editors is unchartered terrain to me, but this looks like something I can follow step by step and --hopefully-- get some level of understanding of the ins and outs of those. I will find a quiet evening for this very soon (fingers crossed).
Hi Jesper,
Maybe have a look at the source code for my Color Selector property editor?
It solves a similar problem, but without a full-blown color picker (it's mainly used by editors who knows how to get the hex color for any additional color that's not one of the presets :-)
/Chriztian
is working on a reply...