react-frontend-common-components 0.0.50 → 0.0.52

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "react-frontend-common-components",
3
- "version": "0.0.50",
3
+ "version": "0.0.52",
4
4
  "description": "Reusable frontend library",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.mjs",
@@ -1,4 +1,4 @@
1
- import React from "react";
1
+ import React, { MouseEventHandler } from "react";
2
2
  import { Image } from "antd";
3
3
  import "./app-image-box.css";
4
4
 
@@ -12,6 +12,7 @@ interface AppImageBoxProps {
12
12
  text?: string;
13
13
  image: ImageType;
14
14
  className?: string;
15
+ handleClick?: MouseEventHandler<HTMLElement>;
15
16
  }
16
17
 
17
18
  const AppImageBox = ({
@@ -20,9 +21,10 @@ const AppImageBox = ({
20
21
  text,
21
22
  image,
22
23
  className,
24
+ handleClick,
23
25
  }: AppImageBoxProps) => {
24
26
  return (
25
- <div className={`appImageBox ${className}`}>
27
+ <div className={`appImageBox ${className}`} onClick={handleClick}>
26
28
  <Image
27
29
  preview={false}
28
30
  width={width}
@@ -1,6 +1,5 @@
1
1
  .header {
2
2
  width: 100%;
3
- padding: 0 16px;
4
3
  }
5
4
 
6
5
  .title,
@@ -6,6 +6,7 @@ const { Sider } = Layout;
6
6
 
7
7
  interface SidebarProps {
8
8
  links: {
9
+ onClick: (() => void) | undefined;
9
10
  label: string;
10
11
  path: string;
11
12
  icon: React.ReactNode;
@@ -31,15 +32,25 @@ const Sidebar = ({
31
32
  activeLink,
32
33
  }: SidebarProps) => {
33
34
  const handleNavigation = (path: string) => {
34
- window.location.href = path;
35
+ if (path) {
36
+ window.location.href = path;
37
+ }
38
+ };
39
+
40
+ const handleClick = (path: string, onClick?: () => void) => {
41
+ if (onClick) {
42
+ onClick();
43
+ } else {
44
+ handleNavigation(path);
45
+ }
35
46
  };
36
47
 
37
48
  const menuItems = links.map((link) => ({
38
- key: link.path,
49
+ key: link.path || link.label,
39
50
  icon: link.path === activeLink ? link.activeIcon : link.icon,
40
51
  className: link.path === activeLink ? "active" : "",
41
52
  label: (
42
- <span onClick={() => handleNavigation(link.path)}>
53
+ <span onClick={() => handleClick(link.path, link.onClick)}>
43
54
  {link.label}
44
55
  {link.tag && <span className={"tag"}>{link.tag}</span>}
45
56
  </span>