Skip to content

Commit

Permalink
feat: carbonize
Browse files Browse the repository at this point in the history
  • Loading branch information
philippfromme committed Aug 9, 2023
1 parent b44dad0 commit 7b57a45
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 16 deletions.
27 changes: 13 additions & 14 deletions colors/ColorContextPadProvider.js
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,10 @@ ColorContextPadProvider.prototype._createPopupAction = function(elements) {
};

// open new color-picker popup
popupMenu.open(elements, 'color-picker', position);
popupMenu.open(elements, 'color-picker', position, {
orientation: 'horizontal',
separators: true
});
}
}
}
Expand All @@ -82,34 +85,30 @@ function getSvg(elements) {
if (elements.length === 1) {
const { fill, stroke } = getColors(elements[ 0 ]);

return `<svg width="16" height="16" viewBox="0 0 16 16" fill="none" xmlns="http://www.w3.org/2000/svg">
return `<svg width="24" height="24" viewBox="0 0 16 16" fill="none" xmlns="http://www.w3.org/2000/svg">
<circle cx="8" cy="8" r="7" fill="${ fill }" stroke="${ stroke }" stroke-width="2" />
</svg>
`

Check failure on line 91 in colors/ColorContextPadProvider.js

View workflow job for this annotation

GitHub Actions / Build (ubuntu-latest, 16)

Missing semicolon
}

return `<svg width="16" height="16" viewBox="0 0 16 16" fill="none" xmlns="http://www.w3.org/2000/svg">
return `<svg width="24" height="24" viewBox="0 0 16 16" fill="none" xmlns="http://www.w3.org/2000/svg">
<circle cx="8" cy="8" r="7" fill="${ WHITE }" stroke="${ BLACK } stroke-width="2" />
</svg>
`

Check failure on line 97 in colors/ColorContextPadProvider.js

View workflow job for this annotation

GitHub Actions / Build (ubuntu-latest, 16)

Missing semicolon
}

function getStartPosition(canvas, contextPad, elements) {
const pad = contextPad.getPad(elements).html;

var Y_OFFSET = 5;
console.log(pad);

var diagramContainer = canvas.getContainer(),
pad = contextPad.getPad(elements).html;
const padRect = pad.getBoundingClientRect();

var diagramRect = diagramContainer.getBoundingClientRect(),
padRect = pad.getBoundingClientRect();
console.log(padRect);

var top = padRect.top - diagramRect.top;
var left = padRect.left - diagramRect.left;

var pos = {
x: left,
y: top + padRect.height + Y_OFFSET
const pos = {
x: padRect.left,
y: padRect.top - 5
};

return pos;
Expand Down
13 changes: 11 additions & 2 deletions colors/ColorPopupProvider.js
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,8 @@ ColorPopupProvider.prototype.getEntries = function(elements) {
var self = this;

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)" style="stroke-width:2"></rect>
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 16 16" height="100%">
<circle cx="8" cy="8" r="7" fill="var(--fill-color)" stroke="var(--stroke-color)" stroke-width="2" />
</svg>
`);

Expand All @@ -66,6 +66,15 @@ ColorPopupProvider.prototype.getEntries = function(elements) {
colorIcon.style.setProperty('--stroke-color', color.stroke || self._defaultStrokeColor);

return {
group: color.label === 'Default'
? {
id: 'default',
name: 'Default'
}
: {
id: 'custom',
name: 'Custom'
},
title: self._translate(color.label),
id: color.label.toLowerCase() + '-color',
imageUrl: `data:image/svg+xml;utf8,${ encodeURIComponent(colorIcon.outerHTML) }`,
Expand Down

0 comments on commit 7b57a45

Please sign in to comment.