Skip to content

Commit

Permalink
chore: apply prettier
Browse files Browse the repository at this point in the history
  • Loading branch information
piitaya committed Apr 21, 2022
1 parent 1fe8b7a commit 4726160
Show file tree
Hide file tree
Showing 7 changed files with 42 additions and 36 deletions.
2 changes: 1 addition & 1 deletion src/cards/chips-card/chips/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,4 @@ export { MenuChip } from "./menu-chip";
export { TemplateChip } from "./template-chip";
export { ConditionalChip } from "./conditional-chip";
export { LightChip } from "./light-chip";
export { AlarmControlPanelChip } from "./alarm-control-panel-chip";
export { AlarmControlPanelChip } from "./alarm-control-panel-chip";
2 changes: 1 addition & 1 deletion src/cards/lock-card/lock-card-editor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import { LOCK_CARD_EDITOR_NAME } from "./const";
import { LockCardConfig, lockCardConfigStruct } from "./lock-card-config";

const computeSchema = memoizeOne((icon?: string): HaFormSchema[] => [
{ name: "entity", selector: { entity: { domain : LOCK_ENTITY_DOMAINS} } },
{ name: "entity", selector: { entity: { domain: LOCK_ENTITY_DOMAINS } } },
{ name: "name", selector: { text: {} } },
{ name: "icon", selector: { icon: { placeholder: icon } } },
{
Expand Down
2 changes: 1 addition & 1 deletion src/cards/media-player-card/const.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@ import { PREFIX_NAME } from "../../const";

export const MEDIA_PLAYER_CARD_NAME = `${PREFIX_NAME}-media-player-card`;
export const MEDIA_PLAYER_CARD_EDITOR_NAME = `${MEDIA_PLAYER_CARD_NAME}-editor`;
export const MEDIA_PLAYER_ENTITY_DOMAINS = ["media_player"];
export const MEDIA_PLAYER_ENTITY_DOMAINS = ["media_player"];
42 changes: 21 additions & 21 deletions src/utils/debounce.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,27 +6,27 @@
// leading edge, instead of the trailing.

export const debounce = <T extends any[]>(
func: (...args: T) => void,
wait: number,
immediate = false
func: (...args: T) => void,
wait: number,
immediate = false
) => {
let timeout: number | undefined;
const debouncedFunc = (...args: T): void => {
const later = () => {
timeout = undefined;
if (!immediate) {
func(...args);
}
let timeout: number | undefined;
const debouncedFunc = (...args: T): void => {
const later = () => {
timeout = undefined;
if (!immediate) {
func(...args);
}
};
const callNow = immediate && !timeout;
clearTimeout(timeout);
timeout = window.setTimeout(later, wait);
if (callNow) {
func(...args);
}
};
const callNow = immediate && !timeout;
clearTimeout(timeout);
timeout = window.setTimeout(later, wait);
if (callNow) {
func(...args);
}
};
debouncedFunc.cancel = () => {
clearTimeout(timeout);
};
return debouncedFunc;
debouncedFunc.cancel = () => {
clearTimeout(timeout);
};
return debouncedFunc;
};
14 changes: 10 additions & 4 deletions src/utils/entity-styles.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,17 @@ const strAnimations = {
to {
transform: rotate(360deg);
}
}`
}`,
};

export const animation = {
pulse: css`${unsafeCSS(strAnimations.pulse)}`,
spin: css`${unsafeCSS(strAnimations.spin)}`
pulse: css`
${unsafeCSS(strAnimations.pulse)}
`,
spin: css`
${unsafeCSS(strAnimations.spin)}
`,
};
export const animations = css`${unsafeCSS(Object.values(strAnimations).join("\n"))}`;
export const animations = css`
${unsafeCSS(Object.values(strAnimations).join("\n"))}
`;
8 changes: 4 additions & 4 deletions src/utils/icons/state-icon.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,12 @@ import { HassEntity } from "home-assistant-js-websocket";
import { domainIcon } from "./domain-icon";

export function stateIcon(entity: HassEntity): string {
if​ ​(entity.attributes.icon)​ ​{
​    return​ ​entity.attributes.icon;
​  ​ }
if (entity.attributes.icon) {
return entity.attributes.icon;
}

const domain = computeDomain(entity.entity_id);

const state = entity.state;

return domainIcon(domain, entity, state);
Expand Down
8 changes: 4 additions & 4 deletions src/utils/render-status.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
export const afterNextRender = (cb: (value: unknown) => void): void => {
requestAnimationFrame(() => setTimeout(cb, 0));
requestAnimationFrame(() => setTimeout(cb, 0));
};

export const nextRender = () =>
new Promise((resolve) => {
afterNextRender(resolve);
});
new Promise((resolve) => {
afterNextRender(resolve);
});

0 comments on commit 4726160

Please sign in to comment.