Skip to content

Commit

Permalink
Merge pull request #88 from eclipse-tractusx/feat/CPLP-3190/render-wi…
Browse files Browse the repository at this point in the history
…th-leader-when-specified

fix(image): render image with loader when specified
  • Loading branch information
oyo authored Jan 30, 2024
2 parents f017634 + 9682a3d commit 77e5488
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 4 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# Changelog

## 2.1.23

- Render images directly with loader when specified

## 2.1.22

- Select list default value functionality fix
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@catena-x/portal-shared-components",
"version": "2.1.22",
"version": "2.1.23",
"description": "Catena-X Portal Shared Components",
"author": "Catena-X Contributors",
"license": "Apache-2.0",
Expand Down
15 changes: 12 additions & 3 deletions src/components/basic/Image/index.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
/********************************************************************************
* Copyright (c) 2021, 2023 BMW Group AG
* Copyright (c) 2021, 2023 Contributors to the Eclipse Foundation
* Copyright (c) 2021, 2024 Contributors to the Eclipse Foundation
*
* See the NOTICE file(s) distributed with this work for additional
* information regarding copyright ownership.
Expand Down Expand Up @@ -69,13 +68,23 @@ export const Image = ({ src, alt, style, loader }: ImageProps): JSX.Element => {
}
}, [src, loader])

const renderByLoader = () => {
setLoad(true)
getData().catch((e) => {
setError(true)
})
return <img src={LogoGrayData} alt={alt ?? 'Catena-X'} />
}

useEffect(() => {
setError(false)
setLoad(false)
setData(src)
}, [src])

return (
return loader ? (
renderByLoader()
) : (
<img
src={!load && !error && src.startsWith('blob:') ? src : data}
alt={alt ?? 'Catena-X'}
Expand Down

0 comments on commit 77e5488

Please sign in to comment.