-
Notifications
You must be signed in to change notification settings - Fork 2.7k
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
Add experimental sections view #19846
Conversation
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've tested the new experimental dashboard layout and I couldn't find any bugs. Well done on the user interface.
6745968
to
86b8744
Compare
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.
Very nice! 🎉
|
||
@property({ type: Number, attribute: "swap-threshold" }) | ||
public swapThreshold?: number; | ||
@property({ type: String }) |
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.
Should we keep this an attribute now it can also be something else than a string?
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.
If we remove the attribute, we won't be able to do group="card" right?
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.
Yes
@@ -469,6 +481,9 @@ export class HuiTileCard extends LitElement implements LovelaceCard { | |||
transition: | |||
box-shadow 180ms ease-in-out, | |||
border-color 180ms ease-in-out; | |||
display: flex; | |||
flex-direction: column; | |||
justify-content: space-between; |
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.
From my POC, I needed to render hui-card-features
only when this._config.features
was actually set (which would save some resources anyway), is that not needed here, will it not add space between the items?
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 removed the component from the render if no features.
const suggestedCards = this._suggestedCards(this._cards); | ||
const othersCards = this._otherCards(this._cards); | ||
const customCardsItems = this._customCards(this._cards); |
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 not have _loadCards
do this?
Personally I would make _loadCards
a memoized function passing lokalize
and suggestedCards
.
Then for _filterCards
you just combine the 3 arrays.
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 will refactor that is another PR 👍
return nothing; | ||
} | ||
|
||
// Todo improve |
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 that for a new PR?
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.
Yes I will push another PR for this one
src/panels/lovelace/types.ts
Outdated
getCardSize(): number | Promise<number>; | ||
getSize?(): [number, number]; |
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.
We need to think about these names 😅 confusing... first should now be getHeight
or something...
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 agree, I will include experimental in the name so custom card doesn't use it
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.
let's mention in the name what the size is for. Like getGridSize
.
Also, should this also be able to be a promise or not? (can always be added later too ofc)
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 would try to avoid having a card defining it's size async because it will shift the grid during the loading.
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.
It will need to be asynchronous for a card that wraps another custom card, as that card can be lazy loaded
`; | ||
} | ||
|
||
private _addSection(): void { |
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 would love to move the editor code out of here in a future PR, so it will not slow down none edit usage
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.
Me too! I had some issue with sortable when trying to move it out but it should be solvable!
|
||
this._sections = config.sections.map((sectionConfig, index) => { | ||
const element = this.createSectionElement(sectionConfig); | ||
element.index = index; |
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.
Shouldn't we set hass
here?
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.
It's already set inside createSectionElement
Co-authored-by: Bram Kragten <mail@bramkragten.nl>
Co-authored-by: Bram Kragten <mail@bramkragten.nl>
Proposed change
This feature is tagged as experimental because some API or features can change. Also, there may be some bugs and optimization to be done.
An new view type is added and allows user to use sections in dashboards views.
"Sections" view lets you to group cards within multiple section without using vertical stack card, horizontal stack card or grid card. For now, only
grid
section is added and lets you organize your card on section using a 4 column grid. Other type of section may arrived in the future.A new key is added in YAML :
sections
. Each section can have a title and a list of cards.Example of configuration
Only few cards has been adapted to sections : tile, sensor and buttons. API to let the card provide its size on the grid is not finalized yet.
Type of change
Example configuration
Additional information
Checklist
If user exposed functionality or configuration variables are added/changed: