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

Added height and width properties to both progress bars #588

Open
wants to merge 9 commits into
base: main
Choose a base branch
from

Conversation

Duncanr-glitch
Copy link

Adds the feature in issue #428:

Added height and width for both determinatei and indeterminate progress bars.

The Width property can take any valid CSS width value.

The Height property can take any valid CSS height value except the % kind because those seemed to just hide the progress bars.

@width.setter
def width(self, value):
self._width = value
self.dom_node.style.setProperty("width", value)
Copy link
Collaborator

Choose a reason for hiding this comment

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

There's a utility function for this so we can support number as well as strings.

It's in _component_helpers, _css_length.

Copy link
Author

Choose a reason for hiding this comment

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

Perfect, that makes sense. I did modify that utility function so that strings with the unit already applied can be used as well.

Comment on lines 211 to 214
if isinstance(v, str) and re.match(
r"\b\d+(\.\d+)?\s*(cm|mm|in|pt|pc|px|em|rem|vw|vh|vmin|vmax|%)\b", v
):
return v
Copy link
Collaborator

Choose a reason for hiding this comment

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

We dont need this. The try will fail in the next step and will return the original value.

Copy link
Author

Choose a reason for hiding this comment

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

Yeah, I misread that block, just reverted that part.

@@ -8,24 +8,14 @@

css = """ .anvil-role-ae-progress-track, .anvil-role-ae-progress-indicator {
display: block;
height: 3px;
Copy link
Collaborator

Choose a reason for hiding this comment

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

Is it better to leave this in to make it the default if someone sets the height to empty string? Or remove the default values entirely from the custom component and leave this css here. So that it's a sensible fallback

Copy link
Author

Choose a reason for hiding this comment

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

I think it makes more sense to have the default in the designer, then its easier to track because it's always getting set in code imho.

Copy link
Author

Choose a reason for hiding this comment

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

I can add some null-value handling that would then default to 3px as well :)

Comment on lines -19 to -26
.anvil-role-ae-progress-indicator {
top: 0 !important;
}

.anvil-role-ae-progress-track > .holder, .anvil-role-ae-progress-indicator > .holder {
display: block !important;
}

Copy link
Collaborator

Choose a reason for hiding this comment

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

Do we know why we're removing this? Doesn't seem related to the PR?

Copy link
Author

Choose a reason for hiding this comment

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

When I just tried setting height properties with it left it and it was making the code not work or some awkward height settings.

Comment on lines 34 to 36
value = _css_length(value)
self._height = value
self.indicator_dom_node.style.setProperty("height", value)
Copy link
Collaborator

Choose a reason for hiding this comment

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

Better to convert to css length after we assign it to the private variable. That way the value you set is the value you get. This will also mean the designer property editors don't mysteriously change which I think they would currently. If you set the value to 10 then the designer might display 10px.

Copy link
Author

Choose a reason for hiding this comment

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

Fair enough, I'll do that in the next push.

@width.setter
def width(self, value):
self._width = value
self.dom_node.style.setProperty("width", _css_length(value or "3px"))
Copy link
Collaborator

Choose a reason for hiding this comment

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

Let's fix the default widths 😊

Copy link
Author

Choose a reason for hiding this comment

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

Oh right, that one should be 100%, my bad. I'll do that tomorrow, already shut down the computer for the night, haha.

Copy link
Author

Choose a reason for hiding this comment

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

Just di that in the latest push, lmk if there's anything else :)

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.

2 participants