Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: added configuration default fill color and default stroke color #26

Merged
merged 2 commits into from
May 25, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 7 additions & 4 deletions colors/ColorPopupProvider.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,19 +29,22 @@ const COLORS = [ {
} ];


export default function ColorPopupProvider(config, popupMenu, modeling, translate) {
export default function ColorPopupProvider(config, bpmnRendererConfig, popupMenu, modeling, translate) {
this._popupMenu = popupMenu;
this._modeling = modeling;
this._translate = translate;

this._colors = config && config.colors || COLORS;
this._defaultFillColor = bpmnRendererConfig && bpmnRendererConfig.defaultFillColor || 'white';
this._defaultStrokeColor = bpmnRendererConfig && bpmnRendererConfig.defaultStrokeColor || 'rgb(34, 36, 42)';

this._popupMenu.registerProvider('color-picker', this);
}


ColorPopupProvider.$inject = [
'config.colorPicker',
'config.bpmnRenderer',
'popupMenu',
'modeling',
'translate'
Expand All @@ -53,14 +56,14 @@ ColorPopupProvider.prototype.getEntries = function(elements) {

var colorIcon = domify(`
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" height="100%">
<rect rx="2" x="1" y="1" width="22" height="22" fill="var(--fill-color)" stroke="var(--stroke-color)"></rect>
<rect rx="2" x="1" y="1" width="22" height="22" fill="var(--fill-color)" stroke="var(--stroke-color)" style="stroke-width:2"></rect>
</svg>
`);

var entries = this._colors.map(function(color) {

colorIcon.style.setProperty('--fill-color', color.fill || 'white');
colorIcon.style.setProperty('--stroke-color', color.stroke || 'rgb(34, 36, 42)');
colorIcon.style.setProperty('--fill-color', color.fill || self._defaultFillColor);
colorIcon.style.setProperty('--stroke-color', color.stroke || self._defaultStrokeColor);

return {
title: self._translate(color.label),
Expand Down