Skip to content

Commit

Permalink
🧰: add support for embedded color picker
Browse files Browse the repository at this point in the history
Useful in cases where the color picker is not used as a popup but for interactive essay examples.
  • Loading branch information
merryman authored and linusha committed Jul 23, 2024
1 parent cbc81a3 commit 696d2d9
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion lively.ide/styling/color-picker.js
Original file line number Diff line number Diff line change
Expand Up @@ -219,6 +219,7 @@ export class ColorPickerModel extends ViewModel {
static get properties () {
return {
isHaloItem: { defaultValue: true },
embedded: { defaultValue: false },
colorMode: {},
context: {
serialize: false,
Expand Down Expand Up @@ -342,6 +343,7 @@ export class ColorPickerModel extends ViewModel {
}

close () {
if (this.embedded) return; // if embedded cannot be closed
this.view.remove();
const { context } = this;
if (context) context.withTopBarDo(topBar => topBar.setEditMode(topBar.view.recoverMode, true));
Expand Down Expand Up @@ -374,7 +376,7 @@ export class ColorPickerModel extends ViewModel {
const isGradient = ['linearGradient', 'radialGradient'].includes(newMode);
if (isGradient) noUpdate(() => this.context.halos().forEach(m => m.remove()));
else {
if (this._target) { noUpdate(() => $world.showHaloFor(this._target)); }
if (!this.embedded && this._target) { noUpdate(() => $world.showHaloFor(this._target)); }
}
this.ui.gradientControl.toggle(isGradient, this);
this.colorMode = newMode;
Expand Down

0 comments on commit 696d2d9

Please sign in to comment.