-
Notifications
You must be signed in to change notification settings - Fork 2.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Use sections view when creating a new view (#22382)
* Use sections view when creating a new view * Improve default * Update src/panels/lovelace/views/default-section.ts Co-authored-by: Wendelin <[email protected]> * Update src/panels/lovelace/views/get-view-type.ts Co-authored-by: Wendelin <[email protected]> --------- Co-authored-by: Wendelin <[email protected]>
- Loading branch information
Showing
8 changed files
with
78 additions
and
61 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,11 @@ | ||
export const DEFAULT_VIEW_LAYOUT = "masonry"; | ||
export const MASONRY_VIEW_LAYOUT = "masonry"; | ||
export const PANEL_VIEW_LAYOUT = "panel"; | ||
export const SIDEBAR_VIEW_LAYOUT = "sidebar"; | ||
export const SECTION_VIEW_LAYOUT = "sections"; | ||
export const SECTIONS_VIEW_LAYOUT = "sections"; | ||
|
||
export const CARD_LAYOUTS = [ | ||
MASONRY_VIEW_LAYOUT, | ||
PANEL_VIEW_LAYOUT, | ||
SIDEBAR_VIEW_LAYOUT, | ||
]; | ||
export const SECTION_VIEW_LAYOUTS = [SECTIONS_VIEW_LAYOUT]; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
import type { LocalizeFunc } from "../../../common/translations/localize"; | ||
|
||
export const generateDefaultSection = (localize: LocalizeFunc) => ({ | ||
type: "grid", | ||
cards: [ | ||
{ | ||
type: "heading", | ||
heading: localize( | ||
"ui.panel.lovelace.editor.section.default_section_title" | ||
), | ||
}, | ||
], | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
import type { LovelaceViewConfig } from "../../../data/lovelace/config/view"; | ||
import { | ||
MASONRY_VIEW_LAYOUT, | ||
PANEL_VIEW_LAYOUT, | ||
SECTIONS_VIEW_LAYOUT, | ||
} from "./const"; | ||
|
||
export const getViewType = (config?: LovelaceViewConfig): string => { | ||
if (config?.type) { | ||
return config.type; | ||
} | ||
if (config?.panel) { | ||
return PANEL_VIEW_LAYOUT; | ||
} | ||
if (config?.sections) { | ||
return SECTIONS_VIEW_LAYOUT; | ||
} | ||
if (config?.cards) { | ||
return MASONRY_VIEW_LAYOUT; | ||
} | ||
return SECTIONS_VIEW_LAYOUT; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters