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

Some fixes #44

Closed
wants to merge 8 commits into from
Closed

Some fixes #44

wants to merge 8 commits into from

Conversation

DmitrySharabin
Copy link
Collaborator

One thing is left: after updating space, progress is not updated. Investigating...

That's why I submit it as a draft.

but only if the space is changed for real
Eventually, everything will be settled down.
Copy link

netlify bot commented May 17, 2024

Deploy Preview for color-elements ready!

Name Link
🔨 Latest commit 9d9c296
🔍 Latest deploy log https://app.netlify.com/sites/color-elements/deploys/664764b8fb33b000082d5157
😎 Deploy Preview https://deploy-preview-44--color-elements.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

`progress` depends not only on the current value but also on the range this value belongs to.
return this.defaultColor.get(this.channel);
}
catch {
let channel = Object.keys(this.space.coords)[0];
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A comment here about what it means to be in this branch?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Every time we set space on <color-picker>, we update space and channel of underlying <channel-slider>s. This leads to updates defaultColor and, eventually, defaultValue. And this line produced many errors from Color.js when we tried to get no existing channel from the color.

After neutralizing these errors, I could find why the dynamic set of space didn't work.

@@ -80,6 +80,10 @@ const Self = class ColorPicker extends NudeElement {
this._el.sliders.insertAdjacentHTML("beforeend", `<channel-slider space="${ this.space.id }" channel="${ channel }"></channel-slider>`);
}
}

if (change.oldInternalValue || change.oldAttributeValue) {
this.render();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why? A comment would be helpful here!

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When we first come here on component initialization, there is no need to call render() since it'll be rendered automatically after it's connected. So, we only need to re-render the component when space actually changes after the component is mounted.

There were no issues when I called render() without any condition, but I thought I could optimize it a bit by not re-rendering the component when there is no need.

@@ -99,10 +99,10 @@ const Self = class ColorSlider extends NudeElement {
this.style.setProperty("--color", displayedColor);
}
}
else if (name === "value") {
else if (name === "value" || name === "min" || name === "max") {
Copy link
Member

@LeaVerou LeaVerou May 17, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This could also be a direct commit (together with the line below)

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let me commit this change and the one above (with a fix for the typo) directly and rebase this branch so we can iterate.

}
catch {
let channel = Object.keys(this.space.coords)[0];
return this.defaultColor.get(channel);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If we're just trying to get the first coord, it’s easier to do this.defaultColor.coords[0].

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh, yes. Much easier. Thanks!

@DmitrySharabin
Copy link
Collaborator Author

@DmitrySharabin DmitrySharabin deleted the some-fixes branch May 20, 2024 11:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants