1
0
mirror of https://github.com/lensapp/lens.git synced 2025-05-20 05:10:56 +00:00
lens/src/renderer/components/layout/close-button.tsx
Juho Heikka 80a5a77f15 Rename track to capture. Fix types.
Signed-off-by: Juho Heikka <juho.heikka@gmail.com>
2022-08-01 14:45:56 +03:00

55 lines
1.4 KiB
TypeScript

/**
* Copyright (c) OpenLens Authors. All rights reserved.
* Licensed under MIT License. See LICENSE in root directory for more information.
*/
import styles from "./close-button.module.scss";
import type { HTMLAttributes } from "react";
import React from "react";
import { Icon } from "../icon";
import { withInjectables } from "@ogre-tools/injectable-react";
import captureWithIdInjectable from "../../telemetry/capture-with-id.injectable";
export interface CloseButtonProps extends HTMLAttributes<HTMLDivElement> {
}
interface Dependencies {
capture: (id: string, action: string) => void;
}
function NonInjectedCloseButton(props: CloseButtonProps & Dependencies) {
const { capture, ...rest } = props;
return (
<div
{...rest}
onClick={(e) => {
capture(`${window.location.pathname}`, "Close Button Click");
props?.onClick?.(e);
}}>
<div
className={styles.closeButton}
role="button"
aria-label="Close"
>
<Icon material="close" className={styles.icon}/>
</div>
<div className={styles.esc} aria-hidden="true">
ESC
</div>
</div>
);
}
export const CloseButton = withInjectables<Dependencies, CloseButtonProps>(
NonInjectedCloseButton,
{
getProps: (di, props) => ({
capture: di.inject(captureWithIdInjectable),
...props,
}),
},
);