Skip to content

Commit

Permalink
Add 'conditional media' main item
Browse files Browse the repository at this point in the history
  • Loading branch information
matt8707 committed May 19, 2024
1 parent e3a0dfc commit a8d5ad8
Show file tree
Hide file tree
Showing 17 changed files with 1,440 additions and 297 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,5 @@ vite.config.ts.timestamp-*
.vscode
src/routes/playground
src/lib/Playground
/data/configuration.yaml
/data/youtube_credentials.json
3 changes: 2 additions & 1 deletion src/lib/Components/ComputeIcon.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
export let entity_id: string;
export let getIconString: boolean | undefined = undefined;
export let skipEntitiyPicture: boolean | undefined = undefined;
let stateObj: any;
let currentIcon: string | undefined;
Expand Down Expand Up @@ -501,7 +502,7 @@
const entity = $states[entity_id];
const domain = getDomain(entity?.entity_id || entity_id);
if (entity?.attributes?.entity_picture && domain !== 'update') {
if (entity?.attributes?.entity_picture && !skipEntitiyPicture && domain !== 'update') {
return 'entity_picture';
} else if (entity?.attributes?.icon && String(entity.attributes.icon).startsWith('mdi')) {
return entity.attributes.icon.toString();
Expand Down
39 changes: 39 additions & 0 deletions src/lib/Components/Progress.svelte
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
<script lang="ts">
import { onDestroy, onMount } from 'svelte';
import { tweened } from 'svelte/motion';
export let duration: number;
export let size: number;
export let stroke: number;
const progress = tweened(0);
const attributes = {
cx: size / 2,
cy: size / 2,
r: (size - stroke * 2) / 2,
fill: 'none',
'stroke-width': stroke,
'vector-effect': 'non-scaling-stroke'
};
const circumference = 2 * Math.PI * attributes.r;
onMount(() => {
progress.set(100, { duration });
});
onDestroy(() => {
progress.set(0, { duration: 0 });
});
</script>

<svg width={size} height={size} style:transform="rotate(-90deg)">
<circle stroke="rgba(0, 0, 0, 0.35)" {...attributes} />
<circle
stroke="rgb(255, 255, 255, 1)"
stroke-dashoffset={circumference * (1 - $progress / 100)}
stroke-dasharray={circumference}
{...attributes}
/>
</svg>
Loading

0 comments on commit a8d5ad8

Please sign in to comment.