-
Notifications
You must be signed in to change notification settings - Fork 394
Expand file tree
/
Copy pathFeatureLink.tsx
More file actions
38 lines (34 loc) · 886 Bytes
/
FeatureLink.tsx
File metadata and controls
38 lines (34 loc) · 886 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
import { FC, ReactNode } from "react";
import styled from "styled-components";
import ViewState from "../../ReactViewModels/ViewState";
import { useViewState } from "../Context/ViewStateContext";
interface PropsType {
title?: string;
children?: ReactNode | ReactNode[];
onClick: (viewState: ViewState) => void;
}
/**
* A button as link that provides common styling for custom component types
* that open a feature.
*/
const FeatureLink: FC<PropsType> = ({ title, onClick, children }) => {
const viewState = useViewState();
return (
<ButtonAsLink
title={title}
onClick={(e) => {
e.stopPropagation();
onClick(viewState);
}}
>
{children}
</ButtonAsLink>
);
};
const ButtonAsLink = styled.button`
background: none;
border: none;
text-decoration: underline dashed;
color: inherit;
`;
export default FeatureLink;