@geoinsight/react-components 0.2.0 → 0.2.1

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": "@geoinsight/react-components",
3
- "version": "0.2.0",
3
+ "version": "0.2.1",
4
4
  "description": "This library is the main UI component library for geoinsight",
5
5
  "main": "dist/cjs/index.js",
6
6
  "module": "dist/esm/index.js",
@@ -1,6 +1,17 @@
1
1
  import clsx from "clsx";
2
2
  import { ButtonAsButton, ButtonAsLink } from "./index.types";
3
3
  import "./index.css";
4
+ import { ReactNode } from "react";
5
+
6
+ const Anchor = ({
7
+ Custom,
8
+ children,
9
+ ...rest
10
+ }: {
11
+ Custom?: React.ComponentClass<any>;
12
+ children?: ReactNode;
13
+ }) =>
14
+ Custom ? <Custom {...rest}>{children}</Custom> : <a {...rest}>{children}</a>;
4
15
 
5
16
  export function Button({
6
17
  children = "Click me",
@@ -10,10 +21,12 @@ export function Button({
10
21
  mode = "primary",
11
22
  size = "medium",
12
23
  as = "button",
24
+ CustomAnchor,
13
25
  ...rest
14
26
  }: ButtonAsButton | ButtonAsLink): JSX.Element {
15
27
  return as === "link" ? (
16
- <a
28
+ <Anchor
29
+ Custom={CustomAnchor}
17
30
  {...(isNewWindow && { target: "_blank" })}
18
31
  className={clsx(
19
32
  className,
@@ -25,7 +38,7 @@ export function Button({
25
38
  >
26
39
  {children}
27
40
  {icon}
28
- </a>
41
+ </Anchor>
29
42
  ) : (
30
43
  <button
31
44
  className={clsx(
@@ -38,4 +38,6 @@ export interface Base {
38
38
  * Button type.
39
39
  */
40
40
  as?: "button" | "link";
41
+
42
+ CustomAnchor?: React.ComponentClass<any>;
41
43
  }