diff --git a/src/cards/trash-card/trash-card.ts b/src/cards/trash-card/trash-card.ts index 433e802..a32359c 100644 --- a/src/cards/trash-card/trash-card.ts +++ b/src/cards/trash-card/trash-card.ts @@ -11,7 +11,7 @@ import type { HassEntity } from 'home-assistant-js-websocket'; import { loadHaComponents } from 'lovelace-mushroom/src/utils/loader'; import { normaliseEvents } from '../../utils/normaliseEvents'; import type { RawCalendarEvent } from '../../utils/calendarEvents'; -import { registerCustomCard } from 'lovelace-mushroom/src/utils/custom-cards'; +import { registerCustomCard } from '../../utils/registerCustomCard'; import setupCustomlocalize from '../../localize'; import { styleMap } from 'lit/directives/style-map.js'; import type { TrashCardConfig } from './trash-card-config'; diff --git a/src/utils/registerCustomCard.ts b/src/utils/registerCustomCard.ts new file mode 100644 index 0000000..0a95507 --- /dev/null +++ b/src/utils/registerCustomCard.ts @@ -0,0 +1,28 @@ +import { repository } from '../../package.json'; + +interface RegisterCardParams { + type: string; + name: string; + description: string; +} +const registerCustomCard = (params: RegisterCardParams) => { + const windowWithCards = window as unknown as Window & { + customCards: unknown[]; + }; + + // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition + windowWithCards.customCards = windowWithCards.customCards || []; + + // Const cardPage = params.type.replace('-card', '').replace('mushroom-', ''); + + windowWithCards.customCards.push({ + ...params, + preview: true, + // eslint-disable-next-line @typescript-eslint/naming-convention + documentationURL: `${repository.url}/blob/main/README.md` + }); +}; + +export { + registerCustomCard +};