Skip to content

Commit

Permalink
v1.7.0
Browse files Browse the repository at this point in the history
  • Loading branch information
Clooos authored Feb 14, 2024
1 parent d5ed782 commit 08472ab
Show file tree
Hide file tree
Showing 17 changed files with 543 additions and 421 deletions.
150 changes: 87 additions & 63 deletions dist/bubble-card.js

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions dist/bubble-pop-up-fix.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

36 changes: 23 additions & 13 deletions src/bubble-card.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,32 +10,25 @@ import { handleEmptyColumn } from './cards/empty-column.ts';
import BubbleCardEditor from './editor/bubble-card-editor.ts';

let editor;

addUrlListener();

class BubbleCard extends HTMLElement {

set hass(hass) {

initializeContent(this);

this._hass = hass;

editor = checkEditor();
this.editor = editor;

checkResources(hass);

initializeContent(this);

switch (this.config.card_type) {

// Initialize pop-up card
case 'pop-up':
handlePopUp(this);
break;

// Initialize horizontal buttons stack
case 'horizontal-buttons-stack' :
handleHorizontalButtonsStack(this);
break;

// Initialize button
case 'button' :
Expand All @@ -56,8 +49,15 @@ class BubbleCard extends HTMLElement {
case 'empty-column' :
handleEmptyColumn(this);
break;

// Initialize horizontal buttons stack
case 'horizontal-buttons-stack' :
handleHorizontalButtonsStack(this);
break;
}

checkResources(hass);

if (!window.columnFix) {
window.columnFix = this.config.column_fix
}
Expand Down Expand Up @@ -87,7 +87,7 @@ class BubbleCard extends HTMLElement {
definedLinks[config[linkKey]] = true;
}
}
} else if (config.card_type === 'button' || config.card_type === 'cover') {
} else if (config.card_type === 'button' || config.card_type === 'cover' || config.card_type === 'state') {
if (!config.entity) {
throw new Error("You need to define an entity");
}
Expand All @@ -101,8 +101,18 @@ class BubbleCard extends HTMLElement {
}

getCardSize() {
// Fix the empty columns caused by the pop-ups on the dashboard
return window.columnFix ? 0 : -1;
// Fix the empty columns caused by the pop-ups on the dashboard
// Check the value of window.columnFix
if (window.columnFix === "true") {
// Return 0 if it is "true"
return 0;
} else if (typeof window.columnFix === "number") {
// Return the number if it is a number
return window.columnFix;
} else {
// Return -10 otherwise
return -10;
}
}

static getConfigElement() {
Expand Down
23 changes: 23 additions & 0 deletions src/bubble-pop-up-fix.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
function hideElementsUntilBubbleCard() {
const intervalId = setInterval(function() {
const selector = "body";
const root = document.querySelector(selector);
const bubbleCard = customElements.get("bubble-card");

if (bubbleCard) {
clearInterval(intervalId);
root.style.transition = "opacity 0.5s";
root.style.opacity = "1";
} else {
root.style.opacity = "0";
}
}, 0);
}

hideElementsUntilBubbleCard();

console.info(
`%c Bubble Card %c Pop-up fix `,
'background-color: #555;color: #fff;padding: 3px 2px 3px 3px;border-radius: 14px 0 0 14px;font-family: DejaVu Sans,Verdana,Geneva,sans-serif;text-shadow: 0 1px 0 rgba(1, 1, 1, 0.3)',
'background-color: #506eac;color: #fff;padding: 3px 3px 3px 2px;border-radius: 0 14px 14px 0;font-family: DejaVu Sans,Verdana,Geneva,sans-serif;text-shadow: 0 1px 0 rgba(1, 1, 1, 0.3)'
);
12 changes: 0 additions & 12 deletions src/cards/button.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,28 +25,16 @@ export function handleButton(context) {
entityId,
icon,
name,
widthDesktop,
widthDesktopDivided,
isSidebarHidden,
state,
stateChanged,
stateOn,
formatedState,
riseAnimation,
marginCenter,
popUpOpen,
rgbaColor,
rgbColor,
bgOpacity,
shadowOpacity,
bgBlur,
iconColorOpacity,
iconColor,
iconFilter,
iconStyles,
haStyle,
themeBgColor,
color,
} = getVariables(context, context.config, hass, editor);

formatedState = entityId && (stateChanged || editor) ? hass.formatEntityState(hass.states[entityId]) : '';
Expand Down
27 changes: 1 addition & 26 deletions src/cards/cover.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,16 +8,8 @@ import {
getIconStyles
} from '../tools/style.ts';
import {
initializeContent,
checkEditor,
checkResources
} from '../tools/init.ts';
import {
fireEvent,
forwardHaptic,
navigate,
toggleEntity,
hasStateChanged
toggleEntity
} from '../tools/utils.ts';
import { addActions } from '../tools/tap-actions.ts';
import { getVariables } from '../var/cards.ts';
Expand All @@ -33,28 +25,11 @@ export function handleCover(context) {
entityId,
icon,
name,
widthDesktop,
widthDesktopDivided,
isSidebarHidden,
state,
stateChanged,
stateOn,
formatedState,
riseAnimation,
marginCenter,
popUpOpen,
rgbaColor,
rgbColor,
bgOpacity,
shadowOpacity,
bgBlur,
iconColorOpacity,
iconColor,
iconFilter,
iconStyles,
haStyle,
themeBgColor,
color,
} = getVariables(context, config, hass, editor);

const iconOpen = config.icon_open ? config.icon_open : 'mdi:window-shutter-open';
Expand Down
Loading

0 comments on commit 08472ab

Please sign in to comment.