Skip to content

Commit 7c9b9fe

Browse files
authored
fixed the size of loading icon (#6)
* fixed the size of loading icon * add header and height constraint * updated version
1 parent 04bb809 commit 7c9b9fe

File tree

4 files changed

+16
-3
lines changed

4 files changed

+16
-3
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -128,6 +128,7 @@ export default App;
128128
| `hideSpinner` | `bool` | no | render spinner while image loads or not |
129129
| `onError` | `func` | no | if image fails to load (returns error details) |
130130
| `onLoad` | `func` | no | if image loads successfully (returns image headers) |
131+
| `headers` | `object` | no | Custom headers for image |
131132

132133
Any additional props are passed down to underlying `<img />` component.
133134

example/src/modules/ErrorRender/ErrorRender.js

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ export const ErrorRender = ({
66
handleRetry = () => {},
77
icon: Icon,
88
height,
9+
width,
910
}) => {
1011
const handler = useRef();
1112

@@ -18,7 +19,17 @@ export const ErrorRender = ({
1819
if (Icon) return <div onClick={_handleRetry}>{Icon}</div>;
1920
return (
2021
<span
21-
style={{ color: reloadIconColor, fontSize: height / 2 }}
22+
style={{
23+
color: reloadIconColor,
24+
fontSize:
25+
width < height
26+
? height / 2 < 50
27+
? height / 2
28+
: 50
29+
: width / 2 < 50
30+
? width / 2
31+
: 50,
32+
}}
2233
onClick={_handleRetry}
2334
className="assetcrush-reload"
2435
>

example/src/modules/ImageCrush.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ const ImageCrush = ({
2020
height,
2121
acEnv = "production",
2222
alt = '',
23+
headers = {},
2324
...props
2425
}) => {
2526
const [image, setImage] = useState("");
@@ -44,7 +45,7 @@ const ImageCrush = ({
4445
const key = getKey();
4546
let headers = {};
4647

47-
fetch(imageUrl, { headers: { "assetcrush-key": key, "ac-env": acEnv } })
48+
fetch(imageUrl, { headers: { "assetcrush-key": key, "ac-env": acEnv, ...headers } })
4849
.then((r) => {
4950
headers = r.headers;
5051
return r.blob();

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@assetcrush/reactjs-sdk",
3-
"version": "0.1.2",
3+
"version": "0.1.3",
44
"description": "A simple reactjs library to resize image on fly",
55
"main": "dist/index.js",
66
"types": "index.d.ts",

0 commit comments

Comments
 (0)