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

Make it possible to configure items per row for area cards in home view #84

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

Conversation

punxaphil
Copy link
Contributor

@punxaphil punxaphil commented Nov 5, 2023

Make it possible to configure items per row for area cards in home view, as well as make it possible to have different configurations based on the width of the display.

Example yaml

strategy:
  type: custom:mushroom-strategy
  options:
    home_view:
      areas_per_row:
        narrow: 3
        wide: 5
views: []

Example for narrow view

image

Example for desktop view

image

@DigiLive
Copy link
Collaborator

DigiLive commented Nov 5, 2023

This is exactly one of my future ideas for the project. 👍🏻

I do hope you're gonna code a little slower since I'm migrating to Typescript at the moment. 😅

@punxaphil
Copy link
Contributor Author

😁
Should i close it? Delete it? Change it to typescript?

@DigiLive
Copy link
Collaborator

DigiLive commented Nov 5, 2023

Let me review it first, so we can merge it later.
If you want, create a Typescript version after review to merge into the Typescript branch. 😬

src/Helper.js Outdated Show resolved Hide resolved
src/Helper.js Outdated
@@ -119,6 +132,7 @@ class Helper {
*/
static async initialize(info) {
this.#hassStates = info.hass.states;
this.#narrow = info.narrow;
Copy link
Collaborator

Choose a reason for hiding this comment

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

Are you sure the info object has a narrow property?

Object { config: {…}, hass: {…} }
​
config: Object { strategy: {…}, views: [] }
​hass: Object { auth: {…}, connection: {…}, connected: true, … }
​```

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Sure, I have tested it. As you see in the screenshots.
There are also a lot of occurrences of it in the ha frontend code: https://github.com/search?q=repo%3Ahome-assistant%2Ffrontend%20narrow&type=code

Copy link
Collaborator

Choose a reason for hiding this comment

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

Yeah, I've seen it also at different places, but still... it's undefined at my HASS.

Copy link
Collaborator

Choose a reason for hiding this comment

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

This might be a problem: home-assistant/frontend#18201

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ouch. Very strange decision from them IMO. Since they are still using narrow internally.
Quick browse of their code shows that this could work:

this.#narrow = window.matchMedia("(max-width: 870px)").matches;

ref: https://github.com/home-assistant/frontend/blob/589e3b63c71c6434f2375a3614827b2feedba8e8/src/layouts/home-assistant-main.ts#L53

Copy link
Collaborator

Choose a reason for hiding this comment

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

I think that's the way to go.
You should research which of the media-queries will fit best for the "narrow" mode.
max 870px seems quite large to me.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

870px suits what I have tested, and is also the definition of narrow in home assistant. I'll go with that, unless you tell me to go with something else 😄

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Updated now

Copy link
Collaborator

Choose a reason for hiding this comment

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

Since narrow is out, I'd say not to check for undefined and just define it ourselves the way you suggested.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

fixed

README.md Outdated Show resolved Hide resolved
src/views/HomeView.js Outdated Show resolved Hide resolved
@punxaphil punxaphil requested a review from DigiLive November 6, 2023 16:13
@DigiLive
Copy link
Collaborator

DigiLive commented Nov 9, 2023

The narrow property at my hass is undefined and therefor the strategy assumes wide.
However, my homeview always shows a narrow column, making the narrow/wide settings useless.
Did you change something to render a wider column?

afbeelding

@punxaphil
Copy link
Contributor Author

The narrow property at my hass is undefined and therefor the strategy assumes wide. However, my homeview always shows a narrow column, making the narrow/wide settings useless. Did you change something to render a wider column?

afbeelding

It matters if you use panel mode.
image

DigiLive
DigiLive previously approved these changes Nov 12, 2023
@DigiLive
Copy link
Collaborator

It matters if you use panel mode.

Panel mode can't be set if there's more than 1 card.

This view contains more than one card, but a panel view can only show 1 card.

@punxaphil
Copy link
Contributor Author

True
I hide everything else with the new hidden options 😄

@DigiLive
Copy link
Collaborator

Yeah... that's a catch. 😅
Such conditions should actually be known on beforehand.
Now this option is more or less for a specific use case.

Let me think about it if we can get the best out of two worlds.

@punxaphil
Copy link
Contributor Author

Never thought of it that way.
Actually, if one is using a dashboard it's hard for me to understand why anyone wouldn't want to use the full width nearly always (I.e. panel mode)

@DigiLive
Copy link
Collaborator

I agree.
It's the masonry layout which causes the "narrow" column.
I'm not very fond of it.

We must see how to trick it or find another layout to apply.

@DigiLive DigiLive added the enhancement New feature or request label Nov 22, 2023
@DigiLive
Copy link
Collaborator

Warning

The main branch has been switched to TypeScript.
Update your feature branch accordingly!

@DigiLive DigiLive dismissed their stale review November 22, 2023 20:32

Code must be changed to TypeScript

@punxaphil
Copy link
Contributor Author

Warning

The main branch has been switched to TypeScript. Update your feature branch accordingly!

Done.
I see docs are moved to wiki, I can update it if you give me access once this is merged.

@punxaphil punxaphil requested a review from DigiLive November 27, 2023 20:54
@punxaphil
Copy link
Contributor Author

@DigiLive @AalianKhan Has development stopped on this repository?

@DigiLive
Copy link
Collaborator

Not for me, but currently a bit busy with other code and personal matters.

@farridav
Copy link

Bump. This would add a lot of value to my setup, any idea on a timeline, or anything I can do t help ? Thanks

@DigiLive
Copy link
Collaborator

Bump. This would add a lot of value to my setup, any idea on a timeline, or anything I can do t help ? Thanks

It's currently stuck on the requirement of panel view.
We must see how to trick it or find another layout to apply.

@punxaphil
Copy link
Contributor Author

Why not simply change to always use panel? Full width makes more sense to me.

@DigiLive
Copy link
Collaborator

Why not simply change to always use panel? Full width makes more sense to me.

As already said before: Panel mode can't be set if there's more than 1 card.

@soif
Copy link

soif commented Oct 22, 2024

any progess on this, guys?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants