Skip to content

Commit b9f6d6c

Browse files
chore(release): 1.2.4 [skip ci]
## [1.2.4](v1.2.3...v1.2.4) (2023-03-20) ### Bug Fixes * add href to Image ([e8da1ec](e8da1ec)) * code format ([32038eb](32038eb))
1 parent 32038eb commit b9f6d6c

File tree

5 files changed

+30
-6
lines changed

5 files changed

+30
-6
lines changed

CHANGELOG.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,11 @@
1+
## [1.2.4](https://github.com/ocadotechnology/codeforlife-package-javascript/compare/v1.2.3...v1.2.4) (2023-03-20)
2+
3+
4+
### Bug Fixes
5+
6+
* add href to Image ([e8da1ec](https://github.com/ocadotechnology/codeforlife-package-javascript/commit/e8da1ec1fad9d91dd0b8c9a3d3c6926a2724e782))
7+
* code format ([32038eb](https://github.com/ocadotechnology/codeforlife-package-javascript/commit/32038ebd404ecfa7fc7ab9a45c716753e4097fe1))
8+
19
## [1.2.3](https://github.com/ocadotechnology/codeforlife-package-javascript/compare/v1.2.2...v1.2.3) (2023-03-19)
210

311

lib/cjs/components/Image.d.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import { BoxProps } from '@mui/material';
33
export interface ImageProps {
44
alt: string;
55
src: string;
6+
href?: string;
67
boxProps?: BoxProps;
78
}
89
declare const Image: React.FC<ImageProps>;

lib/cjs/components/Image.js

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,9 +27,16 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
2727
Object.defineProperty(exports, "__esModule", { value: true });
2828
var react_1 = __importDefault(require("react"));
2929
var material_1 = require("@mui/material");
30+
var react_router_dom_1 = require("react-router-dom");
3031
var Image = function (_a) {
31-
var alt = _a.alt, src = _a.src, _b = _a.boxProps, boxProps = _b === void 0 ? {} : _b;
32-
var sx = boxProps.sx, otherProps = __rest(boxProps, ["sx"]);
33-
return (react_1.default.createElement(material_1.Box, __assign({ component: 'img', alt: alt, src: src, sx: __assign({ width: '100%' }, sx) }, otherProps)));
32+
var alt = _a.alt, src = _a.src, href = _a.href, _b = _a.boxProps, boxProps = _b === void 0 ? {} : _b;
33+
var sx = boxProps.sx, onClick = boxProps.onClick, _c = boxProps.style, style = _c === void 0 ? {} : _c, otherProps = __rest(boxProps, ["sx", "onClick", "style"]);
34+
// Override onClick if href provided.
35+
if (href !== undefined) {
36+
var navigate_1 = (0, react_router_dom_1.useNavigate)();
37+
onClick = function () { navigate_1(href); };
38+
style.cursor = 'pointer';
39+
}
40+
return (react_1.default.createElement(material_1.Box, __assign({ component: 'img', alt: alt, src: src, onClick: onClick, style: style, sx: __assign({ width: '100%' }, sx) }, otherProps)));
3441
};
3542
exports.default = Image;

lib/esm/components/Image.d.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import { BoxProps } from '@mui/material';
33
export interface ImageProps {
44
alt: string;
55
src: string;
6+
href?: string;
67
boxProps?: BoxProps;
78
}
89
declare const Image: React.FC<ImageProps>;

lib/esm/components/Image.js

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,16 @@ var __rest = (this && this.__rest) || function (s, e) {
2222
};
2323
import React from 'react';
2424
import { Box } from '@mui/material';
25+
import { useNavigate } from 'react-router-dom';
2526
var Image = function (_a) {
26-
var alt = _a.alt, src = _a.src, _b = _a.boxProps, boxProps = _b === void 0 ? {} : _b;
27-
var sx = boxProps.sx, otherProps = __rest(boxProps, ["sx"]);
28-
return (React.createElement(Box, __assign({ component: 'img', alt: alt, src: src, sx: __assign({ width: '100%' }, sx) }, otherProps)));
27+
var alt = _a.alt, src = _a.src, href = _a.href, _b = _a.boxProps, boxProps = _b === void 0 ? {} : _b;
28+
var sx = boxProps.sx, onClick = boxProps.onClick, _c = boxProps.style, style = _c === void 0 ? {} : _c, otherProps = __rest(boxProps, ["sx", "onClick", "style"]);
29+
// Override onClick if href provided.
30+
if (href !== undefined) {
31+
var navigate_1 = useNavigate();
32+
onClick = function () { navigate_1(href); };
33+
style.cursor = 'pointer';
34+
}
35+
return (React.createElement(Box, __assign({ component: 'img', alt: alt, src: src, onClick: onClick, style: style, sx: __assign({ width: '100%' }, sx) }, otherProps)));
2936
};
3037
export default Image;

0 commit comments

Comments
 (0)