Allow min column width setting for sections view
Proposed change
Lack of customization options for sections view makes it awkward to use on a control panel ipad. For example in landscape it defaults to 2 large columns which cannot hold much information. This change allows reducing the minimum column width so that more columns can be displayed.
Type of change
- [ ] Dependency upgrade
- [ ] Bugfix (non-breaking change which fixes an issue)
- [X] New feature (thank you!)
- [ ] Breaking change (fix/feature causing existing functionality to break)
- [ ] Code quality improvements to existing code or addition of tests
Example configuration
Additional information
- This PR fixes or closes issue: fixes #
- This PR is related to issue or discussion:
- Link to documentation pull request:
Checklist
- [X] The code change is tested and works locally.
- [X] There is no commented out code in this PR.
- [ ] Tests have been added to verify that the new code works.
If user exposed functionality or configuration variables are added/changed:
- [ ] Documentation added/updated for www.home-assistant.io
Summary by CodeRabbit
-
New Features
- Added a
min_column_widthsetting to specify minimum column width for section views. - Introduced the ability to configure
min_column_widthin the view editor. - Updated section view styling to respect
min_column_widthsetting.
- Added a
-
Localization
- Added translation for
min_column_widthwith the label "Minimum column width (px)".
- Added translation for
Please take a look at the requested changes, and use the Ready for review button when you are done, thanks :+1:
Walkthrough
Walkthrough
The update introduces a min_column_width setting to the Lovelace configuration, allowing users to specify a minimum column width for section views. This setting is integrated across various files, involving changes to the Lovelace configuration interface, view editor functionality, section view rendering, and corresponding translations.
Changes
| File | Change Summary |
|---|---|
src/data/lovelace/config/view.ts |
Added min_column_width property to LovelaceBaseViewConfig interface. |
src/panels/lovelace/editor/.../hui-view-editor.ts |
Enhanced HuiViewEditor to handle min_column_width setting when SECTION_VIEW_LAYOUT is selected. |
src/panels/lovelace/views/hui-sections-view.ts |
Added minColumnWidth variable to use min_column_width in CSS for section views. |
src/translations/en.json |
Added translation key min_column_width with the value "Minimum column width (px)". |
Sequence Diagram(s)
sequenceDiagram
participant User
participant ViewEditor
participant LovelaceConfig
participant SectionView
User->>ViewEditor: Open view editor
ViewEditor->>LovelaceConfig: Fetch current view config
LovelaceConfig->>ViewEditor: Return view config
User->>ViewEditor: Set min_column_width
ViewEditor->>ViewEditor: Validate and save setting
User->>ViewEditor: Save view configuration
ViewEditor->>LovelaceConfig: Update view config with min_column_width
LovelaceConfig->>SectionView: Pass updated config
SectionView->>SectionView: Apply min_column_width to CSS variable
Recent review details
Configuration used: CodeRabbit UI Review profile: ASSERTIVE
Commits
Files that changed from the base of the PR and between cf1523ee73c06dc3812ed5dd6e91902486f24c7d and 73727d1cee9a4a6b65ed45db65f1866e804ed093.
Files selected for processing (4)
- src/data/lovelace/config/view.ts (1 hunks)
- src/panels/lovelace/editor/view-editor/hui-view-editor.ts (4 hunks)
- src/panels/lovelace/views/hui-sections-view.ts (2 hunks)
- src/translations/en.json (1 hunks)
Additional context used
Biome
src/panels/lovelace/editor/view-editor/hui-view-editor.ts
[error] 160-160: Avoid the delete operator which can impact performance. (lint/performance/noDelete)
Unsafe fix: Use an undefined assignment instead.
[error] 164-164: Avoid the delete operator which can impact performance. (lint/performance/noDelete)
Unsafe fix: Use an undefined assignment instead.
[error] 168-168: Avoid the delete operator which can impact performance. (lint/performance/noDelete)
Unsafe fix: Use an undefined assignment instead.
[error] 189-189: Forbidden non-null assertion. (lint/style/noNonNullAssertion)
Unsafe fix: Replace with optional chain operator ?. This operator includes runtime checks, so it is safer than the compile-only non-null assertion operator
[error] 203-203: Forbidden non-null assertion. (lint/style/noNonNullAssertion)
Unsafe fix: Replace with optional chain operator ?. This operator includes runtime checks, so it is safer than the compile-only non-null assertion operator
src/panels/lovelace/views/hui-sections-view.ts
[error] 54-54: Forbidden non-null assertion. (lint/style/noNonNullAssertion)
[error] 110-110: Unexpected any. Specify a different type. (lint/suspicious/noExplicitAny)
any disables many type checking rules. Its use should be avoided.
[error] 165-165: Forbidden non-null assertion. (lint/style/noNonNullAssertion)
Unsafe fix: Replace with optional chain operator ?. This operator includes runtime checks, so it is safer than the compile-only non-null assertion operator
[error] 165-165: Forbidden non-null assertion. (lint/style/noNonNullAssertion)
[error] 169-169: Forbidden non-null assertion. (lint/style/noNonNullAssertion)
Unsafe fix: Replace with optional chain operator ?. This operator includes runtime checks, so it is safer than the compile-only non-null assertion operator
[error] 176-176: Forbidden non-null assertion. (lint/style/noNonNullAssertion)
Unsafe fix: Replace with optional chain operator ?. This operator includes runtime checks, so it is safer than the compile-only non-null assertion operator
[error] 178-178: Forbidden non-null assertion. (lint/style/noNonNullAssertion)
Unsafe fix: Replace with optional chain operator ?. This operator includes runtime checks, so it is safer than the compile-only non-null assertion operator
[error] 180-180: Forbidden non-null assertion. (lint/style/noNonNullAssertion)
[error] 188-188: Forbidden non-null assertion. (lint/style/noNonNullAssertion)
[error] 190-190: Forbidden non-null assertion. (lint/style/noNonNullAssertion)
Unsafe fix: Replace with optional chain operator ?. This operator includes runtime checks, so it is safer than the compile-only non-null assertion operator
[error] 214-214: Forbidden non-null assertion. (lint/style/noNonNullAssertion)
Unsafe fix: Replace with optional chain operator ?. This operator includes runtime checks, so it is safer than the compile-only non-null assertion operator
[error] 214-214: Forbidden non-null assertion. (lint/style/noNonNullAssertion)
[error] 215-215: Forbidden non-null assertion. (lint/style/noNonNullAssertion)
Unsafe fix: Replace with optional chain operator ?. This operator includes runtime checks, so it is safer than the compile-only non-null assertion operator
[error] 223-223: Forbidden non-null assertion. (lint/style/noNonNullAssertion)
Unsafe fix: Replace with optional chain operator ?. This operator includes runtime checks, so it is safer than the compile-only non-null assertion operator
[error] 224-224: Forbidden non-null assertion. (lint/style/noNonNullAssertion)
[error] 225-225: Forbidden non-null assertion. (lint/style/noNonNullAssertion)
[error] 227-227: Forbidden non-null assertion. (lint/style/noNonNullAssertion)
Unsafe fix: Replace with optional chain operator ?. This operator includes runtime checks, so it is safer than the compile-only non-null assertion operator
Gitleaks
src/translations/en.json
6482-6483: Identified a HashiCorp Terraform password field, risking unauthorized infrastructure configuration and security breaches. (hashicorp-tf-password)
Additional comments not posted (7)
src/data/lovelace/config/view.ts (1)
26-26: Add a new optional property toLovelaceBaseViewConfig.The addition of
min_column_widthas an optional property aligns with the PR's objective to allow customization of the minimum column width in sections view. This change is consistent and well-documented in the comment.src/panels/lovelace/editor/view-editor/hui-view-editor.ts (3)
85-98: Add new form schema formin_column_width.The addition of a form schema for
min_column_widthwhen the view type isSECTION_VIEW_LAYOUTis a good implementation detail. It ensures that the property is only configurable when appropriate, aligning with the PR's functionality requirements.
137-142: Set default value formin_column_width.This code correctly sets a default value for
min_column_widthif it is undefined and the view type isSECTION_VIEW_LAYOUT. This ensures a consistent user experience by providing a fallback value. [APROVED]
198-201: Localize new configuration setting.The addition of localization for
min_column_widthis a crucial step for international support, making the UI accessible to non-English speakers.src/panels/lovelace/views/hui-sections-view.ts (2)
84-84: Implement dynamic CSS variable for minimum column width.This implementation effectively uses the configuration to set a CSS variable, which is a clean and efficient way to apply styles dynamically based on the configuration.
101-101: Use styleMap directive for dynamic styling.The use of
styleMapto dynamically set CSS variables based on the configuration is a good practice as it ensures styles are reactive to state changes in LitElement.src/translations/en.json (1)
5466-5466: LGTM!The addition of the
min_column_widthtranslation key is consistent with the new feature's requirements and follows the correct JSON structure.
Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?
Tips
Chat
There are 3 ways to chat with CodeRabbit:
- Review comments: Directly reply to a review comment made by CodeRabbit. Example:
I pushed a fix in commit <commit_id>.Generate unit testing code for this file.Open a follow-up GitHub issue for this discussion.
- Files and specific lines of code (under the "Files changed" tab): Tag
@coderabbitaiin a new review comment at the desired location with your query. Examples:@coderabbitai generate unit testing code for this file.@coderabbitai modularize this function.
- PR comments: Tag
@coderabbitaiin a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:@coderabbitai generate interesting stats about this repository and render them as a table.@coderabbitai show all the console.log statements in this repository.@coderabbitai read src/utils.ts and generate unit testing code.@coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.@coderabbitai help me debug CodeRabbit configuration file.
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.
CodeRabbit Commands (invoked as PR comments)
@coderabbitai pauseto pause the reviews on a PR.@coderabbitai resumeto resume the paused reviews.@coderabbitai reviewto trigger an incremental review. This is useful when automatic reviews are disabled for the repository.@coderabbitai full reviewto do a full review from scratch and review all the files again.@coderabbitai summaryto regenerate the summary of the PR.@coderabbitai resolveresolve all the CodeRabbit review comments.@coderabbitai configurationto show the current CodeRabbit configuration for the repository.@coderabbitai helpto get help.
Additionally, you can add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
CodeRabbit Configration File (.coderabbit.yaml)
- You can programmatically configure CodeRabbit by adding a
.coderabbit.yamlfile to the root of your repository. - Please see the configuration documentation for more information.
- If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation:
# yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json
Documentation and Community
- Visit our Documentation for detailed information on how to use CodeRabbit.
- Join our Discord Community to get help, request features, and share feedback.
- Follow us on X/Twitter for updates and announcements.
For now, there variables are available as theme variable. Do you have a need to have it per view? By adding this settings to the view, every view will need to be customized with the same value.
@piitaya That is true. I contend though that basic layout settings should be front and centre of the UI and preferably not buried in themes files that users need to go and modify manually themselves. Moreover because documentation is very sparse on that front! I.e. there is no reference of theme variables.
Sections view is a great attempt to standardize dashboard and we can use that to forge the way forward with the right level of customization.
There hasn't been any activity on this pull request recently. This pull request has been automatically marked as stale because of that and will be closed if no further activity occurs within 7 days. Thank you for your contributions.
@CreaticDD , hasn't this been resolved in last 2024.9 release?
Some update : we have no plan to bring such a feature to the UI as the card resizing can be really tricky when resizing with a no standard column size so we prefer to keep it in theme as it's an advanced feature. We are still looking with the UX team to find a way to do that in a better way. However, it's still possible to do that with a theme. Some variables are available to adjust the min/max size and the gap between column.
Thank again for the contribution.
Some update : we have no plan to bring such a feature to the UI as the card resizing can be really tricky when resizing with a no standard column size so we prefer to keep it in theme as it's an advanced feature. We are still looking with the UX team to find a way to do that in a better way. However, it's still possible to do that with a theme. Some variables are available to adjust the min/max size and the gap between column.
Thank again for the contributions.
Any hint on where to edit this please?
EDIT:
This fixed it for me, great!!!
https://community.home-assistant.io/t/sections-customize-horizontal-gap-size/713106/24