-
Notifications
You must be signed in to change notification settings - Fork 239
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
feat: sections support #1139
base: dev
Are you sure you want to change the base?
feat: sections support #1139
Conversation
Please merge this into the base branch, guys, we need it :-) |
Honestly I made a quick look at this PR. IMHO we can give this PR a go & test with participation of users who is using sections. |
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.
As the discussion came here before I could look at the UI PR again, I used some travel time to review. I must admit, I don't use sections, so this is from a pure code review perspective now.
Forgive me if I didn't get some parts of the code completely. All suggestions are open to discussion.
src/main.js
Outdated
@@ -127,6 +135,68 @@ class MiniGraphCard extends LitElement { | |||
} | |||
} | |||
|
|||
checkSections() { | |||
let root = document.querySelector('home-assistant'); |
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.
Is this really the best way to check for the view layout? The main frontend suggests, there might be this.layout
?
Also, maybe this.options.layout_options
will only defined in sections view?
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.
this.layout
does not seem to be defined when the graphs are created in getConfig
. I could try to modify graphs height in render
as it seems that this.layout
is defined there.
As for the this.options.layout_options
there could be a situation where user copies card to a different dashboard that is not necessarily a sections
but maybe I am overthinking.
src/main.js
Outdated
} | ||
|
||
getLayoutSize(layout) { | ||
if (!this.sections) { |
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.
Reduce?
return this.sections && layout.grid_rows === 2 ? 'small' : '';
And if that is enough, maybe remove the function and do the logic in the render directly... (Because it seems used only once.)
src/style.js
Outdated
@@ -49,6 +53,9 @@ const style = css` | |||
order: -1; | |||
padding: 0 16px 8px 16px; | |||
} | |||
ha-card[fill].sections .graph__legend { |
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.
Why do the margins and paddings need tweaking? If it's kind of a refactor but yields the same layout, let's consider to change this also in non-section view to keep consistency.
@@ -238,6 +254,10 @@ const style = css` | |||
margin-top: auto; | |||
width: 100%; | |||
} | |||
.sections .graph { |
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.
Here, too: if this is useful also in non-section views, let's consider to just add it to the regular styles.
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.
I think this is only useful for section view. It makes graph position itself so that it's not clipping out of bounds.
return false; | ||
} | ||
|
||
getCurrentLayout() { |
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.
I wonder: isn't this taken care of by home assistant? If we report a minimum row count via getLayoutOptions
, shouldn't this be reflected in this.config.layout_options
?
See also here, maybe: https://github.com/home-assistant/frontend/blob/67217b9dd0f5ad43aafb3bba2fe2821407b25243/src/panels/lovelace/editor/card-editor/hui-card-layout-editor.ts#L68
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.
No, it only clamps the values for setting the card size and for the visual editor, values set by user in this.config.layout_options
stays untouched even when they're lower than minimum set in getLayoutOptions
.
Card is considered small when its row size is 3 or less Simpler sections checking Simpler card height style
@jnnck Awesome. Could you show us how the labels look like on your humidity graph with the PR? |
Hope this PR will only touch sections and will not affect other layouts. As for labels and similar: consider more playing with fonts than with placement. |
|
This comment was marked as off-topic.
This comment was marked as off-topic.
This comment was marked as off-topic.
This comment was marked as off-topic.
Just to let you know: I plan to get this feature released. However, I am currently overloaded and I would prefer to do this properly (rather than iterating the structure over multiple releases). So, I might still need some time. Thanks for bearing with me! |
This adds support for sections dashboard and addresses #1111.
Which means it fixes card size and also add card size restrictions based on the card configuration.
This "shouldn't" affect other types of dashboards.