Skip to content

Commit

Permalink
fix(icon-view): do not show a broken image (#1399)
Browse files Browse the repository at this point in the history
* fix(icon-view): do not show a broken image

* Create funny-kangaroos-hammer.md
  • Loading branch information
reme3d2y authored Oct 11, 2024
1 parent 290acf4 commit 161ad6b
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
5 changes: 5 additions & 0 deletions .changeset/funny-kangaroos-hammer.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@alfalab/core-components-icon-view": patch
---

Изменена логика отрисовки image тэга - теперь image рендерится всегда и скрывается только в случае ошибки загрузки
5 changes: 2 additions & 3 deletions packages/icon-view/src/components/base-shape/component.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,6 @@ export const BaseShape = forwardRef<HTMLDivElement, BaseShapeProps>(
) => {
const [width, height] = typeof size === 'object' ? [size.width, size.height] : [size, size];
const imageLoadingState = useImageLoadingState({ src: imageUrl || '' });
const loadedUrl = imageLoadingState === 'loaded' ? imageUrl : undefined;

const imagePatternId = useId();

Expand Down Expand Up @@ -174,12 +173,12 @@ export const BaseShape = forwardRef<HTMLDivElement, BaseShapeProps>(
d={shapeDPath}
/>

{loadedUrl && (
{imageUrl && imageLoadingState !== 'error' && (
<Fragment>
<defs>
<pattern id={imagePatternId} width='100%' height='100%'>
<image
href={loadedUrl}
href={imageUrl}
width='100%'
height='100%'
preserveAspectRatio='xMidYMid slice'
Expand Down

0 comments on commit 161ad6b

Please sign in to comment.