-
Notifications
You must be signed in to change notification settings - Fork 25
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
base: main
Are you sure you want to change the base?
Changes from 7 commits
59333d2
736b72a
d52300e
3f0e163
d4a8316
06cff4f
4b3fce3
c09095c
75ed17e
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,7 +7,7 @@ | |
from anvil.js import get_dom_node | ||
|
||
from anvil_extras import ProgressBar | ||
from anvil_extras.utils._component_helpers import _get_dom_node_id, _html_injector | ||
from anvil_extras.utils._component_helpers import _css_length, _html_injector | ||
|
||
from ._anvil_designer import IndeterminateTemplate | ||
|
||
|
@@ -18,12 +18,33 @@ | |
|
||
class Indeterminate(IndeterminateTemplate): | ||
def __init__(self, **properties): | ||
self.indicator_dom_node = get_dom_node(self.indicator_panel) | ||
self.dom_node = get_dom_node(self) | ||
self._props = properties | ||
self.role = "ae-progress-track" | ||
self.indicator_panel.role = "ae-indeterminate-progress-indicator" | ||
self.init_components(**properties) | ||
|
||
@property | ||
def height(self): | ||
return self._height | ||
|
||
@height.setter | ||
def height(self, value): | ||
value = _css_length(value) | ||
self._height = value | ||
self.indicator_dom_node.style.setProperty("height", value) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Fair enough, I'll do that in the next push. |
||
|
||
@property | ||
def width(self): | ||
return self._width | ||
|
||
@width.setter | ||
def width(self, value): | ||
value = _css_length(value) | ||
self._width = value | ||
self.dom_node.style.setProperty("width", value) | ||
|
||
@property | ||
def track_colour(self): | ||
return self._props.get("track_colour") | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,24 +8,14 @@ | |
|
||
css = """ .anvil-role-ae-progress-track, .anvil-role-ae-progress-indicator { | ||
display: block; | ||
height: 3px; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 There was a problem hiding this comment. Choose a reason for hiding this commentThe 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. There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 :) |
||
margin: 0; | ||
} | ||
|
||
.anvil-role-ae-progress-track { | ||
width: 100%; | ||
} | ||
|
||
.anvil-role-ae-progress-indicator { | ||
top: 0 !important; | ||
} | ||
|
||
.anvil-role-ae-progress-track > .holder, .anvil-role-ae-progress-indicator > .holder { | ||
display: block !important; | ||
} | ||
|
||
Comment on lines
-19
to
-26
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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? There was a problem hiding this comment. Choose a reason for hiding this commentThe 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. |
||
.anvil-role-ae-indeterminate-progress-indicator, .anvil-role-ae-indeterminate-progress-indicator:before { | ||
height: 3px; | ||
width: 100%; | ||
margin: 0; | ||
} | ||
|
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.