Conversation
| var(--grid-card-column-count, ${DEFAULT_COLUMNS}), | ||
| minmax(0, 1fr) | ||
| ); | ||
| grid-gap: var(--grid-card-gap, 8px); |
There was a problem hiding this comment.
--grid-card-column-count is defined if columns is added to config, otherwise removed and it will take whatever is used.
--grid-card-gap cannot be defined from the config, relies on users setting their own CSS vars.
There was a problem hiding this comment.
Why not just hard code the number in there. The JS in the Static CSS I though was no good?
There was a problem hiding this comment.
also, then the variable can be overwritten in a theme which is not something we want right?
There was a problem hiding this comment.
Why wouldn't we want a theme to change it? It's up to the user to decide to do so.
There was a problem hiding this comment.
We don't want a theme to change it if the card can. Doesn't seem like the correct way having two ways that can change it
There was a problem hiding this comment.
The gap I understand. I think that the grid column config should only be apart of the card config
| #root { | ||
| display: grid; | ||
| grid-template-columns: repeat( | ||
| var(--grid-card-column-count, ${DEFAULT_COLUMNS}), |
There was a problem hiding this comment.
Variable css in the static styles? I thought this was frowned upon?
There was a problem hiding this comment.
It's not variable, it's a constant defined at the top. Inside static styles it's fine, as it is only fetched and processed once. You should not have dynamic CSS inside a render block.
zsarnett
left a comment
There was a problem hiding this comment.
Is this a card that should be added to the Card Picker? If so, we need to add it to src\panels\lovelace\editor\lovelace-cards.ts
|
I think that with the grid card we can phase out the horizontal and vertical stack cards. |
|
|
||
| return ( | ||
| maxCardSize * | ||
| (this._cards.length / (this._config.columns || DEFAULT_COLUMNS)) |
There was a problem hiding this comment.
Should we limit the columns to the number of cards when there are less cards than columns?
| (this._cards.length / (this._config.columns || DEFAULT_COLUMNS)) | |
| (this._cards.length / (this._config.columns || (Math.min(DEFAULT_COLUMNS, this._cards.length))) |
There was a problem hiding this comment.
^ thats not going it work reading the code below but still... 😛
There was a problem hiding this comment.
So if we want that, we can't expose the CSS var. I'm fine either way. What do you prefer?
There was a problem hiding this comment.
I think it is nice for a user to not have to worry about the columns setting, and if you add 2 cards you don't get a blank space. But also to make it work like our current horizontal stack.
There was a problem hiding this comment.
Back to the drawing board. I think that we should make sure that the height is included (but removable maybe?) to have multiple grid cards look the same.
|
Docs missing? |
That would currently be a breaking change which we shouldn't do as Lovelace is now considered 1.0. Even if you intend to take defined horizontal/vertical cards and render them with grid, you are missing |
|
Sorry, my bad. With phasing out I didn't mean remove but don't promote in the card picker. I actually have to also retract that statement, I think that vertical stack still has a use case in case you want to make sure 2 cards always get grouped together. |





Breaking change
Proposed change
Add a new grid card. Config is like vertical/horizontal stack with an added optional
columnscount (default to 3) and asquareoption (default to true).If square option is given, it will make sure all cells are square. This will make sure that 2 grid cards in different columns have the same height/width.
2 cards with
square: true(default):2 cards with
square: falseType of change
Example configuration
Additional information
Checklist
If user exposed functionality or configuration variables are added/changed: