-
Notifications
You must be signed in to change notification settings - Fork 19
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
BZ-11848: feat: added support for fallback image in list item left icon
- create Img component with support for handling fallback images - integrated Img component in ListItemComponent for leftIcon - added support for leftIconfallback to list item
- Loading branch information
1 parent
7537d0f
commit 7913e1a
Showing
4 changed files
with
58 additions
and
22 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
<script lang="ts"> | ||
export let src: string; | ||
export let alt: string; | ||
export let fallback: string | null = null; | ||
function handleFallback(): void { | ||
if (fallback !== null) { | ||
src = fallback; | ||
} | ||
} | ||
</script> | ||
|
||
{#if typeof src === 'string' && typeof alt === 'string'} | ||
<img {src} {alt} on:error|once={handleFallback} /> | ||
{/if} | ||
|
||
<style> | ||
img { | ||
object-fit: var(--image-object-fit); | ||
height: var(--image-height, 24px); | ||
width: var(--image-width, 24px); | ||
padding: var(--image-padding, 0px); | ||
border-radius: var(--image-border-radius, 0px); | ||
margin: var(--image-margin, 0px); | ||
filter: var(--image-filter, none); | ||
background: var(--image-background); | ||
border: var(--image-border); | ||
transition: var(--image-transition); | ||
} | ||
img:hover { | ||
background: var(--image-hover-background, var(--image-background)); | ||
border: var(--image-hover-border, var(--image-border)); | ||
} | ||
</style> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters