Skip to content

Commit

Permalink
Add support for user presets
Browse files Browse the repository at this point in the history
  • Loading branch information
jcwillox committed Dec 13, 2022
1 parent 7b0bfd8 commit 4165d4f
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion src/presets.ts
@@ -1,16 +1,23 @@
import { ButtonConfig, PaperButtonRowConfig } from "./types";
import deepmerge from "deepmerge";
import { getLovelace } from "custom-card-helpers";

let lovelace = getLovelace();

export function handleButtonPreset(
bConfig: ButtonConfig,
config?: PaperButtonRowConfig
): ButtonConfig {
if (!lovelace) lovelace = getLovelace();
const userPresets = lovelace?.config?.paper_buttons_row?.presets || {};
const preset = bConfig.preset || config?.preset;
return preset
? deepmerge(
{
mushroom: presetMushroom
}[preset] || {},
}[preset] ||
userPresets[preset] ||
{},
bConfig
)
: bConfig;
Expand Down

0 comments on commit 4165d4f

Please sign in to comment.